Skip to content

Commit

Permalink
fixed typos
Browse files Browse the repository at this point in the history
  • Loading branch information
coeibu authored Mar 14, 2018
1 parent 68f0393 commit 6342988
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/nested_inlines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ How to add nested inlines in Django admin?

You have yor models defined like this::

class Catgeory(models.Model):
class Category(models.Model):
...

class Hero(models.Model):
catgeory = models.ForeignKey(Catgeory)
category = models.ForeignKey(Catgeory)
...

class HeroAcquaintance(models.Model):
Expand All @@ -18,18 +18,18 @@ You have yor models defined like this::
You want to have one admin page to create :code:`Category`, :code:`Hero` and :code:`HeroAcquaintance` objects. However, Django doesn't support nested inline with Foreign Keys or One To One relations which span more than one levels. You have a few options,


You can change the :code:`HeroAcquaintance` model, so that it has a direct FK to :code:`Catgeory`, something like this::
You can change the :code:`HeroAcquaintance` model, so that it has a direct FK to :code:`Category`, something like this::

class HeroAcquaintance(models.Model):
hero = models.OneToOneField(Hero, on_delete=models.CASCADE)
category = models.ForeignKey(Catgeory)
category = models.ForeignKey(Category)

def save(self, *args, **kwargs):
self.category = self.hero.category
super().save(*args, **kwargs)


Then you can attach :code:`HeroAcquaintanceInline` to :code:`CatgeoryAdmin`, and get a kind of nested inline.
Then you can attach :code:`HeroAcquaintanceInline` to :code:`CategoryAdmin`, and get a kind of nested inline.

Alternatively, there are a few third party Django apps which allow nested inline. A quick Github or DjangoPackages search will find one which suits your needs and tastes.

0 comments on commit 6342988

Please sign in to comment.