David Ray 8 gadi atpakaļ
vecāks
revīzija
3594066b17
1 mainītis faili ar 13 papildinājumiem un 7 dzēšanām
  1. 13 7
      bakerydemo/base/models.py

+ 13 - 7
bakerydemo/base/models.py

@@ -111,19 +111,25 @@ class AboutPage(Page):
 
 def getImageCollections():
     # We return all collections to a list that don't have the name root.
-    return [(
-        collection.id, collection.name
-        ) for collection in Collection.objects.all().exclude(
-        name='Root'
-        )]
+    try:
+        collection_images = [(
+            collection.id, collection.name
+            ) for collection in Collection.objects.all().exclude(
+            name='Root'
+            )]
+        return collection_images
+    except:
+        return [('','')]
 
 
 class GalleryPage(Page):
     """
     This is a page to list all the locations on the site
     """
-
+    # try:
     CHOICES_LIST = getImageCollections()
+    # except:
+    #     CHOICES_LIST = [("", "")]
     # To return our collection choices for the editor to access we need to
     # make the choices list a variable rather than a function
 
@@ -145,7 +151,7 @@ class GalleryPage(Page):
         blank=True)
 
     content_panels = Page.content_panels + [
-        # FieldPanel('choices'),
+        FieldPanel('choices'),
         ImageChooserPanel('image'),
         FieldPanel('introduction')
     ]