DEV Community

Bret
Bret

Posted on

How do you make a about page route?

I’m trying to create a simple route for a about page:

path(‘about/‘ aboutpage_view, as_view(), name=‘about’)

But it’s not working,
It says it can’t find the name, then also it can’t find the views.

I named it def aboutpage_view

Top comments (7)

Collapse
 
hlee131 profile image
H Lee

If it's a class based view, the as_view function is a member of the class View, that you inherited from:

path("about/", aboutpage_view.as_view(), name="about")

If it's a functional view, you don't even need the as_view function:

path("about/", aboutpage_view, name="about")

Oh and don't forget the comma after the first parameter.

Collapse
 
yobretyo profile image
Bret

It starts out as def aboutpage_view,
I tried that but it didn’t work

Collapse
 
yobretyo profile image
Bret

It was the templates folder, it wasn’t with manage.py

Collapse
 
merichard123 profile image
Richard • Edited

As H lee said if it's a functional view you need to link your app.urls in the main project URLs and then you can do from app import views then in your app URLs you can add views.aboutpage_view

Make sure you have an about view:

#app views.py
def aboutpage_view():
      return whatever

#app URLs
urlpatterns = [
   path('about/', view.aboutpage_view, name='about')
]

# main project URLs
path("", include ('app.urls'))

Take a look at this dev.to/merichard123/django-diaries...

If it's a class based view do the same but add the as_view() method to the view parameter

Collapse
 
yobretyo profile image
Bret

This is what I have

Collapse
 
yobretyo profile image
Bret

It’s not working

Collapse
 
merichard123 profile image
Richard

Are you getting any errors? Is your code on GitHub?