Thanks very much Vijay its works. But it doesn't really solve my problem, because i want to be able to edit more than one rows in a table not just one row. any help will be very much appreciated.
Cheers, On Mon, Jan 12, 2015 at 11:38 AM, Vijay Khemlani <[email protected]> wrote: > If you changed the url mapping then you need to include the id of the > newleave in the URL you are accessing, for example > > http://10.0.X.X:8000/update_form/1/ > > On Sun, Jan 11, 2015 at 7:27 PM, sum abiut <[email protected]> wrote: > >> Hi James, >> >> I am try to visit this url http://10.0.X.X:8000/update_form/ >> >> >> >> here is the traceback: >> >> >> Request Method: GET >> Request URL: http://10.0.x.x:8000/update_form/ >> >> Django Version: 1.7.1 >> Python Version: 2.7.6 >> Installed Applications: >> ('django.contrib.admin', >> 'django.contrib.auth', >> 'django.contrib.contenttypes', >> 'django.contrib.sessions', >> 'django.contrib.messages', >> 'django.contrib.staticfiles', >> 'eLeave') >> Installed Middleware: >> ('django.contrib.sessions.middleware.SessionMiddleware', >> 'django.middleware.common.CommonMiddleware', >> 'django.middleware.csrf.CsrfViewMiddleware', >> 'django.contrib.auth.middleware.AuthenticationMiddleware', >> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', >> 'django.contrib.messages.middleware.MessageMiddleware', >> 'django.middleware.clickjacking.XFrameOptionsMiddleware') >> >> >> Traceback: >> File >> "/var/www/html/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" >> in get_response >> 111. response = wrapped_callback(request, >> *callback_args, **callback_kwargs) >> >> Exception Type: TypeError at /update_form/ >> Exception Value: update_form() takes exactly 2 arguments (1 given) >> >> >> >> thanks, >> >> >> >> >> >> >> On Fri, Jan 9, 2015 at 4:46 PM, James Schneider <[email protected]> >> wrote: >> >>> What URL are you visiting and can you post the traceback? >>> On Jan 8, 2015 9:25 PM, "sum abiut" <[email protected]> wrote: >>> >>>> 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 >>>> <https://groups.google.com/d/msgid/django-users/CAPCf-y6t%2BRfjRTDWkBpoeG7djMOGHd6PtG-kZ33giuySJ5%2BQww%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%2BciXUovZySb%3DY6cKL2rrJH_jM8J2yh69-TKYBZJ_fHTjy_Q%40mail.gmail.com >>> <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXUovZySb%3DY6cKL2rrJH_jM8J2yh69-TKYBZJ_fHTjy_Q%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-y4LsKGS%3DV6qGLm-j4g0LqLqWE-0rPLaM2S9jaDmwhxzKQ%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAPCf-y4LsKGS%3DV6qGLm-j4g0LqLqWE-0rPLaM2S9jaDmwhxzKQ%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/CALn3ei1t4YL9Wcet%3DW-GRezakHna8tO6g6z5isMUut0Gx_QEDQ%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CALn3ei1t4YL9Wcet%3DW-GRezakHna8tO6g6z5isMUut0Gx_QEDQ%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-y4%2B7Eg2EXOdRerEi%2BHLPbQAJPF6WChW62F_6s9ALguFDQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

