# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
wget -qO- https://astral.sh/uv/install.sh | sh
# Github Action
sudo ln -s /home/ubuntu/.local/bin/uv /usr/local/bin/uv
- For the function-based view, declaring the whole view using "async def"
- For the class-based view, declaring the HTTP method handlers, such as "async def get()" and "async def post()"
async for author in Author.objects.filter(name__startswith="A"):
book = await author.books.afirst()
python -m venv .venv
.venv\Scripts\activate
python -m pip install pip --upgrade
pip install -r requirements\development.txt
pip install -r requirements\production.txt
python3 -m venv .venv
. venv/bin/activate
python -m pip install pip --upgrade
pip install -r requirements/development.txt
pip install -r requirements/production.txt
- Ready Bootstrap-themed pages
- User Registration/Sign up
- Better Security with 12-Factor recommendations
- Logging/Debugging Helpers
- Works on Python 3 and Django 2
!!! project name CAN NOT use '-' due to python conflict
- Change project name and django_skeleton folder name
To set up a development environment quickly, first install Python 3. It
comes with virtualenv built-in. So create a virtual env by:
1. $ python3 -m venv {{ project_name }}
2. $ python -m pip install --upgrade pip
3. $ . {{ project_name }}/bin/activate
Install all dependencies:
pip install -r requirements.txt
Run migrations: # Update database change scripts python manage.py makemigrations
# Update database change
python manage.py migrate
# Create superuser
python manage.py createsuperuser
daphne myproject.asgi:application
https://www.youtube.com/watch?v=NG48CLLsb1A https://developers.google.com/gmail/api/quickstart/js https://console.developers.google.com/ PO File Translate
(venv)$ python manage.py startapp <new_app>
- Delete application relate tables and data $ python manage.py migrate registrationform zero
- Recreate Table $ python manage.py ./manage.py migrate
- Export Data from Workbench (Data Only)
- Update exported data
- Drop Table from database
- Update Drop Table status in Django $ python manage.py ./manage.py migrate --fake [table_name] zero
- Recreate Table $ python manage.py ./manage.py migrate
The ping_google() command only works if you have registered your site with Google Webmaster Tools. Registered your site with Google Webmaster Tools. Google Search Console
python manage.py ping_google
daphne django_skeleton.asgi:application
# Translate language
python manage.py makemessages -a
python manage.py makemessages -l fr
python manage.py makemessages -l zh_Hans
# Compile language po for production
python manage.py compilemessages -l fr -l zh_Hans
# django-autotranslate (User custom version)
python manage.py translate_messages -u -f
python manage.py compilemessages
In definitions like forms or models you should use gettext_lazy because the code of this definitions is only executed once (mostly on django's startup);
In views and similar function calls you can use gettext without problems, because everytime the view is called gettext will be newly executed, so you will always get the right translation fitting the request!
python manage.py loaddata api/books.json
python manage.py generateschema --file static/site/openapi/schema.yaml
django-allauth==0.50.0 dj-rest-auth==4.0.1
python manage.py shell
>>> from dharro.utils import SendEmail
>>> SendEmail('test', 'test')
# Apply all change to DB
python manage.py migrate
# Squash merge from 0003_faqcategory_order (last migration) to 0002_faqcategory_faqs
python manage.py squashmigrations products 0002_faqcategory_faqs 0003_faqcategory_order
# Delete migrations and rename squash migrations to
0002_squash_0002_faqcategory_faqs.py -> 0002_faqcategory_faqs.py
# Validate the squash merge migraiton
python manage.py makemigration
python manage.py migrate
# Show migration
python manage.py showmigrations
python manage.py runserver
python manage.py livereload