Package: django-actual-helpers
OverviewThis project is a follow up of the old project django-common from Tivix. The project served as a base to this one but it doesn’t mean that we’ll keep things like it was before.Django-actual consists of the following things:A middleware that makes sure your web-app runs either on or without ‘www’ in the domain.ASessionManagerBasebase class, that helps in keeping your session related  code object-oriented and clean! See session.py for usage details.AnEmailBackendfor authenticating users based on their email, apart from username.Some custom db fields that you can use in your models including aUniqueHashFieldandRandomHashField.Bunch of helpful functions in helper.pyArender_form_fieldtemplate tag that makes rendering form fields easy and DRY.A dry response class:XMLResponsein the django_actual.http that can be used in views that give xml responses.InstallationInstall django_actual (ideally in your virtualenv!) using pip or simply getting a copy of the code and putting it in a directory in your codebase.Adddjango_actualto your Django settingsINSTALLED_APPS:INSTALLED_APPS = [
    # ...
    "django_actual",
]Add the following to your settings.py with appropriate values:IS_DEVIS_PRODDOMAIN_NAMEWWW_ROOTAddcommon_settingsto your Django settingsTEMPLATE_CONTEXT_PROCESSORS:TEMPLATE_CONTEXT_PROCESSORS = [
        # ...
        'django_actual.context_processors.common_settings',
]AddEmailBackendto the Django settingsAUTHENTICATION_BACKENDS:AUTHENTICATION_BACKENDS = (
        'django_actual.auth_backends.EmailBackend',
        'django.contrib.auth.backends.ModelBackend'
)AddWWWRedirectMiddlewareif required to the list of middlewares:MIDDLEWARE_CLASSES = [
        # ...
        "WWWRedirectMiddleware",
]Scaffolding featureInstallingTo get scaffold install it through pip withpip installdjango-actual-helpersand adddjango_actualto the INSTALLED_APPS.Default is set to main app directory. However if you use django_base_project you must set up this toSCAFFOLD_APPS_DIR = 'apps/'.RunTo run scaffold type:python manage.py scaffold APPNAME --model MODELNAME [fields]APPNAME is app name. If app does not exists it will be created.
MODELNAME is model name. Just enter model name that you want to create (for example: Blog, Topic, Post etc). It must be alphanumerical. Only one model per run is allowed![fields] - list of the model fields.Field typesAvailable fields:char - CharField (default)
text - TextField
int - IntegerField
decimal -DecimalField
datetime - DateTimeField
foreign - ForeignKey
email - EmailField
bool - BooleanFieldAll fields requires name that is provided before:sign, for example:title  body:text posts:int create_date:datetimeTwo fieldsforeignanddecimalrequires additional parameters:“foreign” as third argument takes foreignkey model, example:blog:foreign:Blog, post:foreign:Post, added_by:foreign:UserNOTICE: All foreign key models must already exist in project. User and Group model are imported automatically.decimal field requires two more argumentsmax_digitsanddecimal_places, example:total_cost:decimal:10:2char field also have a length parameter on the third positionall fields have a required as the last argumenttotal_cost:deciman:10:2:True
name:char:50:TrueNOTICE: To all models scaffold automatically adds two fields: update_date and create_date.How it works?Scaffold creates models, views (CRUD), forms, templates, admin, urls and basic tests (CRUD). Scaffold templates are using two blocks extending from base.html:{% extends "base.html" %}
{% block page-title %} {% endblock %}
{% block content %} {% endblock %}So be sure you have your base.html set up properly.Scaffolding example usageLet’s create simpleforumapp. We needForum,TopicandPostmodel.Forum modelForum model needs just one fieldname:python manage.py scaffold forum --model Forum nameTopic modelTopics are created by site users so we need:created_by,titleandForumforeign key (update_dateandcreate_dateare always added to models):python manage.py scaffold forum --model Topic created_by:foreign:User title forum:foreign:ForumPost modelLast one are Posts. Posts are related to Topics. Here we need:title,body,created_byand foreign key toTopic:python manage.py scaffold forum --model Post title body:text created_by:foreign:User topic:foreign:TopicAll data should be in place!Now you must addforumapp toINSTALLED_APPSand include app inurls.pyfile by adding into urlpatterns:urlpatterns = [
    ...
    path('forum', include('forum.urls')),
]Now syncdb new app and you are ready to go:python manage.py makemigrations
python manage.py migrateRun your server:python manage.py runserverAnd go to forum main page:http://localhost:8000/forum/All structure are in place. Now you can personalize models, templates and urls.At the end you can test new app by runing test:python manage.py test forum

Creating test database for alias 'default'...
.......
----------------------------------------------------------------------
Ran 7 tests in 0.884s

OKHappy scaffolding!Generation of SECRET_KEYSometimes you need to generate a newSECRET_KEYso now you can generate it using this command:$ python manage.py generate_secret_keySample output:$ python manage.py generate_secret_keySECRET_KEY: 7,=_3t?n@’wV=p`ITIA6”CUgJReZf?s:`f~Jtl#2i=i^z%rCp-Optional arguments--length- is the length of the keydefault=50--alphabet- is the alphabet to use to generate the keydefault=ascii letters + punctuation symbolsDjango settings keysDOMAIN_NAME - Domain name,"www.example.com"WWW_ROOT - Root website url,"https://www.example.com/"IS_DEV - Current environment is development environmentIS_PROD - Current environment is production environmentThis open-source app is brought to you by Sipmann, Inc. (http://sipmann.com/)Changelog0.9.3Changed the minimum Django version to 3.X. Version 2 might work (but not tested)Removed unused thingsAdd __str__ to generated modelsBootstrap layout to the templates