Metadata lookup field

Questions, comments, discussions. Over time certain topics might be moved to their own category.
Post Reply
asfalter
Posts: 2
Joined: Tue Aug 18, 2020 4:52 pm

Metadata lookup field

Post by asfalter »

Hello, I've been trying to use the lookup option in a metadata field, and was able to display a dropdown with a list of options by just adding strings separated by comma, like this:

Code: Select all

'ARCOM', 'MAE', 'MERNMR', 'MINISTERIO DE MINERÍA', 'SENAGUA'
This was a simple use case to display different government branches in the drop down field. But what if my list is 100 times bigger? Do I really need to add the options as a single line of strings?

Also, would it be possible to order the list in alphabetical order? I've tried different methods explained in the Django docs but have not been successful so far.
User avatar
rosarior
Developer
Developer
Posts: 649
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: Metadata lookup field

Post by rosarior »

Hi,

This will be possible with the next version of Mayan. The next version includes a "split" filter and a special tag named "method" that allows calling Python method on objects.

Code: Select all

{% spaceless %}
{% set "B,D,A,8,2,5,1"|split:"," as list %}
{% method list "sort" as none %}{{ list|join:"," }}
{% endspaceless %}
The list will need to be in a single line because the list is a variable.
Attachments
2020-08-20_04-05.png
2020-08-20_04-05.png (56.53 KiB) Viewed 6694 times
asfalter
Posts: 2
Joined: Tue Aug 18, 2020 4:52 pm

Re: Metadata lookup field

Post by asfalter »

Thanks for the quick response Roberto, I'll look forward to the next Mayan version.
crang
Posts: 4
Joined: Wed Mar 03, 2021 9:52 pm

Re: Metadata lookup field

Post by crang »

@rosarior,

Thanks for all you do for us users. In your response including the split function. Is it possible to have the source of the list be the content of a metadata field. What I would like to do is have our users pick from the existing list of values or add a new one if it is not in the list. Is this possible?

Thanks from a beginner.
Post Reply