Hi everyone,
I have written a utility script that scans a models.py file and
automatically outputs the corresponding newforms-admin source code
(the code that goes into the admin.py file). The purpose is to
simplify the migration to newforms-admin.
Here is what it outputs:
* an import line that imports only the necessary models
* inline editing classes - inheriting from either admin.TabularInline
or admin.StackedInline
* ModelAdmin classes containing any original Admin class contents
('fields' is replaced by 'fieldsets' and the value of 'classes is made
into a tuple), plus the following fields whose values are determined
automatically: inlines, prepopulated_fields, filter_horizontal,
filter_vertical and raw_id_fields
* invocations of admin.site.register for admin options classes.
Example usage of the script (generates the admin.py file for the
models.py file in the satchmo.product module):
./new-forms-gen.py satchmo.product > admin.py
I uploaded the code to djangosnippets:
http://www.djangosnippets.org/snippets/603/
Hopefully it can be of use to someone. Please note that the script
doesn't modify any files, it just writes the generated code to
standard output.
I'm quite new to the newforms-admin branch and the documentation is
not yet complete so I was not sure how members of the Inline classes
relate to old keyword arguments used in field declarations. Currently
the 'extra' field in the generated Inline classes is based on the
value of 'num_in_admin'. If someone knows this to be wrong, please let
me know and I'll fix it.
Regards,
Nils
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---