Re: do I need to run syncdb when I change the default value in a field of a model?

2014-04-07 Thread Venkatraman S
On Fri, Mar 21, 2014 at 5:43 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

>
> On Thu, Mar 20, 2014 at 6:50 PM, Venkatraman S  wrote:
>
>>
>> On Sat, Mar 15, 2014 at 7:11 AM, Russell Keith-Magee <
>> russ...@keith-magee.com> wrote:
>>
>>>
>>> On Sat, Mar 15, 2014 at 7:19 AM, Jonathan Baker <
>>> jonathandavidba...@gmail.com> wrote:
>>>
 Does that mean that the default="" functionality is implemented by the
 ORM, instead of in the database layer?

 This is correct - Django's "default" argument is an API level default,
>>> not a database level default.
>>>
>>>
>> @Russ, any specific reasons for this choice?
>>
>
> Honestly - not a clue. It was like that when I got here, so the reasons
> are probably lost in the depths of time. :-)
>
> Trying to reverse engineer the decision, the most likely reason is that
> Django has allowed callable defaults; if you define a callable in your
> Django model as a default, there's no way to pass this down to the database
> (or, at least, not an easy way).
>
>
This helped me in one of the cases just now and it was an Aha moment!
 Never realized that this feature would be so darn useful. Thanks devs.

-V
@venkasub 

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


Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-20 Thread Mike Dewhirst

On 21/03/2014 11:13am, Russell Keith-Magee wrote:


On Thu, Mar 20, 2014 at 6:50 PM, Venkatraman S > wrote:


On Sat, Mar 15, 2014 at 7:11 AM, Russell Keith-Magee
> wrote:


On Sat, Mar 15, 2014 at 7:19 AM, Jonathan Baker
> wrote:

Does that mean that the default="" functionality is
implemented by the ORM, instead of in the database layer?

This is correct - Django's "default" argument is an API level
default, not a database level default.


@Russ, any specific reasons for this choice?


Honestly - not a clue. It was like that when I got here, so the reasons
are probably lost in the depths of time. :-)


If some things are done in the database and some in the ORM, developer 
madness ensues.


I think keeping everything in the ORM is entirely manageable for 
programmers. Tweaking the database is last straw optimisation.


Mike



Trying to reverse engineer the decision, the most likely reason is that
Django has allowed callable defaults; if you define a callable in your
Django model as a default, there's no way to pass this down to the
database (or, at least, not an easy way).

Yours,
Russ Magee %-)

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


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/532B8936.4090502%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-20 Thread Russell Keith-Magee
On Thu, Mar 20, 2014 at 6:50 PM, Venkatraman S  wrote:

>
> On Sat, Mar 15, 2014 at 7:11 AM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>
>>
>> On Sat, Mar 15, 2014 at 7:19 AM, Jonathan Baker <
>> jonathandavidba...@gmail.com> wrote:
>>
>>> Does that mean that the default="" functionality is implemented by the
>>> ORM, instead of in the database layer?
>>>
>>> This is correct - Django's "default" argument is an API level default,
>> not a database level default.
>>
>>
> @Russ, any specific reasons for this choice?
>

Honestly - not a clue. It was like that when I got here, so the reasons are
probably lost in the depths of time. :-)

Trying to reverse engineer the decision, the most likely reason is that
Django has allowed callable defaults; if you define a callable in your
Django model as a default, there's no way to pass this down to the database
(or, at least, not an easy way).

Yours,
Russ Magee %-)

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


Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-20 Thread Venkatraman S
On Sat, Mar 15, 2014 at 7:11 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

>
> On Sat, Mar 15, 2014 at 7:19 AM, Jonathan Baker <
> jonathandavidba...@gmail.com> wrote:
>
>> Does that mean that the default="" functionality is implemented by the
>> ORM, instead of in the database layer?
>>
>> This is correct - Django's "default" argument is an API level default,
> not a database level default.
>
>
@Russ, any specific reasons for this choice?

