L'objet 'str' n'a pas d'attribut 'resolve' lors de l'accès au site d'administration
Je reçois cette erreur:
'str' object n'a pas d'attribut de 'résoudre'
lorsque vous essayez d'accéder à l'admin de django site et je ne peux pas comprendre
pourquoi.
J'ai des applications au sein de mon projet qui ont leur propre admin.py les fichiers.
Cela pourrait-il provoquer?
voici mon urls.py:
from django.conf.urls.defaults import *
import settings
from django.contrib.auth.views import login, logout
from views import index, simple, complex
from django.views.generic.simple import direct_to_template
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^django_jchat/', include('django_jchat.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
...
Heres la trace de retour:
'str' object has no attribute 'resolve'
Request Method: GET
Django Version: 1.3
Exception Type: AttributeError
Exception Value:
'str' object has no attribute 'resolve'
Exception Location: /home/dockedin/webapps/peebletalk/lib/python2.7/
django/core/urlresolvers.py in resolve, line 252
Python Executable: /usr/local/bin/python
Python Version: 2.7.1
Python Path:
['/home/dockedin/webapps/peebletalk',
'/home/dockedin/webapps/peebletalk/lib/python2.7',
'/home/dockedin/lib/python2.7',
'/usr/local/lib/python27.zip',
'/usr/local/lib/python2.7',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk',
'/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/site-packages/PIL']
Server time: Wed, 10 Aug 2011 15:24:55 -0400
Traceback Switch to copy-and-paste view
/home/dockedin/webapps/peebletalk/lib/python2.7/django/core/
handlers/base.py in get_response
response = middleware_method(request)
...
▶ Local vars
/home/dockedin/webapps/peebletalk/lib/python2.7/django/middleware/
common.py in process_request
if (not _is_valid_path(request.path_info, urlconf)
and
...
▶ Local vars
/home/dockedin/webapps/peebletalk/lib/python2.7/django/middleware/
common.py in _is_valid_path
urlresolvers.resolve(path, urlconf)
...
▶ Local vars
/home/dockedin/webapps/peebletalk/lib/python2.7/django/core/
urlresolvers.py in resolve
return get_resolver(urlconf).resolve(path)
...
▶ Local vars
/home/dockedin/webapps/peebletalk/lib/python2.7/django/core/
urlresolvers.py in resolve
def resolve(self, path):
tried = []
match = self.regex.search(path)
if match:
new_path = path[match.end():]
for pattern in self.url_patterns:
try:
sub_match = pattern.resolve(new_path)
...
except Resolver404, e:
sub_tried = e.args[0].get('tried')
if sub_tried is not None:
tried.extend([[pattern] + t for t in
sub_tried])
else:
tried.append([pattern])
source d'informationauteur de1337ed
Vous devez vous connecter pour publier un commentaire.
Selon l'excellente réponse posté ici:
http://redsymbol.net/articles/django-attributeerror-str-object-no-attribute-resolve/
Il y a généralement plusieurs sources de cette erreur:
Vous avez manqué modèle "mot-clé":
cela devrait être changé pour:
Noter que dans Django 1.8+, il est préférable d'utiliser une liste de regexes au lieu de
patterns
.Vous avez oublié une virgule dans certains tuple, comme:
Vous commentée d'une url()s à l'aide de triple-citations
Vous négligemment laisser un crochet de fermeture au mauvais endroit:
au lieu de:
Vous définissez
ROOT_URLCONF
une listeLors de la migration à partir de l'ensemble des n-uplets d'une liste vous avez oublié de supprimer le vide
''
argument de la répétition.Veuillez vérifier attentivement si vous n'avez pas un de ces cas dans votre code.
Pour moi, ce qui a causé le problème:
et cela a résolu:
J'ai vu cette possibilité dans un commentaire sur http://redsymbol.net/articles/django-attributeerror-str-object-no-attribute-resolve/