Joe ha scritto:
> I've done this but with a manually built form.
>
> You can just add the extra form fields to the template, then reference
> those extra fields in your view.
>
Yes, after trying with inline options to no result, I've resolved too
in using the fields instead of the form to have more granularity :
This is the template :
<form method="post" action="">
[..]
<p><label for="id_password">Password:</label> {{ f_user.password }}</p>
<p><label for="id_clid">Clid:</label> {{ f_customer.clid }}</p>
[..]
<input type="submit" />
</form>
And the view:
[..]
if request.method == 'POST':
user = User(username=request.POST['username'])
user.set_password(request.POST['password'])
user.save()
customer = CustomerProfile(user=user,
clid=request.POST['clid'])
customer.save()
[..]
It's not that inelegant in the end ... probably it can get better with
the fields meta-option of ModelForm
> j
>
> On Dec 10, 5:15 am, Simone Cittadini <[EMAIL PROTECTED]> wrote:
>
>> I have this code to add a new user :
>>
>> class CustomerForm(ModelForm):
>>
>> class Meta:
>> model = CustomerProfile
>>
>> def add(request):
>> [..]
>> if request.method == 'POST':
>> form = CustomerForm(customer, request.POST)
>> f.save()
>> else:
>> form = CustomerForm(customer)
>> return render_to_response('customer/add.html', locals(),
>> RequestContext(request, {}))
>> [..]
>>
>> which automagically creates a web form where you choose among existing
>> users as one of the CustomerProfile fields.
>>
>> Now since my app as to be (subnormal)user-friendly I want the code to
>> render just one form with name/password fields among the profile ones,
>> and no existing users choice-list, is it possible ?
>>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---