#32348: Error description of Django document in "tutorial07"
-----------------------------------------+------------------------
Reporter: Guan | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
[https://docs.djangoproject.com/en/3.1/intro/tutorial07/#writing-your-
first-django-app-part-7 writing-your-first-django-app-part-7]
There is a description: **Note that you can’t remove the original three
slots. **
But I find that ''the original three slots''** is able to** be removed in
Django 3.1.5. The code is as follows:
{{{
# polls.models.py
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField(verbose_name="date published")
def __str__(self):
return self.question_text
def was_published_recently(self):
now = timezone.now()
return now >= self.pub_date >= now - datetime.timedelta(days=1)
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __str__(self):
return self.choice_text
}}}
{{{
# polls.admin.py
class ChoiceInline(admin.StackedInline):
model = Choice
extra = 3
class QuestionAdmin(admin.ModelAdmin):
# fields = ["pub_date", "question_text"]
fieldsets = [
(None, {"fields": ["question_text"]}),
("Date Information", {"fields": ["pub_date"]})
]
inlines = [ChoiceInline]
admin.site.register(Question, QuestionAdmin)
}}}
The image url is: https://s3.ax1x.com/2021/01/13/stTQWq.png).
--
Ticket URL: <https://code.djangoproject.com/ticket/32348>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/057.4a3938040ba52ed5fe8348c79e05ef02%40djangoproject.com.