Stefan-ci / Django-Polling-Minimal-API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DJANGO POLLING APP API: Minimal stuffs

Prerequisites

Install the following prerequisites:

  1. Python
  2. PostgreSQL

Installation

1. Create a virtual environment

From the root directory run:

python -m venv env

2. Activate the virtual environment

From the root directory run:

On macOS:

source env/bin/activate

On Windows:

env\scripts\activate

3. Install required dependencies

From the root directory run:

pip install -r requirements.txt

4. Set up a PostgreSQL database

With PostgreSQL up and running, in a new Terminal window run:

dropdb --if-exists django_polls

Start psql, which is a terminal-based front-end to PostgreSQL, by running the command:

psql postgres

Create a new PostgreSQL database:

CREATE DATABASE django_polls;

Create a new database admin user:

CREATE USER yourusername WITH SUPERUSER PASSWORD 'yourpassword';

To quit psql, run:

\q

5. Set up environment variables

Setup your database by editing .env config file. Replace yourusername by your postgresql username and yourpassword by your postgresql password.

6. Run migrations

From the root directory run:

python manage.py makemigrations
python manage.py migrate

7. Create an admin user to access the Django Admin interface

From the root directory run:

python manage.py createsuperuser

When prompted, enter a username, email, and password.

Run the application

From the root directory run:

python manage.py runserver

View the application

URLs

Add data to the application

Add data through Django Admin.

About


Languages

Language:Python 100.0%