Foreign key model in Django Admin
<p>I have two user roles in Django:</p>

<ul>
<li>Commercials</li>
<li>Sellers</li>
</ul>

<p>I have created two models, Seller Model has a ForeignKey field to Commercials (every seller has a commercial related to). When I register the models in admin I can create Commercials and related sellers using <code>StackedInline</code>, <code>TabularInline</code> etc.</p>

<p>The problem I have is I need to associate users to this models in order to authenticate, login, etc. In admin I need to create a user (in an inline way, not dropdown box)</p>

<p>This is my code:</p>

<p>In <strong>models.py</strong>:</p>

<pre><code>class Commercial(models.Model):
    name = models.CharField(max_length=255, null=True)
    user = models.OneToOneField(User, null=True)


class Seller(models.Model):
    name = models.CharField(max_length=255, null=True)
    commercial = models.ForeignKey('Commercial')
    user = models.OneToOneField(User, null=True)
</code></pre>

<p>In <strong>admin.py</strong>:</p>

<pre><code>class SellerAdmin(admin.StackedInline):
    model = Seller
    extra = 1

class CommercialAdmin(admin.ModelAdmin):
   inlines = [SellerAdmin]

admin.site.register(Commercial, CommercialAdmin)
</code></pre>

<p>I need to edit, create, users etc. related to this models inline not in a modal window, Is there any way?</p>

<p><a href="http://i.stack.imgur.com/w54tZ.png" rel="nofollow"><img src="http://i.stack.imgur.com/w54tZ.png" alt="enter image description here"></a></p>

<p><a href="https://github.com/s-block/django-nested-inline" rel="nofollow">Django nested inlines</a> library might help you.</p>

python django django-models django-admin