dev server hiccups after saving from in Django admin - django

This is starting bug me: whenever I use the django admin to add or edit a record, I hit save and expect a confirmation page, but the result is a page that tells me the website is experiencing an error (it's not a Django page with a traceback, just a default view in my browser). If I hit reload or back in the browser, it takes me back to the user form. Even though the confimation page doesn't display, it never fails to save my entry in the database, so it's apparently just a problem generating/serving the confirmation page.
Has anyone else had this problem? Am I missing something obvious?
My server: Django dev server
My browser: Internet Explorer 7 (but same problem occurs with any broswer I use)
My OS: Windows XP

I got such a behaiviour when I overwrote __init__ incorrectly. Or to be more precise when switching to a new version of Django with these worng __init__s. That was the day I started to love signals :D.
Can you post your models?

This is certainly not how it's supposed to work! Have you been messing around in the Django codebase at all? The first thing that comes to mind here is a "pdb.set_trace()" left by mistake somewhere in the change_list codepath. Off-hand I can't think what else would cause the server to simply not respond.

Related

I can't sign into the Django admin login page

I have started multiple Django projects with like four different tutorials. Every single time I try "python manage.py createsuperuser", the admin login page just loads and loads and never goes anywhere. I want to make it absolutely clear that I haven't touched a thing in the code and everything is default code. I migrated everything before login. I've tried deleting the database and re-migrating. None of that works. Can someone help me? I have made around 10-15 accounts and NONE of them work. The page just keeps loading indefinitely and never goes anywhere. I've looked at EVERY stackoverflow post and no answers work. I started a virtualenv, downloaded Django, didn't touch the code, made migrations, I followed every tutorial TOO THE LETTER(!!!) and this is what I keep getting. The current tutorial hasn't changed in default code and he signed in with no problems. I'm assuming if he did, I can...I don't think putting code in is necessary since it's all virgin code, never touched. I didn't even make any apps yet.
I've tried deleting database and re-migrating
changing the password of current superuser
deleting the entire project and following everything the instructor said (TO THE LETTER!!!)
I have made 10-15 superuser accounts and none work
This sounds similar to a problem I was seeing. I wrote a question for it here (no answers yet): Django local dev server hangs with chrome after form submission. Works in firefox
Are you using windows and the chrome browser? Try using firefox to access the admin page and login. That worked for me. I'm still trying to figure out why Chome doesn't work, though. Like you, I created a brand new project from scratch; sometimes Chrome works and most of the time it doesn't. I've also found that hitting the stop button while the browser is sitting there thinking, then refresh, makes the logged in admin page show up.

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.

Django authentication works on Chrome, but not on Firefox

I'm having a problem where Django's login is working okay on Chrome but not on Firefox: when trying to login to a restricted portion of the site on Firefox, it simply loops back again and again to the login page; furthermore, no error message appears on the log regarding that.
Interestingly, the error doesn't happen when the server is on the local machine.
Does someone have a general idea of what could be causing that strange behavior?
I'm using Django 1.6 on Python 2.7
this isn't much of an answer, but a linking to other similar problems. Because I don't have rep, all I can do is leave an answer.
A issue like this was encountered in 2012 but was never conclusively answered:
Django session doesn't work in Firefox
A similar question where the user could login via local server but not remote firefox was encoutered:
Unable log in to the django admin page with a valid username and password
The second was very well documented and had an accepted answer that was well liked.
Recommendations:
If you are not using https make sure you have this setting SESSION_COOKIE_SECURE = False.
If you are using a database backed, Check if the session is actually being created in the django_sessions table .
If you are using a cached backed, check that SESSION_ENGINE is django.contrib.sessions.backends.cache and that CACHE_BACKEND is properly configured.

Django: Session created in database when login page loaded

My django_session table was growing very large and it seems to be due to a pingdom bot that I set-up hitting my login page. I tried creating a brand new django 1.4 app and the behaviour is replicated on any page that uses the django.contrib.auth.views.login page, including the default admin login page.
This surely can't be the desired behaviour. Is it a bug? Is there a fix?
(I have redirected the pingdom bot to another page that doesn't cause a new session to be created but I'd like to solve the django issue itself too).
I have seen the question here Huge Django Session table, normal behaviour or bug? and it doesn't seem to be the same issue
After a little bit of searching I found that this is done by the login view (line 55) in the set_test_cookie() method.
In the latest version of Django (git main) it has been removed however: https://github.com/django/django/commit/9d2c0a0ae6ce931699daa87735d5b8b2afaa20f9#django/contrib/auth/views.py
For the time being I would simply recommend you to use a modified version of the login page which doesn't use the set_test_cookie() method.

Django/IE8 Admin Interface Weirdness

Esteemed Django experts and users:
I have been using Django's admin interface for some data editing needs. I am using it on Windows Server 2008, and using django-mssql to connect to a SQL Server backend. Python 2.6.2 Django 1.1.0 final 0
As per usual w/ Django, this was fairly easy to set up, and works beautifully on Firefox, but using IE8 I intermittently get a puzzling 'Internet Explorer cannot display this webpage' when I save a record.
In the log, looks like typically on a save there's a POST request that returns a 302 status followed by a GET returning a lovely 200. This is on Firefox. On IE8 looks like sometimes POST works but GET doesn't.
So that's what I have going on. Any help w/ this will be appreciated. Thank you.
I suspect the bug is within IE8's refusal to process the redirect properly.
The 302 POST pushes to browser to the 200 GET, but if the browser never processes the 302 then the Django (or the server) will not log a 200 GET because the browser never opened the page (the server can only log what is accessed, ergo the browser is not making the call).
If you have Django behind something (IIS using FastCGI, or Apache, or something), bump up the logs to make sure there's no silent error in rendering. I had the same problem on Vista x64 Ultimate IE8 Beta 2, but compatibility mode appeared to fix the problem somewhat -- there was still some intermittently occurring refusal to redirect.
I realize this post is a bit old now, but I had the exact same symptoms recently. After a lot of digging around, I found that IE8 has issues accepting cookies with a life of less than 20 minutes.
In our Django project's settings.py we had the property SESSION_COOKIE_AGE set to 10 minutes. Once I bumped it to 20 minutes, IE8 had no problems logging in.