Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 9, 2022 09:21 am GMT

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:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To