A project in django is a collection of settings for an instance of Django. This includes:
Select the project directory where you want to host your django setup. Now change into that directory.
~ $ cd ~/Documents/my_d3_project/django
Since, we have installed django using pip utility, django-admin.py should be on your system path. You can verify if you can access it:
~/Documents/my_d3_project/django $ which django-admin.py
/opt/anaconda/bin/django-admin.py
This is the path of django-admin.py. Now, run the following command to create a myD3site directory in our current directory.
~/Documents/my_d3_project/django $ django-admin.py startproject myD3site
~/Documents/my_d3_project/django $ ls
myD3site
Let us look inside to find what startproject created. We can use the tree command in Ubuntu:
~/Documents/my_d3_project/django $ tree .
.
`-- myD3site
|-- manage.py
`-- myD3site
|-- __init__.py
|-- settings.py
|-- urls.py
`-- wsgi.py
2 directories, 5 files
~/Documents/my_d3_project/django $
- Django specific options
- application specific settings
- database configuration
Select the project directory where you want to host your django setup. Now change into that directory.
~ $ cd ~/Documents/my_d3_project/django
Since, we have installed django using pip utility, django-admin.py should be on your system path. You can verify if you can access it:
~/Documents/my_d3_project/django $ which django-admin.py
/opt/anaconda/bin/django-admin.py
This is the path of django-admin.py. Now, run the following command to create a myD3site directory in our current directory.
~/Documents/my_d3_project/django $ django-admin.py startproject myD3site
~/Documents/my_d3_project/django $ ls
myD3site
Let us look inside to find what startproject created. We can use the tree command in Ubuntu:
~/Documents/my_d3_project/django $ tree .
.
`-- myD3site
|-- manage.py
`-- myD3site
|-- __init__.py
|-- settings.py
|-- urls.py
`-- wsgi.py
2 directories, 5 files
~/Documents/my_d3_project/django $
The files are:
- The outer myD3site/ root directory - It is just a container for your project. Its name does not matter to Django, you can rename it to anything you like.
- manage.py - a command line utility that lets you interact with this django project in various ways
- The inner myD3site/ directory - It is the python package for your project. It is the name you will use to import anything inside it. (for example, myD3site.urls)
- myD3site/__init__.py - an empty file that tells Python that this directory should be considered a Python package. This is a file required by Python and tells it to treat this directory as a package (i.e, a group of modules)
- myD3site/settings.py - settings or configuration for this django project
- myD3site/urls.py - The URL declarations for this django project: "a table of contents for your django powered site"
- myD3site/wsgi.py - an entry point for WSGI-compatible web servers to serve your project.
No comments:
Post a Comment