Skip to content

A simple articles web application built with django + htmx + Bootstrap

License

Notifications You must be signed in to change notification settings

stefanoandroni/mysite-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

django      htmx      bootstrap

A simple articles web application built with django + htmx + Bootstrap. (learning django)

Installation

  1. Clone git repository
  2. $ git clone https://github.com/stefanoandroni/mysite-django 
  3. (Optional) Create a Python virual environment and activate it (py version in runtime.txt)
  4. Install requirements
  5. $ cd mysite-django
    $ pip install -r requirements.txt
  6. Change directory to src
  7. $ cd src
  8. Make migrations and migrate
  9. $ py manage.py makemigrations
    $ py manage.py migrate
  10. Run server
  11. $ py manage.py runserver
Note Change DJANGO SECRET_KEY in .env for production

Note

To use all features is highly recommended to:
  1. Create an admin user
  2. $ python manage.py createsuperuser 
  3. Register as a user in '/accounts/register' and login
Only registered users will be able to use the functions of the web application. Furthermore, only an administrator can decide which articles to insert on the homepage (front page).

Django applications

'mysite' is the project root directory.

Note The endpoints for htmx requests (not accessible) and for static files are not included

Edpoints

accounts

/accounts /login
          /logout
          /register
          /password-change

articles

/articles /                                             
          /create                             Create
          /list                               Retrieve (List)
          /<slug:article_slug>  /             Retrieve (Detail)
          /<slug:article_slug>  /update/      Update          
          /<slug:article_slug>  /delete/      Delete

profiles

/profiles /

search

/articles /search

Features

accounts

articles

profiles

search

Some implementation notes

  • Views were initially implemented as FBV (Function Based Views), to then be (almost totally) converted to CBV (Class Based Views).
  • A custom middleware has been implemented.
  • Article pages load on click ('Click To Load'). (implemented with django pagination and Htmx)
  • Article images are automatically cropped on upload (fixed aspect ratio). (implemented with the Pillow library)
  • Environment variables are loaded from an .env file. (implemented with the dotenv module)
  • Simple test_models have been implemented for the articles app, executable from the command line:
  • $ py manage.py test articles