Fantomas42 / django-blog-zinnia

Simple yet powerful and really extendable application for managing a blog within your Django Web site.
http://django-blog-zinnia.com/
BSD 3-Clause "New" or "Revised" License
2.12k stars 730 forks source link

Sitemaps doesn't work #188

Closed ghost closed 11 years ago

ghost commented 11 years ago

i'm trying to output the sitemap and it doesnt work because the max in sitemaps.py line 74 returns an empty list. i have posts 4 of them not sure where its getting info from

Fantomas42 commented 11 years ago

Hi,

in which sitemap does the problem occurs ?

Do you have entries published ?

ghost commented 11 years ago

blog sitemap works but when i followed the docs getting started setting up sitemap for the site i got an error when i check sitemap.xml. the posts are published but im working offline with no internet access.

ghost commented 11 years ago

I have the full error description here. The blog works fine no issues whatsoever with it, the blog sitemap works also. I use $ django-admin.py startproject --template=https://github.com/pinax/pinax-project-account/zipball/master to start a project.

HEADER

ValueError at /sitemap.xml

max() arg is an empty sequence

Request Method: GET Request URL: http://127.0.0.1:8000/sitemap.xml Django Version: 1.4.2 Exception Type: ValueError Exception Value:

max() arg is an empty sequence

Exception Location: /home/samuel/Documents/Virtual/1.4/django2/local/lib/python2.7/site-packages/django_blog_zinnia-0.12.dev-py2.7.egg/zinnia/sitemaps.py in set_max_entries, line 74 Python Executable: /home/samuel/Documents/Virtual/1.4/django2/bin/python Python Version: 2.7.3

COMPLETE

Environment:

Request Method: GET Request URL: http://127.0.0.1:8000/sitemap.xml

Django Version: 1.4.2 Python Version: 2.7.3 Installed Applications: ['prismriver', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'south', 'pinax_theme_bootstrap_account', 'pinax_theme_bootstrap', 'django_forms_bootstrap', 'account', 'metron', 'caurosel', 'politics', 'leaks', 'easy_thumbnails', 'photologue', 'debug_toolbar', 'django.contrib.comments', 'tagging', 'mptt', 'zinnia', 'django.contrib.sitemaps'] Installed Middleware: ['django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware']

Traceback: File "/home/samuel/Documents/Virtual/1.4/django2/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, _callback_args, *_callback_kwargs) File "/home/samuel/Documents/Virtual/1.4/django2/local/lib/python2.7/site-packages/django/contrib/sitemaps/views.py" in index
  2. for page in range(2, site.paginator.num_pages + 1): File "/home/samuel/Documents/Virtual/1.4/django2/local/lib/python2.7/site-packages/django/contrib/sitemaps/init.py" in _get_paginator
  3. return paginator.Paginator(self.items(), self.limit) File "/home/samuel/Documents/Virtual/1.4/django2/local/lib/python2.7/site-packages/django_blog_zinnia-0.12.dev-py2.7.egg/zinnia/sitemaps.py" in items
  4. self.set_max_entries() File "/home/samuel/Documents/Virtual/1.4/django2/local/lib/python2.7/site-packages/django_blog_zinnia-0.12.dev-py2.7.egg/zinnia/sitemaps.py" in set_max_entries
  5. self.max_entries = float(max([i[0] for i in self.cache.values()]))

Exception Type: ValueError at /sitemap.xml Exception Value: max() arg is an empty sequence

MY SETTINGS.PY

import os

PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(file), os.pardir)) PACKAGE_ROOT = os.path.abspath(os.path.dirname(file))

DEBUG = True TEMPLATE_DEBUG = DEBUG

ADMINS = [

("Samuel Muiruri", "arnoldwright1@gmail.com"),

]

MANAGERS = ADMINS

DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": "dev.db", } }

Email Settings

EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'arnoldwright1@gmail.com' EMAIL_HOST_PASSWORD = #removed for security issues

TIME_ZONE = "UTC"

LANGUAGE_CODE = "en-us"

SITE_ID = 1

USE_I18N = True

USE_L10N = True

USE_TZ = True

MEDIA_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "media")

MEDIA_URL = "/media/"

STATIC_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "static")

Memchache

CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } }

STATIC_URL = "/static/"

