Answer the question
In order to leave comments, you need to log in
How to link to foreignkey django?
Let's say there are two models.
class A(models.Model):
name = models.CharField(max_length=200)
def __str__(self):
return self.name
class B(models.Model):
name = models.CharField(max_length=200)
modela = models.ForeignKey(A, on_delete=models.DO_NOTHING)
def __str__(self):
return self.name
Answer the question
In order to leave comments, you need to log in
By hand, through the admin method (for example, def render_my_foreign_key_link(self, obj)).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question