Could you give me some hints on model overriding?
Do you mean you want to override the default save method to put in some processing first? This is covered here
https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods
If you are wanting to generate a legal URL slug, you can use the slugify method like this...
from django.template.defaultfilters import slugify
Class MyImageModel(models.Model):
def save(self, *args, **kwargs):
self.slug_field = slugify(self.some_unique_image_reference_field)
and then call the super save method as defined in the URL above.
HTH
Adrian
Auckland, NZ
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/XcPk-oFwFBQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment