Resolves [28](https://github.com/beatonma/django-wm/issues/28)
New MentionableMixin classmethod: `resolve_from_url_kwargs(**url_kwargs)`
- This method receives captured parameters from an `urlpatterns` path.
- By default, it uses `<slug:slug>` to look up your object by a unique `slug` field.
- You can customize this by overriding the classmethod in your
MentionableMixin implementation
e.g.
python
urls.py
urlpatterns = [
path(
fr"<int:year>/<int:month>/<int:day>/<slug:post_slug>/",
MyBlogPostView.as_view(),
name="my-blog",
kwargs={
"model_name": "myapp.MyBlog",
},
),
]
models.py
class MyBlog(MentionableMixin, models.Model):
date = models.DateTimeField(default=timezone.now)
slug = models.SlugField()
content = models.TextField()
def all_text(self):
return self.content
def get_absolute_url(self):
return reverse(
"my-blog",
kwargs={
"year": self.date.strftime("%Y"),
"month": self.date.strftime("%m"),
"day": self.date.strftime("%d"),
"post_slug": self.slug,
}
)
classmethod
def resolve_from_url_kwargs(cls, year, month, day, post_slug, **url_kwargs):
return cls.objects.get(
date__year=year,
date__month=month,
date__day=day,
slug=post_slug,
)
`mentions.resolution.get_model_for_url_path` now delegates to
`MentionableMixin.resolve_from_url_kwargs` to resolve captured URL
parameters to a model instance.