Repository: nautobot/nautobot

Issue:
2.0 TODO Housekeeping: Core
## Core
nautobot/core/views/generic.py
- `# 2.0 TODO: Remove this method in 2.0. Can be retrieved from instance itself now`
- `"changelog_url": changelog_url,  # 2.0 TODO: Remove in 2.0. This information can be retrieved from the object itself now.`



Discussion:
These have been replaced by separate stories that will remove them:

nautobot/core/graphql/schema.py
- `# 2.0 TODO: str_to_var_name is lossy, it may cause different relationships to map to the same rel_name` via #824


nautobot/core/models/generics.py
- `# 2.0 TODO: remove this, force migration to the newer django-taggit API.` #1633

Resolving patch:
diff --git a/nautobot/core/views/generic.py b/nautobot/core/views/generic.py
--- a/nautobot/core/views/generic.py
+++ b/nautobot/core/views/generic.py
@@ -15,7 +15,6 @@
 from django.forms import Form, ModelMultipleChoiceField, MultipleHiddenInput, Textarea
 from django.http import HttpResponse
 from django.shortcuts import get_object_or_404, redirect, render
-from django.urls import NoReverseMatch, reverse
 from django.utils.html import escape
 from django.utils.http import is_safe_url
 from django.utils.safestring import mark_safe
@@ -36,7 +35,6 @@
 )
 from nautobot.core.forms.forms import DynamicFilterFormSet
 from nautobot.core.templatetags.helpers import bettertitle, validated_viewname
-from nautobot.core.utils.lookup import get_route_for_model
 from nautobot.core.utils.permissions import get_permission_for_model
 from nautobot.core.utils.requests import (
     convert_querydict_to_factory_formset_acceptable_querydict,
@@ -47,7 +45,6 @@
 from nautobot.core.views.mixins import GetReturnURLMixin, ObjectPermissionRequiredMixin
 from nautobot.core.views.utils import check_filter_for_display, csv_format, handle_protectederror, prepare_cloned_fields
 from nautobot.extras.models import CustomField, ExportTemplate
-from nautobot.extras.models.change_logging import ChangeLoggedModel
 from nautobot.extras.utils import remove_prefix_from_cf_key
 
 
@@ -89,44 +86,12 @@ def get_extra_context(self, request, instance):
             "active_tab": request.GET.get("tab", "main"),
         }
 
-    # 2.0 TODO: Remove this method in 2.0. Can be retrieved from instance itself now
-    # instance.get_changelog_url()
-    # Only available on models that support changelogs
-    def get_changelog_url(self, instance):
-        """Return the changelog URL for a given instance."""
-        meta = self.queryset.model._meta
-
-        # Don't try to generate a changelog_url for an ObjectChange.
-        if meta.model_name == "objectchange":
-            return None
-
-        route = get_route_for_model(instance, "changelog")
-
-        # Iterate the pk-like fields and try to get a URL, or return None.
-        fields = ["pk", "slug"]
-        for field in fields:
-            if not hasattr(instance, field):
-                continue
-
-            try:
-                return reverse(route, kwargs={field: getattr(instance, field)})
-            except NoReverseMatch:
-                continue
-
-        # This object likely doesn't have a changelog route defined.
-        return None
-
     def get(self, request, *args, **kwargs):
         """
         Generic GET handler for accessing an object by PK or slug
         """
         instance = get_object_or_404(self.queryset, **kwargs)
 
-        changelog_url = None
-
-        if isinstance(instance, ChangeLoggedModel):
-            changelog_url = instance.get_changelog_url()
-
         return render(
             request,
             self.get_template_name(),
@@ -134,7 +99,6 @@ def get(self, request, *args, **kwargs):
                 "object": instance,
                 "verbose_name": self.queryset.model._meta.verbose_name,
                 "verbose_name_plural": self.queryset.model._meta.verbose_name_plural,
-                "changelog_url": changelog_url,  # 2.0 TODO: Remove in 2.0. This information can be retrieved from the object itself now.
                 **self.get_extra_context(request, instance),
             },
         )
diff --git a/nautobot/core/views/renderers.py b/nautobot/core/views/renderers.py
--- a/nautobot/core/views/renderers.py
+++ b/nautobot/core/views/renderers.py
@@ -20,7 +20,7 @@
 )
 from nautobot.core.views.paginator import EnhancedPaginator, get_paginate_count
 from nautobot.core.views.utils import check_filter_for_display
-from nautobot.extras.models.change_logging import ChangeLoggedModel, ObjectChange
+from nautobot.extras.models.change_logging import ObjectChange
 from nautobot.extras.utils import get_base_template
 
 
@@ -136,7 +136,6 @@ def get_context(self, data, accepted_media_type, renderer_context):
         form = None
         table = None
         search_form = None
-        changelog_url = None
         instance = None
         filter_form = None
         queryset = view.alter_queryset(request)
@@ -146,8 +145,6 @@ def get_context(self, data, accepted_media_type, renderer_context):
         if view.action in ["create", "retrieve", "update", "destroy", "changelog", "notes"]:
             instance = view.get_object()
             return_url = view.get_return_url(request, instance)
-            if isinstance(instance, ChangeLoggedModel):
-                changelog_url = instance.get_changelog_url()
         else:
             return_url = view.get_return_url(request)
         # Get form for context rendering according to view.action unless it is previously set.
@@ -208,7 +205,6 @@ def get_context(self, data, accepted_media_type, renderer_context):
                 table = self.construct_table(view, object=instance, content_type=content_type)
 
         context = {
-            "changelog_url": changelog_url,  # NOTE: This context key is deprecated in favor of `object.get_changelog_url`.
             "content_type": content_type,
             "form": form,
             "filter_form": filter_form,


Test patch: