Django

Code

Ticket #4373: modeltests.get_object_or_404.models.py.diff

File modeltests.get_object_or_404.models.py.diff, 0.8 kB (added by SuperJared, 1 year ago)

Diff for tests/modeltests/get_object_or_404/models.py

  • modeltests/get_object_or_404/models.py

    old new  
    6969>>> get_object_or_404(Article.by_a_sir, title="Run away!") 
    7070<Article: Run away!> 
    7171 
     72# QuerySets can be used too 
     73>>> get_object_or_404(Article.objects.all(), title__contains="Run") 
     74<Article: Run away!> 
     75 
    7276# get_list_or_404 can be used to get lists of objects 
    7377>>> get_list_or_404(a.article_set, title__icontains='Run') 
    7478[<Article: Run away!>] 
     
    8387>>> get_list_or_404(Article.by_a_sir, title__icontains="Run") 
    8488[<Article: Run away!>] 
    8589 
     90# QuerySets can be used too 
     91>>> get_list_or_404(Article.objects.all(), title__icontains="Run") 
     92[<Article: Run away!>] 
     93 
    8694"""}