I
I
Ilya Chichak2016-08-23 08:02:03
Django
Ilya Chichak, 2016-08-23 08:02:03

How to split a model into several blocks in the admin panel?

there is models.py (example)

class PersonSex(models.Model):
    sex = models.CharField(max_length=10)

    def __str__(self):
        return self.sex


class FamilyStatus(models.Model):
    family = models.CharField(max_length=20)

    def __str__(self):
        return self.family

class Seeker(models.Model):
    user = models.ForeignKey(User)
    # Person Info
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    birth_date = models.DateField(null=True, blank=True)
    # Common Person Info
    sex = models.ForeignKey(PersonSex, null=True, blank=True)
    family_status = models.ForeignKey(FamilyStatus, null=True, blank=True)

in this case, all models in the admin panel are in the same category with the name of the application. can they be separated so that PersonSex and FamilyStatus are in one category and Seeker in another?
UPDATE:
Found a similar situation on StackOverflow and suggest using
class Meta:
    app_label = 'some new app'

but it doesn't work if the model is used as a ForeignKey

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2016-08-23
@ilya_chch

In the old days, a tuple of two values ​​was enough for the sex field!
Maybe django-modeladmin-reorder will help you .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question