How to start a new Django project
Question:
Environment:
Windows 7
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Django==1.7.5
Whenever I try to create a new project:
python .Scriptsdjango-admin.py startproject new_project,
I get this error:
python: can't open file 'django-admin.py': [Errno 2] No such file or directory
Where am I going wrong? Thank you all in advance.
Answers:
If you have the system environment variables set up right (All the three below):
C:Python34;
C:Python34Scripts;
C:Python34Libsite-packagesdjangobin
then,
python .Scriptsdjango-admin.py startproject new_project,
gives error:
python: can't open file 'django-admin.py': [Errno 2] No such file or directory
since the command is system internally unrecognisable.
Instead, do:
django-admin startproject new_project
Note django-admin
without .py
extension
Read more at Writing your first Django app, part 1ΒΆ
If you’re using Windows, which I believe you are, leave off the .py on the django-admin.py. In other words, try django-admin startproject new_project.
Boilerplate Code
To create django as well create django app you have to follow many common commands. for simplicity, kindly follow the below single-line commands separated by semicolon:
django-admin startproject project_name; cd project_name;python3 manage.py startapp app_name; cd app_name; mkdir templates
Those commands will create commonly used structure for django.
Environment:
Windows 7
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Django==1.7.5
Whenever I try to create a new project:
python .Scriptsdjango-admin.py startproject new_project,
I get this error:
python: can't open file 'django-admin.py': [Errno 2] No such file or directory
Where am I going wrong? Thank you all in advance.
If you have the system environment variables set up right (All the three below):
C:Python34;
C:Python34Scripts;
C:Python34Libsite-packagesdjangobin
then,
python .Scriptsdjango-admin.py startproject new_project,
gives error:
python: can't open file 'django-admin.py': [Errno 2] No such file or directory
since the command is system internally unrecognisable.
Instead, do:
django-admin startproject new_project
Note django-admin
without .py
extension
Read more at Writing your first Django app, part 1ΒΆ
If you’re using Windows, which I believe you are, leave off the .py on the django-admin.py. In other words, try django-admin startproject new_project.
Boilerplate Code
To create django as well create django app you have to follow many common commands. for simplicity, kindly follow the below single-line commands separated by semicolon:
django-admin startproject project_name; cd project_name;python3 manage.py startapp app_name; cd app_name; mkdir templates
Those commands will create commonly used structure for django.