resort
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from django.contrib import admin
|
||||
|
||||
class ChoiceInline(admin.TabularInline):
|
||||
model = Choice
|
||||
extra = 2
|
||||
|
||||
admin.site.register(Choice)
|
||||
# Register your models here.
|
||||
class QuestionAdmin(admin.ModelAdmin):
|
||||
list_display = ('question_text', 'pub_date')
|
||||
list_display_links = ('question_text', 'pub_date')
|
||||
search_fields = ('question_text',)
|
||||
|
||||
admin.site.register(Question, QuestionAdmin)
|
||||
|
||||
class ChoiceAdmin(admin.ModelAdmin):
|
||||
list_display = ('choice_text', 'question', 'votes')
|
||||
list_display_links = ('choice_text', 'question')
|
||||
search_fields = ('choice_text',)
|
||||
admin.site.register(Choice, ChoiceAdmin)
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PollsConfig(AppConfig):
|
||||
name = 'polls'
|
||||
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 6.0.4 on 2026-04-08 10:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
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_text', models.CharField(max_length=200, verbose_name='Вопрос')),
|
||||
('pub_date', models.DateTimeField(verbose_name='Дата публикации')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 6.0.4 on 2026-04-08 10:43
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('polls', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Choice',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('choice_text', models.CharField(max_length=200, verbose_name='Ответ')),
|
||||
('votes', models.IntegerField(default=0, verbose_name='Количество голосов')),
|
||||
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.question')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class Question(models.Model):
|
||||
question_text = models.CharField(verbose_name='Вопрос', max_length=200)
|
||||
pub_date = models.DateTimeField(verbose_name='Дата публикации')
|
||||
|
||||
class Choice(models.Model):
|
||||
question = models.ForeignKey(Question, on_delete=models.CASCADE)
|
||||
choice_text = models.CharField(verbose_name='Ответ', max_length=200)
|
||||
votes = models.IntegerField(verbose_name='Количество голосов', default=0)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,8 @@
|
||||
from djano.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
# path('', views.index, name='index'),
|
||||
# path('<int:question_id>/', views.detail, name='detail'),
|
||||
# path('<int:question_id>/results/', views.results, name='results'),
|
||||
# path('<int:question_id>/vote/', views.vote, name='vote'),
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user