hi..Can anyone please tell me how to handle old image after uploading new image.
--
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...@googlegroups.com.
To post to this group, send email to django...@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/83341a1f-5684-4aad-8f87-268f25f15adb%40googlegroups.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...@googlegroups.com.
To post to this group, send email to django...@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/4aa4ac92-e622-4130-8ea0-dfbe46862c08%40googlegroups.com.
--
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...@googlegroups.com.
To post to this group, send email to django...@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/ca9fa002-cbd5-4bbf-b42c-2a6ce88e8e0c%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/oZrAdWgzwo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@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/CALXYUbkpM6op303LMxA2iGNuzqgzB%3DjBPWw2KXkpjwdaho2Z%2BQ%40mail.gmail.com.
Head Office:
|
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANSMZiTGE4rue_LtY3YrsERGqBuy%3DoFX0eJb_9o81R_us-OibQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALXYUb%3DxUnSdyTevvw3oSwA%2B1kpvMwBXednRxkswXMUkMdU78g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANSMZiRtfvrhxmUrw-GM4dsbakkM7ccONbHDVA4y4NCywX3aFA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALXYUbmecLasSsdZkk_7-uOB_5N3PVqY0i4rhbhV2o_DcDf3aQ%40mail.gmail.com.
def save(self, *args, **kwargs):
try:
this = MyModelName.objects.get(id=self.id)
if this.MyImageFieldName != self.MyImageFieldName:
this.MyImageFieldName.delete()
except: pass
super(MyModelName, self).save(*args, **kwargs)
class User(models.Model):
image=models.FileField(verbose_name = "Image(limit 1Mb) *",blank=True,upload_to=path_and_rename(''),storage=save('self'))
def __unicode__(self):
return self.first_name
i have doubt about storage in my file field which i have highlighted. Is it right, Please sugges.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANSMZiTwrGT%3D%2BqS6H6_qusp-oL9H0nSsQV0frOhRuqaJeZnHHg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALXYUbkv75Y-3hRqOpeGEUs1GOAVB4aFmEFEhhMx3cdvaZvWaw%40mail.gmail.com.
class Meta:This tells django that the form is created from the model. When you then save the form, it automatically saves the model instance (i.e. your User object), and then calls the save function. See: https://docs.djangoproject.com/en/1.7/topics/forms/modelforms/ and https://docs.djangoproject.com/en/1.7/topics/db/ . If you look at the documentation it will tell you how this should all be connected together.
model = User
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANSMZiQedy7mEY5NSMc5Y1h9sBZXLme%2BBXEinSjhgnP9Gq3dEQ%40mail.gmail.com.