Ok I found the error, but I still cant understand why this is
happening. What I did was that, in the blogango.urls, I have a line
like
import feeds
THe feeds.py is,
class main_feed (Feed):
blog = Blog.objects.all()[0]
title = blog.title
link = "/rss/latest/"
description = blog.tag_line
def items (self):
entries = BlogEntry.objects.all()[:10]
return entries
If I navigate to any page after I have just run manage.py reset ...,
there is no Blog object and Blog.objects.all()[0] raises exception. If
I change feeds.py to something like,
class main_feed (Feed):
try:
blog = Blog.objects.all()[0]
except:
class DummyBlog:
def __init__ (self):
self.title = ''
self.tag_line = ''
blog = DummyBlog()
title = blog.title
link = "/rss/latest/"
description = blog.tag_line
def items (self):
entries = BlogEntry.objects.all()[:10]
return entries
I get no error. What I do not understand is why should the main_feed
class be instantiated as soon as I import feeds? Should not the
instantiation happen only when the feed is accesed?
On Dec 22, 1:26 pm, shabda <[EMAIL PROTECTED]> wrote:
> Getting this error, "Error while importing URLconf 'blogango.urls':
> list index out of range". The exception stack does not give any cles
> to what might be wrong. The exception stack is,
> Traceback:
> File "C:\Python24\lib\site-packages\django\core\handlers\base.py" in
> get_response
> 73. callback, callback_args, callback_kwargs =
> resolver.resolve(request.path)
> File "C:\Python24\lib\site-packages\django\core\urlresolvers.py" in
> resolve
> 233. sub_match = pattern.resolve(new_path)
> File "C:\Python24\lib\site-packages\django\core\urlresolvers.py" in
> resolve
> 231. for pattern in self.urlconf_module.urlpatterns:
> File "C:\Python24\lib\site-packages\django\core\urlresolvers.py" in
> _get_urlconf_module
> 255. raise ImproperlyConfigured, "Error while
> importing URLconf %r: %s" % (self.urlconf_name, e)
>
> Exception Type: ImproperlyConfigured at /
> Exception Value: Error while importing URLconf 'blogango.urls': list
> index out of range
>
> The urls.py is,
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
> # Example:
> # (r'^foo/', include('foo.foo.urls')),
>
> # Uncomment this for admin:
> #(r'^admin/', include('django.contrib.admin.urls')),
> (r'^', include('blogango.urls')),
> )
>
> Any clues why this is happening?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---