197👍
syncdb
command is deprecated in django 1.7. Use the python manage.py migrate
instead.
14👍
You have to use python manage.py migrate
instead rather than python manage.py syncdb
- [Django]-DatabaseError: current transaction is aborted, commands ignored until end of transaction block?
- [Django]-Difference between auto_now and auto_now_add
- [Django]-Import data from excel spreadsheet to django model
13👍
Run python manage.py makemigrations
result below
Migrations for 'blog':
blog/migrations/0001_initial.py:
- Create model Blog
and after that run python manage.py migrate
result below
Operations to perform:
Apply all migrations: admin, blog, auth, contenttypes, sessions
Running migrations:
Applying article.0001_initial... OK
- [Django]-Django error – matching query does not exist
- [Django]-Django models.py Circular Foreign Key
- [Django]-Django: Model Form "object has no attribute 'cleaned_data'"
6👍
the actual command is :
python manage.py migrate --run-syncdb
It will solve many errors in django like , Operational error ,No Table found in databse etc.
- [Django]-How to save pillow image object to Django ImageField?
- [Django]-Can you give a Django app a verbose name for use throughout the admin?
- [Django]-Error: No module named staticfiles
0👍
You can do it like this in stages, let’s say you have an app called “example”:
- Run python manage.py makemigrations example
- A number generates like ‘0001’ get the number
- Run python manage.py sqlmigrate example 0001, using the number. Check out the scripts.
- Run python manage.py migrate example 0001
You can also look at all your migrations like this: python manage.py showmigrations
.
If you don’t want to commit it, go to the folder and move it somewhere or delete it before doing step 4.
- [Django]-Django test app error – Got an error creating the test database: permission denied to create database
- [Django]-Django contrib admin default admin and password
- [Django]-How to produce a 303 Http Response in Django?
0👍
However, there is another error that can be happened as strict mode needs to be enabled for MariaDB.
Keep Database connection in the settings.py file as follows:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'test',
'USER': 'root',
'PASSWORD': '',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
'OPTIONS': {
'sql_mode': 'traditional',
}
}
}
keep in mind about the below code:
'OPTIONS': {
'sql_mode': 'traditional',
}
After all, if your DJango version is backdated, "python manage.py syncdb" will work but for an updated version more than or equal to 1.7, please use "python manage.py migrate"
Thanks
- [Django]-Django fix Admin plural
- [Django]-Gunicorn, no module named 'myproject
- [Django]-How to force application version on AWS Elastic Beanstalk