[Fixed]-Django Tutorial: Generic Views. Attribute Error

40๐Ÿ‘

โœ…

I think the code you posted above, is not the one you have on your disk.

I had the same problem, but then I looked carefully at both, my code and the tutorial. The regex I had in my code was different from the tutorial.

This was my code:

 url(r'^(?P<poll_id>\d+)/$',-$                                               
 url(r'^(?P<poll_id>\d+)/results/$',-$                                       

This is the correct core:

 url(r'^(?P<pk>\d+)/$',-$                                               
 url(r'^(?P<pk>\d+)/results/$',-$                                       

Note that *poll_id* was in the previous sections of the tutorial, but generic views require pk. Also note that the tutorial is correct, and you posted the correct code (from the tutorial.)

๐Ÿ‘คnbensa

0๐Ÿ‘

Look Carefully in the Tutorials they have mentioned to change the urlpatterns to use primarykey instead of question_id.

๐Ÿ‘คNaman

Leave a comment