Skip to content

app-generator/sample-docker-django-pgsql

Repository files navigation

Django & PostgreSQL Docker Sample

Open-Source seed project provided by AppSeed in Django Framework on top of Material Kit design. Designed for those who like bold elements and beautiful websites, Material Kit 2 is ready to help you create stunning websites and web apps. Material Kit 2 is built with over 60 frontend individual elements, like buttons, inputs, navbars, nav tabs, cards, or alerts, giving you the freedom of choosing and combining.


Black Friday - 75%OFF

The campaign is active until 30.NOV and applies to all products and licenses.

AppSeed - Black Friday 2022 Campaign, 75% OFF Discount (all products).


🚀 Built with App Generator, Timestamp: 2022-09-18 07:49

  • Up-to-date dependencies
  • Session-Based authentication, Forms validation
  • Docker: bundled with PostgreSQL
    • LIVE-reload on changes

Material Kit - Starter generated by AppSeed.


✨ Start in Docker

Note: Make sure the PORT 5432 is free (usually reserved by the local PostgreSQL instance).

👉 Step 1 - Download the code from the GH repository (using GIT)

$ git clone https://github.com/app-generator/sample-docker-django-pgsql.git
$ cd sample-docker-django-pgsql

👉 Step 2 - Start the APP in Docker

$ docker-compose up --build 

👉 Step 3 - Migrate DB

$ docker-compose run --rm appseed-app python manage.py makemigrations
$ docker-compose run --rm appseed-app python manage.py migrate

👉 Step 4 - Create Superuser

$ docker-compose run --rm appseed-app python manage.py createsuperuser

👉 Step 5 - Access the APP

Visit http://localhost:5085 in your browser. The app should be up & running.


✨ Manual Build

Download the code

$ # Get the code
$ git clone https://github.com/app-generator/sample-docker-django-pgsql.git
$ cd sample-docker-django-pgsql

👉 Set Up for Unix, MacOS

Install modules via VENV

$ virtualenv env
$ source env/bin/activate
$ pip3 install -r requirements.txt

Set Up Database

$ python manage.py makemigrations
$ python manage.py migrate

Start the app

$ python manage.py runserver

At this point, the app runs at http://127.0.0.1:8000/.


👉 Set Up for Windows

Install modules via VENV (windows)

$ virtualenv env
$ .\env\Scripts\activate
$ pip3 install -r requirements.txt

Set Up Database

$ python manage.py makemigrations
$ python manage.py migrate

Start the app

$ python manage.py runserver

At this point, the app runs at http://127.0.0.1:8000/.


✨ Create Users

By default, the app redirects guest users to authenticate. In order to access the private pages, follow this set up:

  • Start the app via flask run
  • Access the registration page and create a new user:
    • http://127.0.0.1:8000/register/
  • Access the sign in page and authenticate
    • http://127.0.0.1:8000/login/

✨ Code-base structure

The project is coded using a simple and intuitive structure presented below:

< PROJECT ROOT >
   |
   |-- core/                               # Implements app configuration
   |    |-- settings.py                    # Defines Global Settings
   |    |-- wsgi.py                        # Start the app in production
   |    |-- urls.py                        # Define URLs served by all apps/nodes
   |
   |-- apps/
   |    |
   |    |-- home/                          # A simple app that serve HTML files
   |    |    |-- views.py                  # Serve HTML pages for authenticated users
   |    |    |-- urls.py                   # Define some super simple routes  
   |    |
   |    |-- authentication/                # Handles auth routes (login and register)
   |    |    |-- urls.py                   # Define authentication routes  
   |    |    |-- views.py                  # Handles login and registration  
   |    |    |-- forms.py                  # Define auth forms (login and register) 
   |    |
   |    |-- static/
   |    |    |-- <css, JS, images>         # CSS files, Javascripts files
   |    |
   |    |-- templates/                     # Templates used to render pages
   |         |-- includes/                 # HTML chunks and components
   |         |    |-- navigation.html      # Top menu component
   |         |    |-- footer.html          # App Footer
   |         |    |-- scripts.html         # Scripts common to all pages
   |         |
   |         |-- layouts/                   # Master pages
   |         |    |-- base.html             # Used by common pages
   |         |
   |         |-- accounts/                  # Authentication pages
   |         |    |-- login.html            # Login page
   |         |    |-- register.html         # Register page
   |         |
   |         |-- home/                      # UI Kit Pages
   |              |-- index.html            # Index page
   |              |-- page-404.html         # 404 page
   |              |-- *.html                # All other pages
   |
   |-- requirements.txt                     # Development modules - SQLite storage
   |
   |-- .env                                 # Inject Configuration via Environment
   |-- manage.py                            # Start the app - Django default start script
   |
   |-- ************************************************************************


Django & PostgreSQL Docker Sample - Open-source starter provided by AppSeed Generator.