Search code examples
djangodjango-modelsdjango-formsdjango-viewsdjango-formwizard

updating Database using django form wizard


Hello People here is my code

class FarticlesWizard(SessionWizardView):

def done(self,form_list,**kwargs):
    form_dict={}
    for x in form_list:
        form_dict=dict(form_dict.items()+x.cleaned_data.items())
    insert_db=Marticles(heading = form_dict['heading'],
    content = form_dict['content'],
    country=form_dict['country'],work=form_dict['work'],created_by=self.request.user)
    insert_db.save()
    return HttpResponseRedirect('/display/')

above code works fine by inserting data into database.. now i wanna update database for a particular 'id' is there a way to fix it? iam id through urls.py

url(r'^create/(?P<id>\d+)/$', FarticlesWizard.as_view([F1articles, F2articles])),

above url looks like this

http://MyIp/create/12/

as you can see id=12,now how to update databse for a particular Id??


Solution

  • use obj = Obj.objects.get(pk = some_id) get the id and for displaying use render