Answer the question
In order to leave comments, you need to log in
Your django middleware?
models
class Project(models.Model):
short_name = models.CharField(verbose_name=u'краткое название', max_length=16)
full_name = models.TextField(verbose_name=u'полное название', blank=True)
class ProjectUser(models.Model):
project = models.ForeignKey(Project, null=True)
user = models.ForeignKey(User, on_delete=models.CASCADE)
user_role = models.ForeignKey(UserRole)
company = models.ForeignKey(Company, verbose_name=u'Организация')
default_project = models.BooleanField(verbose_name=u'Проект по умолчанию')
Answer the question
In order to leave comments, you need to log in
class ProjectMiddleware:
def process_request(self, request):
assert hasattr(request, 'user'), (
"The Project middleware "
"requires authentication middleware to be installed. Edit your "
"MIDDLEWARE_CLASSES setting to insert "
"'django.contrib.auth.middleware.AuthenticationMiddleware'. "
"If that doesn't work, ensure your TEMPLATE_CONTEXT_PROCESSORS "
"setting includes 'django.core.context_processors.auth'."
)
if request.user.is_authenticated():
request.project = ...
settings.MIDDLEWARE_CLASSES
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question