[GeoNode-devel] Patch metadata with geonode 4 (master)

Toni Schönbuchner toni.schoenbuchner at csgis.de
Wed Dec 8 05:12:29 PST 2021


Hi devs,

I’m just testing the workshop docs for gn 4 (master branch). 
https://docs.geonode.org/en/master/devel/workshops/index.html <https://docs.geonode.org/en/master/devel/workshops/index.html>

One question regarding (the really usefuel) extending of metadata.
In master it looks several fields have moved from resourceBase to Dataset Model.
So let’s say we patch directly the Dataset Model in apps:

    ….
    def patch_layers_dataset(self, cls):
        self._get_logger().info("Patching Dataset")
        animals_help_text = _('Your animals')
        animals = models.TextField(
            _('animals'),
            blank=True,
            null=True,
            help_text=animals_help_text)
        cls.add_to_class('animals', animals)

	...

    def ready(self):
        super(AppConfig, self).ready()
        run_setup_hooks()
	...
        from geonode.layers.models import Dataset
        self.patch_layers_dataset(Dataset)


The new animals field now shows up in Django Admin and saves the data correctly.
I would now expect to extend the metadata Wizard in /layers/templates/layouts/panels.html
like:


          <span><label for="{{ dataset_form.animal|id }}">{{ dataset_form.animals.label }}</label></span>
          {{ dataset_form.animals }}

But the animals field is not populated (which in my opinion it should: https://github.com/GeoNode/geonode/blob/8b45f7d70a907764a99af9e99abfe7a9ea232a33/geonode/layers/forms.py#L45-L59 <https://github.com/GeoNode/geonode/blob/8b45f7d70a907764a99af9e99abfe7a9ea232a33/geonode/layers/forms.py#L45-L59>)


What do I miss that the dataset form respects the new field?


Thanks,

Toni

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-devel/attachments/20211208/0af6747d/attachment.html>


More information about the geonode-devel mailing list