Skip to content

Latest commit

 

History

History
 
 

backend

test_33602

This is a repository for a web application developed with Django, built with Crowdbotics

Table of Contents

  1. Project Structure
  2. Features
  3. Getting Started: Backend
  4. Usage

Project Structure

..
├── home                           # Starter home app
├── modules                        # Crowdbotics Modules app
├── test_33602  # Django project configurations
├── static                         # Static assets
├── users                          # Starter users app
├── web_build                      # React Native Web build
├── ...
├── README.md
└── ...

Features

  1. Local Authentication using email and password with allauth
  2. Rest API using django rest framework
  3. Forgot Password
  4. Bootstrap4
  5. Toast Notification
  6. Inline content editor in homepage

Getting Started: Backend

Following are instructions on setting up your development environment.

The recommended way for running the project locally and for development is using Docker.

It's possible to also run the project without Docker.

Docker Setup (Recommended)

This project is set up to run using Docker Compose by default. It is the recommended way. You can also use existing Docker Compose files as basis for custom deployment, e.g. Docker Swarm, kubernetes, etc.

  1. Install Docker:

  2. Clone this repo and cd test_33602

  3. Make sure Pipfile.lock exists. If it doesn't, generate it with:

    $ docker run -it --rm -v "$PWD":/django -w /django python:3.7 pip3 install --no-cache-dir -q pipenv && pipenv lock
  4. Use .env.example to create .env:

    $ cp .env.example .env
  5. Update .env and docker-compose.override.yml replacing all <placeholders>

    1. Use python -c 'from secrets import token_urlsafe; print("SECRET_KEY=" + token_urlsafe(50))' to generate the random SECRET_KEY
  6. Start up the containers:

    $ docker-compose up

    This will build the necessary containers and start them, including the web server on the host and port you specified in .env.

    Current (project) directory will be mapped with the container meaning any edits you make will be picked up by the container.

  7. Seed the Postgres DB (in a separate terminal):

    $ docker-compose exec web python3 manage.py makemigrations
    $ docker-compose exec web python3 manage.py migrate
  8. Create a superuser if required:

    $ docker-compose exec web python3 manage.py createsuperuser

    You will find an activation link in the server log output.

Local Setup (Alternative to Docker)

  1. Postgresql
  2. Python

Installation

  1. Install pipenv
  2. Clone this repo and cd test_33602
  3. Run pip install --user --upgrade pipenv to get the latest pipenv version.
  4. Run pipenv --python 3.6
  5. Run pipenv install
  6. Run cp .env.example .env
  7. Update .env file DATABASE_URL with your database_name, database_user, database_password, if you use postgresql. Can alternatively set it to sqlite:////tmp/my-tmp-sqlite.db, if you want to use sqlite for local development.

Getting Started

  1. Run pipenv shell
  2. Run python manage.py makemigrations
  3. Run python manage.py migrate
  4. Run python manage.py runserver

Usage

Admin Panel

Admin Panel can be accessed through http://localhost:8000/admin/. If you are the Project Owner, admin credentials can be generated from App > Settings on Crowdbotics App Dashboard. If not, please request your PM or Project Owner to generate admin credentials and share with you.

API Documentation

API Documentation is generated automatically and can be access through http://localhost:8000/api-docs/. Please make sure you are signed in to the admin panel before navigating to this page.