35👍
From Django docs, Options.managed
: “If False, no database table creation or deletion operations will be performed for this model.”
And I see you have
options={
'db_table': 'tblclients',
'managed': False,
},
Try setting managed=True
in the model.
100👍
python manage.py migrate --fake APPNAME zero
This will make your migration to fake.
Now you can run the migrate script
python manage.py migrate APPNAME
Tables will be created
and you solved your problem.. Cheers!!!
- [Django]-Django authentication and Ajax – URLs that require login
- [Django]-How to get a list of all users with a specific permission group in Django
- [Django]-Function decorators with parameters on a class based view in Django
22👍
In my case, what created the tables was this:
python manage.py migrate --run-syncdb
I am using Django 1.9.6.
- [Django]-Include intermediary (through model) in responses in Django Rest Framework
- [Django]-Django Overriding Model Clean() vs Save()
- [Django]-Manage.py runserver
18👍
I had manually deleted one of the tables and the trick that worked for me was to execute the following steps:
- Removed the migrations folder.
- deleted the migrations from db:
DELETE from django_migrations WHERE app=’alerts_db’; - python manage.py migrate –run-syncdb’ before
- python manage.py makemigrations ‘app_name’
- python manage.py migrate –fake
Note: earlier I was not executing the #3 step and the table was not getting created.
my django version: v3.0.5
- [Django]-UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 2: ordinal not in range(128)
- [Django]-Using {% url ??? %} in django templates
- [Django]-What is "load url from future" in Django
9👍
I face same issue:
python manage.py migrate poll
Operations to perform:
Apply all migrations: poll
Running migrations:
No migrations to apply.
Follow these steps to create tables for your app.
Go to your app folder
1.delete migration folder.
2.python manage.py makemigrations.
3 Rename 0001_initial.py file to 0001_initial_manual.py.
4 python manage.py migrate APPNAME.
After this my tables created smoothly.
python manage.py migrate poll
Operations to perform:
Apply all migrations: poll
Running migrations:
Applying poll.0002_initial... OK
- [Django]-In Django models.py, what's the difference between default, null, and blank?
- [Django]-No Module named django.core
- [Django]-Create custom buttons in admin change_form in Django
5👍
This worked in Django v.3 :
-
Delete the rows related to your application from database:
DELETE FROM django_migrations WHERE app='<app_name>';
-
Delete your app’s migration folder
-
Finally
./manage.py makemigrations <app_name> ./manage.py migrate <app_name>
-
Done. Table created.
- [Django]-How to get Gunicorn to use Python 3 instead of Python 2 (502 Bad Gateway)
- [Django]-Django – is not a registered namespace
- [Django]-How to access array elements in a Django template?
1👍
Please check if you are using multiple databases in your project. If multiple databases configured, check the default database is the one you are looking for.
If default and your expected database are different, run below command pointing to your db configuration.
python manage.py migrate $app_name –database $dbname_from_setting
Hope this helps.
- [Django]-Why does my Django admin site not have styles / CSS loading?
- [Django]-Django's timezone.now does not show the right time
- [Django]-Mac OS X – EnvironmentError: mysql_config not found
1👍
The answer to this depends if you already have a history of migrations in your app folder. In my case I didn’t…I think I deleted original migration scripts.
So following the Django docs, I did the following:
- Comment out new updates in models.py
- Follow section Adding migrations to apps…
- Create migrations for what is already existing:
python manage.py makemigrations yourapp
- Do fake applying of these migrations (below singles that the tables already exist and not to try to recreate):
python manage.py migrate –fake-initial
- Uncomment changes in model.py
-
Follow steps in section Workflow …
python manage.py makemigrations yourapp
python manage.py migrate
- [Django]-How can modify request.data in django REST framework
- [Django]-Circular dependency in Django Rest Framework serializers
- [Django]-Add class to form field Django ModelForm
1👍
First try this;
Check your migration files for the app, if you have the create model portion in your migrations file, remove it and redo migrations. I.e remove this;
migrations.CreateModel(
name=’YourModelName’,
…….
…..)
(venv)root@debian:~/Desktop/project$ python manage.py makemigrations appName
(venv)root@debian:~/Desktop/project$ python manage.py migrate appName
Else; navigate to your database and delete all migrations for that app,
you may have to drop the related tables too.
postgres=# \c db_yourdb
db_yourdb=# delete from django_migrations where app='appName';
then go to your code and;
(venv)root@debian:~/Desktop/project$ python manage.py makemigrations appName
(venv)root@debian:~/Desktop/project$ python manage.py migrate appName
To do fresh migrations entirely, first do the necessary deletions for migrations and droping the tables if need be then;
(venv)root@debian:~/Desktop/project$ find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
(venv)root@debian:~/Desktop/project$ find . -path "*/migrations/*.pyc" -delete
finally do;
(venv)root@debian:~/Desktop/project$ python manage.py makemigrations
(venv)root@debian:~/Desktop/project$ python manage.py migrate
- [Django]-Migrating Django fixtures?
- [Django]-Django: how does manytomanyfield with through appear in admin?
- [Django]-Django orm get latest for each group
0👍
This is how I got @JulienD’s answer to work:
- I added metadata to my model def in models.py:
class thing(models.Model):
name = models.CharField(max_length=200)
class Meta:
app_label = 'things'
managed = True
- Execute:
python manage.py makemigrations
- Execute:
python manage.py migrate
After that python manage.py showmigrations
shows the migrations and the admin site started working.
- [Django]-Django: How to get current user in admin forms?
- [Django]-How do I perform query filtering in django templates
- [Django]-STATIC_ROOT vs STATIC_URL in Django
- [Django]-Which Model Field to use in Django to store longitude and latitude values?
- [Django]-How to manage local vs production settings in Django?
- [Django]-Combining Django F, Value and a dict to annotate a queryset
0👍
I had also that problem, all I had to do to solve it was to(I was using phpymyadmin):
1. Go into phpmyadmin panel
Pick the database I connected to, and empty the table named django_migrations
Then, I did the usual: python manage.py makemigrations app_name
Lastly: python manage.py migrate app_name
And voi’le, done and ready 😉
- [Django]-Plug in django-allauth as endpoint in django-rest-framework
- [Django]-AttributeError: 'module' object has no attribute 'tests'
- [Django]-What is {% block content %} and {% endblock content %} for in Django?
0👍
Add your app name in settings.py
as per the following:
https://docs.djangoproject.com/en/3.2/ref/applications/
- [Django]-Python 3 list(dictionary.keys()) raises error. What am I doing wrong?
- [Django]-Django-tables2: How to use accessor to bring in foreign columns?
- [Django]-Python- How to flush the log? (django)
0👍
I recently faced this issue and I identified the problem was that my app, (which was also added in settings), started with an uppercase letter.
It is interesting that no errors were ever thrown to warn about this, but I kept seeings errors that certain tables related to the app do not exist.
So, make sure your app name starts with a small letter, and python manage.py makemigrations <appName>
and python manage.py migrate
- [Django]-Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?'
- [Django]-Modifying Dictionary in Django Session Does Not Modify Session
- [Django]-Retrieving parameters from a URL
0👍
I had a similar problem too.
py manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, token_blacklist
Running migrations:
No migrations to apply.
After checking lots of solutions finally, I found that I’ve used the same environment for many projects. I was running manage.py of another project. The case might be the same as mine. If the case is not as similar to mine then all the solutions of the above works.
- [Django]-Django 1.7 migrations — how do I clear all migrations and start over from scratch?
- [Django]-Setting default value for Foreign Key attribute in Django
- [Django]-Loading initial data with Django 1.7+ and data migrations