tango_with_django_2_code icon indicating copy to clipboard operation
tango_with_django_2_code copied to clipboard

Chapter 5 Tests

Open mental-that-like opened this issue 1 year ago • 0 comments

The tests for Chapter 5 are producing the error message on line 178 of the tests_chapter5.py file. The error message reads: "We couldn't find the correct output in the Page view within the admin interface for page listings. Did you complete the exercises, adding extra columns to the admin view for this model? Are the columns in the correct order?"

I can see that the pertinent test checks whether expected_str is in response_body. When I print response_body, the string is identical to expected_str except for the start of the string, which begins

instead of , but everything else is the same.

I.e. response_body reads:

image

instead of:

image

The code in my admin.py file for the project reads as follows:

"from django.contrib import admin from rango.models import Category, Page

class PageAdmin (admin.ModelAdmin): list_display = ('title', 'category', 'url')

Register your models here.

admin.site.register(Category) admin.site.register(Page,PageAdmin)"

which matches the code suggested in the Excercise Hints part of the book on Page 89. The code also produces the correct Pages view on the /admin/ site:

image

The above is a screenshot of the /admin/ page from my project which exactly matches the screenshot on page 88 of the book.

I am running a later version of Django than suggested in the book (4.1), which perhaps explains this error.

Can you please confirm whether there is something wrong with my implementation or whether the error is produced due to external reasons (e.g. using a later version of Django)? Thanks in advance for your help!

mental-that-like avatar Jan 26 '24 13:01 mental-that-like