// models.py class Product(models.Model): title = models.CharField(max_length=225, unique=True) slug = models.SlugField(max_length=225, unique=True, null=True) // admin.py class ProductAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('title',)} // views.py class productDetail(generic.DetailView): model = Detail template_name = 'detail.html' // urls.py path('product/<slug:slug>/', views.productDetail.as_view(), name='productDetail'),
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter