Unable to log into the Django admin - django

Im trying to log into the admin GUI but keep getting the error :
Please enter a correct username and password. Note that both fields are case-sensitive.
Ive created a new user, dropped all the db tables for auth_xxx and resynced. And also checked that the is_staff,is_active,is_superuser flags are all true within the db.
Does anyone have any other ideas ?

The following within the settings.py resolved the issue
django.contrib.auth.backends.ModelBackend

Related

django admin renders links on readonly foreign key to which I don't have permission

I am using the latest django version (3.2.8) and I have the following problem:
My user can see model "inspection" via permisson "view_inspection"
My user cannot (!) see any foreign keys due to missing permissions
The readonly-foreign key is still rendered as a link which leads to a 403 page
What I need:
Showing just the name of the object and not linking to it.
Any ideas how I can fix this? Looks like a bug somehow... Googleing and browsing stack overflow didn't return any solutions.
Thx in advance!

Django Authentication Hardcoding Users

I have a django project with two apps (app and authenticate) that I got from a template. I developped my "app" app and it works fine. Now I want to add logins to limit access to certain pages of the app.
I looked accross the Internet and they use
user = User.objects.create_user('myusername', 'myemail#crazymail.com', 'mypassword')
to create a user. I tried that (and tried logging in with the username and password but it doesn't work. I probably put the code in a wrong area (I put it in authentication/models.py). I would really like this to work but I can't seem to figure out why the user isn't created.
there is no method create_user(). You must write User.objects.create('myusername', 'myemail#crazymail.com', 'mypassword')

Magento 2 cannot login admin because form key invalid

I'm in a brain-breaking problem here. I've created a nice Magento 2.1.7 installation with two websites (two stores, two domains) and somehow after a while we are unable to login the backend of Magento.
Invalid Form Key. Please refresh the page.
Now, after trying a few options, still no success. Checked core_config_data, edit max_input_vars, nothing works. The strange thing is, on the front it's still possible to checkout and do your shopping.
Anyway, I'm stumped here. Why is this happening, and how can this be fixed. Any help is welcome.
I often get this error, clearing the cookies for that site, then opening the admin panel in a new tab will resolve this.
You can recreate this error message if you double click the login button after filling out your login information.
Here are a few other reasons you may experience this issue
The form key inputs are outside of the form, you should check the html on the admin panel to check these inputs and exists and have correct values
Make sure the link you use to get to the admin page does not already have a form key in the url
Does this issue generate anything in var/log/system.log ?
Eventually, nothing helped, but what did the trick was creating a new install, setup this new install with all necessary modules (fortunately there were only four), configure the fresh installment like the old one (long live GitHub) and compare your fresh installation to the old one in the database table core_config_data. Basically reproduce your entire setup without any products in it, but just create your stores and categories.
If you spot any differences between the new installment and the old one in the core_config_data, edit them in the old one to be the same as your new one.
Next, edit your env.php with the database credentials to the old database which you've compared and edited.
And the last step, recompile, flush/clean cache and reindex.
Oh, and word of advice, if you're going to use https for your store, setup magento on https. I think something went very wrong when we've changed the base url's from insecure to secure.

Superuser credentials not recognized for new Django website and Admin site

I've created a new website using Django 1.8, created a superuser account and logged into the admin interface to initialize some database fields. I can log continue to log into both the admin site and the actual website, as can a couple hundred users.
I've created a second Django website under a separate project (separate database, settings file, etc.) that contains identical code. I ran syncdb and created a different superuser account but when I attempt to log into the admin site with my superuser account, it tells me my username or password is incorrect. I've compared everything with the original website and I can't find anything that's not consistent.
I've confirmed:
I can log directly into the MySQL database using the database name, database user and password that are contained in the settings file
I'm referencing the correct settings file from manage.py
My user record in auth_user has is_staff, is_superuser and is_active all set to 1
I've tried to compare all the configuration files between the two projects and everything matches up as expected. Does anyone have any suggestions about what could affect the authentication or how I might debug this?
Thanks.
After running out of places to look, I deleted and recreated the site database and then reran manage.py syncdb. After that, I was able to log into the admin site. My working theory is that when I entered the superuser password the first time, I pasted into a PUTTY terminal and what it stored for the password was not what I thought it was.
Which kind of doesn't make sense because I did try to add a second superuser using manage.py createsuperuser with a really simple password and I still couldn't log in.
Anyway, thanks for the help.

django 1.6 When creating superuser in cmd.exe, why ask password for three times?

django 1.6.1,python 3.3.3, windows 8.
I choose Substituting a custom User model, and everything is ok except creating superuser at the beginning:
As you can see, django asked password for three times, why?
this is the source code, if needed. Thanks.
It turns out to be that I should not add 'password' to REQUIRED_FIELDS.
More infomation please click