Problem in updating database models.

19 views
Skip to first unread message

akshat

unread,
Jun 1, 2015, 1:55:16 AM6/1/15
to django...@googlegroups.com
I am using Django 1.8 to build a demo project.Inside my project I have one app 'Book'.Book app initially had this model - 

class Book(models.Model):
      title = models.CharField(max_length=200)
      author = models.TextField()
      pub_date = models.DateTimeField('date published')

I applied makemigrations and then filled some data through my frontend website.Now Book model has 3 rows. Now I wanted to add another field to Book model like this  -

class Book(models.Model):
      title = models.CharField(max_length=200)
      author = models.TextField()
      pub_date = models.DateTimeField('date published')
       thumbnail
= models.FileField(upload_to=get_upload_file_name)

In fear of losing my existing data I dumped my data in a json file using python manage.py dumpdata command. Now what are the next steps in this?I mean now I want to empty the whole book table.Then apply makemigrations because I added one field.Also will I have to add default to thumbnail field when applying migrations?
After that I want to populate the table again from an existing json file.

Thanks.



Reply all
Reply to author
Forward
0 new messages