This has bamboozled me some. And the best thing I've found on-line doesn't seem to apply:
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.
like that :app_name = 'polls' in polls folder and in url.pyOn Wed, Aug 30, 2017 at 4:26 PM, mohammad k <k252...@gmail.com> wrote:you have Different app in your project yes ?you have to use app_name in url.py in each app
--
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...@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...@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.
--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...@googlegroups.com.
To post to this group, send email to django...@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.
https://github.com/bernd-wechner/CoGsand I want to lose app name form my URLs (and ideally understand why they are there to begin with) not add them!
you have Different app in your project yes ?
you have to use app_name in url.py in each app
like that :
app_name = 'polls' in polls folder and in url.py
from django.conf.urls import urlfrom . import views
app_name = 'polls'urlpatterns = [url(r'^$', views.IndexView.as_view(), name='index'),url(r'^(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'),url(r'^(?P<pk>[0-9]+)/results/$', views.ResultView.as_view(), name='results'),url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),]
you have to create a url.py for each app in them folder
and in url.py beside settings.py use code like that :url('^polls/',include('polls.urls')),
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@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/CACOk0Tz1oBdnusZLeyHpcYSsVhSynKNOSsd%3DQdNoHuzQmkWdJQ%40mail.gmail.com.
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.
ALLOWED_HOSTS = ["127.0.0.1", "leaderboard.space"]And I see "Django settings: Development Server" echoed by runserver when it starts and by uwsgi on the web server.
import platform
HOSTNAME = platform.node()
if HOSTNAME == WEBSERVER:
print("Django settings: Web Server")
else:
print("Django settings: Development Server")
DEBUG = True
Request Method: | GET |
---|---|
Request URL: | http://leaderboard.space/list/Player |
Raised by: | Leaderboards.views.view_List |
Using the URLconf defined
in CoGs.urls
,
Django tried these URL patterns, in this order:
The current path, Player
, didn't
match any of these.
You're seeing this error
because you have DEBUG = True
in your
Django settings file. Change that to False
, and Django
will display a standard 404 page.
--
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...@googlegroups.com.
To post to this group, send email to django...@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/92ba18a5-4332-493b-a268-928e1f5feabc%40googlegroups.com.
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django...@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/862e89bd-19ab-1a20-9fcc-8f5152eed92d%40gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.
--
Melvyn Sopacua
--
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...@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/CA%2Bgw1GUnbnTcqA4TjQTHyOEuy_bZKSDTSsLWfhs8vymPFYneBA%40mail.gmail.com.
from django.core.handlers.wsgi import WSGIHandlerAnd it (mostly) works. Mostly as the admin site doesn't work. But I'm working on it, and have some insights (thanks for that) on where to look, namely the environment that is flowing from web server to wsgi server to django.
import os, django
class MyWSGIHandler(WSGIHandler):
def __call__(self, environ, start_response):
environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO']
environ['SCRIPT_NAME'] = ''
response = super().__call__(environ, start_response)
return response
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CoGs.settings")
django.setup()
application = MyWSGIHandler()
--
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...@googlegroups.com.
To post to this group, send email to django...@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/CA%2Be%2BciXMNwCimngxQ9Ouq6f9gy79zLCeC_UJaCrtnRwZ311q0g%40mail.gmail.com.