> Den 16. maj 2016 kl. 19.16 skrev JoeCodeswell <joecodesw...@gmail.com>: > > How can I flush/clear database for single app, i.e. NOT the Project? > > I have a multi-app project. > In a particular app I created my model with single class. > I populated the db for that model with the Admin Interface. > Now i have changed the model to have 2 classes related by a ForeignKey. > I ran makemigrations on that app and it said, "you are trying to add a > non-nullable field 'song' to part without a default; we can't do that (the > database needs something to populate existing rows)." > I don't want to keep the existing populated tables for that app.
I can do it manually before the migration, i.e.: YourModel.objects.all().delete() If you want to do it as part of the migration, then create a data migration (https://docs.djangoproject.com/en/1.9/topics/migrations/#data-migrations) that deletes all relevant model instances, and place the migration before the migration that adds the ForeignKey. Erik -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/136259B2-2BE4-4AD0-A49E-5F4D7C4CC9A0%40cederstrand.dk. For more options, visit https://groups.google.com/d/optout.