Josh VanderLinden avatar Josh VanderLinden committed bbfc43c

Fixed a small problem with doing a syncdb on a fresh site with django-articles in the list of INSTALLED_APPS

Comments (0)

Files changed (2)

articles/__init__.py

-__version__ = '2.2.0'
+__version__ = '2.2.1'
 
 from articles.directives import *
 try:

articles/feeds.py

 from django.core.urlresolvers import reverse
 from articles.models import Article, Tag
 
-SITE = Site.objects.get_current()
-
 # default to 24 hours for feed caching
 FEED_TIMEOUT = getattr(settings, 'ARTICLE_FEED_TIMEOUT', 86400)
 
-class LatestEntries(Feed):
+class SiteMixin(object):
+
+    @property
+    def site(self):
+        if not hasattr(self, '_site'):
+            try:
+                self._site = Site.objects.get_current()
+            except AttributeError:
+                self._site = Site(domain='example.com', name='Demo Site')
+
+        return self._site
+
+class LatestEntries(Feed, SiteMixin):
     def title(self):
-        return "%s Articles" % SITE.name
+        return "%s Articles" % (self.site.name,)
 
     def link(self):
         return reverse('articles_archive')
     def item_pubdate(self, item):
         return item.publish_date
 
-class TagFeed(Feed):
+class TagFeed(Feed, SiteMixin):
     def get_object(self, bits):
         if len(bits) != 1:
             raise FeedDoesNotExist
         return Tag.objects.get(name__iexact=bits[0])
 
     def title(self, obj):
-        return "%s: Newest Articles Tagged '%s'" % (SITE.name, obj.name)
+        return "%s: Newest Articles Tagged '%s'" % (self.site.name, obj.name)
 
     def link(self, obj):
         if not obj:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.