halilsafakkilic / Django-Playground

This repo was created following Django tutorials. A few experimental studies have been added to it.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django Playground

This playground was created from Django framework on Python3. This project was created with the tutorials under https://docs.djangoproject.com/en/3.2/. PostgreSQL is preferred as database.

django-environ, jsons , gunicorn packages, dataclass, csrf_exempt, register.simple_tag, admin.display decorators and one custom middleware and JsonResponse used.

 

If you need a development environment with docker maybe you must see dockerkit-python.

 

Before you launch the application, you should check that your definitions in the .env are correct.

Admin: http://localhost:8001/admin/
Polls: http://localhost:8001/polls/

Example API Requests

Poll Create

curl --location --request POST 'http://localhost:8001/polls/api/add' \
--header 'X-Access-Token: always-better' \
--header 'Content-Type: application/json' \
--data-raw '{"author": "HSK", "questionText": "What'\''s up?", "status":1, "publishTime": "2020-06-08T11:30:59Z"}'

Poll Detail

curl --location --request GET 'http://localhost:8001/polls/api/1/' \
--header 'X-Access-Token: always-better'

 

Useful Commands

Migration

python3 manage.py makemigrations
python3 manage.py makemigrations polls
python3 manage.py sqlmigrate polls 0001
python3 manage.py migrate

 

Test

python3 manage.py test

 

Pre-Release

python3 manage.py collectstatic
pip3 freeze > requirements.txt
LDFLAGS=-L/opt/homebrew/opt/openssl@1.1/lib pip install  -r requirements.txt

 

How to create a super user?

python3 manage.py createsuperuser --username=admin --email=your@email.com

 

Start with lightweight development Web server

python3 manage.py runserver 0.0.0.0:8001

 

Start with Gunicorn

gunicorn --bind 0.0.0.0:8001 firstApp.wsgi

About

This repo was created following Django tutorials. A few experimental studies have been added to it.


Languages

Language:Python 90.2%Language:HTML 7.4%Language:CSS 1.2%Language:Shell 1.2%