Friday, January 31, 2014

Re: Pre-populating data in the admin panel

Add your foreign key table to the admin.py and register it.  Admin will magically add the (+) button.
Or add it inline and have it all on the same page.
Depends on which is right for your application.

admin.py:

from project.models import *

class PropertyAdmin(admin.ModelAdmin):
    pass
admin.site.register(Property, PropertyAdmin)

class PhysicAdmin(admin.ModelAdmin):
    pass
admin.site.register(Physic, PhysicAdmin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5a583bfa-288a-4802-907b-fd3ceb926b9f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment