/ / django admin app obscured when urls.py refers to any other app - django, amazon-ec2, django-urls, django-authentication

django admin app obscurecido quando urls.py se refere a qualquer outro aplicativo - django, amazon-ec2, django-urls, django-authentication

this seems to be a misunderstanding on my part of how the urls config works in django. I thought that the first regex that matches is where it gets "dispatched", but if I have others in the urls list, it goes to them instead of the first.

The contents of project"s urls.py when the admin site is accessible:

from django.conf.urls import include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings


urlpatterns = [
url(r"^admin/", admin.site.urls),
#url(r"^api/", include("api.urls")),
#url(r"^index", include("limbo.urls")),
#url(r"^polls/", include("polls.urls")),
# url(r"^limbo/", include("limbo.urls")),
#url(r"edit/", include("limbo.urls")),
]  + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

but when I un-comment the 1st, 2nd or last comment-out lines, I get an error:

invalid literal for int() with base 10: ""

Alguma ideia?

for example, if I un-comment the line that says url(r"^api/", include("api.urls")),, I get the error I stated.
api/urls.py conteúdo:

from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from . import views

urlpatterns = [
url(r"^(?:addUse.?[html]{,4})?$", views.addUsageHistory, name="addUsageHistory"),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

and the In the traceback, I can see it seems to originate with this file: /home/ec2-user/limbo/limboenv/local/lib/python2.7/site-packages/django/contrib/admin/templates/admin/login.html and a ways down the stacktrace (second from bottom), i can see that in /home/ec2-user/limbo/limboenv/local/lib/python2.7/site-packages/django/utils/regex_helper.py, a variável pattern está configurado para "(?:addUse\.?[html]{,4})?$, which is one of the values in api/urls.py. Why would it have ended up in api/urls.py at all? it should have gone to admin.site.urls before it ever saw r"^api/"

Respostas:

0 para resposta № 1

as is so often the case, I figured it out after beating my head against a wall for so long, then as soon as I post a question on SO, I figured it out. for future reference, using ?: in the beginning of a regex in an app"s urls.py is very dangerous. I changed my app urls.py to not have it and it all works as expected. see my udpated api/urls.py Aqui:

from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from . import views

urlpatterns = [
url(r"^addUse.html$", views.addUsageHistory, name="addUsageHistory"),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)