Re: Updating data via admin not visible on restful api without admin specified in url until restart server

2017-09-26 Thread Xavier Ordoquy
Hi,

You likely have an issue with scope in your code. Something similar to 
https://stackoverflow.com/questions/15395521/django-form-field-will-not-update-without-server-reset-instantiating-a-clas
 

 for example.

Regards,


> Le 26 sept. 2017 à 21:42, cnn.market...@gmail.com a écrit :
> 
> 
> After login to my account via http://127.0.0.1:8000/admin, I update the data 
> in field 'name' for 'demo'. I can see the updated data for 'name' by using 
> http://127.0.0.1:8000/admin/demo. However, the field 'name' is showing the 
> old data via url (restful api) http://127.0.0.1:8000/demo (NOTICE, no 'admin' 
> in the url) until I manually restart the server via 'python manage.py 
> runserver'.
> 
> Is this a known issue?
> 
> -- 
> 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+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-users@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/75a7bc85-5520-4ff9-a846-fde426b72927%40googlegroups.com
>  
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/FE0B581F-DA2D-48F5-BFEE-C8636AA744B6%40linovia.com.
For more options, visit https://groups.google.com/d/optout.


Re: updating data in a row

2015-01-12 Thread sum abiut
Thanks heaps James, It works perfectly . :)

Cheers,


On Tue, Jan 13, 2015 at 12:48 PM, James Schneider 
wrote:

> 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
> On Jan 12, 2015 4:49 PM, "sum abiut"  wrote:
>
>> I am having a slight issue. click on the edit to working fine but when i
>> make change ans click save. i get this error
>>
>>
>> Page not found (404) Request Method: POST  Request URL:
>> http://10.0.x.x:8000/update_form//
>> i think something is not right on th update_from.html. i just can't seem
>> to figure it out.
>>
>> here are my two templates
>>
>>
>> displayleave.html
>>
>> 
>> 
>>
>> Edit
>>   First Name
>>   Last Name
>>   Position
>>   Department
>>   Leave Type
>>
>>
>> 
>> {%for a in new_leave%}
>> 
>>
>> edit
>> {{a.first_name}}
>>   {{a.last_name}}
>>   {{a.position}}
>>   {{a.department}}
>> {{a.leave_type}}
>>
>>
>>
>>
>> update_form.html
>>
>>
>>
>> {%csrf_token%}
>> 
>> {{form.as_table}}
>> 
>> 
>> 
>>
>>
>>
>>
>>
>> On Tue, Jan 13, 2015 at 10:58 AM, sum abiut  wrote:
>>
>>> Hi James,
>>>
>>> Thanks heaps for your help. your help is very much appreciated . I
>>> manage to fix my issue. I wouldn't have done it without your help. :)
>>>
>>> Cheers.
>>>
>>> On Tue, Jan 13, 2015 at 10:24 AM, sum abiut  wrote:
>>>
 Hi James,

 I have already  coding the two views my problem is updating the rows.
 I am a bit confuse on how to get that done.

 Cheers,

 On Mon, Jan 12, 2015 at 4:27 PM, James Schneider <
 jrschneide...@gmail.com> wrote:

> 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/ where the
>  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: Edit
>
> 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  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 
>> 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 
>>> 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 
 wrote:


Re: updating data in a row

2015-01-12 Thread James Schneider
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
On Jan 12, 2015 4:49 PM, "sum abiut"  wrote:

> I am having a slight issue. click on the edit to working fine but when i
> make change ans click save. i get this error
>
>
> Page not found (404) Request Method: POST  Request URL:
> http://10.0.x.x:8000/update_form//
> i think something is not right on th update_from.html. i just can't seem
> to figure it out.
>
> here are my two templates
>
>
> displayleave.html
>
> 
> 
>
> Edit
>   First Name
>   Last Name
>   Position
>   Department
>   Leave Type
>
>
> 
> {%for a in new_leave%}
> 
>
> edit
> {{a.first_name}}
>   {{a.last_name}}
>   {{a.position}}
>   {{a.department}}
> {{a.leave_type}}
>
>
>
>
> update_form.html
>
>
>
> {%csrf_token%}
> 
> {{form.as_table}}
> 
> 
> 
>
>
>
>
>
> On Tue, Jan 13, 2015 at 10:58 AM, sum abiut  wrote:
>
>> Hi James,
>>
>> Thanks heaps for your help. your help is very much appreciated . I manage
>> to fix my issue. I wouldn't have done it without your help. :)
>>
>> Cheers.
>>
>> On Tue, Jan 13, 2015 at 10:24 AM, sum abiut  wrote:
>>
>>> Hi James,
>>>
>>> I have already  coding the two views my problem is updating the rows.  I
>>> am a bit confuse on how to get that done.
>>>
>>> Cheers,
>>>
>>> On Mon, Jan 12, 2015 at 4:27 PM, James Schneider <
>>> jrschneide...@gmail.com> wrote:
>>>
 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/ where the
  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: Edit

 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  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 
