is_staff field is not showing in Django admindjango - inlineformset_factory with more than one ForeignKeyDjango south migration error with unique field in postgresql databasedifferentiate null=True, blank=True in djangoRadio buttons in django adminFor statement in django templates doesn't work'NoneType' object is not subscriptable in using django smart selectsHow to expose some specific fields of model_b based on a field of model_a?Customer User Authentication error : AttributeError: Manager isn't available; 'auth.User' has been swapped for 'user_management.CustomUser'How to edit requested params in Django Admin Page?How to implement update_or_create inside create method of ModelSerializer
Pronouncing Dictionary.com's W.O.D "vade mecum" in English
Draw simple lines in Inkscape
How to report a triplet of septets in NMR tabulation?
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
Motorized valve interfering with button?
Is it possible to do 50 km distance without any previous training?
GPS Rollover on Android Smartphones
Do airline pilots ever risk not hearing communication directed to them specifically, from traffic controllers?
N.B. ligature in Latex
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
What do you call a Matrix-like slowdown and camera movement effect?
Is there really no realistic way for a skeleton monster to move around without magic?
Why is this code 6.5x slower with optimizations enabled?
"You are your self first supporter", a more proper way to say it
What defenses are there against being summoned by the Gate spell?
declaring a variable twice in IIFE
Why are only specific transaction types accepted into the mempool?
How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)
Are tax years 2016 & 2017 back taxes deductible for tax year 2018?
I probably found a bug with the sudo apt install function
What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
Is it possible to make sharp wind that can cut stuff from afar?
How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?
is_staff field is not showing in Django admin
django - inlineformset_factory with more than one ForeignKeyDjango south migration error with unique field in postgresql databasedifferentiate null=True, blank=True in djangoRadio buttons in django adminFor statement in django templates doesn't work'NoneType' object is not subscriptable in using django smart selectsHow to expose some specific fields of model_b based on a field of model_a?Customer User Authentication error : AttributeError: Manager isn't available; 'auth.User' has been swapped for 'user_management.CustomUser'How to edit requested params in Django Admin Page?How to implement update_or_create inside create method of ModelSerializer
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
is_staff is defined as boolean field but its checkbox is not visible in the admin page. But is_admin is visible and it can be changed.
I can't able to make changes to that field using views.py
class Users(AbstractBaseUser, PermissionsMixin):
objects = UserManager()
mobile_no = models.IntegerField(_('MobNumber'), null=True, blank=True,unique=True)
email = models.EmailField(_('Email'), max_length=75, null=False, blank=False)
first_name = models.CharField(_('FirstName'), max_length=50, null=True, blank=True)
last_name = models.CharField(_('LastName'), max_length=70, null=True, blank=True)
role = models.CharField(_('Role'), max_length=70, null=True, blank=True)
location = models.CharField(_('Location'), max_length=70, null=True, blank=True)
date_time = models.DateTimeField(_('DateTime'), auto_now=True, null=True, blank=True)
activated = models.BooleanField(_('Activated'), default=False)
is_admin = models.BooleanField(_('is_admin'), default=False)
is_staff = models.BooleanField(_('is_staff'), default=False)
def __unicode__(self):
return str(self.mobile_no)
def __str__(self):
return str(self.mobile_no)
def get_full_name(self):
return self.first_name + " " + self.last_name
class Meta:
ordering = ['-id']
@property
def is_staff(self):
return self.is_admin
def has_perm(self, perm, obj=None):
return self.is_admin
def has_module_perms(self, app_label):
return self.is_admin
USERNAME_FIELD = 'mobile_no'
REQUIRED_FIELDS = ['role']
django django-models django-views django-admin django-custom-user
add a comment |
is_staff is defined as boolean field but its checkbox is not visible in the admin page. But is_admin is visible and it can be changed.
I can't able to make changes to that field using views.py
class Users(AbstractBaseUser, PermissionsMixin):
objects = UserManager()
mobile_no = models.IntegerField(_('MobNumber'), null=True, blank=True,unique=True)
email = models.EmailField(_('Email'), max_length=75, null=False, blank=False)
first_name = models.CharField(_('FirstName'), max_length=50, null=True, blank=True)
last_name = models.CharField(_('LastName'), max_length=70, null=True, blank=True)
role = models.CharField(_('Role'), max_length=70, null=True, blank=True)
location = models.CharField(_('Location'), max_length=70, null=True, blank=True)
date_time = models.DateTimeField(_('DateTime'), auto_now=True, null=True, blank=True)
activated = models.BooleanField(_('Activated'), default=False)
is_admin = models.BooleanField(_('is_admin'), default=False)
is_staff = models.BooleanField(_('is_staff'), default=False)
def __unicode__(self):
return str(self.mobile_no)
def __str__(self):
return str(self.mobile_no)
def get_full_name(self):
return self.first_name + " " + self.last_name
class Meta:
ordering = ['-id']
@property
def is_staff(self):
return self.is_admin
def has_perm(self, perm, obj=None):
return self.is_admin
def has_module_perms(self, app_label):
return self.is_admin
USERNAME_FIELD = 'mobile_no'
REQUIRED_FIELDS = ['role']
django django-models django-views django-admin django-custom-user
add a comment |
is_staff is defined as boolean field but its checkbox is not visible in the admin page. But is_admin is visible and it can be changed.
I can't able to make changes to that field using views.py
class Users(AbstractBaseUser, PermissionsMixin):
objects = UserManager()
mobile_no = models.IntegerField(_('MobNumber'), null=True, blank=True,unique=True)
email = models.EmailField(_('Email'), max_length=75, null=False, blank=False)
first_name = models.CharField(_('FirstName'), max_length=50, null=True, blank=True)
last_name = models.CharField(_('LastName'), max_length=70, null=True, blank=True)
role = models.CharField(_('Role'), max_length=70, null=True, blank=True)
location = models.CharField(_('Location'), max_length=70, null=True, blank=True)
date_time = models.DateTimeField(_('DateTime'), auto_now=True, null=True, blank=True)
activated = models.BooleanField(_('Activated'), default=False)
is_admin = models.BooleanField(_('is_admin'), default=False)
is_staff = models.BooleanField(_('is_staff'), default=False)
def __unicode__(self):
return str(self.mobile_no)
def __str__(self):
return str(self.mobile_no)
def get_full_name(self):
return self.first_name + " " + self.last_name
class Meta:
ordering = ['-id']
@property
def is_staff(self):
return self.is_admin
def has_perm(self, perm, obj=None):
return self.is_admin
def has_module_perms(self, app_label):
return self.is_admin
USERNAME_FIELD = 'mobile_no'
REQUIRED_FIELDS = ['role']
django django-models django-views django-admin django-custom-user
is_staff is defined as boolean field but its checkbox is not visible in the admin page. But is_admin is visible and it can be changed.
I can't able to make changes to that field using views.py
class Users(AbstractBaseUser, PermissionsMixin):
objects = UserManager()
mobile_no = models.IntegerField(_('MobNumber'), null=True, blank=True,unique=True)
email = models.EmailField(_('Email'), max_length=75, null=False, blank=False)
first_name = models.CharField(_('FirstName'), max_length=50, null=True, blank=True)
last_name = models.CharField(_('LastName'), max_length=70, null=True, blank=True)
role = models.CharField(_('Role'), max_length=70, null=True, blank=True)
location = models.CharField(_('Location'), max_length=70, null=True, blank=True)
date_time = models.DateTimeField(_('DateTime'), auto_now=True, null=True, blank=True)
activated = models.BooleanField(_('Activated'), default=False)
is_admin = models.BooleanField(_('is_admin'), default=False)
is_staff = models.BooleanField(_('is_staff'), default=False)
def __unicode__(self):
return str(self.mobile_no)
def __str__(self):
return str(self.mobile_no)
def get_full_name(self):
return self.first_name + " " + self.last_name
class Meta:
ordering = ['-id']
@property
def is_staff(self):
return self.is_admin
def has_perm(self, perm, obj=None):
return self.is_admin
def has_module_perms(self, app_label):
return self.is_admin
USERNAME_FIELD = 'mobile_no'
REQUIRED_FIELDS = ['role']
django django-models django-views django-admin django-custom-user
django django-models django-views django-admin django-custom-user
asked Mar 22 at 0:53
VA splashVA splash
2410
2410
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can edit the User admin in admin.py by importing and inheriting from it. Here's an example:
# admin.py
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
class UserAdmin(BaseUserAdmin):
model = Users
list_display = ('mobile_no', 'email', 'first_name', 'last_name', 'role', 'location')
fieldsets = (
(('Personal info'), 'fields': ('first_name', 'last_name',)),
(('Permissions'), 'fields': ('activated', 'is_staff', 'is_superuser', 'groups')),
(('Important dates'), 'fields': ('date_time', 'last_login')),
)
class Meta:
model = User
admin.site.register(User, UserAdmin)
ERRORS: <class 'CustomAcco.admin.UserAdmin'>: (admin.E033) The value of 'ordering[0]' refers to 'username', which is not an attribute of 'CustomAcco.Users'. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[0]' refers to 'is_staff', which does not refer to a Field. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[2]' refers to 'is_active', which does not refer to a Field.
– VA splash
Mar 22 at 1:15
@VA splash - In the admin remove username, change is_active to activated, and I'm not sure why it's not picking up is_staff, but you can remove it for now, see if it works, and then debug from there. Ah and just realized your model is named Users not User. See above... but I would just call your model User.
– Whodini
Mar 22 at 1:19
It worked when I changed is_staff to some other field name. Django may have default is_staff.
– VA splash
Mar 22 at 1:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291354%2fis-staff-field-is-not-showing-in-django-admin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can edit the User admin in admin.py by importing and inheriting from it. Here's an example:
# admin.py
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
class UserAdmin(BaseUserAdmin):
model = Users
list_display = ('mobile_no', 'email', 'first_name', 'last_name', 'role', 'location')
fieldsets = (
(('Personal info'), 'fields': ('first_name', 'last_name',)),
(('Permissions'), 'fields': ('activated', 'is_staff', 'is_superuser', 'groups')),
(('Important dates'), 'fields': ('date_time', 'last_login')),
)
class Meta:
model = User
admin.site.register(User, UserAdmin)
ERRORS: <class 'CustomAcco.admin.UserAdmin'>: (admin.E033) The value of 'ordering[0]' refers to 'username', which is not an attribute of 'CustomAcco.Users'. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[0]' refers to 'is_staff', which does not refer to a Field. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[2]' refers to 'is_active', which does not refer to a Field.
– VA splash
Mar 22 at 1:15
@VA splash - In the admin remove username, change is_active to activated, and I'm not sure why it's not picking up is_staff, but you can remove it for now, see if it works, and then debug from there. Ah and just realized your model is named Users not User. See above... but I would just call your model User.
– Whodini
Mar 22 at 1:19
It worked when I changed is_staff to some other field name. Django may have default is_staff.
– VA splash
Mar 22 at 1:26
add a comment |
You can edit the User admin in admin.py by importing and inheriting from it. Here's an example:
# admin.py
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
class UserAdmin(BaseUserAdmin):
model = Users
list_display = ('mobile_no', 'email', 'first_name', 'last_name', 'role', 'location')
fieldsets = (
(('Personal info'), 'fields': ('first_name', 'last_name',)),
(('Permissions'), 'fields': ('activated', 'is_staff', 'is_superuser', 'groups')),
(('Important dates'), 'fields': ('date_time', 'last_login')),
)
class Meta:
model = User
admin.site.register(User, UserAdmin)
ERRORS: <class 'CustomAcco.admin.UserAdmin'>: (admin.E033) The value of 'ordering[0]' refers to 'username', which is not an attribute of 'CustomAcco.Users'. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[0]' refers to 'is_staff', which does not refer to a Field. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[2]' refers to 'is_active', which does not refer to a Field.
– VA splash
Mar 22 at 1:15
@VA splash - In the admin remove username, change is_active to activated, and I'm not sure why it's not picking up is_staff, but you can remove it for now, see if it works, and then debug from there. Ah and just realized your model is named Users not User. See above... but I would just call your model User.
– Whodini
Mar 22 at 1:19
It worked when I changed is_staff to some other field name. Django may have default is_staff.
– VA splash
Mar 22 at 1:26
add a comment |
You can edit the User admin in admin.py by importing and inheriting from it. Here's an example:
# admin.py
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
class UserAdmin(BaseUserAdmin):
model = Users
list_display = ('mobile_no', 'email', 'first_name', 'last_name', 'role', 'location')
fieldsets = (
(('Personal info'), 'fields': ('first_name', 'last_name',)),
(('Permissions'), 'fields': ('activated', 'is_staff', 'is_superuser', 'groups')),
(('Important dates'), 'fields': ('date_time', 'last_login')),
)
class Meta:
model = User
admin.site.register(User, UserAdmin)
You can edit the User admin in admin.py by importing and inheriting from it. Here's an example:
# admin.py
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
class UserAdmin(BaseUserAdmin):
model = Users
list_display = ('mobile_no', 'email', 'first_name', 'last_name', 'role', 'location')
fieldsets = (
(('Personal info'), 'fields': ('first_name', 'last_name',)),
(('Permissions'), 'fields': ('activated', 'is_staff', 'is_superuser', 'groups')),
(('Important dates'), 'fields': ('date_time', 'last_login')),
)
class Meta:
model = User
admin.site.register(User, UserAdmin)
edited Mar 22 at 1:22
answered Mar 22 at 1:04
WhodiniWhodini
656117
656117
ERRORS: <class 'CustomAcco.admin.UserAdmin'>: (admin.E033) The value of 'ordering[0]' refers to 'username', which is not an attribute of 'CustomAcco.Users'. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[0]' refers to 'is_staff', which does not refer to a Field. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[2]' refers to 'is_active', which does not refer to a Field.
– VA splash
Mar 22 at 1:15
@VA splash - In the admin remove username, change is_active to activated, and I'm not sure why it's not picking up is_staff, but you can remove it for now, see if it works, and then debug from there. Ah and just realized your model is named Users not User. See above... but I would just call your model User.
– Whodini
Mar 22 at 1:19
It worked when I changed is_staff to some other field name. Django may have default is_staff.
– VA splash
Mar 22 at 1:26
add a comment |
ERRORS: <class 'CustomAcco.admin.UserAdmin'>: (admin.E033) The value of 'ordering[0]' refers to 'username', which is not an attribute of 'CustomAcco.Users'. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[0]' refers to 'is_staff', which does not refer to a Field. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[2]' refers to 'is_active', which does not refer to a Field.
– VA splash
Mar 22 at 1:15
@VA splash - In the admin remove username, change is_active to activated, and I'm not sure why it's not picking up is_staff, but you can remove it for now, see if it works, and then debug from there. Ah and just realized your model is named Users not User. See above... but I would just call your model User.
– Whodini
Mar 22 at 1:19
It worked when I changed is_staff to some other field name. Django may have default is_staff.
– VA splash
Mar 22 at 1:26
ERRORS: <class 'CustomAcco.admin.UserAdmin'>: (admin.E033) The value of 'ordering[0]' refers to 'username', which is not an attribute of 'CustomAcco.Users'. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[0]' refers to 'is_staff', which does not refer to a Field. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[2]' refers to 'is_active', which does not refer to a Field.
– VA splash
Mar 22 at 1:15
ERRORS: <class 'CustomAcco.admin.UserAdmin'>: (admin.E033) The value of 'ordering[0]' refers to 'username', which is not an attribute of 'CustomAcco.Users'. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[0]' refers to 'is_staff', which does not refer to a Field. <class 'CustomAcco.admin.UserAdmin'>: (admin.E116) The value of 'list_filter[2]' refers to 'is_active', which does not refer to a Field.
– VA splash
Mar 22 at 1:15
@VA splash - In the admin remove username, change is_active to activated, and I'm not sure why it's not picking up is_staff, but you can remove it for now, see if it works, and then debug from there. Ah and just realized your model is named Users not User. See above... but I would just call your model User.
– Whodini
Mar 22 at 1:19
@VA splash - In the admin remove username, change is_active to activated, and I'm not sure why it's not picking up is_staff, but you can remove it for now, see if it works, and then debug from there. Ah and just realized your model is named Users not User. See above... but I would just call your model User.
– Whodini
Mar 22 at 1:19
It worked when I changed is_staff to some other field name. Django may have default is_staff.
– VA splash
Mar 22 at 1:26
It worked when I changed is_staff to some other field name. Django may have default is_staff.
– VA splash
Mar 22 at 1:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291354%2fis-staff-field-is-not-showing-in-django-admin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown