An application created following Django's tutorial with some modifications.
This project requires:
Python 3.6
or newerDjango 2.1.2
or newer- Other Python packages as in requirements.txt
From the directory root, install required packages using the following command:
$ pip install -r requirements.txt
Create .env
text file in the project directory root and configure settings value for Django.
Create the database using the following command:
$ python manage.py migrate
(Optional) Create sample poll data using the following command:
$ python manage.py loaddata sample_poll_data
You're all set now!
Note: A required configuration value for
.env
isSECRET_KEY
.
A useful tool to generate one: https://www.miniwebtool.com/django-secret-key-generator/.Example:
# A line in `project_directory/.env` SECRET_KEY=c07(7b9676lfo8l6xwe#mn(ua%%bpt4c0bh)9jcr0p+v4fs*8k
Start the server using the following command:
$ python manage.py runserver
The server should be up at localhost on port 8000.
Go to the polls app at polls/
and the admin site at admin/
.
If you choose to use the sample data, an account with admin privileges will have already been created for you:
Username: admin
Password: password
If for some reason port 8000 is not available, simply specify another port like so:
$ python manage.py runserver 8001
You can use any port that's available, not just 8001 like shown.
Note: To use the admin site, you must have an account that can login to it.
See the Django documentation on how to create one.
- Part 1: Requests and responses
- Part 2: Models and the admin site
- Part 3: Views and templates
- Part 4: Forms and generic views
- Part 5: Testing
- Part 6: Static files
- Part 7: Customizing the admin site
If you see error messages like
'python' is not recognized as an internal or external command, operable program or batch file.
or Command not found: pip
, you might not have Python and pip
correctly installed and/or included in your path. Such problems are not in the
scope of this README.
Copy your error message and search it on Google (or other search engines) and there should be plenty of answers in sites like Stack Overflow.