south django migrate - django

I installed south and I try to use it to migrate now:
./manage.py schemamigration myapp --initial
I get a :
-bash: ./manage.py: Permission denied
and if I sudo I get:
sudo: ./manage.py: command not found
Response.
Whats wrong?
Thanks!

Your manage.py isn't executable. Simply pass it to the interpreter instead.
python manage.py ...

You could also make it executable:
sudo chmod u+x
So you can run it like ./manage.py

Related

django : py manage.py runserver command doesnt work

I installed python 3.8.1 and django 3.0.3
Following tutorials I already created project but couldnt run server
PS D:\Study\django> django-admin startproject mysite
PS D:\Study\django> py --version
Python 3.8.1
PS D:\Study\django> py -m django --version
3.0.3
PS D:\Study\django> cd .\mysite\
PS D:\Study\django\mysite> py .\manage.py runserver
PS D:\Study\django\mysite> py .\manage.py runserver
PS D:\Study\django\mysite>
My working directory is
and terminal is
I read similar questions here, nothing doesnt help.
What's the issue?
Try this -
PS D:\Study\django\mysite> .\manage.py runserver
Or
PS D:\Study\django\mysite> python manage.py runserver
If still nothing seems to work, maybe python or django installation was not successful. In this case, try installing django first, if still not works, try installing python. Hope it will do.

Error while running the django server in eclipse

Type 'manage.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: The SECRET_KEY setting must not be empty.).
You need to include the “runserver” flag in what ever setting determines to run manage.py to actually start the server.
E.g
python manage.py runserver
Or to run on a specific port.
python manage.py runserver 1234

"Unknown command syncdb" running "python manage.py syncdb"

I want to create the tables of one database called "database1.sqlite", so I run the command:
python manage.py syncdb
but when I execute the command I receive the following error:
Unknown command: 'syncdb'
Type 'manage.py help' for usage.
But when I run
manage.py help
I don`t see any command suspicious to substitute
python manage.py syncdb
Version of Python I use: 3.4.2 Version of Django I use:1.9
I would be very grateful if somebody could help me to solve this issue.
Regards and thanks in advance
If you look at the release notes for django 1.9, syncdb command is removed.
Please use migrate instead. Moving forward, the migration commands would be as documented here
Please note that the django-1.9 release is not stable as of today.
Edit: Django 1.9 is stable now
the new django 1.9 has removed "syncdb",
run "python manage.py migrate",
if you are trying to create a super user, run "python manage.py createsuperuser"
$python manage.py syncdb is deprecated and not supported now.
So instead of this follow below instructions..
Whatever model you have created:
First run:
$python manage.py makemigrations
After running this command you model will be reflected in a migration.
Then you have to run:
$python manage.py migrate
Then run server:
$python manage.py runserver
Now, your project will run perfectly.
In Django 1.9 onwards syncdb command is removed. So instead of use that one, you can use migrate command,eg: python manage.py migrate.Then you can run your server by python manage.py runserver command.
Django has removed python manage.py syncdb command now you can simply use python manage.py makemigrations followed bypython manage.py migrate. The database will sync automatically.
You can run the command from the project folder as: "python.exe manage.py migrate", from a commandline or in a batch-file.
You could also downgrade Django to an older version (before 1.9) if you really need syncdb.
For people trying to run Syncdb from Visual Studio 2015:
The option syncdb was removed from Django 1.9 (deprecated from 1.7), but this option is currently not updated in the context menu of VS2015.
Also, in case you didn't get asked to create a superuser you should manually run this command to create one: python.exe manage.py createsuperuser
Run the command python manage.py makemigratons,and than python manage.py migrate to sync.
Alternarte Way:
Uninstall Django Module from environment
Edit Requirements.txt a type Django<1.9
Run Install from Requirments option in the enviroment
Try Syncdb again
This worked for me.
I also tried this command. Lastly I found the release note from django
Features removed in 1.9
The syncdb command is removed.
Djnago Releases note 1.9
I had the same problem, the only thing worked for me was this command.
python3 manage.py migrate --run-syncdb
Running this got me this result.
Ranvijays-Mac:djangodemo rana.singh$ python3 manage.py migrate --run-syncdb
Operations to perform:
Synchronize unmigrated apps: messages, staticfiles
Apply all migrations: admin, auth, contenttypes, msg, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Running migrations:
Applying msg.0001_initial... OK

setting manage.py to executable is not working

I'm trying to follow a tutorial on django.
In the directory where manage.py is located I've run the following command in iTerm to set the file to execute: chmod +x manage.py
However when I type in manage.py startapp greetings and hit return, I get the following error:
zsh: command not found: manage.py
But when I run ls -l, it shows what I believe to be the correct permissions:
-rwxr-xr-x
Also, if I enter ./manage.py I get this error:
zsh: permission denied: ./manage.py
What am I doing wrong?
Normally you would use:
python manage.py <cmd>
There is no space between startapp.
Also you need to make manage.py executable to execute it. Do chmod +x manage.py to make it executable. Alternatively you can do python manage.py <cmd> instead.
Make sure that the first line in manage.py is #!/usr/bin/env python so that the shell will now that it needs to execute this file using Python. Read more... Shebang (Unix)

django south: problems with path to django

The problem causes this error when I try to use south:
$ python manage.py schemamigration
You must provide an app to create a migration for.
$ python manage.py schemamigration myapp --initial
OSError: [Errno 13] Permission denied: '../myapp/migrations'
$ sudo python manage.py schemamigration myapp --initial
ImportError: No module named django.core.management
$ python
>>> import south
>>> import django.core.management
>>> south.__file__
'/home/mydev/venv/lib/python2.7/site-packages/south/__init__.pyc'
>>> django.__file__
'/home/mydev/venv/lib/python2.7/site-packages/django/__init__.pyc'
It seems to me that manage.py schemamigration generates an error message that appears to be returned by schemamigration. But schemamigration and other south commands cannot find django once they are called.
'/home/mydev/venv/lib/python2.7/site-packages/' is on my sys.path. The /south folder is a sim link to the actual south package which is in a /dist-packages folder. I did put a sim link in the actual /south folder back to the the django package, but that didn't solve anything.
What could be wrong?
The problem is due to permissions and use of virtualenv. You got the 'permission denied' error as your current user does not have write permissions for this project.
You can change the permissions for the entire project and make you current user as the owner of all files and folders in the project
sudo chown -R <username>:<username> <project_folder>
When you tried running migration using sudo it was not able to find django package as it lies in the virtualenv which has been activated by normal user. I guess these steps should solve this incase you don't want to change the permissions.
sudo -i
source /<virtualenv_path>/bin/activate
This should activate the virtualenv for sudo and now you'll be able to access all packages in the virtualenv
I think you should go the permissions way