[Fixed]-Django 1.6 UpdateView, losing PK on POST

1👍

You are using action="." for your form, but that strips the primary key from the url because the url pattern does not have a trailing slash.

You can either add a trailing slash to your url pattern

/update/(?P<pk>[\d]+)/$

or change your form’s action in your form helper:

self.helper.form_action = ""

or to be explicit:

self.helper.form_action = reverse('update_user', args=(self.instance.pk,))

Leave a comment