Ajoutez des fichiers projet.
This commit is contained in:
46
polls/models.py
Normal file
46
polls/models.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import datetime
|
||||
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class Vehicles(models.Model):
|
||||
sName = models.CharField (max_length=250)
|
||||
bEnabled = models.BooleanField( default=0 )
|
||||
|
||||
class Vhc_problems(models.Model):
|
||||
Vehicle = models.ForeignKey( Vehicles, on_delete=models.CASCADE)
|
||||
sTitle = models.CharField( max_length=250)
|
||||
sDesc = models.TextField()
|
||||
bEnabled = models.BooleanField( default=1)
|
||||
dtStart = models.DateTimeField()
|
||||
dtEnd = models.DateTimeField()
|
||||
sAuthor = models.CharField( max_length=120)
|
||||
Author = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING )
|
||||
dtUpdated = models.DateTimeField('date updated')
|
||||
dtCreated = models.DateTimeField('date published')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Question(models.Model):
|
||||
question_txt = models.CharField( max_length=250)
|
||||
pub_date = models.DateTimeField('date published')
|
||||
|
||||
def __str__(self):
|
||||
return self.question_txt
|
||||
|
||||
def was_published_recently(self):
|
||||
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
|
||||
|
||||
class Choice(models.Model):
|
||||
question = models.ForeignKey(Question, on_delete=models.CASCADE)
|
||||
choice_txt = models.CharField( max_length=200)
|
||||
votes = models.IntegerField( default=0)
|
||||
|
||||
def __str__(self):
|
||||
return self.choice_txt
|
||||
|
Reference in New Issue
Block a user