# Path: django_flickr_gallery/settings.py
#     API_KEY = settings.FLICKR_API_KEY
#     SECRET = settings.FLICKR_SECRET
#     USER_ID = settings.FLICKR_USER_ID
# PHOTOSETS_LIST_TEMPLATE = getattr(settings, 'FLICKR_PHOTOSETS_LIST_TEMPLATE', "gallery/flickr/photoset_list.html")
# PHOTOS_LIST_TEMPLATE = getattr(settings, 'FLICKR_PHOTOS_LIST_TEMPLATE', "gallery/flickr/photo_list.html")
# PHOTOSET_LIST_VIEW = getattr(settings, 'FLICKR_PHOTOSET_LIST_VIEW', 'django_flickr_gallery.FlickrPhotosetListView')
# PHOTO_LIST_VIEW = getattr(settings, 'FLICKR_PHOTO_LIST_VIEW', 'django_flickr_gallery.FlickrPhotosListView')
# PAGINATOR_CLASS = Paginator
# PAGE_FIELD = getattr(settings, 'FLICKR_PAGE_FIELD', "page")
# PER_PAGE_FIELD = getattr(settings, 'FLICKR_PER_PAGE_FIELD', "per_page")
# PHOTOS_PER_PAGE = getattr(settings, 'FLICKR_PHOTOS_PER_PAGE', 10)
# PHOTOSETS_PER_PAGE = getattr(settings, 'FLICKR_PHOTOSETS_PER_PAGE', 10)
# CACHE = getattr(settings, 'FLICKR_CACHE', True)
# STORE_TOKEN = getattr(settings, 'FLICKR_STORE_TOKEN', False)
# CACHE_BACKEND = load_class(getattr(
#     settings,
#     'FLICKR_CACHE_BACKEND',
#     None))
# 
# Path: django_flickr_gallery/shortcuts.py
# def get_paginator(iterator, page=None, per_page=10, pages=None, total=None):
#     """
#     Returns paginator instance from the iterator object.
#     :param iterator:
#         Iterator object to paginate.
#     :param page:
#         Number of current page. If not default 1.
#     :param per_page:
#         How many objects per page.
#     :param pages:
#         Total pages count.
#     :param total:
#         Total objects count.
#     :return: paginator and page_obj
#     """
#     paginator = Paginator(
#         iterator, per_page=per_page,
#         page=page, pages=pages,
#         total=total)
#     return paginator, paginator.page


from django.core.urlresolvers import reverse
from django.http import Http404
from django.utils.translation import ugettext as _
from django_flickr_gallery import settings
from django_flickr_gallery.shortcuts import get_paginator
from flickrapi import FlickrAPI as BaseFlickrAPI, FlickrError
                'media': 'photos',
                'extras': 'description'
            })

            response = flickr.photosets.getPhotos(**params)

            if isinstance(response, (str, bytes)):
                response = flickr.parse_json(response)

            def parse_reponse(response):
                _photoset = response.get('photoset', None)

                if not _photoset:
                    return [None, None, None, None, None]

                return [
                    _photoset['photo'],
                    _photoset['total'],
                    _photoset['page'],
                    _photoset['perpage'],
                    _photoset['pages']
                ]

            photos, total, page, per_page, pages = parse_reponse(response)
            paginator, page_obj = None, None

            if photos is not None:
                photos = [Photo(photo['id'], data=photo) for photo in photos]

            if per_page is not None:

# Path: django_flickr_gallery/settings.py
#     API_KEY = settings.FLICKR_API_KEY
#     SECRET = settings.FLICKR_SECRET
#     USER_ID = settings.FLICKR_USER_ID
# PHOTOSETS_LIST_TEMPLATE = getattr(settings, 'FLICKR_PHOTOSETS_LIST_TEMPLATE', "gallery/flickr/photoset_list.html")
# PHOTOS_LIST_TEMPLATE = getattr(settings, 'FLICKR_PHOTOS_LIST_TEMPLATE', "gallery/flickr/photo_list.html")
# PHOTOSET_LIST_VIEW = getattr(settings, 'FLICKR_PHOTOSET_LIST_VIEW', 'django_flickr_gallery.FlickrPhotosetListView')
# PHOTO_LIST_VIEW = getattr(settings, 'FLICKR_PHOTO_LIST_VIEW', 'django_flickr_gallery.FlickrPhotosListView')
# PAGINATOR_CLASS = Paginator
# PAGE_FIELD = getattr(settings, 'FLICKR_PAGE_FIELD', "page")
# PER_PAGE_FIELD = getattr(settings, 'FLICKR_PER_PAGE_FIELD', "per_page")
# PHOTOS_PER_PAGE = getattr(settings, 'FLICKR_PHOTOS_PER_PAGE', 10)
# PHOTOSETS_PER_PAGE = getattr(settings, 'FLICKR_PHOTOSETS_PER_PAGE', 10)
# CACHE = getattr(settings, 'FLICKR_CACHE', True)
# STORE_TOKEN = getattr(settings, 'FLICKR_STORE_TOKEN', False)
# CACHE_BACKEND = load_class(getattr(
#     settings,
#     'FLICKR_CACHE_BACKEND',
#     None))
# 
# Path: django_flickr_gallery/shortcuts.py
# def get_paginator(iterator, page=None, per_page=10, pages=None, total=None):
#     """
#     Returns paginator instance from the iterator object.
#     :param iterator:
#         Iterator object to paginate.
#     :param page:
#         Number of current page. If not default 1.
#     :param per_page:
#         How many objects per page.
#     :param pages:
#         Total pages count.
#     :param total:
#         Total objects count.
#     :return: paginator and page_obj
#     """
#     paginator = Paginator(
#         iterator, per_page=per_page,
#         page=page, pages=pages,
#         total=total)
#     return paginator, paginator.page


# Path: django_flickr_gallery/base.py
from django.core.urlresolvers import reverse
from django.http import Http404
from django.utils.translation import ugettext as _
from django_flickr_gallery import settings
from django_flickr_gallery.shortcuts import get_paginator
from flickrapi import FlickrAPI as BaseFlickrAPI, FlickrError

                'media': 'photos',
                'extras': 'description'
            })

            response = flickr.photosets.getPhotos(**params)

            if isinstance(response, (str, bytes)):
                response = flickr.parse_json(response)

            def parse_reponse(response):
                _photoset = response.get('photoset', None)

                if not _photoset:
                    return [None, None, None, None, None]

                return [
                    _photoset['photo'],
                    _photoset['total'],
                    _photoset['page'],
                    _photoset['perpage'],
                    _photoset['pages']
                ]

            photos, total, page, per_page, pages = parse_reponse(response)
            paginator, page_obj = None, None

            if photos is not None:
                photos = [Photo(photo['id'], data=photo) for photo in photos]

            if per_page is not None:

                paginator, page_obj = get_paginator(