Hi Peter, The main reason this hasn't been done in the past was that Django has never made use of database defaults, mostly for the reason described in that thread - that Django is sufficiently expressive with its defaults (you can pass in any callable) that we can't represent them in the database. The only reason they're ever set at all is because we need them to add columns, and even then I'd considered a mode where django adds all columns as NULL and calls the default once per row rather than doing one call for the whole set of rows.
I'm not totally against the idea, but I'd want to see a convincing method as to how you detect and deal with defaults that are not expressible in the database (for example, what if someone does the very common default=datetime.datetime.now). Obviously all calls through Django will still work as intended, but other database users will have entirely the wrong value in that field whenever they insert rows but no errors to tell them about it (and if you don't have other database users than Django, why do you need the defaults in there in the first place?) Andrew On Thu, Oct 30, 2014 at 8:47 AM, Peter Coles <peter.m.co...@gmail.com> wrote: > Hey all, > > I'm interested in getting database migrations to support setting > database-level default values. I've heard talk of this being a hotly > contested issue in the past, but I haven't been able to find the actual > conversations, so far this > <https://groups.google.com/forum/#!searchin/django-developers/database$20defaults/django-developers/fHjzttZTkzc/oXbrpBa0dHAJ> > is the best thread I've found and I've already asked about it in > django-users > <https://groups.google.com/forum/#!topic/django-users/_N2mtxFTFjI>. > > Instead of just asking for this feature, I've gone ahead and created a new > db backend that is almost exactly > the `django.db.backends.postgresql_psycopg2` module, but with two key code > blocks removed (that appear to be the logic to remove default values from > the database). > > Here's the repo: https://github.com/ringly/django-postgres-dbdefaults > > and here it is in pypi: > https://pypi.python.org/pypi/django-postgres-dbdefaults/0.0.1 > > I'd love to hear feedback/thoughts/concerns. > > -Peter > > -- > 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 http://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/5bf3f984-30fb-4adf-a992-616cbdedd864%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/5bf3f984-30fb-4adf-a992-616cbdedd864%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django 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 http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFwN1upVCC%2B8qr7_xuyg08e96%3DEWh-akcrvyuk27aJwBTdAsTQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.