Tuesday, August 4, 2015

Re: Celery to process task and modify the model fields

Hi,
Thank you so very much kind sir. This really helped!

On Wed, Jul 15, 2015 at 4:08 PM, 'Tom Evans' via Django users <django-users@googlegroups.com> wrote:
On Tue, Jul 14, 2015 at 9:15 PM, Robin Lery <robinlery@gmail.com> wrote:
> Yes. That time you were the one to guide me. I was looking at other projects
> after that.
>
> I am just confused on how to get the video.mp4_720 to be the converted
> video. Will you please help.
>

This is explained in the docs for FileField, you need to create a
django.core.files.File subclass, and save() it on the FieldFile object
that is returned when you access the FileField field on your model
instance.

Eg:

from django.core.files import File
fp = open('/path/to/file')
myfile = File(fp)
my_obj.mp4_720.save(name="....", content=myfile)

https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.fields.files.FieldFile.save

Also, you should not pass objects as arguments to celery tasks, you
should instead pass the id of the object and fetch the object again in
the celery task.

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFHbX1J%2BGf_hRB7ERLonXpT_jhDqX8NkEYtV5qnftyMgKvJ0OA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B4-nGrVp5AeTeC%3D7w%2BDgy2b02XXZ5qpi7q6%3DGb%2BFr7A9ojrMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment