Ajoutez des fichiers projet.
This commit is contained in:
0
polls/__init__.py
Normal file
0
polls/__init__.py
Normal file
9
polls/admin.py
Normal file
9
polls/admin.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from polls.models import Question, Choice, Vehicles
|
||||
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(Question)
|
||||
admin.site.register(Choice)
|
||||
admin.site.register(Vehicles)
|
6
polls/apps.py
Normal file
6
polls/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PollsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'polls'
|
40
polls/migrations/0001_initial.py
Normal file
40
polls/migrations/0001_initial.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# Generated by Django 4.0 on 2021-12-18 16:39
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Question',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('question_txt', models.CharField(max_length=250)),
|
||||
('pub_date', models.DateTimeField(verbose_name='date published')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Vehicles',
|
||||
fields=[
|
||||
('nID', models.PositiveIntegerField(primary_key=True, serialize=False)),
|
||||
('sName', models.CharField(max_length=250)),
|
||||
('bReady', models.BooleanField(default=0)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Choice',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('choice_txt', models.CharField(max_length=200)),
|
||||
('votes', models.IntegerField(default=0)),
|
||||
('questionID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.question')),
|
||||
],
|
||||
),
|
||||
]
|
18
polls/migrations/0002_rename_questionid_choice_question.py
Normal file
18
polls/migrations/0002_rename_questionid_choice_question.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0 on 2021-12-18 17:00
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('polls', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='choice',
|
||||
old_name='questionID',
|
||||
new_name='question',
|
||||
),
|
||||
]
|
0
polls/migrations/__init__.py
Normal file
0
polls/migrations/__init__.py
Normal file
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
|
||||
|
3
polls/tests.py
Normal file
3
polls/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
8
polls/urls.py
Normal file
8
polls/urls.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from django.urls import path
|
||||
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('',views.index, name='index'),
|
||||
]
|
6
polls/views.py
Normal file
6
polls/views.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("Hello, world kirosbr ! test 2")
|
||||
# Create your views here.
|
Reference in New Issue
Block a user