Archive for the ‘admin’ tag
SlugField and Django 1.0
I stumbled upon this non-functional fix for using prepopulated admin fields in Django 1.0. If you manage to read the code you’ll notice that it really does not conform to Django-1.0 standards; it uses old-style inner Admin-classes.
The proper way to do this is of course to use the ModelAdmin classes that were introduced with the merge of the newforms-admin branch.
Declare your model as usual in models.py without the inner Admin class:
class Article(models.Model):
title = models.CharField()
slug = models.SlugField()
Then declare the ModelAdmin class in admins.py. This is where you set properties regarding the admin interface, it replaces the old-style inner Admin class:
class ArticleAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("title",)}
admin.site.register(Article, ArticleAdmin)
This is the correct way to do it. Rip out the inner Admin-classes and create new ModelAdmin-classes. Read the new and updated documentation for more on newforms-admin.