Django base views for implementing your API

lizard_structure.views provides base views for each of the core concepts defined in Introducing the four core Lizard concepts. The basic premise is that lizard-structure only shows a data source’s structure. There are no edit actions, so no POST/PUT/DELETE: only GET.

For the Django API we use Django REST framework.

Every view has a doctring that can mostly be used as-is by the subclasses that implement the actual functionality. The docstring is rendered by Django REST framework in the html API interface, so the view’s docstring is the most important information your API user is going to see. The base views’ docstring must be really clear and concise!

You normally do not have to implement any .get() method on a view, that is all taken care of. Every view tells you which methods you have to fill in to get the base view working with your data.

Data source view

Base view for a Data source.

class lizard_structure.views.DataSourceView(**kwargs)[source]

Information about the data source itself and its list of layer trees.

Use this to discover the layer trees you can show in your user interface. The result is a dictionary with the following items:

Metadata about ourselves, like the software version that generated it. Do not depend on the actual items in here, just display them when desired as background information.
The list of available layer trees. A layer tree is a collection of layers you can show on a map or in an overview.

There is one method you always have to implement:


Return list of layer trees.

Overwrite this method in your subclass and return a list of lizard_structure.items.LayerTreeItem instances you create from whatever constitutes a layer tree in your own models. To give you an idea, here are some example layer trees:

  • Categories in lizard-wms/lizard-maptree.
  • FEWS connections in lizard-fewsjdbc.

If you want to return more information about ourselves than the default:


Return metadata about ourselves.

The result should be a flat dictionary, so only key/value pairs. By default “generator” is returned with our package name and version as returned by our_name_and_version().

Normally, you should not have to modify or implement the other methods.

get(request, format=None)[source]

Return about_ourselves and layer trees as REST response.


Return automatically detected name and version number of our package.

The default should be OK in most cases.

TODO: Layer tree view

Base view for a Layer tree.

class lizard_structure.views.LayerTreeView(**kwargs)[source]

Information about the layer tree and its list of layers.

TODO: Layer view

Base view for a Layer.

class lizard_structure.views.LayerView(**kwargs)[source]

Information about the layer and its list of features.

TODO: Feature view

Base view for a Feature.

class lizard_structure.views.FeatureView(**kwargs)[source]

Information about the feature and most importantly its representations.