On this page it is explained how to configure your environment and your django app to start using pyforms.
Note
The instructions on this page assumes you know how the Django framework works.
- Install Pyforms using pip.
pip install pyforms-web
Execute the next command in the terminal to start a Django project.
django-admin startproject <project-name>
Edit the django project settings.py file to include the next configurations.
INSTALLED_APPS = [
'orquestra',
'sorl.thumbnail',
'pyforms_web.web',
'jfu',
'sorl.thumbnail',
...
]
MIDDLEWARE = [
...
'pyforms_web.web.middleware.PyFormsMiddleware'
]
Edit the django project urls.py file to include the next urls configurations.
from django.conf import settings
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('pyforms/', include('pyforms_web.web.urls') ),
path('', include('orquestra.urls') ),
]
if settings.DEBUG:
from django.conf.urls.static import static
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
In the django project root folder (same folder of the manage.py file) create the local_settings.py file with the next content.
SETTINGS_PRIORITY = 0 # Will define this settings file as priority. Will override all the settings with lower priority.
PYFORMS_MODE = 'WEB' # Will configure pyforms to run as WEB mode.
cd <project-name>
python3 manage.py migrate
python3 manage.py runserver
Access to http://localhost:8000
Use the local_settings.py file to set some pyforms-web settings.
# Do not use the compressed JS file, and use the original files
PYFORMS_DEBUG = True
# Activate verbose mode for the
PYFORMS_VERBOSE = True
(optional)
django-allauth is a reusable Django app that allows for both local and social authentication, with flows that just work.
To make it work with Orquestra follow the instructions described @django-allauth documentation.
pip install django-allauth
Add the next configuration to your Django project setttings.
...
INSTALLED_APPS = [
...
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'django.contrib.sites',
...
]
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
]
LOGIN_URL = '/accounts/login/'
LOGIN_REDIRECT_URL = '/'
Edit the urls.py file to add the next code.
from django.urls import path
urlpatterns = [
path('accounts/', include('allauth.urls')),
...
]
Add the next configuration to the local_settings.py file to configure orquestra to require always authentication before accessing the applications.
ORQUESTRA_REQUIREAUTH = True
Note
Do not forget to apply the db migrations to your project.
Initialize allauth configuration by adding a new register to the sites.Site model, using the next command.
python manage.py loaddata conf-allauth-site