sections: writing_plugins:writing-plugins-configuration
This data as json
id | page | ref | title | content | breadcrumbs | references |
---|---|---|---|---|---|---|
writing_plugins:writing-plugins-configuration | writing_plugins | writing-plugins-configuration | Writing plugins that accept configuration | When you are writing plugins, you can access plugin configuration like this using the datasette plugin_config() method. If you know you need plugin configuration for a specific table, you can access it like this: plugin_config = datasette.plugin_config( "datasette-cluster-map", database="sf-trees", table="Street_Tree_List" ) This will return the {"latitude_column": "lat", "longitude_column": "lng"} in the above example. If there is no configuration for that plugin, the method will return None . If it cannot find the requested configuration at the table layer, it will fall back to the database layer and then the root layer. For example, a user may have set the plugin configuration option like so: { "databases: { "sf-trees": { "plugins": { "datasette-cluster-map": { "latitude_column": "xlat", "longitude_column": "xlng" } } } } } In this case, the above code would return that configuration for ANY table within the sf-trees database. The plugin configuration could also be set at the top level of metadata.json : { "title": "This is the top-level title in metadata.json", "plugins": { "datasette-cluster-map": { "latitude_column": "xlat", "longitude_column": "xlng" } } } Now that datasette-cluster-map plugin configuration will apply to every table in every database. | ["Writing plugins"] | [] |