0

I have a class like this (I didn't know about abstract class at the beginning):

class Client(models.Model):
    company_name = models.CharField(max_length=50)
    referrer = models.ForeignKey(User, null=True, blank=True)
    address = models.CharField(max_length=400, blank=True)

class Customer(Client):
    def __str__(self):
        return "{company:s}".format(company=self.company_name)

I tried to add abstract class to client, did the makemigrations but migrate crash with this message:

django.core.exceptions.FieldError: Local field 'address' in class 'Customer' clashes with field of similar name from base class 'Client'

I tried to restart from scratch because I don't need migration right now and delete the folder.

I run manage.py migrate and It tells me that I didn't have auth_user table. Then I use manage.py migrate auth then manage.py migrate and it works !

Cool, almost, my django project is now running but when I launch the test I still have the issue:

can't find auth_user table...

I guess test didn't create the migrate auth for the test database.

What did I do wrong?

styvane
  • 59,869
  • 19
  • 150
  • 156
Idaho
  • 1,355
  • 1
  • 9
  • 10
  • see [this](http://stackoverflow.com/questions/23755523/how-to-reset-migrations-in-django-1-7) – Pynchia Jul 03 '15 at 22:31
  • Thanks I did this, but it didn't trigger migrate for auth module. I have to did it manually and brokes test database generation. – Idaho Jul 03 '15 at 22:53
  • 1
    You need to pass the app label to `makemigrations` to force the creation of a new `migrations` folder. You get that error because the now unmigrated app has a foreign key to the migrated `auth` app. For further reference, the easiest way to reset migrations is to delete all files in `/migrations/` except `__init__.py`. – knbk Jul 03 '15 at 23:17
  • Indeed, it works ! The system didn't recreate the migrations folder even if `__init__.py` file is empty. – Idaho Jul 04 '15 at 08:34

0 Answers0