I have Django 5.1.1 on both my local machine (windows 11) and the server (Ubuntu 20.04). The code I have is the same for both local and server:
<script>
const is_manager = /^true/i.test('{{request.user.is_employee_manager}}');
</script>
Both local and server uses the same exact database.
Yet on the server the template evaluates to: <script>const is_manager = /^true/i.test('');</script>
and local template evaluates to: <script>const is_manager = /^true/i.test('True');</script>
or
<script>const is_manager = /^true/i.test('False');</script>
depending on the user.
Model:
class User(AbstractUser):
birth_date = models.DateField(null=True, blank=True)
password_changed = models.DateTimeField(null=True, blank=True)
@property
def is_employee_manager(self):
return self.is_in_group(r'Employee Admin')
def is_in_group(self, pat):
if self.is_superuser or self.groups.filter(name__iregex=pat).exists():
return True
return False
This is very strange bug. Currently I’m passing the request.user.is_employee_manager
in a separate context in the view as {'is_manager': request.user.is_employee_manager }
and this hotfixes the issue.
Any help in trying to figure out what’s going on here would be greatly appreciated.