Regards,
Venkat

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


Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-14 Thread Russell Keith-Magee
On Sat, Mar 15, 2014 at 7:19 AM, Jonathan Baker <
jonathandavidba...@gmail.com> wrote:

> Does that mean that the default="" functionality is implemented by the
> ORM, instead of in the database layer?
>
> This is correct - Django's "default" argument is an API level default, not
a database level default.

Yours,
Russ Magee %-)

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


Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-14 Thread Craig Schmidt
On Mar 14, 2014, at 7:24 PM, Shawn Milochik  wrote:

> On Fri, Mar 14, 2014 at 7:19 PM, Jonathan Baker 
>  wrote:
> Does that mean that the default="" functionality is implemented by the ORM, 
> instead of in the database layer?
> 
> 
> Perhaps I'm wrong -- I'm looking at my South migrations and they do pass the 
> defaults. I believe that, either way, if you only touch the database through 
> the ORM it'll be set properly. It probably depends on what database you're 
> using.
> 
> However, there's a bigger issue -- if you run syncdb a second time, it will 
> do nothing, so it doesn't matter either way. If you want to modify an 
> existing table you need to use South (or do it manually). Syncdb will not 
> touch existing tables -- it only adds new ones. Or you can wipe out your 
> whole database and then run syncdb, that would fix it if you don't care about 
> your data.

In my case, it is for a system that isn't in production yet, so I was planning 
to wipe the database before running syncdb.  I just didn't know if that is 
necessary.

-Craig


> 
> Shawn 
> 
> -- 
> 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/CAOzwKwHmO%3D3T9BvRU6c1OL6G7HbR-At0pbn5-V47Nb-fLrs-kQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/B823C8A7-120E-4ADC-A99B-811C64E9D8D6%40craigschmidt.com.
For more options, visit https://groups.google.com/d/optout.


Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-14 Thread Shawn Milochik
On Fri, Mar 14, 2014 at 7:19 PM, Jonathan Baker <
jonathandavidba...@gmail.com> wrote:

> Does that mean that the default="" functionality is implemented by the
> ORM, instead of in the database layer?
>
>
Perhaps I'm wrong -- I'm looking at my South migrations and they do pass
the defaults. I believe that, either way, if you only touch the database
through the ORM it'll be set properly. It probably depends on what database
you're using.

However, there's a bigger issue -- if you run syncdb a second time, it will
do nothing, so it doesn't matter either way. If you want to modify an
existing table you need to use South (or do it manually). Syncdb will not
touch existing tables -- it only adds new ones. Or you can wipe out your
whole database and then run syncdb, that would fix it if you don't care
about your data.

Shawn

-- 
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/CAOzwKwHmO%3D3T9BvRU6c1OL6G7HbR-At0pbn5-V47Nb-fLrs-kQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-14 Thread Jonathan Baker
Does that mean that the default="" functionality is implemented by the ORM,
instead of in the database layer?


On Fri, Mar 14, 2014 at 5:16 PM, Shawn Milochik wrote:

> No, no syncdb required. The default applies to newly-created instances,
> not existing ones.
>
> --
> 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/CAOzwKwH-5UNR7ajWb%2B-w%3DepQRSUooEk%3DA-gwAjAhE8vtUT%3DA_Q%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

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


Re: do I need to run syncdb when I change the default value in a field of a model?

2014-03-14 Thread Shawn Milochik
No, no syncdb required. The default applies to newly-created instances, not
existing ones.

-- 
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/CAOzwKwH-5UNR7ajWb%2B-w%3DepQRSUooEk%3DA-gwAjAhE8vtUT%3DA_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


do I need to run syncdb when I change the default value in a field of a model?

2014-03-14 Thread Craig Schmidt
This is probably an easy question, but I didn't manage to find the answer.

If I just change the default value of a field in a model, do I need to run 
syncdb?

Specifically I changed:

foo = models.IntegerField(default=1)

to

foo = models.IntegerField(default=5)

Thanks,
Craig

-- 
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/1E74D9D7-51D1-4EF3-9772-3E54CC652B97%40craigschmidt.com.
For more options, visit https://groups.google.com/d/optout.