Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(models): replace custom method with GenericForeignKey #90

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -28,6 +29,7 @@ class Reference(models.Model):
blank=True,
null=True,
)
referenced_object = GenericForeignKey()

def __str__(self):
title = self.bibtexjson.get("title")
Expand All @@ -42,10 +44,6 @@ def bibtexjson(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
Loading