L
L
Lexx Xell2021-09-08 22:58:35
Django
Lexx Xell, 2021-09-08 22:58:35

How to implement a model of links to external resources in the Django admin panel?

There are two models:

class Link(models.Model):
    man = models.ForeignKey('Man', related_name='links', on_delete=models.CASCADE)
    resource = models.CharField(max_length=255)
    link = models.CharField(max_length=255)

class Man(models.Model):
    name = models.CharField(max_length=100)


As a result, there are two fields in the admin panel:
613914570a91e544080390.png
First, the Man object is created, then separately you have to create link objects with a binding.

It is necessary to implement the ability to add links immediately in the same window when creating a Man object, similar to how it was done for ManyToMany.

How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-09-08
@LexxXell

Use inlines.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question