Code Monkey home page Code Monkey logo

mysite-django's Introduction

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 

mysite-django's People

Contributors

stefanoandroni avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.