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:
>
> 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 charm
>
>
> *Views.py*
>
> @login_required
> def 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.user
> profile = user.profile
> form = ProfielenForm(instance=profile)
> form2 = ProfielenForm2(instance=profile)
>
>
> args = {}
> args.update(csrf(request))
> args['context_instance'] = RequestContext(request)
> args['form'] = form
> args['form2'] = form2
>
>
> return 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.py*
> *
> *
> class ProfielenForm(forms.ModelForm):
>
> class Meta:
> model = Profielen
> fields = ('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 = Profielen
> fields = ('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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.