5👍
Not too sure on this, but syncdb might remove the superuser you just created. Try creating a superuser when syncdb prompts you to.
Otherwise, take a look at the user model in ./manage.py shell
. Check User.objects.all()[0].is_superuser
.
25👍
There is some kind of limitation in django-nonrel.
To create a superuser:
- Stop the local webserver
-
Create the superuser
python manage.py createsuperuser
-
Run the webserver again
python manage.py runserver
- How do I simulate connection errors and request timeouts in python unit tests
- Paypal monthly subscription plan settings for first day of the month and making monthly recurring payment – django python
- Django template tag: How to send next_page in {url auth_logout}?
8👍
Assuming you have the correct username and password, the only thing that will present the same behavior as a failed login is having is_staff=False
for the user in question.
Go into your database and inspect the auth_user table. Make sure that is_staff
is set to TRUE
on the user you are using to log in.
- In python django how do you print out an object's introspection? The list of all public methods of that object (variable and/or functions)?
- How to upgrade Django on ubuntu?
- How to set timeout for urlfetch in Google App Engine?
- Django render_to_string() ignores {% csrf_token %}
- Registered models do not show up in admin
5👍
In urls.py uncomment:
# Uncomment the next line to enable the admin:
**# url(r'^admin/', include(admin.site.urls)),**
and that should make you good for the races 🙂
PS. do not forget to run a ./manage.py syncdb and it will ask to setup an admin user.
5👍
If you’re an idiot, like me, you might be trying to login with your email rather than your username.
I think I was doing this because when creating the superuser I remembered entering an email and not a username (because django offers you a username without having to type it), and perhaps the usual convention of using emails for usernames.. Man I feel stupid haha.
- How to have a link in label of a form field
- In django, is there a way to directly annotate a query with a related object in single query?
- Django template tag: How to send next_page in {url auth_logout}?
- Create a canonical "parent" product in Django Oscar programmatically
5👍
I had met the same situation just as you. And I found I switched the authentication backend to
someproject.backends.EmailCheckmodelBackend
And in the settings.py I had added a line:
AUTHENTICATION_BACKENDS = (‘someproject.backends.EmailCheckModelBackend’,)
And the backend is like:
class EmailCheckModelBackend(ModelBackend):
def authenticate(self, username = None, password = None, is_staff = None):
try:
user = User.objects.get(email = username)
if user.check_password(password):
if is_staff is not None:
if user.is_staff == is_staff:
return user
else:
return None
return user
except User.DoesNotExist:
return None
You will find actually the username is forced to be alternated by ’email’. So you have to login your page with email account.
If like
Username: someone@somewhere.com
password: password
Then it works.
Hope this helpful for everyone.
0👍
I had the same problem and could not understand why I could not login because all the settings were correct. However, I traced it to Django offering me a superuser name containing an initial capital letter, but actually saving the name as completely lowercase!
I naturally used the superuser name with capitals (as offered by Django) and authentication failed. When inspecting the data tables to check ‘is_staff’ etc I spotted the error. I know I was not mistaken because I repeated the setup process a couple of times and noted the superuser credentials to be sure of details like case.
So, the moral is be careful when accepting the default name offered by Django! It lies!
- Have a url that accepts all characters
- How can I test if my redis cache is working?
- How does django-nose differ from the default Django test-runner
- How to make follower-following system with django model
- How to create custom groups in django from group
- Proper declaration of an empty Django PostgreSQL JSONField default value in migration file
- Is there a way to render a html page without view model?
- How to set timeout for urlfetch in Google App Engine?
- How to customize django rest auth password reset email content/template
- How can I disable a model field in a django form
-1👍
It’s not that difficult to fix.
First of all make sure to allow your default settings
(DEBUG=TRUE,ALLOWED_HOST=[ ])
in the settings file of your website folder.
Get into your website folder (using the command prompt), and type the following command:
$ python manage.py createsuperuser
name:
email:e.g fulluser@admin.com
password:
Go back into the browser and run the server. Set the username (not the email), alongside your password which you created earlier. It will surely work fine this time.