Thanks!
Your best bet is probably to read the source right now; when the
branch is complete there will undoubtedly be documentation showing the
sorts of things you can do with it, but at the moment the code is
still under development.
--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."
In the branch, almost all of the admin app functionality has been
moved out of the inner Admin class and into a separate class called
ModelAdmin. If you want to customize the admin app's behavior, simply
subclass ModelAdmin and override the default functionality.
For example, look at this sample ModelAdmin subclass:
-----
from django.contrib import admin
[...]
class ProfileOptions(admin.ModelAdmin):
list_display = ('display_name', 'headline','setup_date')
filter_horizontal = ('techniques', 'products', 'setup')
fields = (('Administrative Settings',{'fields':
('subscriber','active')}),('Contact Information',{'fields':
('phone_numbers','im_accounts','zip_code')}),('Photos',{'fields':
('primary_photo','secondary_photos','private_photos')}),)
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'zip_code':
return ZipCodeField(**kwargs)
else:
return super(ProfileOptions,self).formfield_for_dbfield(db_field,
**kwargs)
def queryset(self, request):
return self.model.user_profiles.get_query_set()
adminsite.register(Profile,ProfileOptions)
----
list_display and fields are used exactly as they were in inner Admin
classes. filter_horizontal is simply a tuple of fields that will use
the javascript multiple-select filter.
The queryset() function allows you to specify which manager should be
used to obtain the change list objects.
Then there's formfield_for_dbfield(), a function that allows you to
override the default form field types that are returned for your
models' fields. In this example, the function returns a custom field
class (ZipCodeField) for any model field named "zip_code".
Alternatively, you could specify a custom widget like so:
if db_field.name == 'zip_code':
kwargs['widget'] = WIDGET
return super(ProfileOptions,self).formfield_for_dbfield(db_field,
**kwargs)
Finally, don't forget to register your ModelAdmin subclass for the
model.
You can find more information on the branch's homepage:
http://code.djangoproject.com/wiki/NewformsAdminBranch
I hope this helps! If I am wrong about any of this, please post so
others don't repeat my mistakes.
Cheers,
LS
Yeah. As you've discovered, one of the big points of newforms-admin is
to get as much stuff as possible out of the model -- it doesn't really
belong there, and that's why you use a ModelAdmin class and register
with an admin site.