Install Django: Link
This project was developed with Django 3.1.
pip install django-registration
for registration pages to work
python manage.py runserver
- Create view function in <app-name>/views.py
- Add path to view in urlpatterns list in <app-name>/urls.py
(May need to add path to urlpatterns list in badger_buddy/urls.py as well, e.g. if app is new)
- Add / edit model classes in <app-name>/models.py
- Store changes to models as migrations: python manage.py makemigrations
- Apply migrations to database: python manage.py migrate
- Create app: python manage.py startapp <app-name>
(Notice app has a configuration class in <app-name>/apps.py) - Install app to a project: in INSTALLED_APPS list (badger_buddy/settings.py), add a reference to the app's configuration class
Overview with examples: Link
Get everything in a table: <model-name>.objects.all()
Lookup: <model-name>.objects.filter(), <model-name>.objects.get()
RelatedManager useful for querying one-to-many or many-to-many relations: Link
Double underscores to follow relationships (see example at end of overview linked above)
- In <app-name>/admin.py, import <model-name> from .models
- In <app-name>/admin.py, register the model: admin.site.register(<model-name>)
Insert {% include "style/bootstrap.html" %}
at the top
Usage guide: https://getbootstrap.com/docs/4.3/components/
Use block-content and endblock. More details: https://docs.djangoproject.com/en/3.1/ref/templates/language/#id1
Consider these as static files: https://docs.djangoproject.com/en/3.1/howto/static-files/
Linking jsx or react files: transfer to js file first: https://reactjs.org/blog/2013/08/19/use-react-and-jsx-in-python-applications.html