Liz Liz - 2 months ago 9
Python Question

AttributeError: '__proxy__' object has no attribute 'regex'

My urls.py looks like this; can anyone explain where the error (AttributeError: 'proxy' object has not attribute 'regex') is coming from? Because the error message isn't giving me any place where the error is coming from, so I'm really confused. Thanks!

from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.core.urlresolvers import reverse_lazy
#from django.views.generic.simple import direct_to_template
from django.views.generic import TemplateView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r"^$", TemplateView.as_view(template_name = "homepage.html")),
reverse_lazy("homepage.html"),
url(r'^grappelli/', include('grappelli.urls')), # grappelli URLS

url(r"^admin/", include(admin.site.urls)),

url(r"^account/", include("account.urls")),

# url(r"^search/", include("haystack.urls")),

# WIBO URLs
url(r'^cards/', include('cards.urls')),
url(r'^contacts/', include('contacts.urls')),
url(r'^invoice/', include('invoice.urls')),
url(r'^employee/',include('employee.urls')),
url(r'^sapub/request/$', 'wibo.views.sapub_request', name='jobrequeseturl'),
url(r'^wibo/logout-all-users/$', 'wibo.views.logout_all_users', name='logoutallurl'),
url(r'^wibo/cardmigrationextra00091/$', 'wibo.views.cards_migration_extras_0009_1', name='cardsmigrationextra0009url'),
url(r'^wibo/cardmigrationextra00092/$', 'wibo.views.cards_migration_extras_0009_2', name='cardsmigrationextra0009url'),
url(r'^wibo/cardmigrationextra00093/$', 'wibo.views.cards_migration_extras_0009_3', name='cardsmigrationextra0009url'),
url(r"^reports/", include('reports.urls')),
#url(r"^printsmart/$",direct_to_template,{"template":"printsmart_request.html"}, name="printsmarturl"),
url(r"^printsmart/$", TemplateView.as_view(template_name="printsmart_request.html")),
url(r'^select2/', include('django_select2.urls')),
)

urlpatterns += staticfiles_urlpatterns()
#reverse(urlpatterns)





Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
response = self.get_response(request)
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 218, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 268, in handle_uncaught_exception
return callback(request, **param_dict)
File "/Library/Python/2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/views/defaults.py", line 45, in server_error
return http.HttpResponseServerError(template.render())
File "/Library/Python/2.7/site-packages/django/template/backends/django.py", line 74, in render
return self.template.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 209, in render
return self._render(context)
File "/Library/Python/2.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "/Library/Python/2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/Library/Python/2.7/site-packages/django/template/loader_tags.py", line 135, in render
return compiled_parent._render(context)
File "/Library/Python/2.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "/Library/Python/2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/Library/Python/2.7/site-packages/django/template/loader_tags.py", line 135, in render
return compiled_parent._render(context)
File "/Library/Python/2.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "/Library/Python/2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/Library/Python/2.7/site-packages/django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "/Library/Python/2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/Library/Python/2.7/site-packages/django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "/Library/Python/2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/Library/Python/2.7/site-packages/django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "/Library/Python/2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/Library/Python/2.7/site-packages/django/template/defaulttags.py", line 493, in render
url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 579, in reverse
return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 433, in _reverse_with_prefix
self._populate()
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 298, in _populate
p_pattern = pattern.regex.pattern
AttributeError: '__proxy__' object has no attribute 'regex'
[29/Sep/2016 13:23:13]"GET / HTTP/1.1" 500 59

Answer

You have a stray reverse_lazy() in your urlpatterns:

urlpatterns = patterns('',
    url(r"^$", TemplateView.as_view(template_name = "homepage.html")),
    reverse_lazy("homepage.html"),