On Aug 19, 6:18 am, "Jorge Vargas" <[EMAIL PROTECTED]> wrote:
> On Mon, Aug 11, 2008 at 1:26 AM, Donn <[EMAIL PROTECTED]> wrote:
>
> > On Monday, 11 August 2008 08:56:13 Oleg Oltar wrote:
> >> I want to use text stored in field title to generate slugs.
> > In the svn (> 0.96) you have to use ModelAdmin like this:
>
> > clas Toon(models.Model):
> > title = models.CharField(max_length=50)
> > slug = models.SlugField(db_index=True,unique=True)
>
> > class ToonAdmin(admin.ModelAdmin):
> > prepopulated_fields = {"slug": ("title",)} #sluggify the title field
>
> > admin.site.register(Toon, ToonAdmin)
>
> Since we are in the topic is there a less verbose way of doing this? I
> have several objects (4 so far) that all share the same slug/title
> pattern. which translates into 5 classes and 10 properties. could it
> be a good idea to subclass Slug providing the defaults I want?
>
> > HTH,
There's no reason not to subclass the ModelAdmin object if you want
the same prepopulated_fields in more than one admin.
class PrepopulatedAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("title",)}
class ToonAdmin(PrepopulatedAdmin):
... other declarations...
class AnotherAdmin(PrepopulatedAdmin):
.... more declarations ....
admin.site.register(Toon, ToonAdmin)
admin.site.register(Another, AnotherAdmin)
etc.
--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---