Wednesday, August 30, 2017

Re: Bizarre URL behaviour after deploying

like that : 
app_name = 'polls' in polls folder and in url.py

On Wed, Aug 30, 2017 at 4:26 PM, mohammad k <k2527806@gmail.com> wrote:
you have Different app in your project yes ?
you have to use app_name in url.py in each app 

On Wed, Aug 30, 2017 at 4:11 PM, Bernd Wechner <bernd.wechner@gmail.com> 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.




--
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/c2b971d4-61be-e74f-e6bc-6f3ed8ce2a65%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
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/CACOk0TxJLH8usGm%2B8sYCwcCp6A83T5ERZg5vXcYUpXJAPK2vZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment