Implement get_absolute_url()
on BaseModel
#2901
Labels
type: housekeeping
Changes to the application which do not directly impact the end user
Milestone
Proposed Changes
Base models should always provide
get_absolute_url()
so that each model doesn’t have to hard-code this as well.e.g. This should suffice:
Justification
Since we’re aligning around pk for all objects, then this is even easier in that we know the app_label and model_name for the model, so we can automatically have something like above. We could just as easily align around the
natural_key_slug
(see: #2900) as well (e.g.args=self.natural_key_slug
should we so desire).More importantly, this is another boiler plate reduction. The majority of model objects are using
{app_label}.{model}
as their detail route name, andpk
as the unique identifier in detail routes, so this would eliminate most places whereget_absolute_url()
is required to be defined in the common case.The text was updated successfully, but these errors were encountered: