Can't save and instantiate a child class in my django model
<p>Ok now I changed my models as follow:</p>

<pre><code>from django.contrib.auth.models import User

class Company(User):
    company_name = models.CharField(max_length = 20)


class Employee(User):
    pass
</code></pre>

<p>When I run from pytho manage.py shell the following commands:</p>

<pre><code>u = Employee(first_name = 'john', last_name = 'smith', password = 'test', email = 'smith@gmail.com')
u.save()
e = Employee(user = u)
e.save()
</code></pre>

<p>I get the following errors and can't really understand why.
Any help is appreciated, thanks in advance.</p>

<p>when writing:</p>

<pre><code>class x(y)
</code></pre>

<p>in Python this means x extends (inherit from) y.</p>

<p>while</p>

<blockquote>
  <p>class Employee(User):<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass</p>
</blockquote>

<p>makes a little sense (an employee is a user), this</p>

<blockquote>
  <p>class Company(User):</p>
</blockquote>

<p>makes no sense at all (Company is not a user).</p>

<p>If you want that a user will have the right to log in as a company, I'd advise to use foreign key:</p>

<pre><code>class Company(models.Model):
    user_with_permissions_fk = models.ManyToManyField((User)
</code></pre>

<p><br><br><br>
As to this piece of code:</p>

<blockquote>
  <p>u = Employee(first_name = 'john', last_name = 'smith', password = 'test', email = 'smith@gmail.com')<br>
  u.save()<br>
  e = Employee(user = u)<br>
  e.save()</p>
</blockquote>

<p>Please provide your syntax error -or- please consider replacing with this code:</p>

<pre><code>new_records_to_insert = []
new_records_to_insert += Employee(first_name = 'john', last_name = 'smith', password = 'test', email = 'smith@gmail.com')
new_records_to_insert += Employee(first_name = 'john', last_name = 'smith', password = 'test', email = 'smith@gmail.com')
Employee.objects.bulk_create(new_records_to_insert)
# No need to .save()
</code></pre>

python django database django-models