26👍
Migrations were first added in version 1.7, officially released on September 2, 2014. You need to make sure your tutorial matches the version of Django you’re working with. For instance, this version of the tutorial covers 1.9:
https://docs.djangoproject.com/en/1.9/intro/tutorial01/
Or, if you’re using an older version of Django, you can change the “1.9” in that URL to whatever version you’re on (back to 1.3). Or use the dropdown on the docs page to pick the version and search for “tutorial”.
3👍
Find out what version of django you’re running (thanks @BradyEmerson):
python -c "import django; print(django.get_version())"
If older than 1.8:
pip install --upgrade django
- [Django]-Get count of related model efficiently in Django
- [Django]-Django serving robots.txt efficiently
- [Django]-Django runserver hangs at "System check identified no issues (0 silenced)."
2👍
I was using version 1.9 and still getting this error. I had unapplied migrations and that was the root cause in my case. I ran ‘python manage.py migrate
‘ to apply them and it worked for me.
- [Django]-How to configure X-Frame-Options in Django to allow iframe embedding of one view?
- [Django]-Prepopulate Django (non-Model) Form
- [Django]-How can I save my secret keys and password securely in my version control system?
2👍
In django makemigration added after 1.7 so if you are using older version of Django then you have to change settings.py and add your application in installed app like
INSTALLED_APPS = (
'Demo',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
and then you can run command
python manage.py syncdb
- [Django]-UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 2: ordinal not in range(128)
- [Django]-Slicing a list in Django template
- [Django]-How do I get odd and even values in a Django for loop template?
1👍
You need to load the virtual environment before doing it.
Use below code for Linux/OSX:
source venv/bin/active
And the following code for Windows
source venv/Scripts/activate
- [Django]-What's the point of Django's collectstatic?
- [Django]-Readonly models in Django admin interface?
- [Django]-Django – convert a list back to a queryset
0👍
I did following (for python version 3.6.4) to get this issue resolved:
- install virtualenv
- Activate virtualenv
Cheers
- [Django]-Indexing JSONField in Django PostgreSQL
- [Django]-How to use refresh token to obtain new access token on django-oauth-toolkit?
- [Django]-How to monkey patch Django?
0👍
This worked for me: using ubuntu 20.04, Django 3.2
First after creating the model and addind to the setting, I did:
python manage.py makemigrations
I obtained the migration number here.
After that I did:
python manage.py sqlmigrate [NAME_OF_MODEL] [NUMBER_OF_THE_MIGRATION]
Finally:
python manage.py migrate
- [Django]-Cannot access django app through ip address while accessing it through localhost
- [Django]-What is a "django backend"?
- [Django]-Using only the DB part of Django
-1👍
First time I add following piece of code into project_name\settings.py file.
`INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#Django REST Framework
'rest_framework',
#Games application
'games.apps.GamesConfig',
]`
After save it, when run following code I got error.
`python manage.py makemigrations games`
Then I check the settings.py file I realize that there are two INSTALLED_APPS and second one has not followings. When I added these the code worked.
`#Django REST Framework
'rest_framework',
#Games application
'games.apps.GamesConfig',`
- [Django]-Filter on prefetch_related in Django
- [Django]-How to fix " AttributeError at /api/doc 'AutoSchema' object has no attribute 'get_link' " error in Django
- [Django]-Get javascript variable's value in Django url template tag