Hello,

I'd like to propose the following change to Model interface: optional
step to fixup the data got from the form before validation. This may
easily be done in custom views, but there is no proper way to do it in
admin interface. This fixup should operate on whole form data, exactly
as validation does.

Example application may be the custom slug generation (filling slug
from the title if no explicit slug provided):

------------------------------------------------------------------------
class AutopopulatedSlugField(models.SlugField):
    def __init__() ...

    def fixup(self, field_name, all_data):
        if all_data[field_name] == "":
            all_data[field_name] = utils.urlify(all_data[self.populate_from])

class Entry(models.Model):
    headline = models.CharField(maxlength = 512)
    slug = models.AutopopulatedSlugField(populate_from='headline')

    class Admin: pass
------------------------------------------------------------------------

AFAIU, changes to the codebase will be minimal (slight change of Model
class and additional no-op Field class operation). Is it worth to
implement it by myself and post in ticket?

-- 
JID: [EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to