Giter Club home page Giter Club logo

todo_list_in_django's Introduction

Todo List In Django

Build a Priority todo list in Django

In this app, you get to contribute to and help building a simple web app in which you can add, delete todos to a database. We also fetch and display the todos according to their assigned priority.

The Database used in this app

Consists of a single Todo table

With attributes id(Primary Key), title, content, created_at(timestamp) and priority

id title content created_at priority
1 Todo 1 Todo 1 Content Date time 1
2 Todo 2 Todo 2 Content Date time 2
3 Todo 3 Todo 3 Content Date time 3
4 Todo 4 Todo 4 Content Date time 1

Functionalities

  • GET - fetches all todos present in the database and displays them according to their priority field.
  • ADD - creates a new todo and inserts it in the database.
  • DELETE - Removes a specific todo (given id) from the database.

Steps to replicate this project on your computer

  1. Create a virtual environment - python3 -m venv /path/to/new/virtual/environment

  2. Activate it

    • In Terminal - source <venv>/bin/activate
    • In cmd.exe - <venv>\Scripts\activate.bat
  3. In case of difficulties, read more about Virtual environments here.

  4. To Install sqlite3, please go through this link.

  5. Install all the required modules for the project via pip with the command.

     `pip3 install -r requirements.txt`
    
  6. This installs Django and other required packages.

  7. To start the project and run the server - cd Priority_Todo_List and then run

     `python3 manage.py runserver`
    
  8. Similarly, to create a super user for the DB

     `python3 manage.py createsuperuser`
    
  9. Make migrations

    `python3 manage.py makemigrations`
    
  10. Migrate changes to the Database

    `python3 manage.py migrate`
    

NOTE - The Commands above may not work as there are issues which you can solve by sending PRs to this repository!

todo_list_in_django's People

Contributors

anirudhrowjee avatar chmey avatar varun487 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

todo_list_in_django's Issues

UI Fix: Add csrf tokens to all forms

For all forms in index.html file, add csrf_tokens. This improves the security of the forms and ensures the post request is from a legitimate user.

Incomplete add function in views.py

This function adds the received todo object from the user to the database.
Steps to complete this function:

  1. The function accepts only post requests.
  2. Extract information of todo object from the request body.
  3. Create a todo object from the information
  4. Add the object to the DB
  5. Redirect to the '/todo' page

Install app in settings.py

In the settings.py file, the Todo app hasn't been installed. Hence Django doesn't know the app exists and doesn't serve the app's files when the server is run.

Incomplete index function in views.py

Complete the index function of views.py.
To complete this, you must get all the Todo objects in the database and send the todo objects to be displayed in the rendered index.html file.

Incomplete delete function in views.py

This function is used to delete a todo from the todolist.
Steps to complete this function:

  1. Add id parameter, that is, a parameter in the function to get the id of the todo object to delete.
  2. Accept request only if it is a post request.
  3. Delete todo Object with given id from DB.
  4. Redirect to the '/todo' page

Incomple url patterns in Todo/urls.py file

In the url_patterns of Todo App's urls.py file, create paths to different views present in the views.py file. A path to index view, add view and the delete view. Note that the delete view must also accept an id parameter of the Todo task to delete.

UI Fix: Incomplete form to add todo object

In the first form in index.html, we allow the user to add a todo item to the list.
Steps to complete this form:

  1. Add action and method attributes to below form.
  2. Make a post request to the url 'add/' with the information provided by user.
  3. Add csrf_token for security.
  4. Add options 1, 2, 3 to the dropdown menu to set priority.

Incomplete models for the database.

Complete the model 'Todo' in models.py with the attributes given in the README.md namely

  1. create a title attribute -> character field (add a reasonable max length)
  2. create a content attribute -> text
  3. create a created_at attribute -> timestamp (use imported datetime module)
  4. create priority attribute -> integer
  5. create priority attribute -> integer
  6. In the str function, return the todo object's title

UI Fix: Priority lists do not filter todos on priority

In the second, third and fourth forms in the index.html file, all todos are listed indiscriminately without the priority of the todo objects taken into account.
Steps to solve this issue:

  1. Filter todos according to their priority.
  2. In the form, Add action and method attributes to the below form. The form makes a post request to delete/id to delete the todo from the Database.
  3. Add csrf_token for each form for security.
  4. Add title, content, priority, timestamp and a submit button to each of the priority list forms.

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.