Two question:
First: There are multiple type user, for example: NormalUser, StaffUser, EnterpriseUser, the model like this:
class User(AbstractBaseUser):
# some auth related field here
class NormalUser(User):
# extend , not abstract
class StaffUser(User):
class EnterpriseUser(User):
class AdminUser(User):
my solution:
But EnterpriseUser, can create childuser, so enterprise_user have two type. there is one way add one user_type field to User model, represent what type the user is, or according the
user relationship determine what the user type is: normaluser, enterpriseuser, enterprise_child_user, admin.
Second: There are two user background manager page, one for staff to manage order, enterprise. one for normaluser to manage themself order. So there are two url path: /staff_bg/ /user_bg/
But they are use the same base template, the only different is the header tab is not same. For example:
user_header.html
{% extends "core/base.html" %}
<header>
<ul>
<li>your orders</li>
</ul>
</header>
staff_header.html
{% extends "core/base.html" %}
<header>
<ul>
<li>enterprise</li>
</ul>
</header>
then:
user_realted.html:
{% extends "core/user_header.html" %} # focus here
{% block body %}
# something
{% endblock %}
then:
staff_related.html
{% extends "core/staff_header.html" %} # focus here
{% block body %}
# something
{% endblock %}
my solution:
create core/middle.html:
{% extends the_template_name %}
then
user_realted.html:
{% extends "core/middle.html" %} # focus here
{% block body %}
# something
{% endblock %}
One way write custom template processor, base one request.path pass different the_template_name( "cms/user_header.html" or "core/staff_header.html" ) to middle.html, but I think it's dirty,
and if code wrong, maybe normal user can see the staff tabs.
another way:
pass different the_template_name to middle.html, in every view. of course, it will change every view that already wrote.