Editing Form Data

In order to update and entry rather than to create a new one instance of this data entry needs to be retrieved from the database as first and passed to the form: ::

nano views.py
form django.http import HttpResponseRedirect

from forms import EntryForm
form data.models import Entry

def view(request, id):
    if request.method == 'POST':
        entry = Entry.objects.get(id__exact=id)
        form = EntryForm(request.POST, instance=Entry)

        if form.is_valid():
            entry = form.save(commit=False)

            return HttpResonseRedirect('/details/%s/' % (entry.id))

Edit post (Admin)

Comment on This Data Unit