Hi Gerd,
I have been following your question quite closely and I wish to find a way to assist. Are you creating multiple forms? If so, are you using Formsets?
I need to understand what exactly you want to accomplish before I can render any assistance.
Sithu
On Saturday, August 31, 2013 4:13:25 PM UTC+2, Gerd Koetje wrote:
-- I have been following your question quite closely and I wish to find a way to assist. Are you creating multiple forms? If so, are you using Formsets?
I need to understand what exactly you want to accomplish before I can render any assistance.
Sithu
On Saturday, August 31, 2013 4:13:25 PM UTC+2, Gerd Koetje wrote:
When i use it with list(form)It shows the form normally, but when i save the form, nothing gets saved, no errors also.im trying a difrant approach now:Im makking multiple forms on forms.py each with the fields i want in it.Code so far, seems to work only when i do for before form2 it wont save form, when i di form2 and then form then it works like a charmViews.py@login_requireddef create(request):if request.POST:logger.debug('>>>>>>>>>>>POST POST POST<<<<<<<<<<<<<<<')form = ProfielenForm(request.POST, instance=request.user.profile)form2 = ProfielenForm2(request.POST, instance=request.user.profile)if form2.is_valid():form2.save()if form.is_valid():form.save()return HttpResponseRedirect('/profielen/all') else:user = request.userprofile = user.profileform = ProfielenForm(instance=profile) form2 = ProfielenForm2(instance=profile) args = {}args.update(csrf(request))args['context_instance'] = RequestContext(request)args['form'] = formargs['form2'] = form2return render(request, 'create_profiel.html', args)create_profiel.html{% extends "base.html" %}{% block sidebar %}<ul><li><a href="/profielen/all">Cancel</a></li> </ul>{% endblock %}{% block content %}<form action="/profielen/create/" method="post">{% csrf_token %}<!-- first --><div id="tabeltop">Kies een profielnaam</div><div id="tabel"><div class="fieldWrapper">{{ form.as_ul }}</div><div style="clear: both;"></div></div><br><!-- first --><div id="tabeltop">anders</div><div id="tabel"><div class="fieldWrapper">{{ form2.as_ul }}</div><div style="clear: both;"></div></div><br><input type="submit" name="submit" value="Update"></form>{% endblock %}forms.pyclass ProfielenForm(forms.ModelForm): class Meta:model = Profielenfields = ('profielnaam',)class ProfielenForm2(forms.ModelForm): #kleurogen = forms.ModelMultipleChoiceField( queryset=Keuzes.objects. filter(groep_id='kleurogen')) #lengtehaar = forms.ModelMultipleChoiceField( queryset=Keuzes.objects. filter(groep_id__name=' lengtehaar')) burgelijkestaat = forms.ModelMultipleChoiceField( queryset=Burgelijkestaat_data. objects, widget=forms. CheckboxSelectMultiple(), required=False) class Meta:model = Profielenfields = ('burgelijkestaat',)class Media:css = {'all': 'checkbox.css',}def __init__(self, *args, **kwargs):super(ProfielenForm2, self).__init__(*args, **kwargs)self.fields['burgelijkestaat'].widget.attrs['class'] = 'checkboxen'
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.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment