I am using Django version 1.6.11 and when I want to create the project by using the command Django-admin start project my site it throws the error:
\Python27\python.exe: No module named Django-admin
and when I use Django-admin.py start project my site it opens a new file named Django-admin.py.
I don't know what the issue is as when I open an already created Django project I am able to run the project using python manage.py run server but then also I am not able to create new app inside the project as it requires Django-admin startapp.
Are you sure you are using the right command to start a project?
According to official documentation, it should be:
django-admin startproject mysite
not
Django-admin start project my site
Which means: no uppercase and less spaces.
New apps should be created using:
python manage.py startapp app_name_here
not through django-admin.
https://docs.djangoproject.com/en/2.0/intro/tutorial01/
Related
I am actually following a youtube tutorial for learning Django and admin site is not showing properly.
The admin tab in the video looks like this:
My admin tab however looks like this:
An answer in stack overflow suggested to put DEBUG = True in settings.py file. But it is already set to that in my case.
You've probably set static files' location the wrong way. Sending settings.py is needed for any further help.
You can check this document for default values.
It would be better to start a simple project using the instructions provided in this documentation Django - Introduction tutorial
Initially, you can also try the following instructions to check it.
At first, install django (latest version) using the following command
python -m pip install django
Then, open a folder in which you would like to create a django project, and open the terminal in that folder, then paste the following code
django-admin startproject MyProject
Copy and paste the following two commands one-by-one,
py manage.py makemigrations
py manage.py migrate
After that, create a admin user by providing the e-mail, username and password through the following command as follows,
py manage.py createsuperuser
Now, copy and paste the link you get in the browser along with 'admin/', which will direct you to the admin login page as specified in the documentation
I have been trying to start a new Django project for the first time and I can't seem to figure out how to run the server. On the tutorial page for Django it says
Change into the outer mysite directory, if you haven’t already, and run the following commands:
...\> py manage.py runserver
When I do this, nothing happens. I tried running the command from the mysite directory and from the Django test folder I made for the project.
Here is a screenshot :
The Django tutorial says I should be expecting this result:
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
February 19, 2021 - 15:50:53
Django version 3.1, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Before I did this I installed pipenv by following this guide and followed the guide all the way up to "Next Steps".
I have also attached a screen shot of what the folder looks like:
What am I doing wrong?
From the initial command prompt image shared, it appeared you tried starting the server from c:\Users\Timo\DesktopTest> which doesn't manage.py. It obvious from the last two screenshots that, manage.py reside in a sub directory of DesktopTest.
Change directory to `c:\Users\Timo\DesktopTest\mysite>, then start the dev server.
Note: You should make sure your virtual environment is active
Though, it appears the you haven't activated pipenv. And if this is correct, python may not be aware you have any package called Django outside the virtual environment.
To activate pipenv, from c:\Users\Timo\DesktopTest> run the command pipenv shell, if it runs successfully, your currently cmd path should look something like this
(some strings)c:\Users\Timo\DesktopTest>
then you can be sure your virtual environment is active. you may the CD to your django project directory and do python manage.py runserver
New to Django and I created a project with Django 3.0 based on a tutorial, then created Project 2 based on a second tutorial, following the steps.
But when I use the command django-admin startproject project2_project it populates project2's folder with all of the directories/files from project 1, and everything else on my Desktop.
When I run the server, I get Project 1's website. Have looked in the Django docs and on here but can't find any answers to this. Also, when I enter the virtual environment pipenv shell it says I am on my desktop: (Desktop) bash-3.2$ This might have something to do with it?
This error is easy to reproduce. Basically just start a new django project and run the server with django-admin. I read many StackOverflow posts and tried multiple methods but did not work. Here are the detailed steps to reproduce:
Created new directory named testproject
pipenv install django
Started new project named test with the django start project script
pipenv shell
django-admin runserver
Error: "django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings."
Typed this in ubuntu as suggested in the official django docs: export DJANGO_SETTINGS_MODULE=test.settings
django-admin runserver
Got a giant line of error followed by ModuleNotFoundError: No module named 'test'. However, if i do django-admin runserver --pythonpath=. --settings="test.settings" the server successfully runs.
I know I can just use python manage.py to start the server but my project uses Django cache framework and when I try to access the cache the same settings are not configured error is thrown. Trying to understand what is going on, any help would be greatly appreciated.
In your list I did not see the virtual env activation.
Did you activate the virtual env ?
'''
source activate testproject
'''
I created a new project with
django-admin startproject basicform
And then created a new application
django-admin startapp basicapp
But, when i started my server,
python manage.py runserver
It made duplicated files, like this
https://drive.google.com/open?id=1MTvpHf7pACsp9o_b129g5wPsKqwbbZDp
Is this an ERROR?
Should i delete the files?
I am working on django-1.11 and Python 3.6.4 :: Anaconda, Inc.
Also, when i tried running the server, it worked fine.
python manage.py runserver
https://drive.google.com/open?id=1arjf3U8Mm8ggwLTbSk5Gc9bd_FDl5lJj
EDIT:
I have deleted the duplicate -tpl.c~ files and the project is working fine.
"~" is a common suffix for backup files created by an editor. It is safe to remove them if you don't need them, and you should be using a VCS to handle old revisions regardless.