An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
April 9, 2022 09:21 am GMT
Original Link: https://dev.to/kaede_io/django-tutorial-part-3-choice-teburuwo-crud-suru-14j
Django Tutorial Part 3 -- Choice CRUD
Question id 1 .create(column='hoge') Choice
>>> q = Question.objects.get(pk=1)>>> q.choice_set.all()<QuerySet []>
parent.children_set.all()
>>> q.choice_set.create(choice_text='Not much', votes=0)<Choice: Not much>>>> q.choice_set.all()<QuerySet [<Choice: Not much>]>
.create(column_name='text', column_name2=0)
.count()
>>> q.choice_set.count()1
.count
.delete()
>>> c = q.choice_set.filter(choice_text__startswith='Not')>>> c<QuerySet [<Choice: Not much>]>>>> c.delete<bound method QuerySet.delete of <QuerySet [<Choice: Not much>]>>>>> c.delete()(1, {'polls.Choice': 1})>>> q.choice_set.all()<QuerySet []>>>>
.delete()
def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
1
https://docs.djangoproject.com/en/4.0/intro/tutorial02/#introducing-the-django-admin
admin
Original Link: https://dev.to/kaede_io/django-tutorial-part-3-choice-teburuwo-crud-suru-14j
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To