STATICFILES_DIRS = [ os.path.join(PACKAGE_ROOT, "static"), ]

STATICFILES_FINDERS = [ "django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder", ]

SECRET_KEY = #removed for security issues

TEMPLATE_LOADERS = [ "django.template.loaders.filesystem.Loader", "django.template.loaders.app_directories.Loader", ]

TEMPLATE_CONTEXT_PROCESSORS = [ "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", "django.core.context_processors.tz", "django.core.context_processors.request", "django.contrib.messages.context_processors.messages", "pinax_utils.context_processors.settings", "account.context_processors.account",

#zinnia
'zinnia.context_processors.version',

]

MIDDLEWARE_CLASSES = [ "django.middleware.common.CommonMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware",

#debug toolbar
'debug_toolbar.middleware.DebugToolbarMiddleware',

]

ROOT_URLCONF = "anonymous.urls"

Python dotted path to the WSGI application used by Django's runserver.

WSGI_APPLICATION = "anonymous.wsgi.application"

TEMPLATE_DIRS = [ os.path.join(PACKAGE_ROOT, "templates"), ]

INSTALLED_APPS = [ 'prismriver', "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.sites", "django.contrib.messages", "django.contrib.staticfiles", "south",

# theme
"pinax_theme_bootstrap_account",
"pinax_theme_bootstrap",
"django_forms_bootstrap",

# external
"account",
"metron",

# project
'caurosel',
'politics',
'leaks',
'easy_thumbnails',
'photologue',

#additional
'debug_toolbar',

#zinnia
'django.contrib.comments',
'tagging',
'mptt',
'zinnia',
'django.contrib.sitemaps',

]

INTERNAL_IPS = ('127.0.0.1',)

A sample logging configuration. The only tangible logging

performed by this configuration is to send an email to

the site admins on every HTTP 500 error when DEBUG=False.

See http://docs.djangoproject.com/en/dev/topics/logging for

more details on how to customize your logging configuration.

LOGGING = { "version": 1, "disable_existing_loggers": False, "filters": { "require_debug_false": { "()": "django.utils.log.RequireDebugFalse" } }, "handlers": { "mail_admins": { "level": "ERROR", "filters": ["require_debug_false"], "class": "django.utils.log.AdminEmailHandler" } }, "loggers": { "django.request": { "handlers": ["mail_admins"], "level": "ERROR", "propagate": True, }, } }

FIXTURE_DIRS = [ os.path.join(PROJECT_ROOT, "fixtures"), ]

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

ACCOUNT_OPEN_SIGNUP = True ACCOUNT_USE_OPENID = True ACCOUNT_REQUIRED_EMAIL = False ACCOUNT_EMAIL_VERIFICATION = False ACCOUNT_EMAIL_AUTHENTICATION = False ACCOUNT_LOGIN_REDIRECT_URL = "home" ACCOUNT_LOGOUT_REDIRECT_URL = "home" ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 7

MY URLS.PY

from django.conf import settings from django.conf.urls import patterns, include, url from django.conf.urls.static import static

from django.views.generic.simple import direct_to_template

from django.contrib import admin admin.autodiscover()

from zinnia.sitemaps import TagSitemap from zinnia.sitemaps import EntrySitemap from zinnia.sitemaps import CategorySitemap from zinnia.sitemaps import AuthorSitemap from zinnia.models.entry import Entry

from anonymous.views import *

sitemaps = {'tags': TagSitemap, 'blog': EntrySitemap, 'authors': AuthorSitemap, 'categories': CategorySitemap,}

urlpatterns = patterns("", url(r"^$", home, name="home",), url(r"^admin/", include(admin.site.urls)),

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

#zinnia
url(r'^weblog/', include('zinnia.urls')),
url(r'^comments/', include('django.contrib.comments.urls')),

url(r"^contact/", contact),
url(r'^whistle/', include('leaks.urls')),
(r'^photologue', include('photologue.urls')),

)

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

urlpatterns += patterns( 'django.contrib.sitemaps.views', url(r'^sitemap.xml$', 'index', {'sitemaps': sitemaps}), url(r'^sitemap-(?P

.+).xml$', 'sitemap', {'sitemaps': sitemaps}),)

Fantomas42 commented 11 years ago

Ok I have reproduced the issue with no entries published. A fix will be written soon.