0

I want to add some set of classes to models.py file in the django app which already has some classes created in that synchronized and contain data in each one of them in the database (created in mysql).

when I add new classes and type command

python manage.py makemigrations app-label//(using django 1.8 version)

it shows the

creating table names ...

but I when I run :

   python manage.py migrate 

it shows ...

  table "access_log" already exists 

I have tried many of the stack overflow links but nothing helped me. Like few of them are :

link 1 -stack-overflow

link 2 -stack-overflow

link 3 -stack-overflow

Also my exiting tables with data in database have attribute managed = false. Will that affect ?

Why is this happening?

Please help, I am not much well-versed with django.

Community
  • 1
  • 1
shubhanjalee
  • 47
  • 1
  • 8
  • Try look into your SQL db - your tables should be named like `appname_modelname` - do you already have an app named `access` with a model `log` in your db, e.g. `access_log`? If so, do you recognize the data? – henrikstroem Jun 07 '15 at 16:53
  • @henrikstroem : my app name is fcui, the table access_log is the model previously created in the models.py for which managed = false. it has data too. My issue is that I am not able to add new classes to models.py – shubhanjalee Jun 07 '15 at 17:04
  • I must be missing something, sorry. If you have removed an unmanaged table, Django will not remove the database table for you, you must do that manually if you are creating a table with the same name. – henrikstroem Jun 07 '15 at 17:13
  • @henrikstroem : i am not creating the table with same name, it is like i had say class abcd was already present in the models.py and had the data in the database (which is access_log in my case), in that class, sub-class meta has managed = false. Now, i am adding a new class with name – shubhanjalee Jun 07 '15 at 17:26
  • account_users to models .py . After adding, i ran `python manage.py makemigrations app_name` and then `python manage.py migrate` – shubhanjalee Jun 07 '15 at 17:33
  • Have you looked at this: https://docs.djangoproject.com/en/1.8/ref/django-admin/#showmigrations-app-label-app-label - maybe it will shine some light on the problem. – henrikstroem Jun 07 '15 at 17:45

0 Answers0