https://github.com/stefanbschneider/django_tutorial
An example web app for polls. Following the official Django tutorial.
https://github.com/stefanbschneider/django_tutorial
Last synced: 3 months ago
JSON representation
An example web app for polls. Following the official Django tutorial.
- Host: GitHub
- URL: https://github.com/stefanbschneider/django_tutorial
- Owner: stefanbschneider
- Created: 2020-06-11T16:10:30.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-07T21:16:33.000Z (over 1 year ago)
- Last Synced: 2025-01-03T21:27:30.646Z (5 months ago)
- Language: Python
- Homepage: https://docs.djangoproject.com/en/3.0/intro/tutorial01/
- Size: 173 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# Django Tutorial
Following the [Django tutorial](https://docs.djangoproject.com/en/3.0/intro/tutorial01/) to create a simple app for
creating polls, ie, questions with multiple choices where people can vote.The `polls` app is packaged `django-tutorial`. The Django project is in `mysite`.
## Development
Super user: `admin/admin`
### PyCharm Django Support
PyCharm Professional has special Django support that can be enabled in the settings.
* The project root should be `mysite/mysite` here
* Not sure how it helps/works yet. See https://www.jetbrains.com/help/pycharm/django-support7.html#### Django
Relevant Django CLI commands.
#### General dev
* `python manage.py runserver`: Start dev server (run from within `quotify`)
* `python manage.py check`: Check for problems in the project
* `python manage.py shell`: Interactive Python shell with some extra configs for Django
* For checking/testing the model API
* Restart shell after making changes to model
* `python manage.py test polls`: Run the test cases for the `polls` app (`polls/tests*.py`)
* More details on Testing Django: https://docs.djangoproject.com/en/3.0/topics/testing/#### Setup new project or app
* `django-admin startproject mysite`: Create a new project (here: `quotify`)
* `python manage.py startapp polls`: Create a new app `polls`
* Adding the app in `quotify/settings.py/INSTALLED_APPS`#### DB Setup or changes
* Change models in `models.py` (per app, eg, `polls`) and register in `admin.py`
* `python manage.py makemigrations polls`: Create migrations for given/changed models, here, in `polls/models.py`
* `python manage.py migrate`: Setup & sync DB by applying migrations. Can safely be run again - won't repeat actions twice.
* (`python manage.py sqlmigrate polls 0001`: Translate Django migrations to SQL commands (printed out; not yet applied to DB))#### Django admin
* `python manage.py createsuperuser`: Create new admin user
* Register models that should be managed by the admin under `app/admin.py`. Eg: `admin.site.register(Question)`