Reading-Notes


Project maintained by eslamakram Hosted on GitHub Pages — Theme by mattgraham

Django CRUD and Forms

Django CRUD (Create, Retrieve, Update, Delete) Function Based Views:

creating a form

  1. create the model

    After creating this model, we need to run two commands in order to create Database for the same. Python manage.py makemigrations Python manage.py migrate

  2. create form.py

  3. Create View Create View refers to a view (logic) to create an instance of a table in the database

  4. Create a template in templates/create_view.html

  5. Retrieve View Retrieve view is basically divided into two types of views Detail View and List View. List View List View refers to a view (logic) to list all or particular instances of a table from the database in a particular order. It is used to display multiple types of data on a single page or view

  6. Create a template in templates/list_view.html

  7. Detail View Detail View refers to a view (logic) to display a particular instance of a table from the database with all the necessary details. It is used to display multiple types of data on a single page or view, for example, profile of a user.
  8. create a view and template for the same. In geeks/views.py

  9. Create a template in templates/Detail_view.html
  10. Update View Update View refers to a view (logic) to update a particular instance of a table from the database with some extra details. It is used to update entries in the database for example, updating an article at geeksforgeeks.
  11. Delete View Delete View refers to a view (logic) to delete a particular instance of a table from the database. It is used to delete entries in the database for example,In views.py

Template for delete view includes a simple form confirming whether user wants to delete the instance or not. In templates/delete_view.html,