> 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 
>> 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 
>>> 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 <

Re: updating data in a row

2015-01-12 Thread sum abiut
I am having a slight issue. click on the edit to working fine but when i
make change ans click save. i get this error


Page not found (404) Request Method: POST  Request URL:
http://10.0.x.x:8000/update_form//
i think something is not right on th update_from.html. i just can't seem to
figure it out.

here are my two templates


displayleave.html




Edit
  First Name
  Last Name
  Position
  Department
  Leave Type



{%for a in new_leave%}


edit
{{a.first_name}}
  {{a.last_name}}
  {{a.position}}
  {{a.department}}
{{a.leave_type}}




update_form.html



{%csrf_token%}

{{form.as_table}}








On Tue, Jan 13, 2015 at 10:58 AM, sum abiut  wrote:

> Hi James,
>
> Thanks heaps for your help. your help is very much appreciated . I manage
> to fix my issue. I wouldn't have done it without your help. :)
>
> Cheers.
>
> On Tue, Jan 13, 2015 at 10:24 AM, sum abiut  wrote:
>
>> Hi James,
>>
>> I have already  coding the two views my problem is updating the rows.  I
>> am a bit confuse on how to get that done.
>>
>> Cheers,
>>
>> On Mon, Jan 12, 2015 at 4:27 PM, James Schneider > > wrote:
>>
>>> 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/ where the
>>>  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: Edit
>>>
>>> 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  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 
 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  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 
>> 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 >> > 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 
 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',
>  

Re: updating data in a row

2015-01-12 Thread sum abiut
Hi James,

Thanks heaps for your help. your help is very much appreciated . I manage
to fix my issue. I wouldn't have done it without your help. :)

Cheers.

On Tue, Jan 13, 2015 at 10:24 AM, sum abiut  wrote:

> Hi James,
>
> I have already  coding the two views my problem is updating the rows.  I
> am a bit confuse on how to get that done.
>
> Cheers,
>
> On Mon, Jan 12, 2015 at 4:27 PM, James Schneider 
> wrote:
>
>> 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/ where the 
>> 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: Edit
>>
>> 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  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 
>>> 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  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  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 
>> 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 
>>> 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
   

Re: updating data in a row

2015-01-12 Thread sum abiut
Hi James,

I have already  coding the two views my problem is updating the rows.  I am
a bit confuse on how to get that done.

Cheers,

On Mon, Jan 12, 2015 at 4:27 PM, James Schneider 
wrote:

> 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/ where the 
> 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: Edit
>
> 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  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 
>> 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  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  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 
> 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  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 <
>>> 

Re: updating data in a row

2015-01-11 Thread James Schneider
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/ where the 
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: Edit

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  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 
> 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  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  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 
 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  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 <
