How to assign default values at the level of SQL in Django (PostgreSQL)?

Create model with default fields, expecting that they will be saved at the sql level:

class Car(models.Model):
 name = models.CharField('Name', max_length=255, default='Audi')
 max_speed = models.IntegerField('Max Speed', default=220)


But in fact, the default values are not generated in SQL:
$ ./manage.py sqlmigrate car 0001
BEGIN;
--
-- Create model Car
--
CREATE TABLE "car" ("id" serial NOT NULL PRIMARY KEY, "name" varchar(255) NOT NULL, "max_speed" integer NOT NULL);
COMMIT;


How do I save default values on the sql level?
July 4th 19 at 23:14
2 answers
July 4th 19 at 23:16
Solution
You don't want that want
TK profit with this is no, but hemorrhoids - mass
Thanks for the advice, but still, how to implement it? - trycia_Rau commented on July 4th 19 at 23:19
: https://docs.djangoproject.com/en/1.10/ref/migrati...

do a migration and there in pure sql, write your alter table - marilyne_Roh commented on July 4th 19 at 23:22
But the default value does not mean that this field can simply be filled when inserting? Don't know how it will be in Django, when using SQLAlchemy, it would be possible to make a Car(max_speed=400) and the value of the name would be "Audi". - tremaine.Kiehn commented on July 4th 19 at 23:25
: Jung it will throw you exacty when you save and don't save you, what you specify in the default value in the table
So all your work will go nowhere - marilyne_Roh commented on July 4th 19 at 23:28
: Not a convenient behavior - trycia_Rau commented on July 4th 19 at 23:31
because it is not clear why you want to use raw sql - marilyne_Roh commented on July 4th 19 at 23:34
: all inserts go via the form.
How you will behave in alchemy, in this case, if she is out of shape comes an empty field? - marilyne_Roh commented on July 4th 19 at 23:37
: Objective: retain the default value of the fields in the database in case of change of the framework. I think it should provide - trycia_Rau commented on July 4th 19 at 23:40
: no
You should cover the code with tests including acceptance

If you're going to change the frame, you better immediately start writing on a new frame and not torment Django - marilyne_Roh commented on July 4th 19 at 23:43
: I don't plan to change the framework. I just want to provide for this case - trycia_Rau commented on July 4th 19 at 23:46
: then you should include such things as the fall of the meteorite in three DTS in which you have deployed copy of the project

I'm suggesting that some things are not worth wasting time

Most of the questions takes documentation and good test coverage - marilyne_Roh commented on July 4th 19 at 23:49
July 4th 19 at 23:18
Fill hands in the migration files

Find more questions by tags DjangoPostgreSQL