I did, is not celery related. The only thing, that maybe is influencing the path, is that the Image model is used in an inlineformset.
On Wednesday, January 17, 2018 at 6:37:40 PM UTC+2, Matemática A3K wrote: > > > b > On Wed, Jan 17, 2018 at 12:17 PM, Paul <[email protected] <javascript:>> > wrote: > >> I have the following model: >> >> >> class Image(models.Model): image = models.ImageField(upload_to= >> file_upload_to) >> >> >> I have a dynamic file_upload function: >> >> >> def file_upload_to(instance, filename): >> base = '_'.join([str(instance.item.pk), instance.item.slug]) >> return os.path.join('accounts', base, 'item', base_2, 'images', filename) >> >> and in a ModelForm: >> >> >> class ImageModelForm(ModelForm) >> def save(self, commit=True): >> image_obj = super().save(commit=commit) >> product_image__task.delay(image_obj.image.path, image_obj.image.name, >> image_obj.product_id) return image_obj >> >> >> >> I tried also to wait for transaction: >> >> >> transaction.on_commit( lambda: >> product_image_crop_task.delay(image_obj.image.path, image_obj.image.name, >> image_obj.product_id)) >> >> >> >> The file is saved properly in a path like: >> >> >> media/account/12_blue/images/image_name.jpeg >> >> >> >> The problem is that image_obj.image.path is not reporting the correct >> path, but this path: >> >> >> media/image_name.jpeg >> >> >> I use the image path, further passing it as an argument to a task, but >> because I received the wrong path, it will fail. >> >> >> How can I fix this, and receive the correct path ? I tried also using >> time.sleep(), nothing works, the path/location returned is wrong, even if >> is saved to the correct one. >> > > The first thing I would do is to comment out all the celery tasks to see > if those are messing with path property (you are not using a custom > storage, right?) Also, the upload_to function you posted does not > correspond to the path generated, try to post the latest code :) > > >> >> -- >> 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 [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/7d57595e-95b5-49f4-a29a-34f73e30620d%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/7d57595e-95b5-49f4-a29a-34f73e30620d%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0ac7266a-b913-4135-8a34-12ae22c15ee5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

