Url Redirection in django - django

I have an app created in django and deployed at KeshavBits heroku.
And after deploying app I purchased a domain (https://keshavbits.in/) and managed to point it to https://keshavbits.herokuapp.com/
So now I have two domains to acccess my website
https://keshavbits.herokuapp.com/
https://keshavbits.in/
Both links shows the same website i.e hosted at heroku but the problem is when someone logs in at keshavbits-heroku then session is stored under its domain so when they visit keshavbits.in they have to log in again.
I have checked django documentation and other stuff as well about multiple session manager but it works only when website is like home.keshavbits.in and play.keshavbits.in
So I thought to redirect traffic to keshavbits.in when someone hits https://keshavbits.herokuapp.com/
But I don't have any idea to do that.
Kindly help me :)

Related

Django web site URLS gets "?next=" randomly after deployed to heroku

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!

PythonAnywhere cannot get site to redirect without www

Whenever I try to access my pythonanywhere django site without "www." in front it redirects to the pythonanywhere "COMING SOON! This is going to be another great website hosted by PythonAnywhere." landing page.
ALLOWED_HOSTS = [u'webapp-******.pythonanywhere.com',
u'******.pythonanywhere.com',
u'******.co.uk',
u'www.******.co.uk']
Anyone encountered and solved this before?
If you do not have a web app without www, then there is no site there, so you'll get the Coming Soon page.

Serve multiple Django applications from one server

Good morning. I have a dedicated ubuntu server behind my company's firewall. It is using Django, Gunicorn, and Nginx to serve an Intranet application to employees. The original app responds to the URL [server_name]/[original_application_name]. I want to serve additional apps from this server. I have followed this tutorial as I did when setting up the original app.
I can run Gunicorn and serve the app, I have created a second systemd service file that appears steady (copied from the original app with paths changed - service runs), same for a new 'sites-available' file in Nginx (copied from original and modified), new .sock file exists, binding appears successful. However, I have yet to hit on the right configuration combination between settings.py [allowed_hosts], [new_app].service, and nginx etc.
The original app is running and when I try a URL related to the new app it gives an error saying it cannot find the request in the url.py of the original app. The new app would be used by the IT dept. Ideally, the new URL would be something like: it.[server_name]/[new_application_name].
I have looked through other cases with this problem but most use Apache or are on a public hosting site. I have seen this but it requires a "socket file". My original app is not using a socket file. I was hoping to do this without interfering with the original app. Is a "socket file" required? How can I configure this to serve both apps? Never having done this, what will the new URL be? The URL for the admin site in both apps is 'admin/', how can I accommodate this? Thanks!
I combined into one file as you suggested and I am almost there! I have original site responding at [server_name]/inventory and new site responding at [server_name]/assets. Great! My only problem is the admin page. In both apps the admin site is called admin! So, [server_name]/admin brings up the original site. How can I get to the new admin page?

django oscar paypal redirect

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.

Shopify Django app failing in shopify_app/views.py in finalize

I created a Shopify app hosted on Heroku. I had to modify the name of the shopify app from shopify_app to shopifyapp for Heroku to recognize it as a Django app.
If I visit my app directly though app-name.herokuapp/login and connect the app to my store, It correctly pulls my recent orders and products.
If I visit the app through the app menu and it redirects to app-name.herokuapp/login/finalize it shows
KeyError at /login/finalize/
I haven't modified anything in shopify_app except changed it's name to shopifyapp everywhere.
I suspect since the app cant finalize, that is why the links like this also don't work:
https://{{ current_shop.domain }}/admin/orders/{{ order.id }}">{{ order.name }}
They just direct to something like
https://admin/orders/000000000
Can anyone help troubleshoot this problem with the shopify app?
I've made my app repo public since it's still essentially just the demo app:
https://github.com/dpetrillo740/scm
App is running at http://scmapp.herokuapp.com/
This was a bug in the demo App. I just fixed it with this commit 27d5091.
Update the path in your application url to /login from /login/finalize. The redirect_uri is now provided for authentication with shopify, so it will still redirect back to the finalize endpoint.