GoConqr has a new look! Let us know what you think.

Mind map

DJANGO

Julio Sebastian Cardoza Boulangger English

Map content

DJANGO

  1. Python

    • The language used in django will be python so we can use many of its libraries like datetime for example.
  2. Creating a Project

    • To create a project first you will have to create a virtual enviroment specifically for that project. After that proceed to create the project Notes: django-admin and py manage.py wont work unless you have a virtual enviroment open
  3. Microservices

    • Django will allow you to create one big project that groups different apps with different functions called microservices
  4. Views

    • Different pages that will be shown to the user, they can be html pages or just string messages via httpResponse
  5. Static Files

    • Files that will not change, differente from dynamic webpages like templates we have in our apps, static files could be css files that will not change thorough a run.
    • normally this will be saved in a cloud and could be saved in cache. In this case if you are changing your file and you are not seeing the changes hard reload and empty cache your webpage
  6. Best Practices

    • 1st It is recommended to create folders inside the templates or the static folders with the name of the app, that way there wont be a problem with name duplication or namespace collition. Also creating a app_name on the urls.py so even if theres repeated names when you put the url it wont be a collision with any other one.
    • 2nd It is recommended to call static files instead of hard coding them that way no matter where you put them, the app will take care of searching for it instead of you hard coding it again
    • 3rd you are suggested to use the name of url instead of hard coding the direction so django can take care of figuring out where the page will be
  7. Inheritance

  8. Security

    • CSRF Token
      • Cross-site request forging Token, help the site identify that we are actually sending a form via the page we are in and not other person sending a request from other page trying to acces or do something fraudulent
    • Form Validation
      • Not only should form validation be client-side since it could be disabled, it should also be server-side since it could that validation could be up to date and also represent and additional layer of security
  9. SQL

    • Models
      • A way to create a python class that represents data that we want django to store inside of our database. When we create a model django is gonna take care of all the sql language to tell it what to do.
      • Migrations
        • A set of instructions on how to handle a database in django, you first need to define the instructions and then migrate them to apply them, Its a 2-step process (makemigrations & migrate)
        • Ojo: Si la migracion afecta a bases de datos ya creada, como un cambio de tipo de campo, entonces el migrate no funcionara correctamente, ya que habra una diferencia de tipos. Mi solucion: Eliminar todas los datos existentes xd. Revisar si hay mejores soluciones
    • Steps
      • To work with models in DJANGO first create your model in the models.py file in your apps folder Second proceed to run the command py manage.py makemigrations Third when you got your migration ready, run the code py manage.py migrate
      • After the third step you could actually use sql language to modify your database but in this case we will be working with shell since it will add a layer of abstraction and make it easier. Fourth Run Shell in command prompt by writing py manage.py shell to run your pyhton commands to modify your database.
  10. Admin

    • Its a default app that will let us interact better with data
    • To use it we must create an administrative account in your django app via command py manage.py createsuperuser
    • To manipulate databases through here we must enter to our apps folder admin.py and register our models writing admin.site.register(modelname)
    • Finally we enter the /admin page and we can add or remove different model classes

Information

Description
Mind Map on DJANGO, created by Julio Sebastian Cardoza Boulangger on 19/04/2021.
Views
2
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?