“Django -Modelle” Code-Antworten

Primärschlüssel -Django -Modell

class Garden(models.Model):
    garden_id = models.IntegerField(primary_key=True)
Noobie Nareshhhh

Erstellen Sie Modelle in Django

from django.db import models
# Create your models here.

class Contact(models.Model):
    name = models.CharField(max_length=50)
    email = models.CharField(max_length=50)
    contact = models.CharField(max_length=50)
    content = models.TextField()
    def __str__(self):
        return self.name + ' ' + self.email
Annoying Anaconda

Modell in Django

from django.db import models

class Musician(models.Model):
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    instrument = models.CharField(max_length=100)

class Album(models.Model):
    artist = models.ForeignKey(Musician, on_delete=models.CASCADE)
    name = models.CharField(max_length=100)
    release_date = models.DateField()
    num_stars = models.IntegerField()
Jolly Jellyfish

Django -Modell

class Video(models.Model):
   title = models.CharField(max_length=200, null=True, blank=True)
   description = models.TextField(null=True, blank=True)
   url = models.CharField(max_length=200, null=True, blank=True)
   video_id = models.CharField(max_length=200, null=True, blank=True)
   created_at = models.DateTimeField(auto_now_add=True)
   updated_at = models.DateTimeField(auto_now=True)

   def __str__(self):
      return self.title
Copy
Disgusted Deer

Django -Modell

from django.db import models


class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')


class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)
Tender Tamarin

Django -Modelle

poll = models.ForeignKey(
    Poll,
    on_delete=models.CASCADE,
    verbose_name="the related poll",
)
sites = models.ManyToManyField(Site, verbose_name="list of sites")
place = models.OneToOneField(
    Place,
    on_delete=models.CASCADE,
    verbose_name="related place",
)
Better Beetle

Ähnliche Antworten wie “Django -Modelle”

Fragen ähnlich wie “Django -Modelle”

Weitere verwandte Antworten zu “Django -Modelle” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen