Skip to content

Commit

Permalink
fix(models): replace custom method with GenericForeignKey
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Oct 11, 2024
1 parent c8b2609 commit a5c7997
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions apis_bibsonomy/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.urls import reverse
from django.conf import settings
Expand Down Expand Up @@ -26,6 +27,7 @@ class Reference(models.Model):
blank=True,
null=True,
)
referenced_object = GenericForeignKey()

def __str__(self):
title = self.bibtex.get("title")
Expand All @@ -36,10 +38,6 @@ def __str__(self):
def get_absolute_url(self):
return reverse("apis_bibsonomy:referencedetail", kwargs={"pk": self.pk})

@property
def referenced_object(self):
return self.content_type.get_object_for_this_type(id=self.object_id)

@property
def similar_references(self, with_self=False):
similarity_fields = getattr(
Expand Down

0 comments on commit a5c7997

Please sign in to comment.