Well, that might be a simple case, but it's hard for me to figure it out.
I have two user registration sequences (corporate and all others). When a corporate user creates a user instance through my registration form, I would also like them to enter secondary forms that create linked instances (based on the Website and Organization_Contact models).
I know how to solve this problem by completing additional synchronous or asynchronous requests, but I would like the user to fill out three forms and submit with one click.
My problem is that the other two forms rely on the user's foreign key as a field. I created this field "null = True, blank = True" so that I can check and save forms without a foreign key, but in the end I want to add this key to both instances of the model.
I thought that I could check three forms, save UserForm, and then use a model query to return a new User.id (all in one view). Then I would add this user_id value to two other form dictionaries (WebsiteForm and Organization_ContactForm).
This will work like this:
def register_company(request):
if request.method=='POST'
uform=UserCreationForm(request.POST, prefix='user')
sform=SiteForm(request.POST, prefix='site')
oform=OrgForm(request.POST, prefix='site')
if uform.is_valid() and sform.is_valid() and oform.is_valid():
uform.save()
user=User.objects.get(email__iexact=uform.cleaned_data['email'])
uid=unicode(user.id)
Problems: 1) Not sure if I can save the model form and then return the model instance as a set of queries in one view
2) I say that I am not sure, because I could not pass the problem of trying to pass the variable to the set of queries.
get, , . , , .
, ( ), ( ), , ,
, , , .
. .