Django Integration




Generic, re-usable views for use with Fedora-based Django projects. These views expose data intended for use with eulindexer. These views currently return data in JSON form.

Projects that use this module should include the following settings in their

# Index server url. In this example case, we are wish to push data to a Solr instance.
SOLR_SERVER_URL = "http://localhost:8983/solr/"
# IPs that will be allowed to access the indexdata views
EUL_INDEXER_ALLOWED_IPS = "ANY" #Or put in a list such as ("", "")

# OPTIONAL SETTING: A list of lists of content models you want this application to index.
# If this setting is missing, the code will automatically detect all content
# models the application is using. In this example, it will index items with BOTH
# content-model_1 and content-model_2 as well as those that have just content-model_3.
EUL_INDEXER_CONTENT_MODELS = "[['content-model_1', 'content-model_2'], ['content-model_3']]"

To use these views in your eulfedora -based application, make sure that eulfedora is included in INSTALLED_APPS in your

    # Additional installed applications here,

And then bind the indexdata views to a url in your application

from django.conf.urls import *

urlpatterns = patterns('',
    url(r'^indexdata/', include('eulfedora.indexdata.urls', namespace='indexdata')),
    # Additional url patterns here,

An example Solr schema with fields defined for all the index values exposed in the default index_data() method is included with eulfedora.indexdata to be used as a starting point for applications.


This view returns the index configuration of the current application as JSON. Currently, this consists of a Solr index url and the Fedora content models that this application expects to index.


By default, Fedora system content models (such as fedora-system:ContentModel-3.0) are excluded. Any application that actually wants to index such objects will need to customize this view to include them.

eulfedora.indexdata.views.index_data(request, id, repo=None)

Return the fields and values to be indexed for a single object as JSON. Index content is generated via eulfedora.models.DigitalObject.index_data().

Parameters:id – id of the object to be indexed; in this case a Fedora pid

Management commands

The following management commands will be available when you include eulfedora in your django INSTALLED_APPS and rely on the existdb settings described above.

For more details on these commands, use <command> help

  • syncrepo - load simple content models and fixture object to the configured fedora repository

Template tags

eulfedora adds custom template tags for use in templates.


Catch fedora failures and permission errors encountered during template rendering:

{% load fedora %}

{% fedora_access %}
   <p>Try to access data on fedora objects which could be
     <span class='{{ obj.inaccessible_ds.content.field }}'>inaccessible</span>
     or when fedora is
     <span class='{{ obj.regular_ds.content.other_field }}'>down</span>.</p>
{% permission_denied %}
   <p>Fall back to this content if the main body results in a permission
     error while trying to access fedora data.</p>
{% fedora_failed %}
   <p>Fall back to this content if the main body runs into another error
     while trying to access fedora data.</p>
{% end_fedora_access %}

The permission_denied and fedora_failed sections are optional. If only permission_denied is present then non-permission errors will result in the entire block rendering empty. If only fedora_failed is present then that section will be used for all errors whether permission-related or not. If neither is present then all errors will result in the entire block rendering empty.

Note that when Django’s TEMPLATE_DEBUG setting is on, it precludes all error handling and displays the Django exception screen for all errors, including fedora errors, even if you use this template tag. To disable this Django internal functionality and see the effects of the fedora_access tag, add the following to your Django settings: