It isn't always possible to transform arbitrary Python defaults 
(particularly callables) into SQL.

A search query would help you answer a question like this. I typed
"django database column defaults site:code.djangoproject.com" into Google 
and found
https://code.djangoproject.com/ticket/470 among other tickets.

...or searching the archives of this mailing list for "django database 
defaults" gives discussions such as:
https://groups.google.com/d/topic/django-developers/nrVzOnHBk64/discussion

On Tuesday, October 25, 2016 at 3:39:54 PM UTC-4, Chris Foresman wrote:
>
> Out of curiosity, why isn't this added as part of the column definition? 
> Isn't it better to enforce the default at the DB layer? Or is it to account 
> for differences across database types? (This trips me up a lot because we 
> have a lot of different apps/processes which have to touch the database and 
> only the API server is written in Django.)
>
>
> On Thursday, October 20, 2016 at 7:53:23 AM UTC-5, Tim Graham wrote:
>>
>> The 'default' model field option is used in Python rather than in the 
>> database. SchemaEditor might set a column default to ease populating a 
>> value on existing rows but that default shouldn't be left in the column's 
>> definition. self.assertIsNone(field.default) means that the column 
>> doesn't have a default.
>>
>> On Thursday, October 20, 2016 at 8:29:29 AM UTC-4, Maximiliano Robaina 
>> wrote:
>>>
>>> Hi Tim,
>>>
>>> Thanks for response.
>>>
>>> El martes, 18 de octubre de 2016, 12:07:34 (UTC-3), Tim Graham escribió:
>>>>
>>>> Hi Maxi,
>>>>
>>>> Did you take a look at the relevant commit that introduced the flag?
>>>>
>>>> https://github.com/django/django/commit/75303b01a9cc900eebf1f27ba0bc6508334242fc
>>>>
>>>
>>> Yes, I was looking into this changeset, but I can't understand yet what 
>>> "And that the default is no longer set in the database." means in 
>>> test_add_field_default_dropped [1].
>>> field.default contains the column default definition not the default 
>>> value of the some table record, Is it that correct?, So, why this must be 
>>> None?
>>>
>>>
>>>
>>> [1] 
>>> https://github.com/django/django/commit/75303b01a9cc900eebf1f27ba0bc6508334242fc#diff-888b45a0a8f38ee67e8d22403cf994dbR1371
>>>
>>>
>>> Regards 
>>>
>>>
>>>
>>>>
>>>> On Tuesday, October 18, 2016 at 9:51:46 AM UTC-4, Maximiliano Robaina 
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> How supposed to can_introspect_default must work?
>>>>>
>>>>> I'm working on django firebird backend and I'm trying to figured out 
>>>>> how this feature works, but the schema tests fails. 
>>>>> This default is at database level or django level?
>>>>>
>>>>> If I define a field with a default value, and do a metadata 
>>>>> introspection over this field to know if default value is defined, it 
>>>>> always returns True.
>>>>>
>>>>> I hope be clear (sorry for my bad english)
>>>>>
>>>>> ---
>>>>> Maxi
>>>>>
>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/f68e1d3d-42f4-4cc2-ae25-31226cd2f980%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to