Please, print your variable request.POST on your
view and see if the csrf_token is missing or not?
Same for your formset variable :)

On 02/24/2015 09:55 AM, joulumaa wrote:
Thanks, but I did exactly that and still 403 csrf error, attached my template and related code
thanks for help

<form method="post" action="">
{% csrf_token %}
    <table>
        {{ formset }}
    </table>
 <input type="submit" value="Submit" />
</form>

def school(request):
    SchoolFormSet = modelformset_factory(SchoolHistory)
    if request.method == 'post':
        formset = SchoolFormSetSet(request.POST, request.FILES)
        if formset.is_valid():
            formset.save()
            # do something.
    else:
        formset = SchoolFormSet()
    return render_to_response("testformset.html", {
        "formset": formset,
    })


tiistai 24. helmikuuta 2015 10.31.13 UTC+2 aRkadeFR kirjoitti:

    Hello :)

    The template indeed doesn't show the submit button in the
    documentation here:
    
https://docs.djangoproject.com/en/1.7/topics/forms/formsets/#using-a-formset-in-views-and-templates
    
<https://docs.djangoproject.com/en/1.7/topics/forms/formsets/#using-a-formset-in-views-and-templates>

    In order to add the csrf token, you can use the template tag
    {% csrf %} inside the form tag.
    And add the submit button before closing the form tag too :)

    On 02/24/2015 01:09 AM, joulumaa wrote:
    Hi,
    I just studied and created first modelFormSet, and tried to use
    it in view.
    I have same code in template as is in django documentation.
    modelFormset shows data ok, but submit button is missing,why it
    is not in example template in documentation?
    ok, I added submit button like I have used with basic forms, it
    shows up but cause csrf error,
then I added csrf tag as in form cases before, but still csrf error....

    I am missing some information i guess???, any help for beginner...?

    -Vesa
    btw, i would like to have that saving button on each row in
    formset.... is it possible?
-- 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...@googlegroups.com <javascript:>.
    To post to this group, send email to django...@googlegroups.com
    <javascript:>.
    Visit this group at http://groups.google.com/group/django-users
    <http://groups.google.com/group/django-users>.
    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/django-users/ee930575-0a61-4c74-ad34-847df414f59c%40googlegroups.com
    
<https://groups.google.com/d/msgid/django-users/ee930575-0a61-4c74-ad34-847df414f59c%40googlegroups.com?utm_medium=email&utm_source=footer>.
    For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.


--
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+unsubscr...@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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54EC5805.7000907%40arkade.info.
For more options, visit https://groups.google.com/d/optout.

Reply via email to