feat: add unique URLs for Artwork, Marker, Object, and Exhibit#957
feat: add unique URLs for Artwork, Marker, Object, and Exhibit#957vjpixel wants to merge 1 commit into
Conversation
vjpixel
commented
Jun 21, 2026
- Add slug fields (unique, auto-generated) to Marker, Object, and Artwork models
- Add save() method to auto-generate slugs from titles with collision handling
- Add get_absolute_url() to Marker, Object, Artwork, and Exhibit models
- Add detail views: marker_detail, object_detail, artwork_detail
- Register URL patterns: markers//, objects//, artworks//
- Create Jinja2 templates for marker_detail, object_detail, artwork_detail
- Add migration 0028 to add slug fields to marker, object, and artwork tables
- Add slug fields (unique, auto-generated) to Marker, Object, and Artwork models - Add save() method to auto-generate slugs from titles with collision handling - Add get_absolute_url() to Marker, Object, Artwork, and Exhibit models - Add detail views: marker_detail, object_detail, artwork_detail - Register URL patterns: markers/<slug>/, objects/<slug>/, artworks/<slug>/ - Create Jinja2 templates for marker_detail, object_detail, artwork_detail - Add migration 0028 to add slug fields to marker, object, and artwork tables
| base_slug = slugify(self.title) or "artwork" | ||
| slug = base_slug | ||
| counter = 1 | ||
| while Artwork.objects.filter(slug=slug).exclude(pk=self.pk).exists(): | ||
| slug = f"{base_slug}-{counter}" | ||
| counter += 1 | ||
| self.slug = slug | ||
| super().save(*args, **kwargs) | ||
|
|
There was a problem hiding this comment.
Instead of using this counter in a while. If it conflicts with an existing slug, use directly the ID which is unique, not a counter in a while
There was a problem hiding this comment.
You added new URLs and views, but there is no button anywhere on the site that takes to that URL you defined as the slug, you will have to guess the slug generated for each marker/artwork/object and type it directly into the browser to go to your new page. It is basically hidden from every user besides you, IF you can guess what is the slug to type
|
Our current "details" page are the modal pages we have when the user clicks on any content. Clicking on content opens the modal page and I'm not sure if you are trying to include this new link to replace the modal or include the new links at the modal pages to "see more details" of some content. |