Hi,
I have change the URL mapping to  url(r'^update_form/(?P<id>\d+)
/$', 'eLeave.views.update_form'),

but i am getting the error

Page not found (404)

any advise i am getting this error?


cheers

On Fri, Jan 9, 2015 at 3:20 PM, Vijay Khemlani <[email protected]> wrote:

> You have two choices
>
> 1. Change the URL mapping and pass the "id" in the url
>
> url(r'^update_form/(?P<id>\d+)/$', 'eLeave.views.update_form'),
>
> (then the url is something like /update_form/15/)
>
> 2, Change the view so that it only accepts the "request" argument
>
> def update_form(request):
>
> in that case you can pass the id in the POST body of the request
>
>
> On Fri, Jan 9, 2015 at 12:50 AM, sum abiut <[email protected]> wrote:
>
>> hi James,
>> here is the url.py
>>
>>    url(r'^update_form/$', 'eLeave.views.update_form'),
>>
>>
>>
>> On Fri, Jan 9, 2015 at 2:19 PM, James Schneider <[email protected]>
>> wrote:
>>
>>> Looks like you aren't sending enough arguments to your view from the URL
>>> dispatcher. What does your urls.py look like?
>>>
>>> -James
>>> On Jan 8, 2015 6:49 PM, "sum abiut" <[email protected]> wrote:
>>>
>>>>
>>>> Hi,
>>>> i am trying to update data in a row from an existing database but i
>>>> keep getting this error.
>>>>
>>>> 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')
>>>>
>>>>
>>>>
>>>> model.py
>>>>
>>>> class newleave(models.Model):
>>>>     First_Name = models.CharField(max_length=45)
>>>>     Last_Name =models.CharField(max_length=45)
>>>>     department=models.CharField(max_length =45)
>>>>     position=models.CharField(max_length =45)
>>>>     leave_type =models.CharField(max_length=45)
>>>>     Specify_details=models.TextField(default="")
>>>>     start_Date =models.DateField(null=True)
>>>>     end_date=models.DateField(null=True)
>>>>     total_working_days=models.IntegerField(null=True)
>>>>     authorization =models.CharField(max_length=45)
>>>>     authorized_by=models.CharField(max_length=45,  default ="")
>>>>     remarks=models.TextField()
>>>>     authorizaion_date =models.DateField(null=True)
>>>>     Total_Leave_Left =models.IntegerField(default=20)
>>>>     username  =models.ForeignKey(User,  default =1)
>>>>     staff =models.ForeignKey(staff,  default =1)
>>>>
>>>>     def __unicode__(self):
>>>>         return self.First_Name
>>>>
>>>>
>>>>
>>>> update_form.html
>>>>
>>>> <form action ="/update_form/" method="post">{%csrf_token%}
>>>> <table>
>>>> {{form.as_table}}
>>>> </table>
>>>> <br>
>>>> <input type="submit" name="submit" value="Save Record" >
>>>>
>>>>
>>>> </form>
>>>>
>>>>
>>>>  --
>>>> 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 [email protected].
>>>> To post to this group, send email to [email protected].
>>>> 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
>>>> <https://groups.google.com/d/msgid/django-users/CAPCf-y4bFqUymcHzSC97znJxitpZvb0XEEwZVhhRm_gkyD%3DFkg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> 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/CA%2Be%2BciWYecZ%3DbVtQ_5geoiOG9ToHfUx1dNjfKVnA9MOxEO2OBg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWYecZ%3DbVtQ_5geoiOG9ToHfUx1dNjfKVnA9MOxEO2OBg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit 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 [email protected].
>> To post to this group, send email to [email protected].
>> 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-y4N9abkcMuUdc0hET7cACLRObKaa53hN8BntJ9vRkpZ2A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y4N9abkcMuUdc0hET7cACLRObKaa53hN8BntJ9vRkpZ2A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit 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 [email protected].
> To post to this group, send email to [email protected].
> 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/CALn3ei3ryzPpeQcjpSUEEEscKe7ZggmHZD6Z-mL1W5SvrkmPqA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALn3ei3ryzPpeQcjpSUEEEscKe7ZggmHZD6Z-mL1W5SvrkmPqA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit 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 [email protected].
To post to this group, send email to [email protected].
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-y6t%2BRfjRTDWkBpoeG7djMOGHd6PtG-kZ33giuySJ5%2BQww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to