How to link pages in admin to urls

I am a complete beginner so please bear with me.

I am building an online store and I have done most of the work of setting Django up and I have created an app called pages so that I can edit pages in the admin section of Django and then display the pages on the front end. I can create the pages in admin but how do I link a page to a url like /about for example? So that when I go to localhost:8000/about I see the page I created in the admin section of django.

Help is appreciated

It sounds like you’re implementing something similar to Django’s built-in flatpages app: https://docs.djangoproject.com/en/3.0/ref/contrib/flatpages/ . You can make your app work in the same way for URL mapping - either with a URLconf entry or a middleware. I’d recommend a URLconf entry as the simplest approach, you woud just need to make it last since you won’t have a prefix.

See the flatpage source for how they do this: https://github.com/django/django/tree/stable/3.0.x/django/contrib/flatpages (one URLconf entry mapping to one view).

Thank you for the information highly appreciated

Ok so I installed the flatpages app that is part of django but for the life of me I cannot make it work on my local server. I have added the following to urls.py:

from django.contrib import admin
from django.urls import path
from django.contrib.flatpages import views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('about/', views.flatpage, {'url':'/about/'}, name='about'),
]

and this to settings.py:

'django.contrib.sites',
'django.contrib.flatpages',

I created a page with url /about/ but when I click on view on site it goes to example.com and displays edgecastcdn.net and if I try localhost:8000 or 127.0.0.1:8000 I get server not found. So how do I create a simple site with dynamic pages?

I think you’re being directed to ‘example.com’ because you’ve copied code using that demo url from the docs: https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.view_on_site

The server is accessible on the localhost url’s if you’re using the default runserver, I guess you are already accessing it for the admin?