Tuesday, August 28, 2012

Automatically create an InlineForm object inside an admin page

I hope someone has come across this problem before because it's driving me nuts.  Basically I have a model, Partner and it has a PartnerAdmin page.  Inside the partner I have another model called Data that is an Inline to the Partner.  I used the model.ForeignKey in the Data to reference it back to the Partner instance.  What I want to do is everytime I create a new Partner and click to save it to automatically create one Data object (sort of a requirement) for all new partners.  It currently looks like this:

PartnerAdmin:
 #stuff
 inlines = ['DataInline',]

Data:
 name= model.Char
 #more stuff

DataInline(admin.TabularInline):
   extra = 0
   form = DataForm
   formset = DataFormSet

I have tried using the initial data and trying to bind a form from it but it won't work.  Please any help would be appreciated.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/YvGlPmf_HtEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment