Celery v5.0.1 Documentation
then it must be the tasks responsibility to assert that, not the callers. Another gotcha is Django model objects. They shouldn’t be passed on as arguments to tasks. It’s almost always better to re-fetch an article and a task that automatically expands some abbreviations in it: class Article(models.Model): title = models.CharField() body = models.TextField() @app.task def expand_abbreviations(article): application. blog/models.py The comment model looks like this: from django.db import models from django.utils.translation import ugettext_lazy as _ class Comment(models.Model): name = models.CharField(_('name')0 码力 | 2313 页 | 2.13 MB | 1 年前3Celery v5.0.2 Documentation
then it must be the tasks responsibility to assert that, not the callers. Another gotcha is Django model objects. They shouldn’t be passed on as arguments to tasks. It’s almost always better to re-fetch an article and a task that automatically expands some abbreviations in it: class Article(models.Model): title = models.CharField() body = models.TextField() @app.task def expand_abbreviations(article): application. blog/models.py The comment model looks like this: from django.db import models from django.utils.translation import ugettext_lazy as _ class Comment(models.Model): name = models.CharField(_('name')0 码力 | 2313 页 | 2.14 MB | 1 年前3Celery v5.0.0 Documentation
then it must be the tasks responsibility to assert that, not the callers. Another gotcha is Django model objects. They shouldn’t be passed on as arguments to tasks. It’s almost always better to re-fetch an article and a task that automatically expands some abbreviations in it: class Article(models.Model): title = models.CharField() body = models.TextField() @app.task def expand_abbreviations(article): application. blog/models.py The comment model looks like this: from django.db import models from django.utils.translation import ugettext_lazy as _ class Comment(models.Model): name = models.CharField(_('name')0 码力 | 2309 页 | 2.13 MB | 1 年前3Celery v5.0.5 Documentation
then it must be the tasks responsibility to assert that, not the callers. Another gotcha is Django model objects. They shouldn’t be passed on as arguments to tasks. It’s almost always better to re-fetch an article and a task that automatically expands some abbreviations in it: class Article(models.Model): title = models.CharField() body = models.TextField() @app.task def expand_abbreviations(article): application. blog/models.py The comment model looks like this: from django.db import models from django.utils.translation import ugettext_lazy as _ class Comment(models.Model): name = models.CharField(_('name')0 码力 | 2315 页 | 2.14 MB | 1 年前3Celery 3.0 Documentation
then it must be the tasks responsibility to assert that, not the callers. Another gotcha is Django model objects. They shouldn’t be passed on as arguments to tasks. It’s almost always better to re-fetch an article and a task that automatically expands some abbreviations in it: class Article(models.Model): title = models.CharField() body = models.TextField() @app.task def expand_abbreviations(article): enabling ATOMIC_REQUESTS on the database connection will bring back the transaction-per-request model and the race condition along with it. In this case, the simple solution is using the @transaction0 码力 | 2110 页 | 2.23 MB | 1 年前3Celery v4.0.0 Documentation
then it must be the tasks responsibility to assert that, not the callers. Another gotcha is Django model objects. They shouldn’t be passed on as arguments to tasks. It’s almost always better to re-fetch an article and a task that automatically expands some abbreviations in it: class Article(models.Model): title = models.CharField() body = models.TextField() @app.task def expand_abbreviations(article): enabling ATOMIC_REQUESTS on the database connection will bring back the transaction-per-request model and the race condition along with it. In this case, the simple solution is using the @transaction0 码力 | 2106 页 | 2.23 MB | 1 年前3Celery 1.0 Documentation
application. blog/models.py The comment model looks like this: from django.db import models from django.utils.translation import ugettext_lazy as _ class Comment(models.Model): name = models.CharField(_("name") tasks from blog.models import Comment class CommentForm(forms.ModelForm): class Meta: model = Comment def add_comment(request, slug, template_name="comments/create.html"): post = get_object_or_404(Entry run in a timely manner, so please be wary of the state you pass on to tasks. One gotcha is Django model objects. They shouldn’t be passed on as arguments to task classes, it’s almost always better to re-fetch0 码力 | 221 页 | 283.64 KB | 1 年前3Celery 1.0 Documentation
(stable) blog/models.py The comment model looks like this: from django.db import models from django.utils.translation import ugettext_lazy as _ class Comment(models.Model): name = models.CharField(_("name") blog import tasks from blog.models import Comment class CommentForm(forms.ModelForm): class Meta: model = Comment def add_comment(request, slug, template_name="comments/create.html"): post = get_object_or_404(Entry run in a timely manner, so please be wary of the state you pass on to tasks. One gotcha is Django model objects. They shouldn’t be passed on as arguments to task classes, it’s almost always better to re-fetch0 码力 | 123 页 | 400.69 KB | 1 年前3Celery 2.0 Documentation
application. blog/models.py The comment model looks like this: from django.db import models from django.utils.translation import ugettext_lazy as _ class Comment(models.Model): name = models.CharField(_("name") blog import tasks from blog.models import Comment class CommentForm(forms.ModelForm): class Meta: model = Comment def add_comment(request, slug, template_name="comments/create.html"): post = get_object_or_404(Entry run in a timely manner, so please be wary of the state you pass on to tasks. One gotcha is Django model objects. They shouldn’t be passed on as arguments to task classes, it’s almost always better to re-fetch0 码力 | 165 页 | 492.43 KB | 1 年前3Celery 2.0 Documentation
application. blog/models.py The comment model looks like this: from django.db import models from django.utils.translation import ugettext_lazy as _ class Comment(models.Model): name = models.CharField(_("name") tasks from blog.models import Comment class CommentForm(forms.ModelForm): class Meta: model = Comment def add_comment(request, slug, template_name="comments/create.html"): post = get_object_or_404(Entry run in a timely manner, so please be wary of the state you pass on to tasks. One gotcha is Django model objects. They shouldn’t be passed on as arguments to task classes, it’s almost always better to re-fetch0 码力 | 284 页 | 332.71 KB | 1 年前3
共 51 条
- 1
- 2
- 3
- 4
- 5
- 6