These are chat archives for django/django

17th
Apr 2016
Kiran Kumar Chaudhary
@chaudharykiran
Apr 17 2016 13:07
I want to extends User model and add new field in my model. But while run "python manage.py makemigrations", I am getting error..trying to add a non-nullable field 'id' to doctor without a default;
This message was deleted
class Doctor(models.Model): user = models.OneToOneField(User, on_delete = models.CASCADE) contact_info = models.IntegerField( blank=True)
Matt Bymaster
@anacrust
Apr 17 2016 13:24
Probably not the best approach but if you're in Development and don't care about migrations, go into your migrations folder and the other folder with your .pyc files and erase all those. Then run a makemigrations for that app and migrate again.
This will erase all your past migrations, so if those are important, then don't do the above
But it will not obviously erase your database.
Matt Bymaster
@anacrust
Apr 17 2016 13:29
I really worry about this problem in production but I guess that's why you test in development first and remember to put a working default= in the model before you throw it in production.
Kiran Kumar Chaudhary
@chaudharykiran
Apr 17 2016 15:40
@anacrust That
@anacrust That work , Thnx . But I tried of erasi .pyc everytime when i change my migrations
Matt Bymaster
@anacrust
Apr 17 2016 16:51
It's usually if you're adding or deleting fields you'll end up having to do that. If you delete a field, delete the actual data from that specific field in the database BEFORE deleting it from the model. Otherwise the database will have extra info in it that relates to that deleted field and that causes issues.
Kiran Kumar Chaudhary
@chaudharykiran
Apr 17 2016 17:00
@anacrust Thnx
Shakib Hossain
@shakib609
Apr 17 2016 17:41
Can anyone please provide me the Python Flask gitter room link?