简体   繁体   中英

Can't login in admin site using django 1.7 and mongodb

I'm working in a new project using django 1.7 and mongodb. The issue is that when i try to login in the admin site, my credentials (username, password) are invalid.

I tried this tutorial but uses django 1.5. I tried a second tutorial but when i added 'mongoadmin' to the INSTALLED APPS the project doesn't run.

I can create user using the shell:

from mongoengine.django.auth import User
User.objects.create(username="admin", password="admin", email="admin@admin.com", is_superuser=True)

And i can query it on the views:

from django.shortcuts import render
from mongoengine.django.auth import User

def home(request):
    u = User.objects.all()
    print u

return render(request, 'home.html', {
})

But when I tried to login in localhost:8000/admin using username "admin" and password "admin", my credentials seems to be invalid.

I have created a superuser using de command ./manage.py createsuperuser, but with this user i can't login neither. How can i fix it using django 1.7? and, curiosity, Why the documentation of django-mongodb-engine suggests django 1.5? Thanks, i really need to access soon to the admin site :).

is_staff is False by default, and in this case login to web admin is disabled.

Do

from mongoengine.django.auth import User
user = User.objects.get(username='admin')
user.is_staff = True
user.save()

...and try to login in again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM