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 <

passing variables

2015-01-12 Thread sum abiut
How to you pass variable from one template to another template?

cheers

-- 
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-y451_XOMUF3Ym5BEmaGauFAdTxrj93C0QT8Zus%2BuKairw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrating from OneToOneField to ForeignKey in Django models

2015-01-12 Thread Łukasz Harasimowicz
Hi Colin.

On behalf of my colleague I will answer your question:

We did not have time (at this moment) to investigate this problem any 
further. We've added a raw sql commands to disable foreign key checks 
during this migration. We could do it since we are still learning Django 
(and it's new migrations) and in the end we will probably remove all 
current migrations altogether (just before initial deployment). However we 
also think that this might be a bug and we will try to reproduce this 
problem with a fresh project. Hopefully sometime this week.

W dniu poniedziałek, 12 stycznia 2015 21:32:39 UTC+1 użytkownik Collin 
Anderson napisał:
>
> Hi,
>
> Did you figure it out? This seems like a bug. Can you reproduce it with a 
> fresh project?
>
> Thanks,
> Collin
>
> On Friday, January 9, 2015 at 8:49:56 AM UTC-5, Maciej Szopiński wrote:
>>
>> Hi everyone,
>>
>> I've encountered an issue when working with django and I can't seem to 
>> find a way out of this..
>>
>> I am using django 1.7.2 and a MySQL database. 
>> I have a model that was using a One-to-One relationship with two other 
>> models. At first I thought, the One-to-One relationship will be enough, but 
>> as things changed in the project I had to change the relationship to 
>> Many-to-One.
>>
>> I changed only two lines in my code, in my model I had:
>>
>> product = models.OneToOneField(Product)
>> category = models.OneToOneField(Category)
>>
>> and changed it to:
>>
>> product = models.ForeignKey(Product)
>> category = models.ForeignKey(Category)
>>
>> I created the db migrations using ./manage.py makemigrations, but when I 
>> run the migration with 'migrate' it keeps throwing this error. 
>>
>> django.db.utils.OperationalError: (1553, "Cannot drop index 'product_id': 
>> needed in a foreign key constraint")
>>
>> I tried to check what sql operations are executed in this case and it 
>> seems that django tries to run 
>> ALTER TABLE 'xxx' DROP INDEX 'yyy' and
>> ALTER TABLE `xxx` DROP FOREIGN KEY `xxx_yyy_id_{some_hash}_fk_yyy_id`;
>>
>> I am not sure if this is the right order for these operations, when 
>> running it manually on the database in the reverse order (first the DROP 
>> FOREIGN KEY then DROP INDEX) it works correctly. 
>>
>> Have you encountered this issue before? Have you got any suggestions on 
>> how to resolve this situation? 
>> I would like to avoid any manual SQL changes outside of django 
>> migrations. 
>>
>> Thanks in advance. 
>>
>> Best regards, 
>> Maciej Szopiński
>>
>

-- 
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/5f27985a-fe24-4ac0-9d6e-838445587f6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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: Many-To-Many Relationship changes not accessible in Model.save() ?

2015-01-12 Thread Tobias Dacoir
Thanks for the links. It might be related to that bug. In my scripts I 
added another save() and then it works of course and as for the Admin 
Panel, until I have a solution I put a message into the help text that 
users have to click 'save and continue' first and then 'save' afterwards. 
Then it's fine as well. Phew at least the workaround was quickly 
implemented, still I spend at least 1 hour on figuring out what's going 
wrong. 

-- 
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/ef541b28-43c1-4a4a-a85d-466e76e3e381%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New data field in models.py "does not exist".

2015-01-12 Thread James Schneider
Apologies, Vijay is right. Syncdb will only add new tables (models) on the
fly, not new columns to existing tables. It's been a while since I've had
to deal with syncdb. See here:

https://docs.djangoproject.com/en/1.6/ref/django-admin/#syncdb

The OP will need to issue direct ALTER TABLE commands in the DB, or set up
a schema migration using South.

If you can recreate your existing data or are still in development, you can
drop the entire database and recreate it using 'syncdb', but only do that
in the event you don't mind losing all data in your database. Backup your
data accordingly before performing any irreversible operation.

I'll jump on the "upgrade to 1.7" train in this case, if possible.
Migrations (introduced in 1.7) will handle this situation just fine.

-James

On Mon, Jan 12, 2015 at 12:57 PM, Vijay Khemlani  wrote:

> I just tested it with Django 1.6.9, syncdb does not add fields to existing
> models
>
> On Mon, Jan 12, 2015 at 5:20 PM, James Schneider 
> wrote:
>
>> Adding a column to a model is supported by syncdb, no need for South
>> migrations. Any other operation (ie changing/deleting an existing column)
>> would require a South migration or a manual alteration on the DB itself.
>>
>> -James
>> On Jan 12, 2015 12:16 PM, "James Schneider" 
>> wrote:
>>
>>> The OP is running 1.6 based on the output he provided, so migrations
>>> don't apply.
>>>
>>> You'll need to log into the database directly and interrogate the table
>>> to see what columns actually exist. The error message is coming directly
>>> from the database when the query is executed, not sourced from Django
>>> (Django is just passing it along).
>>>
>>> You should also try running syncdb again. It should be an idempotent
>>> operation, assuming that you haven't made any other changes to your model
>>> code, so you can run it as many times as you want.
>>>
>>> -James
>>> On Jan 12, 2015 11:40 AM, "Vijay Khemlani"  wrote:
>>>
 sqlall only prints the commands that would be executed to create the
 database from scratch, it does not output your current database schema

 if you are using django 1.7, then you need to create a migratino and
 apply it

 python manage.py makemigrations
 python manage.py migrate

 On Mon, Jan 12, 2015 at 4:31 PM, dennis breland 
 wrote:

>
> On Monday, January 12, 2015 at 1:16:17 PM UTC-5, dennis breland wrote:
>>
>> All works fine before making this change.
>>
>> I added new data named "photo" in models.py and admin.py
>> When I bring up the web page, I get this:
>>
>> ProgrammingError at /admin/recipe/dish/
>>
>> column recipe_dish.photo does not exist
>> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style",
>> "recipe_di...
>>  ^
>>
>> Request Method:  GET
>> Request URL:  http://104.236.74.80/admin/recipe/dish/
>> Django Version:  1.6.1
>> Exception Type:  ProgrammingError
>> Exception Value:
>>
>> column recipe_dish.photo does not exist
>> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style",
>> "recipe_di...
>>  ^
>>
>> Exception Location:  /usr/lib/python2.7/dist-
>> packages/django/db/backends/util.py in execute, line 53
>> Python Executable:  /usr/bin/python
>> Python Version:  2.7.6
>> Python Path:
>>
>> ['/home/django/django_project',
>>  '/home/django',
>>  '/usr/bin',
>>  '/usr/lib/python2.7',
>>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>>  '/usr/lib/python2.7/lib-tk',
>>  '/usr/lib/python2.7/lib-old',
>>  '/usr/lib/python2.7/lib-dynload',
>>  '/usr/local/lib/python2.7/dist-packages',
>>  '/usr/lib/python2.7/dist-packages']
>>
>>
>>
>>
>> Here's all the data -
>>
>> models.py:
>>
>> .
>>
>> .
>>
>>
>> class Dish(models.Model):
>> dish_name = models.CharField(max_length=200)
>> steps = models.TextField(default='1. Mix some stuff')
>> def __str__(self):  # Do this for every class.
>> return self.dish_name   # No matter which object is
>> called, the name field is returned.
>>
>>
>> description = models.TextField(default='Does this dish have a
>> story?')
>> ingredients = models.TextField(default='1. Sugar ')
>> utensils = models.TextField(default='1. Bowl')
>> cook_time = models.CharField(max_length=20, default='1 hour, 20
>> minutes')
>> prep_time = models.CharField(max_length=20, default='20 minutes')
>> dish_category = models.CharField(max_length=20,
>> choices=FOOD_CATEGORIES)
>> style = models.CharField(max_length=20, choices=FOOD_STYLE)
>>

Re: Many-To-Many Relationship changes not accessible in Model.save() ?

2015-01-12 Thread Lachlan Musicman
Is that related to this bug?

https://code.djangoproject.com/ticket/8892
https://code.djangoproject.com/ticket/10811

In short - if FK fields aren't saved as objects themselves first, then
they aren't correctly added to the new objects?

I had trouble with this once. Maybe put in a save after the get_or_creates?

cheers
L.
--
"This is a profound psychological violence here. How can one even
begin to speak of dignity in labor when one secretly feels one's job
should not exist?"

On the Phenomenon of Bullshit Jobs, David Graeber
http://strikemag.org/bullshit-jobs/


On 13 January 2015 at 08:06, Tobias Dacoir  wrote:
> I'm trying to access the value of a many-to-many relationship during the
> save() method of my model but it always returns the state it had before,
> even though the first thing I do is call super.save().
>
> class Database(models.Model):
> ...
> questions = models.ManyToManyField(Question)
> pathToAudioFiles = models.CharField(max_length=255, unique=True,
> help_text="Please type in path to folder with Audio Files, e.g.
> media/database1/*.mp3", verbose_name="Path to Audio Files")
>
> def audioData(self):
> return AudioData.objects.filter(database=self.pk)
>
> def __unicode__(self):
> return self.name
>
> def save(self, *args, **kwargs):
> super(Database, self).save(*args, **kwargs)
>
> filelist = glob.glob(self.pathToAudioFiles)
> for file in filelist:
> print "adding file %s" % file
> audioData = AudioData.objects.get_or_create(path=file,
> filename=file, database=self)
>
> # then update pairs
> for a in self.audioData():
> print 'working on %s' % a
> print self.questions.all()
> for q in self.questions.all():
> print "creating pairs with %s" % q
> pair = AudioQuestionPair.objects.get_or_create(audioData=a,
> question=q, database=self)
> for choice in q.choices:
> print "adding answer %s" % choice
> answer = Answers.objects.get_or_create(body=choice,
> audioQuestionPair=pair)
>
> In this case, the idea is that the Admin can add a new 'database' (they
> wanted to call it that way), that contains some audio files that are stored
> somewhere on disk. so far so good. Later on, using the Django Admin Panel
> the admin modifies the questions. When I use the shell I get this output,
> which is normal:
 from play.models import *
 db = Database.objects.create(name="database1",
 pathToAudioFiles="media/database1/*.mp3")
> adding file media/database1\devel_001.mp3
> adding file media/database1\devel_010.mp3
> working on media/database1\devel_001.mp3
> []
> working on media/database1\devel_010.mp3
> []
>
> Then I go to the Admin Panel and edit the associated questions of that
> object, and when I hit save:
> [12/Jan/2015 21:57:50] "GET /admin/play/database/1/ HTTP/1.1" 200 7021
> [12/Jan/2015 21:57:50] "GET /admin/jsi18n/ HTTP/1.1" 200 2372
> adding file media/database1\devel_001.mp3
> adding file media/database1\devel_010.mp3
> working on media/database1\devel_001.mp3
> []
> working on media/database1\devel_010.mp3
> []
> [12/Jan/2015 21:57:56] "POST /admin/play/database/1/ HTTP/1.1" 302 0
>
> So even though I did change the associations it's not accessible during the
> save method. It still turns up empty. How can I solve this? After hitting
> save I need to be able to process self.questions.all() right away.
>
>
>
> --
> 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/16f1653a-764c-4163-9c13-c661513d9321%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGBeqiM_8F4jC24p0Y5uDq0%3DveCpiteAP-%3D6mb8%2BANiKCiRUmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Many-To-Many Relationship changes not accessible in Model.save() ?

2015-01-12 Thread Tobias Dacoir
I'm trying to access the value of a many-to-many relationship during the 
save() method of my model but it always returns the state it had before, 
even though the first thing I do is call super.save().

class Database(models.Model):
...
questions = models.ManyToManyField(Question)
pathToAudioFiles = models.CharField(max_length=255, unique=True, 
help_text="Please type in path to folder with Audio Files, e.g. 
media/database1/*.mp3", verbose_name="Path to Audio Files")

def audioData(self):
return AudioData.objects.filter(database=self.pk)

def __unicode__(self):
return self.name

def save(self, *args, **kwargs):
super(Database, self).save(*args, **kwargs)

filelist = glob.glob(self.pathToAudioFiles)
for file in filelist:
print "adding file %s" % file
audioData = AudioData.objects.get_or_create(path=file, filename=
file, database=self)

# then update pairs
for a in self.audioData():
print 'working on %s' % a
print self.questions.all()
for q in self.questions.all():
print "creating pairs with %s" % q
pair = AudioQuestionPair.objects.get_or_create(audioData=a, 
question=q, database=self)
for choice in q.choices:
print "adding answer %s" % choice
answer = Answers.objects.get_or_create(body=choice, 
audioQuestionPair=pair)

In this case, the idea is that the Admin can add a new 'database' (they 
wanted to call it that way), that contains some audio files that are stored 
somewhere on disk. so far so good. Later on, using the Django Admin Panel 
the admin modifies the questions. When I use the shell I get this output, 
which is normal:
>>> from play.models import *
>>> db = Database.objects.create(name="database1", pathToAudioFiles=
"media/database1/*.mp3")
adding file media/database1\devel_001.mp3
adding file media/database1\devel_010.mp3
working on media/database1\devel_001.mp3
[]
working on media/database1\devel_010.mp3
[]

Then I go to the Admin Panel and edit the associated questions of that 
object, and when I hit save:
[12/Jan/2015 21:57:50] "GET /admin/play/database/1/ HTTP/1.1" 200 7021
[12/Jan/2015 21:57:50] "GET /admin/jsi18n/ HTTP/1.1" 200 2372
adding file media/database1\devel_001.mp3
adding file media/database1\devel_010.mp3
working on media/database1\devel_001.mp3
[]
working on media/database1\devel_010.mp3
[]
[12/Jan/2015 21:57:56] "POST /admin/play/database/1/ HTTP/1.1" 302 0

So even though I did change the associations it's not accessible during the 
save method. It still turns up empty. How can I solve this? After hitting 
save I need to be able to process self.questions.all() right away.



-- 
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/16f1653a-764c-4163-9c13-c661513d9321%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Every field is readonly in admin site

2015-01-12 Thread Collin Anderson
Hi,

Are they not showing up in the admin at all, or are they showing up but 
read-only?

Are you calling "admin.site.register(MyModel)" in admin.py?

Is your user a "superuser" in django?

Collin

On Sunday, January 11, 2015 at 4:30:50 AM UTC-5, Abhinav Agarwal wrote:
>
> I am not getting and 'change' and 'delete' options for user, groups and 
> apps(every model). 
> I have added admin.autodiscover() in url.py
> I have also imported models in admin.py
>

-- 
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/c9b0d574-2ae8-4ed2-90bc-18c1e8e9555d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New data field in models.py "does not exist".

2015-01-12 Thread Vijay Khemlani
I just tested it with Django 1.6.9, syncdb does not add fields to existing
models

On Mon, Jan 12, 2015 at 5:20 PM, James Schneider 
wrote:

> Adding a column to a model is supported by syncdb, no need for South
> migrations. Any other operation (ie changing/deleting an existing column)
> would require a South migration or a manual alteration on the DB itself.
>
> -James
> On Jan 12, 2015 12:16 PM, "James Schneider" 
> wrote:
>
>> The OP is running 1.6 based on the output he provided, so migrations
>> don't apply.
>>
>> You'll need to log into the database directly and interrogate the table
>> to see what columns actually exist. The error message is coming directly
>> from the database when the query is executed, not sourced from Django
>> (Django is just passing it along).
>>
>> You should also try running syncdb again. It should be an idempotent
>> operation, assuming that you haven't made any other changes to your model
>> code, so you can run it as many times as you want.
>>
>> -James
>> On Jan 12, 2015 11:40 AM, "Vijay Khemlani"  wrote:
>>
>>> sqlall only prints the commands that would be executed to create the
>>> database from scratch, it does not output your current database schema
>>>
>>> if you are using django 1.7, then you need to create a migratino and
>>> apply it
>>>
>>> python manage.py makemigrations
>>> python manage.py migrate
>>>
>>> On Mon, Jan 12, 2015 at 4:31 PM, dennis breland 
>>> wrote:
>>>

 On Monday, January 12, 2015 at 1:16:17 PM UTC-5, dennis breland wrote:
>
> All works fine before making this change.
>
> I added new data named "photo" in models.py and admin.py
> When I bring up the web page, I get this:
>
> ProgrammingError at /admin/recipe/dish/
>
> column recipe_dish.photo does not exist
> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style",
> "recipe_di...
>  ^
>
> Request Method:  GET
> Request URL:  http://104.236.74.80/admin/recipe/dish/
> Django Version:  1.6.1
> Exception Type:  ProgrammingError
> Exception Value:
>
> column recipe_dish.photo does not exist
> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style",
> "recipe_di...
>  ^
>
> Exception Location:  /usr/lib/python2.7/dist-
> packages/django/db/backends/util.py in execute, line 53
> Python Executable:  /usr/bin/python
> Python Version:  2.7.6
> Python Path:
>
> ['/home/django/django_project',
>  '/home/django',
>  '/usr/bin',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages']
>
>
>
>
> Here's all the data -
>
> models.py:
>
> .
>
> .
>
>
> class Dish(models.Model):
> dish_name = models.CharField(max_length=200)
> steps = models.TextField(default='1. Mix some stuff')
> def __str__(self):  # Do this for every class.
> return self.dish_name   # No matter which object is
> called, the name field is returned.
>
>
> description = models.TextField(default='Does this dish have a
> story?')
> ingredients = models.TextField(default='1. Sugar ')
> utensils = models.TextField(default='1. Bowl')
> cook_time = models.CharField(max_length=20, default='1 hour, 20
> minutes')
> prep_time = models.CharField(max_length=20, default='20 minutes')
> dish_category = models.CharField(max_length=20,
> choices=FOOD_CATEGORIES)
> style = models.CharField(max_length=20, choices=FOOD_STYLE)
>
> photo = models.CharField(max_length=20, default='photodefault')
>
>
> .
>
> .
>
>
>
> admin.py:
> .
> .
>
> class DishAdmin(admin.ModelAdmin):
> #fields = ['dish_name', 'style', 'dish_category','steps','
> ingredients','utensils','cook_time','prep_time','description']
>
> # list_display is optional. When not used, the str() of each
> object is displayed.
> # This list contains the columns that are displayed on the Dish
> list page.
> # These items are the field names in the class Dish (with
> underscores replaced with spaces) that is defined in models.py
> # Not every field in the class is required to be here, only those
> desired.
> list_display = ('dish_name', 'style', 'dish_category')
>
> search_fields = ['dish_name']
>
> fieldsets = [
> ('None',{'fields': ['dish_name', 'style',
> 

Re: Two QuerySets on a FormSet

2015-01-12 Thread Collin Anderson
Hi,

You can merge the two querysets like this. Would that help?

qs = Song.objects.filter(artist__made_by=request.user) | Song.objects.filter
(album__made_by=request.user)

or use models.Q

from django.db.models import Q
qs = Song.objects.filter(Q(artist__made_by=request.user) | Q(album__made_by=
request.user))

Collin

On Friday, January 9, 2015 at 11:19:01 AM UTC-5, Some Developer wrote:
>
> I have a model Song which has a FormSet associated with it using a 
> ModelForm. 
>
> The Song model has two ForeignKeys (Artist and Album) but I want to 
> limit the options shown in the FormSet to only Artists and Albums made 
> by the currently logged in user. I know to make the QuerySets themselves 
> but I don't know how to associate the two QuerySets with the FormSet. 
>
> I know you can specify one QuerySet by editing the ModelForm instance 
> but I don't see how I would get the current logged in user when doing 
> this and as I said this only lets you specify one QuerySet rather than 
> the two I require as far as I understand it. 
>
> Any help is appreciated. 
>

-- 
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/c06a0ed5-6447-47a2-9238-e5115f1a9c49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What forms library do you pick for a new Project?

2015-01-12 Thread Collin Anderson
Hi,

I personally always do it by hand without a library. What are you hoping to 
get out of your form library?

Collin

On Friday, January 9, 2015 at 9:18:29 AM UTC-5, Frank Bieniek wrote:
>
> Hi All,
>
> I do need a recommendation for the current top notch forms library to use 
> for a new bigger project?
> The project does not have that much of planned ajaxified forms...
>
> django-crispy-forms 1.4 - 2013
> django-floppyforms 1.3 - dec 2014
> django-bootstrap3 5.0.3 - dec 2014
>
> Which one would you pick, and why?
>
> Thanks
> Frank
>
>
>

-- 
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/a2547206-1db7-4128-b158-40a127c49d92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrating from OneToOneField to ForeignKey in Django models

2015-01-12 Thread Collin Anderson
Hi,

Did you figure it out? This seems like a bug. Can you reproduce it with a 
fresh project?

Thanks,
Collin

On Friday, January 9, 2015 at 8:49:56 AM UTC-5, Maciej Szopiński wrote:
>
> Hi everyone,
>
> I've encountered an issue when working with django and I can't seem to 
> find a way out of this..
>
> I am using django 1.7.2 and a MySQL database. 
> I have a model that was using a One-to-One relationship with two other 
> models. At first I thought, the One-to-One relationship will be enough, but 
> as things changed in the project I had to change the relationship to 
> Many-to-One.
>
> I changed only two lines in my code, in my model I had:
>
> product = models.OneToOneField(Product)
> category = models.OneToOneField(Category)
>
> and changed it to:
>
> product = models.ForeignKey(Product)
> category = models.ForeignKey(Category)
>
> I created the db migrations using ./manage.py makemigrations, but when I 
> run the migration with 'migrate' it keeps throwing this error. 
>
> django.db.utils.OperationalError: (1553, "Cannot drop index 'product_id': 
> needed in a foreign key constraint")
>
> I tried to check what sql operations are executed in this case and it 
> seems that django tries to run 
> ALTER TABLE 'xxx' DROP INDEX 'yyy' and
> ALTER TABLE `xxx` DROP FOREIGN KEY `xxx_yyy_id_{some_hash}_fk_yyy_id`;
>
> I am not sure if this is the right order for these operations, when 
> running it manually on the database in the reverse order (first the DROP 
> FOREIGN KEY then DROP INDEX) it works correctly. 
>
> Have you encountered this issue before? Have you got any suggestions on 
> how to resolve this situation? 
> I would like to avoid any manual SQL changes outside of django migrations. 
>
> Thanks in advance. 
>
> Best regards, 
> Maciej Szopiński
>

-- 
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/e339bf29-1dbd-4452-9d57-24741bc53bfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New data field in models.py "does not exist".

2015-01-12 Thread James Schneider
Adding a column to a model is supported by syncdb, no need for South
migrations. Any other operation (ie changing/deleting an existing column)
would require a South migration or a manual alteration on the DB itself.

-James
On Jan 12, 2015 12:16 PM, "James Schneider"  wrote:

> The OP is running 1.6 based on the output he provided, so migrations don't
> apply.
>
> You'll need to log into the database directly and interrogate the table to
> see what columns actually exist. The error message is coming directly from
> the database when the query is executed, not sourced from Django (Django is
> just passing it along).
>
> You should also try running syncdb again. It should be an idempotent
> operation, assuming that you haven't made any other changes to your model
> code, so you can run it as many times as you want.
>
> -James
> On Jan 12, 2015 11:40 AM, "Vijay Khemlani"  wrote:
>
>> sqlall only prints the commands that would be executed to create the
>> database from scratch, it does not output your current database schema
>>
>> if you are using django 1.7, then you need to create a migratino and
>> apply it
>>
>> python manage.py makemigrations
>> python manage.py migrate
>>
>> On Mon, Jan 12, 2015 at 4:31 PM, dennis breland 
>> wrote:
>>
>>>
>>> On Monday, January 12, 2015 at 1:16:17 PM UTC-5, dennis breland wrote:

 All works fine before making this change.

 I added new data named "photo" in models.py and admin.py
 When I bring up the web page, I get this:

 ProgrammingError at /admin/recipe/dish/

 column recipe_dish.photo does not exist
 LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style",
 "recipe_di...
  ^

 Request Method:  GET
 Request URL:  http://104.236.74.80/admin/recipe/dish/
 Django Version:  1.6.1
 Exception Type:  ProgrammingError
 Exception Value:

 column recipe_dish.photo does not exist
 LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style",
 "recipe_di...
  ^

 Exception Location:  /usr/lib/python2.7/dist-
 packages/django/db/backends/util.py in execute, line 53
 Python Executable:  /usr/bin/python
 Python Version:  2.7.6
 Python Path:

 ['/home/django/django_project',
  '/home/django',
  '/usr/bin',
  '/usr/lib/python2.7',
  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
  '/usr/lib/python2.7/lib-tk',
  '/usr/lib/python2.7/lib-old',
  '/usr/lib/python2.7/lib-dynload',
  '/usr/local/lib/python2.7/dist-packages',
  '/usr/lib/python2.7/dist-packages']




 Here's all the data -

 models.py:

 .

 .


 class Dish(models.Model):
 dish_name = models.CharField(max_length=200)
 steps = models.TextField(default='1. Mix some stuff')
 def __str__(self):  # Do this for every class.
 return self.dish_name   # No matter which object is called,
 the name field is returned.


 description = models.TextField(default='Does this dish have a
 story?')
 ingredients = models.TextField(default='1. Sugar ')
 utensils = models.TextField(default='1. Bowl')
 cook_time = models.CharField(max_length=20, default='1 hour, 20
 minutes')
 prep_time = models.CharField(max_length=20, default='20 minutes')
 dish_category = models.CharField(max_length=20,
 choices=FOOD_CATEGORIES)
 style = models.CharField(max_length=20, choices=FOOD_STYLE)

 photo = models.CharField(max_length=20, default='photodefault')


 .

 .



 admin.py:
 .
 .

 class DishAdmin(admin.ModelAdmin):
 #fields = ['dish_name', 'style', 'dish_category','steps','
 ingredients','utensils','cook_time','prep_time','description']

 # list_display is optional. When not used, the str() of each object
 is displayed.
 # This list contains the columns that are displayed on the Dish
 list page.
 # These items are the field names in the class Dish (with
 underscores replaced with spaces) that is defined in models.py
 # Not every field in the class is required to be here, only those
 desired.
 list_display = ('dish_name', 'style', 'dish_category')

 search_fields = ['dish_name']

 fieldsets = [
 ('None',{'fields': ['dish_name', 'style',
 'dish_category', 'photo',  'steps', 'ingredients', 'utensils']}),
 ('Times',   {'fields': ['cook_time','prep_time'],'classes':
 ['collapse']}),
 ('Description', {'fields': ['description'],'classes':
 ['collapse']}),
 ]

 .
 .


 I ran these after 

Re: New data field in models.py "does not exist".

2015-01-12 Thread James Schneider
The OP is running 1.6 based on the output he provided, so migrations don't
apply.

You'll need to log into the database directly and interrogate the table to
see what columns actually exist. The error message is coming directly from
the database when the query is executed, not sourced from Django (Django is
just passing it along).

You should also try running syncdb again. It should be an idempotent
operation, assuming that you haven't made any other changes to your model
code, so you can run it as many times as you want.

-James
On Jan 12, 2015 11:40 AM, "Vijay Khemlani"  wrote:

> sqlall only prints the commands that would be executed to create the
> database from scratch, it does not output your current database schema
>
> if you are using django 1.7, then you need to create a migratino and apply
> it
>
> python manage.py makemigrations
> python manage.py migrate
>
> On Mon, Jan 12, 2015 at 4:31 PM, dennis breland 
> wrote:
>
>>
>> On Monday, January 12, 2015 at 1:16:17 PM UTC-5, dennis breland wrote:
>>>
>>> All works fine before making this change.
>>>
>>> I added new data named "photo" in models.py and admin.py
>>> When I bring up the web page, I get this:
>>>
>>> ProgrammingError at /admin/recipe/dish/
>>>
>>> column recipe_dish.photo does not exist
>>> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style",
>>> "recipe_di...
>>>  ^
>>>
>>> Request Method:  GET
>>> Request URL:  http://104.236.74.80/admin/recipe/dish/
>>> Django Version:  1.6.1
>>> Exception Type:  ProgrammingError
>>> Exception Value:
>>>
>>> column recipe_dish.photo does not exist
>>> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style",
>>> "recipe_di...
>>>  ^
>>>
>>> Exception Location:  /usr/lib/python2.7/dist-
>>> packages/django/db/backends/util.py in execute, line 53
>>> Python Executable:  /usr/bin/python
>>> Python Version:  2.7.6
>>> Python Path:
>>>
>>> ['/home/django/django_project',
>>>  '/home/django',
>>>  '/usr/bin',
>>>  '/usr/lib/python2.7',
>>>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>>>  '/usr/lib/python2.7/lib-tk',
>>>  '/usr/lib/python2.7/lib-old',
>>>  '/usr/lib/python2.7/lib-dynload',
>>>  '/usr/local/lib/python2.7/dist-packages',
>>>  '/usr/lib/python2.7/dist-packages']
>>>
>>>
>>>
>>>
>>> Here's all the data -
>>>
>>> models.py:
>>>
>>> .
>>>
>>> .
>>>
>>>
>>> class Dish(models.Model):
>>> dish_name = models.CharField(max_length=200)
>>> steps = models.TextField(default='1. Mix some stuff')
>>> def __str__(self):  # Do this for every class.
>>> return self.dish_name   # No matter which object is called,
>>> the name field is returned.
>>>
>>>
>>> description = models.TextField(default='Does this dish have a
>>> story?')
>>> ingredients = models.TextField(default='1. Sugar ')
>>> utensils = models.TextField(default='1. Bowl')
>>> cook_time = models.CharField(max_length=20, default='1 hour, 20
>>> minutes')
>>> prep_time = models.CharField(max_length=20, default='20 minutes')
>>> dish_category = models.CharField(max_length=20,
>>> choices=FOOD_CATEGORIES)
>>> style = models.CharField(max_length=20, choices=FOOD_STYLE)
>>>
>>> photo = models.CharField(max_length=20, default='photodefault')
>>>
>>>
>>> .
>>>
>>> .
>>>
>>>
>>>
>>> admin.py:
>>> .
>>> .
>>>
>>> class DishAdmin(admin.ModelAdmin):
>>> #fields = ['dish_name', 'style', 'dish_category','steps','
>>> ingredients','utensils','cook_time','prep_time','description']
>>>
>>> # list_display is optional. When not used, the str() of each object
>>> is displayed.
>>> # This list contains the columns that are displayed on the Dish list
>>> page.
>>> # These items are the field names in the class Dish (with
>>> underscores replaced with spaces) that is defined in models.py
>>> # Not every field in the class is required to be here, only those
>>> desired.
>>> list_display = ('dish_name', 'style', 'dish_category')
>>>
>>> search_fields = ['dish_name']
>>>
>>> fieldsets = [
>>> ('None',{'fields': ['dish_name', 'style',
>>> 'dish_category', 'photo',  'steps', 'ingredients', 'utensils']}),
>>> ('Times',   {'fields': ['cook_time','prep_time'],'classes':
>>> ['collapse']}),
>>> ('Description', {'fields': ['description'],'classes':
>>> ['collapse']}),
>>> ]
>>>
>>> .
>>> .
>>>
>>>
>>> I ran these after making the changes:
>>> python manage.py sqlall recipe
>>> python manage.py syncdb
>>>
>>>
>>>
>>>
>>> python manage.py sqlall recipe
>>> BEGIN;
>>> CREATE TABLE "recipe_site" (
>>> "id" serial NOT NULL PRIMARY KEY,
>>> "locations" varchar(200) NOT NULL
>>> )
>>> ;
>>> CREATE TABLE "recipe_dish" (
>>> "id" serial NOT NULL PRIMARY KEY,
>>> "dish_name" varchar(200) NOT NULL,
>>> "steps" text NOT NULL,
>>> "description" text 

Re: New data field in models.py "does not exist".

2015-01-12 Thread Vijay Khemlani
Then you need to install south and configure it or update to django 1.7

On Mon, Jan 12, 2015 at 4:54 PM, dennis breland 
wrote:

> I am using Django 1.6
>
>
> On Monday, January 12, 2015 at 1:16:17 PM UTC-5, dennis breland wrote:
>
>> All works fine before making this change.
>>
>> I added new data named "photo" in models.py and admin.py
>> When I bring up the web page, I get this:
>>
>> ProgrammingError at /admin/recipe/dish/
>>
>> column recipe_dish.photo does not exist
>> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>>  ^
>>
>> Request Method:  GET
>> Request URL:  http://104.236.74.80/admin/recipe/dish/
>> Django Version:  1.6.1
>> Exception Type:  ProgrammingError
>> Exception Value:
>>
>> column recipe_dish.photo does not exist
>> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>>  ^
>>
>> Exception Location:  
>> /usr/lib/python2.7/dist-packages/django/db/backends/util.py
>> in execute, line 53
>> Python Executable:  /usr/bin/python
>> Python Version:  2.7.6
>> Python Path:
>>
>> ['/home/django/django_project',
>>  '/home/django',
>>  '/usr/bin',
>>  '/usr/lib/python2.7',
>>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>>  '/usr/lib/python2.7/lib-tk',
>>  '/usr/lib/python2.7/lib-old',
>>  '/usr/lib/python2.7/lib-dynload',
>>  '/usr/local/lib/python2.7/dist-packages',
>>  '/usr/lib/python2.7/dist-packages']
>>
>>
>>
>>
>> Here's all the data -
>>
>> models.py:
>>
>> .
>>
>> .
>>
>>
>> class Dish(models.Model):
>> dish_name = models.CharField(max_length=200)
>> steps = models.TextField(default='1. Mix some stuff')
>> def __str__(self):  # Do this for every class.
>> return self.dish_name   # No matter which object is called,
>> the name field is returned.
>>
>>
>> description = models.TextField(default='Does this dish have a story?')
>> ingredients = models.TextField(default='1. Sugar ')
>> utensils = models.TextField(default='1. Bowl')
>> cook_time = models.CharField(max_length=20, default='1 hour, 20
>> minutes')
>> prep_time = models.CharField(max_length=20, default='20 minutes')
>> dish_category = models.CharField(max_length=20,
>> choices=FOOD_CATEGORIES)
>> style = models.CharField(max_length=20, choices=FOOD_STYLE)
>>
>> photo = models.CharField(max_length=20, default='photodefault')
>>
>>
>> .
>>
>> .
>>
>>
>>
>> admin.py:
>> .
>> .
>>
>> class DishAdmin(admin.ModelAdmin):
>> #fields = ['dish_name', 'style', 'dish_category','steps','
>> ingredients','utensils','cook_time','prep_time','description']
>>
>> # list_display is optional. When not used, the str() of each object
>> is displayed.
>> # This list contains the columns that are displayed on the Dish list
>> page.
>> # These items are the field names in the class Dish (with underscores
>> replaced with spaces) that is defined in models.py
>> # Not every field in the class is required to be here, only those
>> desired.
>> list_display = ('dish_name', 'style', 'dish_category')
>>
>> search_fields = ['dish_name']
>>
>> fieldsets = [
>> ('None',{'fields': ['dish_name', 'style',
>> 'dish_category', 'photo',  'steps', 'ingredients', 'utensils']}),
>> ('Times',   {'fields': ['cook_time','prep_time'],'classes':
>> ['collapse']}),
>> ('Description', {'fields': ['description'],'classes':
>> ['collapse']}),
>> ]
>>
>> .
>> .
>>
>>
>> I ran these after making the changes:
>> python manage.py sqlall recipe
>> python manage.py syncdb
>>
>>
>>
>>
>> python manage.py sqlall recipe
>> BEGIN;
>> CREATE TABLE "recipe_site" (
>> "id" serial NOT NULL PRIMARY KEY,
>> "locations" varchar(200) NOT NULL
>> )
>> ;
>> CREATE TABLE "recipe_dish" (
>> "id" serial NOT NULL PRIMARY KEY,
>> "dish_name" varchar(200) NOT NULL,
>> "steps" text NOT NULL,
>> "description" text NOT NULL,
>> "ingredients" text NOT NULL,
>> "utensils" text NOT NULL,
>> "cook_time" varchar(20) NOT NULL,
>> "prep_time" varchar(20) NOT NULL,
>> "dish_category" varchar(20) NOT NULL,
>> "style" varchar(20) NOT NULL,
>> "photo" varchar(20) NOT NULL
>> )
>>
>>
>>
>>
>>
>>
>  --
> 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/a199e98e-7805-4372-a213-033cba6a1d4d%40googlegroups.com
> 

Re: New data field in models.py "does not exist".

2015-01-12 Thread dennis breland
I am using Django 1.6
 

On Monday, January 12, 2015 at 1:16:17 PM UTC-5, dennis breland wrote:

> All works fine before making this change.
>
> I added new data named "photo" in models.py and admin.py
> When I bring up the web page, I get this:
>
> ProgrammingError at /admin/recipe/dish/
>
> column recipe_dish.photo does not exist
> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>  ^
>
> Request Method:  GET
> Request URL:  http://104.236.74.80/admin/recipe/dish/
> Django Version:  1.6.1
> Exception Type:  ProgrammingError
> Exception Value:  
>
> column recipe_dish.photo does not exist
> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>  ^
>
> Exception Location: 
>  /usr/lib/python2.7/dist-packages/django/db/backends/util.py in execute, 
> line 53
> Python Executable:  /usr/bin/python
> Python Version:  2.7.6
> Python Path:  
>
> ['/home/django/django_project',
>  '/home/django',
>  '/usr/bin',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages']
>  
>  
>
>
> Here's all the data -
>
> models.py:
>
> .
>
> .
>
>
> class Dish(models.Model):
> dish_name = models.CharField(max_length=200)
> steps = models.TextField(default='1. Mix some stuff')
> def __str__(self):  # Do this for every class.
> return self.dish_name   # No matter which object is called, 
> the name field is returned.
>
>
> description = models.TextField(default='Does this dish have a story?')
> ingredients = models.TextField(default='1. Sugar ')
> utensils = models.TextField(default='1. Bowl')
> cook_time = models.CharField(max_length=20, default='1 hour, 20 
> minutes')
> prep_time = models.CharField(max_length=20, default='20 minutes')
> dish_category = models.CharField(max_length=20, 
> choices=FOOD_CATEGORIES)
> style = models.CharField(max_length=20, choices=FOOD_STYLE)
>
> photo = models.CharField(max_length=20, default='photodefault')
>
>
> .
>
> .
>
>  
>
> admin.py:
> .
> .
>
> class DishAdmin(admin.ModelAdmin):
> #fields = ['dish_name', 'style', 
> 'dish_category','steps','ingredients','utensils','cook_time','prep_time','description']
>
> # list_display is optional. When not used, the str() of each object is 
> displayed.
> # This list contains the columns that are displayed on the Dish list 
> page.
> # These items are the field names in the class Dish (with underscores 
> replaced with spaces) that is defined in models.py
> # Not every field in the class is required to be here, only those 
> desired.
> list_display = ('dish_name', 'style', 'dish_category')
>
> search_fields = ['dish_name']
>
> fieldsets = [
> ('None',{'fields': ['dish_name', 'style', 'dish_category', 
> 'photo',  'steps', 'ingredients', 'utensils']}),
> ('Times',   {'fields': ['cook_time','prep_time'],'classes': 
> ['collapse']}),
> ('Description', {'fields': ['description'],'classes': 
> ['collapse']}),
> ]
>
> .
> .
>
>
> I ran these after making the changes:
> python manage.py sqlall recipe
> python manage.py syncdb
>
>  
>
>
> python manage.py sqlall recipe
> BEGIN;
> CREATE TABLE "recipe_site" (
> "id" serial NOT NULL PRIMARY KEY,
> "locations" varchar(200) NOT NULL
> )
> ;
> CREATE TABLE "recipe_dish" (
> "id" serial NOT NULL PRIMARY KEY,
> "dish_name" varchar(200) NOT NULL,
> "steps" text NOT NULL,
> "description" text NOT NULL,
> "ingredients" text NOT NULL,
> "utensils" text NOT NULL,
> "cook_time" varchar(20) NOT NULL,
> "prep_time" varchar(20) NOT NULL,
> "dish_category" varchar(20) NOT NULL,
> "style" varchar(20) NOT NULL,
> "photo" varchar(20) NOT NULL
> )
>
>  
>
>
>  
>

-- 
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/a199e98e-7805-4372-a213-033cba6a1d4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New data field in models.py "does not exist".

2015-01-12 Thread Vijay Khemlani
sqlall only prints the commands that would be executed to create the
database from scratch, it does not output your current database schema

if you are using django 1.7, then you need to create a migratino and apply
it

python manage.py makemigrations
python manage.py migrate

On Mon, Jan 12, 2015 at 4:31 PM, dennis breland 
wrote:

>
> On Monday, January 12, 2015 at 1:16:17 PM UTC-5, dennis breland wrote:
>>
>> All works fine before making this change.
>>
>> I added new data named "photo" in models.py and admin.py
>> When I bring up the web page, I get this:
>>
>> ProgrammingError at /admin/recipe/dish/
>>
>> column recipe_dish.photo does not exist
>> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>>  ^
>>
>> Request Method:  GET
>> Request URL:  http://104.236.74.80/admin/recipe/dish/
>> Django Version:  1.6.1
>> Exception Type:  ProgrammingError
>> Exception Value:
>>
>> column recipe_dish.photo does not exist
>> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>>  ^
>>
>> Exception Location:  
>> /usr/lib/python2.7/dist-packages/django/db/backends/util.py
>> in execute, line 53
>> Python Executable:  /usr/bin/python
>> Python Version:  2.7.6
>> Python Path:
>>
>> ['/home/django/django_project',
>>  '/home/django',
>>  '/usr/bin',
>>  '/usr/lib/python2.7',
>>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>>  '/usr/lib/python2.7/lib-tk',
>>  '/usr/lib/python2.7/lib-old',
>>  '/usr/lib/python2.7/lib-dynload',
>>  '/usr/local/lib/python2.7/dist-packages',
>>  '/usr/lib/python2.7/dist-packages']
>>
>>
>>
>>
>> Here's all the data -
>>
>> models.py:
>>
>> .
>>
>> .
>>
>>
>> class Dish(models.Model):
>> dish_name = models.CharField(max_length=200)
>> steps = models.TextField(default='1. Mix some stuff')
>> def __str__(self):  # Do this for every class.
>> return self.dish_name   # No matter which object is called,
>> the name field is returned.
>>
>>
>> description = models.TextField(default='Does this dish have a story?')
>> ingredients = models.TextField(default='1. Sugar ')
>> utensils = models.TextField(default='1. Bowl')
>> cook_time = models.CharField(max_length=20, default='1 hour, 20
>> minutes')
>> prep_time = models.CharField(max_length=20, default='20 minutes')
>> dish_category = models.CharField(max_length=20,
>> choices=FOOD_CATEGORIES)
>> style = models.CharField(max_length=20, choices=FOOD_STYLE)
>>
>> photo = models.CharField(max_length=20, default='photodefault')
>>
>>
>> .
>>
>> .
>>
>>
>>
>> admin.py:
>> .
>> .
>>
>> class DishAdmin(admin.ModelAdmin):
>> #fields = ['dish_name', 'style', 'dish_category','steps','
>> ingredients','utensils','cook_time','prep_time','description']
>>
>> # list_display is optional. When not used, the str() of each object
>> is displayed.
>> # This list contains the columns that are displayed on the Dish list
>> page.
>> # These items are the field names in the class Dish (with underscores
>> replaced with spaces) that is defined in models.py
>> # Not every field in the class is required to be here, only those
>> desired.
>> list_display = ('dish_name', 'style', 'dish_category')
>>
>> search_fields = ['dish_name']
>>
>> fieldsets = [
>> ('None',{'fields': ['dish_name', 'style',
>> 'dish_category', 'photo',  'steps', 'ingredients', 'utensils']}),
>> ('Times',   {'fields': ['cook_time','prep_time'],'classes':
>> ['collapse']}),
>> ('Description', {'fields': ['description'],'classes':
>> ['collapse']}),
>> ]
>>
>> .
>> .
>>
>>
>> I ran these after making the changes:
>> python manage.py sqlall recipe
>> python manage.py syncdb
>>
>>
>>
>>
>> python manage.py sqlall recipe
>> BEGIN;
>> CREATE TABLE "recipe_site" (
>> "id" serial NOT NULL PRIMARY KEY,
>> "locations" varchar(200) NOT NULL
>> )
>> ;
>> CREATE TABLE "recipe_dish" (
>> "id" serial NOT NULL PRIMARY KEY,
>> "dish_name" varchar(200) NOT NULL,
>> "steps" text NOT NULL,
>> "description" text NOT NULL,
>> "ingredients" text NOT NULL,
>> "utensils" text NOT NULL,
>> "cook_time" varchar(20) NOT NULL,
>> "prep_time" varchar(20) NOT NULL,
>> "dish_category" varchar(20) NOT NULL,
>> "style" varchar(20) NOT NULL,
>> "photo" varchar(20) NOT NULL
>> )
>>
>>
>>
> I believe this confirms the column exists:
> python manage.py sqlall recipe
> BEGIN;
> CREATE TABLE "recipe_site" (
> "id" serial NOT NULL PRIMARY KEY,
> "locations" varchar(200) NOT NULL
> )
> ;
> CREATE TABLE "recipe_dish" (
> "id" serial NOT NULL PRIMARY KEY,
> "dish_name" varchar(200) NOT NULL,
> "steps" text NOT NULL,
> "description" text NOT NULL,
> "ingredients" text NOT NULL,
> "utensils" text NOT NULL,
> "cook_time" varchar(20) NOT NULL,
> "prep_time" varchar(20) 

Re: New data field in models.py "does not exist".

2015-01-12 Thread dennis breland

On Monday, January 12, 2015 at 1:16:17 PM UTC-5, dennis breland wrote:
>
> All works fine before making this change.
>
> I added new data named "photo" in models.py and admin.py
> When I bring up the web page, I get this:
>
> ProgrammingError at /admin/recipe/dish/
>
> column recipe_dish.photo does not exist
> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>  ^
>
> Request Method:  GET
> Request URL:  http://104.236.74.80/admin/recipe/dish/
> Django Version:  1.6.1
> Exception Type:  ProgrammingError
> Exception Value:  
>
> column recipe_dish.photo does not exist
> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>  ^
>
> Exception Location: 
>  /usr/lib/python2.7/dist-packages/django/db/backends/util.py in execute, 
> line 53
> Python Executable:  /usr/bin/python
> Python Version:  2.7.6
> Python Path:  
>
> ['/home/django/django_project',
>  '/home/django',
>  '/usr/bin',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages']
>  
>  
>
>
> Here's all the data -
>
> models.py:
>
> .
>
> .
>
>
> class Dish(models.Model):
> dish_name = models.CharField(max_length=200)
> steps = models.TextField(default='1. Mix some stuff')
> def __str__(self):  # Do this for every class.
> return self.dish_name   # No matter which object is called, 
> the name field is returned.
>
>
> description = models.TextField(default='Does this dish have a story?')
> ingredients = models.TextField(default='1. Sugar ')
> utensils = models.TextField(default='1. Bowl')
> cook_time = models.CharField(max_length=20, default='1 hour, 20 
> minutes')
> prep_time = models.CharField(max_length=20, default='20 minutes')
> dish_category = models.CharField(max_length=20, 
> choices=FOOD_CATEGORIES)
> style = models.CharField(max_length=20, choices=FOOD_STYLE)
>
> photo = models.CharField(max_length=20, default='photodefault')
>
>
> .
>
> .
>
>  
>
> admin.py:
> .
> .
>
> class DishAdmin(admin.ModelAdmin):
> #fields = ['dish_name', 'style', 
> 'dish_category','steps','ingredients','utensils','cook_time','prep_time','description']
>
> # list_display is optional. When not used, the str() of each object is 
> displayed.
> # This list contains the columns that are displayed on the Dish list 
> page.
> # These items are the field names in the class Dish (with underscores 
> replaced with spaces) that is defined in models.py
> # Not every field in the class is required to be here, only those 
> desired.
> list_display = ('dish_name', 'style', 'dish_category')
>
> search_fields = ['dish_name']
>
> fieldsets = [
> ('None',{'fields': ['dish_name', 'style', 'dish_category', 
> 'photo',  'steps', 'ingredients', 'utensils']}),
> ('Times',   {'fields': ['cook_time','prep_time'],'classes': 
> ['collapse']}),
> ('Description', {'fields': ['description'],'classes': 
> ['collapse']}),
> ]
>
> .
> .
>
>
> I ran these after making the changes:
> python manage.py sqlall recipe
> python manage.py syncdb
>
>  
>
>
> python manage.py sqlall recipe
> BEGIN;
> CREATE TABLE "recipe_site" (
> "id" serial NOT NULL PRIMARY KEY,
> "locations" varchar(200) NOT NULL
> )
> ;
> CREATE TABLE "recipe_dish" (
> "id" serial NOT NULL PRIMARY KEY,
> "dish_name" varchar(200) NOT NULL,
> "steps" text NOT NULL,
> "description" text NOT NULL,
> "ingredients" text NOT NULL,
> "utensils" text NOT NULL,
> "cook_time" varchar(20) NOT NULL,
> "prep_time" varchar(20) NOT NULL,
> "dish_category" varchar(20) NOT NULL,
> "style" varchar(20) NOT NULL,
> "photo" varchar(20) NOT NULL
> )
>
>  
>
I believe this confirms the column exists:
python manage.py sqlall recipe
BEGIN;
CREATE TABLE "recipe_site" (
"id" serial NOT NULL PRIMARY KEY,
"locations" varchar(200) NOT NULL
)
;
CREATE TABLE "recipe_dish" (
"id" serial NOT NULL PRIMARY KEY,
"dish_name" varchar(200) NOT NULL,
"steps" text NOT NULL,
"description" text NOT NULL,
"ingredients" text NOT NULL,
"utensils" text NOT NULL,
"cook_time" varchar(20) NOT NULL,
"prep_time" varchar(20) NOT NULL,
"dish_category" varchar(20) NOT NULL,
"style" varchar(20) NOT NULL,
"photo" varchar(20) NOT NULL
) 

>
>  
>

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

Re: raise AppRegistryNotReady("Models aren't loaded yet.") .......AppRegistryNotReady: Models aren't loaded yet.

2015-01-12 Thread Collin Anderson
Hi,

Either use `./manage.py shell` or call `django.setup()` before using your 
models.

Collin

On Friday, January 9, 2015 at 8:01:59 AM UTC-5, Ibrahim K wrote:
>
> Hi friends,
>   I am new to django enivorment ... while using pyhton shell window 
> for developing poll app,I got too many errors in console window...pls give 
> the solution  and thanks for advance...
>
> -console --
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\venv\lib\site-packages\django\db\models\base.py", line 589, in 
> save
> force_update=force_update, update_fields=update_fields)
>   File "C:\venv\lib\site-packages\django\db\models\base.py", line 617, in 
> save_base
> updated = self._save_table(raw, cls, force_insert, force_update, 
> using, update_fields)
>   File "C:\venv\lib\site-packages\django\db\models\base.py", line 679, in 
> _save_table
> forced_update)
>   File "C:\venv\lib\site-packages\django\db\models\base.py", line 709, in 
> _do_update
> filtered = base_qs.filter(pk=pk_val)
>   File "C:\venv\lib\site-packages\django\db\models\query.py", line 691, in 
> filter
> return self._filter_or_exclude(False, *args, **kwargs)
>   File "C:\venv\lib\site-packages\django\db\models\query.py", line 709, in 
> _filter_or_exclude
> clone.query.add_q(Q(*args, **kwargs))
>   File "C:\venv\lib\site-packages\django\db\models\sql\query.py", line 
> 1331, in add_q
> clause, require_inner = self._add_q(where_part, self.used_aliases)
>   File "C:\venv\lib\site-packages\django\db\models\sql\query.py", line 
> 1358, in _add_q
> current_negated=current_negated, connector=connector)
>   File "C:\venv\lib\site-packages\django\db\models\sql\query.py", line 
> 1182, in build_filter
> lookups, parts, reffed_aggregate = self.solve_lookup_type(arg)
>   File "C:\venv\lib\site-packages\django\db\models\sql\query.py", line 
> 1120, in solve_lookup_type
> _, field, _, lookup_parts = self.names_to_path(lookup_splitted, 
> self.get_meta())
>   File "C:\venv\lib\site-packages\django\db\models\sql\query.py", line 
> 1383, in names_to_path
> field, model, direct, m2m = opts.get_field_by_name(name)
>   File "C:\venv\lib\site-packages\django\db\models\options.py", line 416, 
> in get_field_by_name
> cache = self.init_name_map()
>   File "C:\venv\lib\site-packages\django\db\models\options.py", line 445, 
> in init_name_map
> for f, model in self.get_all_related_m2m_objects_with_model():
>   File "C:\venv\lib\site-packages\django\db\models\options.py", line 563, 
> in get_all_related_m2m_objects_with_model
> cache = self._fill_related_many_to_many_cache()
>   File "C:\venv\lib\site-packages\django\db\models\options.py", line 577, 
> in _fill_related_many_to_many_cache
> for klass in self.apps.get_models():
>   File "C:\venv\lib\site-packages\django\utils\lru_cache.py", line 101, in 
> wrapper
> result = user_function(*args, **kwds)
>   File "C:\venv\lib\site-packages\django\apps\registry.py", line 168, in 
> get_models
> self.check_models_ready()
>   File "C:\venv\lib\site-packages\django\apps\registry.py", line 131, in 
> check_models_ready
> raise AppRegistryNotReady("Models aren't loaded yet.")
> AppRegistryNotReady: Models aren't loaded yet.
>

-- 
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/91e1d6ee-a1c6-4bc3-8fd1-d6ffa70736da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New data field in models.py "does not exist".

2015-01-12 Thread Florian Schweikert
On 12/01/15 19:16, dennis breland wrote:
> I ran these after making the changes:
> python manage.py sqlall recipe

manage.py sqlall just prints the sql statements for your models

> python manage.py syncdb

Do you use migrations?
If so did you run migrate?

What was the output of syncdb?

-- Florian

-- 
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/54B42099.4010308%40ist-total.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Re: New data field in models.py "does not exist".

2015-01-12 Thread James Schneider
Have you verified that syncdb ran correctly and that the column actually
exists in the database?

-James
On Jan 12, 2015 10:16 AM, "dennis breland"  wrote:

> All works fine before making this change.
>
> I added new data named "photo" in models.py and admin.py
> When I bring up the web page, I get this:
>
> ProgrammingError at /admin/recipe/dish/
>
> column recipe_dish.photo does not exist
> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>  ^
>
> Request Method:  GET
> Request URL:  http://104.236.74.80/admin/recipe/dish/
> Django Version:  1.6.1
> Exception Type:  ProgrammingError
> Exception Value:
>
> column recipe_dish.photo does not exist
> LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
>  ^
>
> Exception Location:
>  /usr/lib/python2.7/dist-packages/django/db/backends/util.py in execute,
> line 53
> Python Executable:  /usr/bin/python
> Python Version:  2.7.6
> Python Path:
>
> ['/home/django/django_project',
>  '/home/django',
>  '/usr/bin',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages']
>
>
>
>
> Here's all the data -
>
> models.py:
>
> .
>
> .
>
>
> class Dish(models.Model):
> dish_name = models.CharField(max_length=200)
> steps = models.TextField(default='1. Mix some stuff')
> def __str__(self):  # Do this for every class.
> return self.dish_name   # No matter which object is called,
> the name field is returned.
>
>
> description = models.TextField(default='Does this dish have a story?')
> ingredients = models.TextField(default='1. Sugar ')
> utensils = models.TextField(default='1. Bowl')
> cook_time = models.CharField(max_length=20, default='1 hour, 20
> minutes')
> prep_time = models.CharField(max_length=20, default='20 minutes')
> dish_category = models.CharField(max_length=20,
> choices=FOOD_CATEGORIES)
> style = models.CharField(max_length=20, choices=FOOD_STYLE)
>
> photo = models.CharField(max_length=20, default='photodefault')
>
>
> .
>
> .
>
>
>
> admin.py:
> .
> .
>
> class DishAdmin(admin.ModelAdmin):
> #fields = ['dish_name', 'style',
> 'dish_category','steps','ingredients','utensils','cook_time','prep_time','description']
>
> # list_display is optional. When not used, the str() of each object is
> displayed.
> # This list contains the columns that are displayed on the Dish list
> page.
> # These items are the field names in the class Dish (with underscores
> replaced with spaces) that is defined in models.py
> # Not every field in the class is required to be here, only those
> desired.
> list_display = ('dish_name', 'style', 'dish_category')
>
> search_fields = ['dish_name']
>
> fieldsets = [
> ('None',{'fields': ['dish_name', 'style', 'dish_category',
> 'photo',  'steps', 'ingredients', 'utensils']}),
> ('Times',   {'fields': ['cook_time','prep_time'],'classes':
> ['collapse']}),
> ('Description', {'fields': ['description'],'classes':
> ['collapse']}),
> ]
>
> .
> .
>
>
> I ran these after making the changes:
> python manage.py sqlall recipe
> python manage.py syncdb
>
>
>
>
> python manage.py sqlall recipe
> BEGIN;
> CREATE TABLE "recipe_site" (
> "id" serial NOT NULL PRIMARY KEY,
> "locations" varchar(200) NOT NULL
> )
> ;
> CREATE TABLE "recipe_dish" (
> "id" serial NOT NULL PRIMARY KEY,
> "dish_name" varchar(200) NOT NULL,
> "steps" text NOT NULL,
> "description" text NOT NULL,
> "ingredients" text NOT NULL,
> "utensils" text NOT NULL,
> "cook_time" varchar(20) NOT NULL,
> "prep_time" varchar(20) NOT NULL,
> "dish_category" varchar(20) NOT NULL,
> "style" varchar(20) NOT NULL,
> "photo" varchar(20) NOT NULL
> )
>
>
>
>
>
>
> --
> 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/ab61c0e9-6d0d-402b-8e92-71b6804be404%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 

Re: AppRegistryNotReady trying to access model's verbose name

2015-01-12 Thread Alexander Serechenko
I've got the same problem while using module django-modelclone.
I'd like to contribute in this module and fix the bug, can you help me wtih 
it?

среда, 6 августа 2014 г., 18:06:51 UTC+3 пользователь Stodge написал:
>
> I'm trying to port my Django project to Dango 1.7rc2 but I'm hitting the 
> app registry error. I know that this is mentioned in the Troubleshooting 
> section of the documentation but I don't understand why this is happening.
>
> __init__.py", line 44, in register_layer
> layer['verbose_name'] = model._meta.verbose_name.capitalize()
>   File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 
> 132, in __wrapper__
> res = func(*self.__args, **self.__kw)
>   File 
> "/usr/lib/python2.7/site-packages/django/utils/translation/__init__.py", 
> line 83, in ugettext
> return _trans.ugettext(message)
>   File 
> "/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py", 
> line 325, in ugettext
> return do_translate(message, 'ugettext')
>   File 
> "/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py", 
> line 306, in do_translate
> _default = translation(settings.LANGUAGE_CODE)
>   File 
> "/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py", 
> line 209, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File 
> "/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py", 
> line 189, in _fetch
> "The translation infrastructure cannot be initialized before the "
> django.core.exceptions.AppRegistryNotReady: The translation infrastructure 
> cannot be initialized before the apps registry is ready. Check that you 
> don't make non-lazy gettext calls at import time.
>
>
> The model's verbose name is a translated string, but models.py uses 
> ugettext_lazy so I don't understand why it ends up using ugettext. Thanks
>

-- 
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/25541520-ac30-47a9-a3cc-97ff8d5a6b21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


New data field in models.py "does not exist".

2015-01-12 Thread dennis breland


All works fine before making this change.

I added new data named "photo" in models.py and admin.py
When I bring up the web page, I get this:

ProgrammingError at /admin/recipe/dish/

column recipe_dish.photo does not exist
LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
 ^

Request Method:  GET
Request URL:  http://104.236.74.80/admin/recipe/dish/
Django Version:  1.6.1
Exception Type:  ProgrammingError
Exception Value:  

column recipe_dish.photo does not exist
LINE 1: ...ipe_dish"."dish_category", "recipe_dish"."style", "recipe_di...
 ^

Exception Location: 
 /usr/lib/python2.7/dist-packages/django/db/backends/util.py in execute, 
line 53
Python Executable:  /usr/bin/python
Python Version:  2.7.6
Python Path:  

['/home/django/django_project',
 '/home/django',
 '/usr/bin',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages']
 
 


Here's all the data -

models.py:

.

.


class Dish(models.Model):
dish_name = models.CharField(max_length=200)
steps = models.TextField(default='1. Mix some stuff')
def __str__(self):  # Do this for every class.
return self.dish_name   # No matter which object is called, the 
name field is returned.


description = models.TextField(default='Does this dish have a story?')
ingredients = models.TextField(default='1. Sugar ')
utensils = models.TextField(default='1. Bowl')
cook_time = models.CharField(max_length=20, default='1 hour, 20 
minutes')
prep_time = models.CharField(max_length=20, default='20 minutes')
dish_category = models.CharField(max_length=20, choices=FOOD_CATEGORIES)
style = models.CharField(max_length=20, choices=FOOD_STYLE)

photo = models.CharField(max_length=20, default='photodefault')


.

.

 

admin.py:
.
.

class DishAdmin(admin.ModelAdmin):
#fields = ['dish_name', 'style', 
'dish_category','steps','ingredients','utensils','cook_time','prep_time','description']

# list_display is optional. When not used, the str() of each object is 
displayed.
# This list contains the columns that are displayed on the Dish list 
page.
# These items are the field names in the class Dish (with underscores 
replaced with spaces) that is defined in models.py
# Not every field in the class is required to be here, only those 
desired.
list_display = ('dish_name', 'style', 'dish_category')

search_fields = ['dish_name']

fieldsets = [
('None',{'fields': ['dish_name', 'style', 'dish_category', 
'photo',  'steps', 'ingredients', 'utensils']}),
('Times',   {'fields': ['cook_time','prep_time'],'classes': 
['collapse']}),
('Description', {'fields': ['description'],'classes': 
['collapse']}),
]

.
.


I ran these after making the changes:
python manage.py sqlall recipe
python manage.py syncdb

 


python manage.py sqlall recipe
BEGIN;
CREATE TABLE "recipe_site" (
"id" serial NOT NULL PRIMARY KEY,
"locations" varchar(200) NOT NULL
)
;
CREATE TABLE "recipe_dish" (
"id" serial NOT NULL PRIMARY KEY,
"dish_name" varchar(200) NOT NULL,
"steps" text NOT NULL,
"description" text NOT NULL,
"ingredients" text NOT NULL,
"utensils" text NOT NULL,
"cook_time" varchar(20) NOT NULL,
"prep_time" varchar(20) NOT NULL,
"dish_category" varchar(20) NOT NULL,
"style" varchar(20) NOT NULL,
"photo" varchar(20) NOT NULL
)

 


 

-- 
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/ab61c0e9-6d0d-402b-8e92-71b6804be404%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deploying Django on Docker

2015-01-12 Thread Aaron C. de Bruyn
My docker setup is pretty easy:

wget -qO- https://raw.github.com/progrium/dokku/v0.3.13/bootstrap.sh |
sudo DOKKU_TAG=v0.3.13 bash

cat ~/.ssh/id_rsa.pub | ssh r...@mynewhost.mydomain.tld "sudo
sshcommand acl-add dokku myproject"

git remote add production do...@mynewhost.mydomain.tld:myproject

git push production master


Dokku is awesome.  ;)



On Sun, Jan 11, 2015 at 10:24 PM, Anssi Kääriäinen  wrote:
> I have given this issue a bit more thought, and it seems using Docker might
> be a bit too complex for the "just completed tutorial use case". Docker is
> nice, but if things do not work out the way you want, troubleshooting can
> get a bit complex.
>
> Instead it might be good to *fully* document how to set up a virtual machine
> based Django setup. The documentation should include:
>   - minimal information about how to install virtualbox and Ubuntu 14.04
> image. (Maybe vagrant would be a better idea?)
>   - how to setup Django with Gunicorn (is supervisord a good idea for
> process management?)
>   - static files
>   - media files
>   - security
>   - logging
>   - multiple environments (for example, how to use settings for multiple
> environments. environment variables are the way to go IMO)
>   - automatic deployment
>   - backup, restore, clone production to qa (clone to qa is a really useful
> feature if your database is small enough for it)
>
> Second step would be to automate as much of the above list as possible.
> Maybe the mezzanine fab file is enough for that.
>
> The above list also tells a pretty good story about why I pursue a
> documented way to fully set up Django. When setting up a small Django app,
> doing all of the above things properly requires just too much effort.
>
>  - Anssi
>
> --
> 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/c6bd553e-f21e-4a4f-ba5a-150e58bac0db%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEE%2BrGpHh-u3rU8G-dZrYLSFvn1ZNeUkpGfbSftHSfYbdD%3DbrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: modelformset question - interspersing extra forms among existing forms

2015-01-12 Thread Richard Brockie
Hello again Collin,

I am using your example as the basis for another similar set of forms and I 
spotted something subtle that passed me by the first time through.

Namely, that to save the data, you are calling the model.save() method, 
rather than the form.save() method that is generally shown in the 
documentation examples.

I've tried both, and they both work. From the documentation I was expecting 
that this line:

forms = [EntryForm(request.POST, instance=e, prefix=e.category.pk) for 
e in entries]

would be one-way, in that the POST and instances would combine in the forms 
and form.save() would be the method that should be used. It appears however 
that the POST data also end up in the instances.

I wasn't expecting that, but it appears to work. Is there a preferred or 
standard method that I should think about using?

R.

On Sunday, January 4, 2015 at 11:41:36 AM UTC-8, Collin Anderson wrote:
>
> Hi,
>
> If the field on the model is already blank=True, then you don't need that.
>
> Also, I realized my (completely untested :) code doesn't exactly match the 
> behavior you want, but I hope it's a good enough start. You may need to 
> store a reference to the original race_number to decide if you need to 
> .save() or not.
>
> Collin
>
> On Friday, January 2, 2015 9:42:47 PM UTC-5, Richard Brockie wrote:
>>
>> Hi Collin,
>>
>> Thanks very much for the advice. I'll be getting to this part of my 
>> development in the next few days and will report back when I have things 
>> working.
>>
>> One question in the meantime - what does this line do given that my model 
>> will already explicitly not require the race_number?
>>
>> race_number = Entry._meta.get_field('race_number').formfield(required=
>> False)
>>
>> Wishing everyone a prosperous New Year.
>> R.
>>
>>
>> On Thursday, January 1, 2015 3:31:45 PM UTC-8, Collin Anderson wrote:
>>>
>>> Hi,
>>>
>>> Your case is complicated enough that I'd actually recommend not using 
>>> formsets here and processing a list of plain ModelForms yourself in the 
>>> view. I bet formsets will ending out getting in your way.
>>>
>>> Here's a some messy code:
>>>
>>> class EntryForm(forms.ModelForm):
>>> race_number = Entry._meta.get_field('race_number').formfield(
>>> required=False)
>>> class Meta:
>>> model = Entry
>>> fields = ['race_number']
>>>
>>> def the_view(request, athlete_id):
>>> athlete = get_object_or_404(Athlete, id=athlete_id)
>>> existing = {e.category_id: e for e in athlete.entry_set.all()}
>>> entries = []
>>> for category in Category.objects.order_by('particular'):
>>> entries.append(existing.get(category.pk, Entry(athlete=athlete, 
>>> category=category)))
>>> if request.method = 'POST':
>>> forms = [EntryForm(request.POST, instance=e, prefix=e.category.
>>> pk) for e in entries]
>>> if all([f.is_valid() for f in forms]):  # be sure to call 
>>> is_valid() on every form
>>> for entry in entries:
>>> if entry.race_number:
>>> entry.save()
>>> if entry.pk and not entry.race_number:
>>> entry.delete()
>>> else:
>>> forms = [EntryForm(instance=e, prefix=e.category.pk) for e in 
>>> entries]
>>> return render(request, 'template.html', {'athlete': athlete, 'forms'
>>> : forms})
>>>
>>> {% for form in forms %}
>>> Category: {{ form.instance.category }}
>>> {{ form }}
>>> {% endfor %}
>>>
>>> Collin
>>>
>>> On Monday, December 29, 2014 6:07:19 PM UTC-5, Richard Brockie wrote:

 Hi,

 I have the following pseudo model that I will use as the basis of a 
 modelformset:

 class Entry:
 athlete = ForeignKey(athlete)
 category = ForeignKey(category)
 race_number = IntegerField

 I have a page that displays each athlete's details so the choice of 
 athlete has already been made. I want to add a formset that allows a user 
 to specify a race_number for each of the possible categories available.

 An obvious way would be for there to be one Entry for each 
 athlete/category, but in practise this will result in a large entry table 
 that is only ~10% actual data, with the rest being superfluous rows. I'd 
 prefer to avoid this.

 Let's assume that an athlete is already entered in 2 categories out of 
 a possible 10. The queryset will return the 2 existing entries, and I can 
 use extra=8 to add in the other possibilities. However, I am not yet done. 
 I want to do the following and would like advice on how to accomplish this:

1. The category for each the 8 possible new entries needs to be 
assigned before displaying the form - I already know what they are and 
 want 
to display these categories to the user, leaving the race_number as the 
only input field.
2. The categories have a particular (chronological) order that I 
want 

Re: python with django orm code , after exits, the entry from db revert backs

2015-01-12 Thread Sergiy Khohlov
Have you enabled autocommit to yes?

-- 
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/CADTRxJM1w%3DJKpR5DtEmWEyOtRiQoBxwYQgdRCY0t8QmGBixuWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.