Wednesday, August 30, 2017

Re: Bizarre URL behaviour after deploying

Daniel,

Yes, I have deployed, that is the problem in a sense. URLs are clean in dev and suddenly contain an app_name when deployed.

Not sure what you mean by configuration? The Django settings are here:

    https://github.com/bernd-wechner/CoGs/blob/master/CoGs/settings.py

The rest of the config is uwsgi under lighttpd, but none of that is likely to impact the appearance of an app_name in my URLs all of a sudden. I don't mind sharing the config files, but it's a distraction I fear. As the site runs fine, only the URLs are modified by Django post deployment for some reason.

I have found more folk wanting same and yet none of the posted solution are useful to me:

https://stackoverflow.com/questions/40322042/remove-django-app-name-from-path-with-custom-domain-heroku
https://stackoverflow.com/questions/18764967/django-admin-removing-app-name-from-url-for-single-app-projects

as my puzzle is why the app name is used post deployment but not in development. I have nowhere asked for it to be used and am not making sense of why it is being used alas.

Kind regards,

Bernd.

Daniel Roseman wrote:

How have you deployed this project? Can you show your deployment configuration?
On Wednesday, 30 August 2017 12:42:01 UTC+1, Bernd Wechner wrote:

This has bamboozled me some. And the best thing I've found on-line doesn't seem to apply:

    https://stackoverflow.com/questions/26944908/django-url-mapping-how-to-remove-app-name-from-url-paths

Let me summarise.

I have a site that I've been building and testing with djangos development server of course. And it implements URLS like:

http://127.0.0.1:8000/list/Model
http://127.0.0.1:8000/add/Model
http://127.0.0.1:8000/edit/Model/nn
http://127.0.0.1:8000/view/Model/nn
http://127.0.0.1:8000/delete/Model/nn

Works like a dream, so I'm deploying, locally first, under lighttpd and uwsgi. That is working fine too. Sort of,

These are all reached with links in my templates like yo:

{% url 'list' model %}
{% url 'add' model %}
{% url 'edit' model pk %}
{% url 'view' model pk %}
{% url 'delete' model pk %}

because in urls.py they all have "name"s defined like that.

All honky dory.

Now after deploying everything works nicely, but those same links point to:

http://mysite.tld/app/list/Model
http://mysite.tld/app/add/Model
http://mysite.tld/app/edit/Model/nn
http://mysite.tld/app/view/Model/nn
http://mysite.tld/app/delete/Model/nn

That is the app name is inserted. Odd. And undesired if not a crisis.

But here's what bamboozles me. I can replace "app" in the url with any string at all, "x" say and the site continues to work but those URLs now point to :

http://mysite.tld/x/list/Model
http://mysite.tld/x/add/Model
http://mysite.tld/x/edit/Model/nn
http://mysite.tld/x/view/Model/nn
http://mysite.tld/x/delete/Model/nn

For what it's worth I don't want to quote urls.py and every other bit of possible config here of course, I am mainly interested to know if someone has insights that aren't shared in that SO link above as none of what is shared there seems to apply.

For anyone really keen on code explorations urls.py is here:

https://github.com/bernd-wechner/CoGs/blob/master/CoGs/urls.py

and the whole site is there too.

What I want to understand is why this "app" suddenly appears in my URLs and how I can control it (remove it ideally). But I have looked at urls.py long enough and scratched my head and not found it. settings.py is right next to if you need to inspect it.

Kind regards,

Bernd.




--
DR. 
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8142e4c2-8a1b-4e6a-8bea-7f39416b1e61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


No comments:

Post a Comment