-
Notifications
You must be signed in to change notification settings - Fork 2
Description
A difficulty I've found integrating this into my existing site is with the requirement for the URL pattern for a MentionableMixin model to just have a slug.
I've added MentionableMixin to my Post model, but the URL pattern for its get_absolute_url() / detail view is like:
"<slug:blog_slug>/<int:year>/<int:month>/<int:day>/<slug:post_slug>/"I could change post_slug to be just slug but the Post.slug field has a unique_for_date constraint on it, and there are many Posts with identical slugs, but with different dates. So the get_model_for_url_path() wouldn't be able to find a Post solely by using the slug field.
My first thought at a solution to this would be to add an optional setting to replace the get_model_for_url_path() function, something like this (as a default):
WEBMENTIONS_GET_MODEL_FUNCTION = "mentions.resolution.get_model_for_url_path"I'm not sure that's the best name, or that it's the best idea, but still.
It would allow the replacement of that function with another that would receive a URL and optional ResolverMatch and either return the found model or else raise one of BadConfig or TargetDoesNotExist exceptions. It would give flexibility over exactly how that model should be found. Is that enough flexibility? Is it a bit too complicated to describe how to replace the function? Will this all end in tears?
As ever, I'm open to other, better ideas.