I'm studying Django 2.0.2, and I'm having trouble with friendly URL along with SlugField in the models.py class, but I can not set def get_absolute_url(self):
correctly. I can access the URL directly. It is now necessary to define the function in the models class to work. can anybody help me?
Below is the url of my app.
from django.urls import include, path, re_path
from simplemooc.courses import views
app_name='courses'
urlpatterns = [
path('', views.index, name='index'),
re_path('(?P<slug>[\w-]+)/$', views.details, name='details'),
]
I also looked in the Django documentation, but I still did not understand: URL Dispatcher
a>.