update_form() takes exactly 2 arguments (1 given)
can someone advise what i am missing here.
here are my code:
view.py
def update_form(request, id):
if request.method == 'POST':
a=newleave.objects.get(id=id)
form =leave_application(request.POST, instance=a)
if form.is_valid():
form.save()
return HttpResponseRedirect('successful.html')
else:
a=newleave.objects.get(id=id)
form = leave_application(instance=a)
return render_to_response('update_form.html', {'form': form},context_instance=RequestContext(request))
form.py
class leave_application(forms.ModelForm):
class Meta:
model =newleave
fields =('First_Name', 'Last_Name', 'department', 'position', 'leave_type', 'Specify_details', 'start_Date', 'end_date', 'total_working_days', 'username')
Looks like you aren't sending enough arguments to your view from the URL dispatcher. What does your urls.py look like?
-James
--
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.
To post to this group, send email to django...@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/CAPCf-y4bFqUymcHzSC97znJxitpZvb0XEEwZVhhRm_gkyD%3DFkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWYecZ%3DbVtQ_5geoiOG9ToHfUx1dNjfKVnA9MOxEO2OBg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y4N9abkcMuUdc0hET7cACLRObKaa53hN8BntJ9vRkpZ2A%40mail.gmail.com.
any advise i am getting this error?
cheers
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei3ryzPpeQcjpSUEEEscKe7ZggmHZD6Z-mL1W5SvrkmPqA%40mail.gmail.com.
What URL are you visiting and can you post the traceback?
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y6t%2BRfjRTDWkBpoeG7djMOGHd6PtG-kZ33giuySJ5%2BQww%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXUovZySb%3DY6cKL2rrJH_jM8J2yh69-TKYBZJ_fHTjy_Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y4LsKGS%3DV6qGLm-j4g0LqLqWE-0rPLaM2S9jaDmwhxzKQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei1t4YL9Wcet%3DW-GRezakHna8tO6g6z5isMUut0Gx_QEDQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y78QXX3um-izEH-n91OMOjsmGuwnN6M105ts_xJKOnJVA%40mail.gmail.com.
Update |
First Name |
Last Name |
Position |
Department |
Leave Type |
|
edit |
|
|
|
|
|
|
edit |
|
|
|
|
|
|
edit |
|
|
|
|
|
|
edit |
|
|
|
|
|
|
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGjPPHna2LxpaTsVv%3DER2qvicYfWH-ftdvCHi8Vx-R5NSXU-jQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y4HfFkEM7b20_j5wv9eEh2wFx7TaPpQT82UpSxoQGhjTQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXP0_hB3EA1wE-z1NgVZkkfufscBVkssO0ZkVqYY15KJQ%40mail.gmail.com.
Request Method: | POST |
---|---|
Request URL: | http://10.0.x.x:8000/update_form// |
In your update_form.html, change the action to:
action=""
This will cause the form to POST to the same URL that generated the form, which should be what you want.
More specifically, you don't have access to {{a.id}} in update_form.html (since this is a separate request from the one that generated the form for your list view), so the form action is missing the ID of the object to update, hence the reason the URL listed in your error has a double slash at the end.
-James
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y5aYuXM49JxXvyT-7C2V08DwSXibVV7i2PPkeiCe4jR_w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUhkg_nZQjdhb4ULCiP7v1%3DKpKtRjNeW22NX3dKXwuMSQ%40mail.gmail.com.