reading-notes2

https://m7madmomani2.github.io/reading-notes2

View the Project on GitHub M7madMomani2/reading-notes2

Django start project


In terminal

-> take folder_name
-> poetry init -n
-> poetry add django
-> poetry add --dev black flake8
-> poetry shell
-> django-admin startproject project_name .
-> python manage.py migrate 
-> django-admin startapp app_name
-> code . 

in vs-code



Django start Model / List View

from app_name in models.py

from django.contrib.auth import get_user_model

class Name_app(models.Model):
    name = model.CharField(max_length=256)
    rating = models.IntegerField(default=0)
    reviewer = models.ForeignKey(get_user_model(),on_delete=models.CASCADE)
    def __str__(self):
        return  self.name