관리 메뉴

Silver Library (Archived)

#Django (Notion) - ManyToManyField, ForeignKey 본문

Personal DB

#Django (Notion) - ManyToManyField, ForeignKey

Chesed Kim 2020. 12. 2. 21:59
반응형

#Django

-Do not forget to claim 'makemigrations' then 'migrate'! Or it won't be reflected on its server database.

 

[Relationship Field]

*ManyToManyField : To express Type list

*ForeignKey : Something is connected to a different object. To work as many to one. If not sure, refer #4.2. Or the following link & Django document:

brunch.co.kr/@ddangdol/5

 

Django Model - ForeignKey

Relationship fields | Relationship fields Django는 또한 관계를 나타내는 필드들을 정의한다. ForeignKey class ForeignKey(to, on_delete, **options) 다대일 관계이고 두 가지 위치 인수가 필요하다. 모델이 관련된 클래

brunch.co.kr

# class Meta:

There is a class inside of module calls Meta class. This meta allows me to configure many things.

 

How I use this?

class Amenity(AbstractItem):

    """ Amenity Object Definition """

#On Django's webpage, this will display as Amenitys

#To edit this; use verbose_name_plural

    class Meta:

        verbose_name_plural = "Amenities"

#note: Plural is not necessary if word is not plural form. verbose_name also works.

 

#To sync git:

git add.

git commit -m ""

 

Not sure what admin.ModelAdmin is?

docs.djangoproject.com/en/3.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin

 

The Django admin site | Django documentation | Django

Django The web framework for perfectionists with deadlines. Overview Download Documentation News Community Code Issues About ♥ Donate

docs.djangoproject.com