root#domU-xx-xx-39-04-x5-36:/opt/sana# ./manage.py syncdb
-bash: ./manage.py: Permission denied
I tried both django.db.backends.mysql and mysql for 'ENGINE'
I am able to connect to root using
mysql -u root -p
My settings.py file is correct
My Django version is 1.1.1 on Ubuntu LTS 10.04 in EC2
Check manage.py has execute permission. If not give it by
# chmod +x manage.py
List permissions:
ls -l
If it has x permission on the first 3 characters "--x":
./manage.py syncdb
Also, you are able to execute it using python just with read permission "r--":
python manage.py syncdb
Related
Trying to get started with Django on pycharm.
(venv) C:\Users\Vince\PycharmProjects\assignment>python manage.py runserver
But I get this error message whenever i run manage.py:
C:\Users\Vince\AppData\Local\Programs\Python\Python37-32\python.exe: can't open file 'manage.py': [Errno 2] No such file or directory
I do have a django directory opened with a manage.py file in it. Can anyone assist me on what to do?
I have tried other solutions, like:
python -vvvvv manage.py runserver
python manage.py migrate
You need to either specify the exact location of the manage.py file. I.e.:
python3 Users/Vince/Desktop/DjangoProject/manage.py runserver
or cd to the directory it's in and run from there.
cd Users/Vince/Desktop/DjangoProject > python manage.py runserver
I had project with django + guicorn + nginx (this tutorial)
I delete virtualenvironment and get a new one, everything works correctly but, when I try to use command:
source projectenv/bin/activate
folder1/project/manage.py collectstatic
I got an error:
-bash: folder1/folder/manage.py: Permission denied
even when I try:
folder1/folder/manage.py runserver 0.0.0.0:8000
-bash: folder1/folder/manage.py: Permission denied
What should I do to make this virtualenvironment work correctly?
python3 folder1/project/manage.py collectstatic
worked properly
thanks to comment falsetru
I have a little issue of trying the exemple file from https://github.com/zhebrak/django-statsy
OperationalError at /
no such table: example_post
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.11.5
Exception Type: OperationalError
Exception Value: no such table: example_post
Exception Location: /home/jeremie/.virtualenvs/statsy/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py in execute_sql, line 894
Python Executable: /home/jeremie/.virtualenvs/statsy/bin/python
Python Version: 2.7.12
Python Path:
['/home/jeremie/django-statsy',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/plat-x86_64-linux-gnu',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/lib-tk',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/lib-old',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/jeremie/.virtualenvs/statsy/local/lib/python2.7/site-packages',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/site-packages',
'/home/jeremie/django-statsy']
Server time: Fri, 15 Sep 2017 15:13:34 -0500
Here is what I have done so far :
git clone https://github.com/zhebrak/django-statsy.git
mkvirtualenv statsy
cd django-statsy
workon statsy
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
I just want to enter inside the example file to see what type of result and test out the app itself. Why do I have the problem? Do you recommend this app if I am working in a project using Django 1.10 and python 2.7?
Update
┌─╼ [~/django-statsy]
└────╼ python2.7 manage.py makemigrations example
Migrations for 'example':
example/migrations/0001_initial.py
- Create model Post
┌─╼ [~/django-statsy]
└────╼ python2.7 manage.py migrate example
Operations to perform:
Apply all migrations: example
Running migrations:
Applying example.0001_initial... OK
Here is the result when I ran localhost:8000 : image
How could I test out the exemple which is given?
Based on your replies in the comments, it's looking like you haven't created the example_post database table. You'll need to add example to your list of INSTALLED_APPS in your settings file, then run through the database migration process:
./manage.py makemigrations
./manage.py migrate
If the example app isn't in INSTALLED_APPS, the database migration files won't be created and the table won't be created as a result.
I am reading a book ("Learning Django Web Development" by Sanjeev Jaiswal and Ratan Kumar) on Django, but the book is based on an earlier version of Django (prior to version 1.9). In order to populate the database with tables, the book uses the syncdb command:
$ python manage.py syncdb
Then the book says that terminal will prompt you to create a superuser account.
the syncdb command is no longer used in Django version 1.9 and up. After some research, it seems as if the migrate command populates the databse with tables, but it does not prompt the creation of a superuser account. How can I do this in Django 1.9.6?
I think you want to run these commands:
python manage.py makemigrations creates migration files based on your models
python manage.py migrate will create the tables in your db based on the migration files created
(see docs for more details on database migrations)
python manage.py createsuperuser will create a superuser for your application in the database (docs)
$ python manage.py migrate
$ python manage.py createsuperuser
https://docs.djangoproject.com/en/1.9/ref/django-admin/
For Django 2
User.objects.create_superuser(username='name',email='email',password='password')
From the docs
create_superuser(username, email, password, **extra_fields)
Same as create_user(), but sets is_staff and is_superuser to True.
Which can be embedded in a script, called from a command line or triggered via an API
first run
$ django-admin startproject mysite
in cmd prompt,then apply migration by
cd mysite
mysite:
python manage.py makemigrations
then
python manage.py migrate
after that
python manage.py createsuperuser
First we’ll need to create a user who can login to the admin site. Run
the following command:
$ python manage.py createsuperuser
Enter your desired username and press enter. Username: admin
You will then be prompted for your desired email address:
Email address: admin#example.com
The final step is to enter your password. You will be asked to enter
your password twice, the second time as a confirmation of the first.
Password: **********
Password (again): *********
Superuser created successfully.
$ python manage.py createsuperuser
It will ask username and password
http://127.0.0.1:8000/admin/
see
https://www.tutorialshore.com/create-new-admin-user-in-django/
you create superuser with this :
python manage.py createsuperuser
this will create superuser for you and you can create many superuser .
but notice before you can make super user you must run these command :
python manage.py makemigrations
and them :
python manage.py migrate
I created a django app on openshift successfully. But, I'm not able to run syncdb using the following deploy hook.
#!/bin/bash
source $OPENSHIFT_HOMEDIR/python/virtenv/bin/activate
cd $OPENSHIFT_REPO_DIR/wsgi/$OPENSHIFT_APP_NAME
python manage.py syncdb --noinput
What could be wrong? Please help!
I think its simply because you forget to add the right for file execution with chmod +x filename