Browse Source

🎨 [pre-commit.ci] Auto format from pre-commit.com hooks

pull/11782/head
pre-commit-ci[bot] 1 year ago
committed by Patrick Arminio
parent
commit
bd01cb9750
Failed to extract signature
  1. 46
      docs_src/django_orm/polls/migrations/0001_initial.py
  2. 8
      docs_src/django_orm/polls/models.py

46
docs_src/django_orm/polls/migrations/0001_initial.py

@ -1,36 +1,52 @@
# Generated by Django 2.1 on 2018-08-08 21:45 # Generated by Django 2.1 on 2018-08-08 21:45
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = []
]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='Choice', name="Choice",
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), (
('choice_text', models.CharField(max_length=200)), "id",
('votes', models.IntegerField(default=0)), models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("choice_text", models.CharField(max_length=200)),
("votes", models.IntegerField(default=0)),
], ],
), ),
migrations.CreateModel( migrations.CreateModel(
name='Question', name="Question",
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), (
('question_text', models.CharField(max_length=200)), "id",
('pub_date', models.DateTimeField(verbose_name='date published')), models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("question_text", models.CharField(max_length=200)),
("pub_date", models.DateTimeField(verbose_name="date published")),
], ],
), ),
migrations.AddField( migrations.AddField(
model_name='choice', model_name="choice",
name='question', name="question",
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.Question'), field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="polls.Question"
),
), ),
] ]

8
docs_src/django_orm/polls/models.py

@ -6,7 +6,7 @@ from django.utils import timezone
class Question(models.Model): class Question(models.Model):
question_text = models.CharField(max_length=200) question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published') pub_date = models.DateTimeField("date published")
def __str__(self): def __str__(self):
return self.question_text return self.question_text
@ -14,10 +14,10 @@ class Question(models.Model):
def was_published_recently(self): def was_published_recently(self):
now = timezone.now() now = timezone.now()
return now - datetime.timedelta(days=1) <= self.pub_date <= now return now - datetime.timedelta(days=1) <= self.pub_date <= now
was_published_recently.admin_order_field = 'pub_date' was_published_recently.admin_order_field = "pub_date"
was_published_recently.boolean = True was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?' was_published_recently.short_description = "Published recently?"
class Choice(models.Model): class Choice(models.Model):

Loading…
Cancel
Save