Kit is a Django project that provides built-in apps and REST API. It also offers several kinds of built-in web sites as well, like conversion and landing page.
It is intend to give you a kit of models, tools and utilities if you will, so you can have your service (landing page, conversion page, REST API, etc.) up and running in no time. You can customize every aspect of it as you can imagine.
- User Account with Email Based Authentication
- Web Sites
- Forms and CSRF
- Apps
- REST API
- Core REST API
- Core Functionalities
- SASS for CSS ans Static Files
- Doxygen Documentation
- Setup
- Road Map
Kit uses email based user authentication, which is built on Django's AbstractBaseUser
class, so users use their email
addresses to log-in.
Kit offers conversion (lean startup) page and landing page via its conversion and landingPage apps respectively. So you can get both sites running in no time. These sites have built-in captcha feature for their forms.
Landing Page Example
Conversion Web Page Example
The web sites provided with the project contain forms such as contact and newsletter subscription. I have built a captcha system based on Django's CSRF protection system in order to prevent automated spams.
I use JavaScript to render a captcha code on a canvas in the forms. This code is portion of the token obtained from
rendered hidden csrfmiddlewaretoken
input. This token is provided by Django so it is very easy to check it on
the server side.
The forms have a captcha
input, which is there to send the captcha to the server, even though they are not required by
the models which the forms use.
Visitor enters the captcha code into captcha
input he/she sees on the canvas and submits the form. Upon receiving the
request, the view uses Form.is_valid
method, which triggers Form.clean_capthca
method that I implemented. If the
captcha doesn't match pre-determined portion of the csrf
token provided previously, the submission fails and the
visitor is asked to confirm the captcha.
For this to work the way we want, we have to renew the csrf
token every time we receive a GET
method for the page.
We do that by invoking django.middleware.csrf.rotate_token
function in the view where applicable.
Rendered form looks like the one below.
PLEASE NOTE: You must edit the following email settings in projectSettings.common
module since forms send email
upon successful submissions.
EMAIL_USE_TLS
EMAIL_PORT
EMAIL_HOST
EMAIL_HOST_USER
DEFAULT_FROM_EMAIL
SERVER_EMAIL
EMAIL_HOST_PASSWORD
App | Description |
---|---|
commonStatic | App for serving common static files, like css, js, etc. |
contact | Contact, address, email, phone, social media |
content | Content and items |
conversion | Conversion web site |
core | Core functionalities and utilities |
errorPage | Renders error pages like 400, 404, etc. |
faq | Frequently Asked Questions |
landingPage | Landing page |
language | Language model, provides language option to models |
newsletter | Newsletter/subscribers related app |
privacyNotice | Privacy Notice |
projectSettings | Project settings, production, development, etc. |
restAPICore | Core functionalities for REST API |
simpleAPIAccount | Simple REST API account (doesn't require user registration) |
termsOfUse | Terms of Use |
testimonial | Testimonial related app |
userAccount | E-mail based user account |
visitorCount | Track user count for all URL that you project has |
The project provides built-in REST API for all the models it uses. Every app also has example Postman
collections in
<APP_NAME>/data/postman
folder. Please check RES API documentation for more information.
Kit REST API uses some core functionalities that I provide in restAPICore app. I'll keep updating this app for more complex functionalities.
Kit provides some core functionalities via core app.
The project uses SASS for CSS. I provided some abstract SASS logic that you can inherit and change based on your needs.
Please check <APP_NAME>/static/<APP-NAME>/sass
folder of the apps where applicable.
Likewise provided static files live under <APP_NANE>/static/
folder of the apps where applicable.
Please check commonStatic app for more information.
Python API documentation (Generated with Doxygen) is provided. Please check kit_doc/doxygen/html/index.html
.
Create a virtual environment. I use Python 3.8.2.
virtualenv -p python3 <NAME>
Activate it.
cd <NAME>;
source bin/activate;
Install requirements.
pip3 install -r requirements.txt
Migrate.
python manage.py makemigrations;
python manage.py migrate;
Create super user.
python manage.py createsuperuser;
Create demo data.
python manage.py createData kit;
Collect static.
python manage.py collectstatic -i *.sass;
Run server.
python manage.py runserver;
Enjoy!
- Adding user registration and verification web pages.
- Adding user agreement app.
- REST API implementation for user account groups and permissions.
- REST API implementation of
conversion.models.Subscriber
model. - Adding advanced features to REST API core app.
- Adding React control panel.