I have installed on Win7 portable Python 2.7.5.1 and Django 1.6.
I followed the first polls tutorial instructions and got an error in the migrate stage, python manage.py migrate:
C:\Natan\Dev\Portable Python 2.7.5.1\App\Scripts\mysite>..\..\python.exe manage.py migrate
Unknown command: 'migrate'
Type 'manage.py help' for usage.
Any idea?
If you've installed 1.6, you should use the 1.6 tutorial, not the one for the development version.
First Step, Install South:
pip install south
Second Step, Add South to INSTALLED APPS in settings
INSTALLED_APPS = (
...,
'south' )
Migrate will be a native command in 1.7 (which is the version you read the tutorial pages from).
For older versions, you'll have to install the third party app"South".
All-
This is likely caused largely by following the 1.7 (DEV version!) tutorial when we all get the last stable version (1.6!) installed by pip.
It would not appear migrate is even a part of 1.7 in general! Will:
python manage.py syncdb
Solve your problems?
So pls either follow the tutorial for the last stable version of django: https://docs.djangoproject.com/en/1.6/intro/tutorial01/
Or follow the instructions to install the dev version of Django.
Dear Django team,
You guys are awesome. The JS developer is very impressed. But PLEASE resolve the discrepancy above. Maybe default to 1.6 docs and put in red letters: Dev version here?
Thank you.
You must install South to add migrate command.
pip install south
If you are using Django older versions before 1.7 then you should sync database by
python manage.py syncdb
while in new versions after 1.7 syncdb is replaced by migration. So for syncdb in new django version is replaced by :-
python manage.py makemigrations
python manage.py migrate
for more type:-
python manage.py help
Related
I'm trying to set up a repo locally but facing an issue i.e python manage.py runserver command gets aborted as soon as I hit localhost URL (http://127.0.0.1:8000/)
error - [1] 7398 abort python manage.py runserver
Django version 1.6.6
Python 2.7
OS -> MacOS Catalina (10.15.3)
Database postgres (PostgreSQL) 12.2
first why ur using old version python and Django. that's first because they didn't have support so I strongly recommend you to upgrade newest versions
I think this is due to Python & Catalina incompatibility. Try using Python 3.7. Similar question
In general, try to avoid using Python 2.x. Insted use Python 3.7.x.
TL;DR: python versions conflicts, i think that the python i downloaded and compiled (3.6) can't use this package (libmysqlclient-dev) to make migrations to mysql. only the system's default python (3.4) can.
my ubuntu server came with python 3.4, all of my django work and other work depend on 3.6. i have learned that upgrading system python is a bad idea, so i compiled python 3.6 (with altinstall).
when i ran python3.6 manage.py migrate it gave me this mysql error:
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1")
i tried virtual environment and normal python 3.6, both gave the same error, and i made sure that libmysqlclient-dev and mysqlclient are installed.
as this answer suggests, the problem is with libmysqlclient-dev because it's installed via apt-get not pip so i guess it's only compatible with the default python (3.4 that came with the system) or my compiled python 3.6 isn't allowed to use it, because when i made a dummy django project with python3.4 (system's default) and attempted python3.6 manage.py migrate on the same mysql database with the same user, it worked!
AGAIN: my problem is that the manually compiled python 3.6 can't use libmysqlclient-dev that has been installed by apt-get, only 3.4 can
reference: Django MySQL error on migrate
UPDATE
i came up with a work around but it's not efficient. i downgraded Django to 2.0.9 and it (python manage.py migrate) worked. but this problem could appear again with a different package.
Django 2.1.* requires MySQL 5.6 or higher. It broke the compatibility by mapping DateTimeField to datetime(6).
You can patch Django MySQL data type mapper. Put this to the top of your settings.py
from django.db.backends.mysql.base import DatabaseWrapper
DatabaseWrapper.data_types['DateTimeField'] = 'datetime' # fix for MySQL 5.5
There is a major difference in the support for django 2.0.* vs django 2.1.*
AS per Django 2.0.* MySQL Notes
Django supports MySQL 5.5 and higher.
As per Django 2.1.* MySQL Notes
Django supports MySQL 5.6 and higher.
Check you MySQL version with: mysql -V and use the correct django version.
from django.db.backends.mysql.base import DatabaseWrapper
DatabaseWrapper.data_types['DateTimeField'] = 'datetime' # fix for MySQL 5.5
Solved my problem!
Thanks Luka Zakrajšek
I'm trying to customize Django admin site. I ran the command "pip install django-suit", everything installed correctly according to CMD, then I made a new .py file called with apps.py in the main folder(same folder that contains settings.py) and here is the code
from suit.apps import DjangoSuitConfig
class SuitConfig(DjangoSuitConfig):
layout = 'horizontal'
and added 'database.apps.SuitConfig',in the settings.py. When I type the command "python manage.py makemigrations database" or "python manage.py runserver" the CMD gives me this error
Does anyone know what am I missing?
My Django version = 2.0.7
If you installed django-suit using pip install django-suit, you installed v0.2.26, and then this whole installation you're doing is wrong. This is how to install in your Django project: Getting started docs. Note that v0.2.26 does introduce support for Django 2.0 so it should work.
If you want to use the v2 (which is not stable and currently still just a development branch), you should use a different source for pip install:
pip uninstall django-suit
pip install https://github.com/darklow/django-suit/tarball/v2
Then you can do as you mention in your question, by subclassing DjangoSuitConfig and adding the new class to your INSTALLED_APPS.
I just installed django and after installing that I created a django project and was trying to run django server by command:
python manage.py runserver
After that I'am getting error as:
SyntaxError: Generator expression must be parenthesized
TL; DR: Upgrade Django to version 1.11.17+ or 2.0+
This error is a known incompatibility related to Python issue #32012. Projects based on Django 1.11.16 and below will raise this exception when started with Python 3.7. A patch for this issue has been merged into Django 2.0 and 2.1 branches and cherry-picked later into Django 1.11.17.
Note: Python 3.7 is officially supported by Django 1.11.17 and above, including any 2.x branch.
Generator expression must be parenthesized
> Update Django version to 1.11.17
pip install django==1.11.17
Had same issue. This is how I changed to django version 2.0 and used python3
$pip3 install django==2.0
$python3 manage.py runserver
Install this version: pip install django==1.11.17
Run cmd.
go to your project folder.
python manage.py runserver
it will give a URL for server and you are good to go.
This is due to the version incompatibility.Just we need to upgrade the Django version to 2.1.
Run the command in cmd:Pip install django==2.1. this will resolve the issue
I just faced an Error like this. I was using Django-1.11.10. I deleted it and installed Django 2.0
Problem is solved.
But if you are using ForeignKey in you model.py files it must be problem again. You should update your coding to 2.0 versiong insted of older versiyon.
Example:
django older version
user = models.ForeignKey('auth.User', related_name='posts')
django 2.0
user = models.ForeignKey('auth.User', related_name='posts', on_delete=models.CASCADE,)
I had the same issue and I realized it is due to the compatibility of the Django version I was working with. So I had to state the Python version explicitly like this: >python3.6 manage.py runserver
Just open file:
venv/lib/python3.7/site-packages/django/contrib/admin/widgets.py
and replace the lines
related_url += '?' + '&'.join(
'%s=%s' % (k, v) for k, v in params.items(),)
with
related_url += '?' + '&'.join('%s=%s' % (k, v) for k, v in params.items())
I'm just starting with the Django tutorial. When I try to run python manage.py migrateas they say, I get
Unknown command: 'migrate'
Type 'manage.py help' for usage.
I am in the directory right above manage.py. What am I doing wrong here? Thanks!
You may be using the wrong Django version. You can figure out which version you're running by doing python ./manage.py shell and then inside the shell, type the following:
>>> import django
>>> django.VERSION
If your django version is less than 1.6, check the docs for the version applying to what you are running.
Previous versions of Django did not use the migrate command, unless you installed a third party module called South.