You'll need two views to do this, one of them is the form, and that you
already have written. Have you read through the tutorial? It explains how
to use an FBV (which seem to be your preference, which is fine) to create
the other view that lists one or more objects in a table format:

https://docs.djangoproject.com/en/1.7/intro/tutorial03/#write-views-that-actually-do-something

The first column would contain a link to /update_form/<id> where the <id>
is the PK of the object you are displaying on that row (ie {{ object.id }}.
You would specify the URL for the link something like this: <a href="{% url
'url_name' object.id %}">Edit</a>

The template in the tutorial shows everything in an unordered list, but the
template can be easily modified to match the table structure you would
like.

I just noticed that you haven't assigned names to your URL's in urls.py. I
highly recommend you name your URL's so that you can reference them in your
templates easier than using the path to the views.

If you want advanced table functionality (such as sorting by column), I
would look at the django-tables2 package. It does a large majority of the
work for you once you specify the columns you need from your models. (
https://django-tables2.readthedocs.org/en/latest/)

Is this all of the functionality that you'll need? Have you considered
looking at the built-in admin, which provides this functionality with
little to no coding required?

-James

On Sun, Jan 11, 2015 at 6:59 PM, sum abiut <[email protected]> wrote:

> Basically my table structure look something of this type. I want to be
> able to allow users to click on edit and to make changes to to the table.
> just wondering if for loop can do the trick? i am a bit confuse.
>
>      Update
>
> First Name
>
> Last Name
>
> Position
>
> Department
>
> Leave Type
>
>
>    edit
>
>
>
>
>
>
>
>    edit
>
>
>
>
>
>
>
>    edit
>
>
>
>
>
>
>
>    edit
>
>
>
>
>
>
>
>
>
> On Mon, Jan 12, 2015 at 1:33 PM, Edgar Gabaldi <[email protected]>
> wrote:
>
>> add or update multiple rows, maybe you should see a little about
>> formsets[1].
>>
>> [1] https://docs.djangoproject.com/en/1.7/topics/forms/formsets/
>>
>> On Mon, Jan 12, 2015 at 12:30 AM, sum abiut <[email protected]> wrote:
>>
>>> I want to be able to click on a row, update it and then click on another
>>> row update it and so on.
>>>
>>> On Mon, Jan 12, 2015 at 12:58 PM, sum abiut <[email protected]> wrote:
>>>
>>>> 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-y78QXX3um-izEH-n91OMOjsmGuwnN6M105ts_xJKOnJVA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPCf-y78QXX3um-izEH-n91OMOjsmGuwnN6M105ts_xJKOnJVA%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/CAGjPPHna2LxpaTsVv%3DER2qvicYfWH-ftdvCHi8Vx-R5NSXU-jQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAGjPPHna2LxpaTsVv%3DER2qvicYfWH-ftdvCHi8Vx-R5NSXU-jQ%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-y4HfFkEM7b20_j5wv9eEh2wFx7TaPpQT82UpSxoQGhjTQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPCf-y4HfFkEM7b20_j5wv9eEh2wFx7TaPpQT82UpSxoQGhjTQ%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%2BciXP0_hB3EA1wE-z1NgVZkkfufscBVkssO0ZkVqYY15KJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to