Django Model Fields And Attributes

Bu dersimizde de djangodaki model yapısına devam ettik. 

Djangonun model ile ilgili orijinal dökümantasyonuna buradan ulaşabilirsiniz .

https://docs.djangoproject.com/en/4.0/topics/db/models/

from django.db import models


class Product(models.Model):
    title = models.CharField(max_length=50,blank=True,verbose_name="Başlık",help_text="Buraya başlık bilgisi gelecek",default="başlık bilgisi girilmesi")
    description = models.TextField()
    price = models.PositiveIntegerField()
    image = models.ImageField(upload_to="media/products/")
    stock = models.PositiveIntegerField()
    is_active = models.BooleanField()
    created_date = models.DateTimeField(auto_now_add=True)
    modified_date = models.DateTimeField(auto_now=True)

    field1 = models.FileField(upload_to="media/products/",)
    emailfield = models.EmailField(null=True,blank=True)
    field3 = models.BigIntegerField(blank=True,null=True)
    field4 = models.JSONField(blank=True,null=True)
    ip_field = models.GenericIPAddressField(blank=True,null=True)

    datefield = models.DateField(blank=True,null=True)
    datetimefield = models.DateTimeField(blank=True,null=True)


    def __str__(self):
        return self.title

 


Comments

    There are no comments yet.

Comment