>> jrschneide...@gmail.com> wrote:
>>
>>> What URL are you visiting and can you post the traceback?
>>> On Jan 8, 2015 9:25 PM, "sum abiut"  wrote:
>>>
 Hi,
 I have change the URL mapping to  url(r'^update_form/(?P\d+)
 /$', 'eLeave.views.update_form'),

 but i am getting the error

 Page not found (404)

 any advise i am 

Re: updating data in a row

2015-01-11 Thread sum abiut
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  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  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  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 
>>> 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  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 <
> jrschneide...@gmail.com> wrote:
>
>> What URL are you visiting and can you post the traceback?
>> On Jan 8, 2015 9:25 PM, "sum abiut"  wrote:
>>
>>> Hi,
>>> I have change the URL mapping to  url(r'^update_form/(?P\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 
>>> wrote:
>>>
 You have two choices

 1. Change the URL mapping and pass the "id" in the url

 url(r'^update_form/(?P\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 
 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 <
> jrschneide...@gmail.com> 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"  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

Re: updating data in a row

2015-01-11 Thread Edgar Gabaldi
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  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  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 
>> 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  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 <
 jrschneide...@gmail.com> wrote:

> What URL are you visiting and can you post the traceback?
> On Jan 8, 2015 9:25 PM, "sum abiut"  wrote:
>
>> Hi,
>> I have change the URL mapping to  url(r'^update_form/(?P\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 
>> wrote:
>>
>>> You have two choices
>>>
>>> 1. Change the URL mapping and pass the "id" in the url
>>>
>>> url(r'^update_form/(?P\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 
>>> 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 <
 jrschneide...@gmail.com> 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"  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': 
>> 

Re: updating data in a row

2015-01-11 Thread sum abiut
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  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 
> 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  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 >> > wrote:
>>>
 What URL are you visiting and can you post the traceback?
 On Jan 8, 2015 9:25 PM, "sum abiut"  wrote:

> Hi,
> I have change the URL mapping to  url(r'^update_form/(?P\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 
> wrote:
>
>> You have two choices
>>
>> 1. Change the URL mapping and pass the "id" in the url
>>
>> url(r'^update_form/(?P\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  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 <
>>> jrschneide...@gmail.com> 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"  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')
>

Re: updating data in a row

2015-01-11 Thread sum abiut
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  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  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 
>> wrote:
>>
>>> What URL are you visiting and can you post the traceback?
>>> On Jan 8, 2015 9:25 PM, "sum abiut"  wrote:
>>>
 Hi,
 I have change the URL mapping to  url(r'^update_form/(?P\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 
 wrote:

> You have two choices
>
> 1. Change the URL mapping and pass the "id" in the url
>
> url(r'^update_form/(?P\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  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 <
>> jrschneide...@gmail.com> 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"  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 

Re: updating data in a row

2015-01-11 Thread Vijay Khemlani
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  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 
> wrote:
>
>> What URL are you visiting and can you post the traceback?
>> On Jan 8, 2015 9:25 PM, "sum abiut"  wrote:
>>
>>> Hi,
>>> I have change the URL mapping to  url(r'^update_form/(?P\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 
>>> wrote:
>>>
 You have two choices

 1. Change the URL mapping and pass the "id" in the url

 url(r'^update_form/(?P\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  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 <
> jrschneide...@gmail.com> 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"  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 

Re: updating data in a row

2015-01-11 Thread sum abiut
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 
wrote:

> What URL are you visiting and can you post the traceback?
> On Jan 8, 2015 9:25 PM, "sum abiut"  wrote:
>
>> Hi,
>> I have change the URL mapping to  url(r'^update_form/(?P\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 
>> wrote:
>>
>>> You have two choices
>>>
>>> 1. Change the URL mapping and pass the "id" in the url
>>>
>>> url(r'^update_form/(?P\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  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 <
 jrschneide...@gmail.com> 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"  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
>>
>> {%csrf_token%}
>> 
>> {{form.as_table}}
>> 
>> 
>> 
>>
>>

Re: updating data in a row

2015-01-08 Thread James Schneider
What URL are you visiting and can you post the traceback?
On Jan 8, 2015 9:25 PM, "sum abiut"  wrote:

> Hi,
> I have change the URL mapping to  url(r'^update_form/(?P\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  wrote:
>
>> You have two choices
>>
>> 1. Change the URL mapping and pass the "id" in the url
>>
>> url(r'^update_form/(?P\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  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 >> > 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"  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
>
> {%csrf_token%}
> 
> {{form.as_table}}
> 
> 
> 
>
>
> 
>
>
>  --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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.
>
  --
 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+unsubscr...@googlegroups.com.
 To post to this group, send email to django-users@googlegroups.com.
 Visit this group at http://groups.google.com/group/django-users.
 To view this discussion on the web visit
 

Re: updating data in a row

2015-01-08 Thread sum abiut
Hi,
I have change the URL mapping to  url(r'^update_form/(?P\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  wrote:

> You have two choices
>
> 1. Change the URL mapping and pass the "id" in the url
>
> url(r'^update_form/(?P\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  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 
>> 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"  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

 {%csrf_token%}
 
 {{form.as_table}}
 
 
 


 


  --
 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+unsubscr...@googlegroups.com.
 To post to this group, send email to django-users@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.

>>>  --
>>> 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+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@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/CA%2Be%2BciWYecZ%3DbVtQ_5geoiOG9ToHfUx1dNjfKVnA9MOxEO2OBg%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>>
>>  --
>> You received 

Re: updating data in a row

2015-01-08 Thread Vijay Khemlani
You have two choices

1. Change the URL mapping and pass the "id" in the url

url(r'^update_form/(?P\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  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 
> 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"  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
>>>
>>> {%csrf_token%}
>>> 
>>> {{form.as_table}}
>>> 
>>> 
>>> 
>>>
>>>
>>> 
>>>
>>>
>>>  --
>>> 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+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@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.
>>>
>>  --
>> 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+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@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/CA%2Be%2BciWYecZ%3DbVtQ_5geoiOG9ToHfUx1dNjfKVnA9MOxEO2OBg%40mail.gmail.com
>> 
>> .
>> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> 

Re: updating data in a row

2015-01-08 Thread sum abiut
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 
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"  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
>>
>> {%csrf_token%}
>> 
>> {{form.as_table}}
>> 
>> 
>> 
>>
>>
>> 
>>
>>
>>  --
>> 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+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@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.
>>
>  --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/CA%2Be%2BciWYecZ%3DbVtQ_5geoiOG9ToHfUx1dNjfKVnA9MOxEO2OBg%40mail.gmail.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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-y4N9abkcMuUdc0hET7cACLRObKaa53hN8BntJ9vRkpZ2A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: updating data in a row

2015-01-08 Thread James Schneider
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"  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
>
> {%csrf_token%}
> 
> {{form.as_table}}
> 
> 
> 
>
>
> 
>
>
>  --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CA%2Be%2BciWYecZ%3DbVtQ_5geoiOG9ToHfUx1dNjfKVnA9MOxEO2OBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Updating data

2010-02-08 Thread Anders Eide
Thank you so much!

I'm new to Django and I have to say that the framework is so easy to
use that it's frustrating to find out how to do things

-Anders

On Feb 8, 3:09 pm, Tom Evans  wrote:
> On Mon, Feb 8, 2010 at 1:46 PM, Anders Eide  wrote:
> > I have a table width movies, and I would like to make a form and a
> > view thats updates a row.
>
> > I build the form automatically from a model
>
> > class SaveMovieForm(ModelForm):
> >    class Meta:
> >        model = Movie
> >    id = forms.IntegerField(
> >        widget = forms.HiddenInput(),
> >        required = False
> >    )
>
> > And populates it like this
>
> > movie = Movie.objects.get(id=id)
>
> > form = SaveMovieForm({
> >    'title' = movie.title,
> >    ...
> > })
>
> > Then sends the form to the template using RequestContext and
> > render_to_response
>
> > But I'm getting the warning that the title already exists. This
> > results in that I can't update the row. How can I tell the form that
> > the request is a update, not a create?
>
> Pass the movie as the instance argument to SaveMovieForm, eg:
>
> form = SaveMovieForm(data=request.POST, instance=movie)
>
> Cheers
>
> Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Updating data

2010-02-08 Thread Tom Evans
On Mon, Feb 8, 2010 at 1:46 PM, Anders Eide  wrote:
> I have a table width movies, and I would like to make a form and a
> view thats updates a row.
>
> I build the form automatically from a model
>
> class SaveMovieForm(ModelForm):
>    class Meta:
>        model = Movie
>    id = forms.IntegerField(
>        widget = forms.HiddenInput(),
>        required = False
>    )
>
> And populates it like this
>
> movie = Movie.objects.get(id=id)
>
> form = SaveMovieForm({
>    'title' = movie.title,
>    ...
> })
>
> Then sends the form to the template using RequestContext and
> render_to_response
>
> But I'm getting the warning that the title already exists. This
> results in that I can't update the row. How can I tell the form that
> the request is a update, not a create?
>

Pass the movie as the instance argument to SaveMovieForm, eg:

form = SaveMovieForm(data=request.POST, instance=movie)

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.