Author Picture

Kim Majali


Deployment Settings Auto Change

Author Avatar wrote on 31/05/2022

import sys

1. Database

if 'runserver' not in sys.argv:
Production database

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': 'aaadb',
            'USER': 'postgres',
            'PASSWORD': 'pass',
            'HOST': 'aaadb.cymjfpovl5ev.eu-west-1.rds.amazonaws.com',
            'PORT': '5432',
        }
    }
else:
Read more

Dump and Load Data in Django

Author Avatar wrote on 31/05/2022

Entire database

Dump
python manage.py dumpdata > db_data.json
Load
python manage.py loaddata db_data.json
Read more

Send Emails in Django

Author Avatar wrote on 31/05/2022

Views.py

For sending emails
from django.core.mail import send_mail from django.utils.html import strip_tags from django.template import Context, Template from pages.models import EmailTemplate Read more

Cron Jobs Django (Crontabs)

Author Avatar wrote on 31/05/2022

1. Install django cron tab
pip install django-crontab
Read more

Django Time Zone

Author Avatar wrote on 31/05/2022

In model

from django.utils import timezone timestamp = models.DateTimeField(default=timezone.now) Read more

Topics: ExtrasBasics

CRUDgen Django CRUD generator