FAQ: Views - Using Primary Keys in URLs

This community-built FAQ covers the “Using Primary Keys in URLs” exercise from the lesson “Views”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Build Python Web Apps with Django

FAQs on the exercise Using Primary Keys in URLs

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I have a question!

When I tried to create, update, or delete the owners or patients, it shows

CSRF verification failed. Request aborted.

I think in the html forms there are {% csrf_token %} already.

Why does this message still show?

1 Like

The mini browser isn’t rendering anything. Here is the code I’ve entered in urls.py per the instructions:

from django.urls import path

from . import views

# Add your path()s inside of urlpatterns:
urlpatterns = [
  path("", views.home, name="home"),
  path("owner/list", views.OwnerList.as_view(), name="ownerlist"),
  path("patient/list", views.PatientList.as_view(), name="patientlist"),
  path("owner/create", views.OwnerCreate.as_view(), name="ownercreate"),
  path("patient/create", views.PatientCreate.as_view(), name="patientcreate"),
  path("owner/update/<pk>", views.OwnerUpdate.as_view(), name="ownerupdate")
  path("patient/update/<pk>", views.PatientUpdate.as_view(), name="patientupdate")
  path("owner/delete/<pk>", views.OwnerDelete.as_view(), name="ownerdelete")
  path("patient/delete/<pk>", views.PatientDelete.as_view(), name="patientdelete")
]

Sometimes the min browser will return this error: https://cdn.zappy.app/ede88307060bc3bc0555391ce1aeac4f.png

Otherwise, it just remains white.

2 Likes

the same here :(, and i have the same code

I have the same issue

I had the same issue. It was resolved by adding commas after each path. Afterwards, the pages were visible in the browser.