I am new to Django. created a super user using manage.py createsuperuser. Can log into the site in Firefox, every time, but never in Chrome or IE, the login popup keeps popping up. The only time it worked was when I used manage.py clearsessions. Not working anymore. Cleaned the session by going into sqlite still no success.
Hmm... cookie settings? Django doesn't use cookie-based sessions by default, but that login form probably does have a CSRF cookie in it. If it keeps rejecting your login over and over on different browsers, it could be because you have those browsers set not to take the cookie.
Related
I am developing a simple app using Django REST framework for the backend and with a Vue multi-page app as a front end. I use axios to make requests to Django from the javascript.
Locally, everything works well. All the pages work and login functionality works fine. For authentication, I am using Django's built in authentication and a store in Vuex.
However, once I started to deploy, it seems to break. To deploy, I initially decided to use ngrok to create an https tunnel to the backend. My frontend is still on localhost, but as soon as I change the url to use the new API, the login functionality stops working. The rest of the site (which does not require login) works fine, but the bits that do just don't work. When I click the login button, Vue tries to redirect me to the logged in 'dashboard' page, but then it identifies that I am not logged in and kicks me out.
The actual login process works and the server responds that I am logged in, but when the site checks again it responds that I am not logged in. There are no errors at any point.
I am happy to share any code that may help identify my issues, but I am not sure what to share at this point since I am not getting any errors!
After deploying django app on heroku the url after every form submission or link in site been press resulting with "?next=" inserts into the URL address, I don't understand from where it comes and why heroku keep inserting them in a random way, running the application locally just working perfectly.
I've deleted the application from heroku and upload it again, the fault persists.
There's no http errors what so ever. If I keep submitting the form eventually will works.
For example: pressing the log button in the django admin console results with this URL: https://appname.herokuapp.com/admin/login/?next=/admin/login/admin/, hitting it quite a bit will finally make it work with the correct url display: https://mishnayot.herokuapp.com/admin/.
Switching from heroku postgres to AWS RDS postgres didn't help.
Help will be very appreciated.
When a user hits a page requiring authentication, they get redirected to the login URL with a ?next= indicating the page they were trying to access. This way, after they've logged in, they'll get the page they intended to access.
In your case, it seems like /admin/login/admin/ requires a login and the login is actually at /admin/login/. I'm guessing you have a bad link to /admin/login/admin/ somewhere when you intended to just have /admin/login/?
Well, struggling for days just to understand it's heroku backend issue and there's not enough information that could help me solving it (i did try to contact heroku support directly but I'm on a free account).
Finally I decided to deploy it using elastic beanstalk. The implementation took some time with long learning curve but now my site works and works great!
Thanks for trying to help Tim.
Cheers!
I am using Django Oscar Paypal for payment. I am having an issue with redirecting back to my website on the production mode.
I have successfully set up in the development mode and I have tried two different IP address for runserver : 127.0.0.1:8000 and 192.168.1.102:8000 -> both worked corrected and redirected to whatever server I was running.
I turned off Sandbox mode and I have a website that has https:// working correctly. I try to make a payment on mywebsite.com/ but it redirects to https://192.168.1.102:8000/checkout/paypal/preview/13/?token=******* when I am redirected to paypal website for payment and click on Continue. (This happens for cancelling as well).
I have checked the views in the paypal app and it has 'reverse' code written correctly. If I paste /checkout/paypal/preview/13/?token=******* part after mywebsite.com/, it seems to be working correctly.
Is there a way to redirect back to mywebsite.com/
Many Thanks
Kyu
I just tried to switch to sandbox mode in the production but it doesn't redirect me to sandbox paypal! It keeps going to proper paypal payment site even with sandbox API... I am getting confused now.
Could this be because I haven't done python manage.py migrate and makemigrations?
Oscar uses the Django sites framework to determine the appropriate return URL.
You probably have the wrong domain (192.168.1.102) configured on your Site.
Edit the site from the admin (at example.com/admin/sites/site/) to set the domain that you use in production. Once you change this the redirect from Paypal should work.
I've recently switched server/database and am having trouble getting the google and facebook social apps to log in. I have the keys set up correctly and when hitting both facebook and google it successfully creates a django user and a social account, but it does not log the user in. Notably, it sends the user to LOGIN_REDIRECT_URL correctly.
When attempting to sign in with an existing user after it has already been created, it also does not log in, but also sends to LOGIN_REDIRECT_URL correctly.
I can't figure out why it is behaving this way in the new environment, and am struggling on finding where to look. My best guess is that somewhere the pre_social_login signal or the social_account_added signal? Any ideas?
EDIT:
Also worth noting, I switched from python 3.4 to python 2.7, but django remained 1.6.5
Turned out I was missing the allauth.account.auth_backends.AuthenticationBackend in the settings AUTHENTICATION_BACKENDS when i did the migrate.
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.