Skip to content
Advertisement

Django: How to use data from a function as a field in Meta class

I’ve created a function in my serializers.py that call an external API and give me a dict back. How can I use the output from return downloads in the get_all_files as a field in class Meta?

After the first answer, I’ve got the following error message:

JavaScript

Line 68 is the following: return get_all_files(instance.bands)

serializers.py

JavaScript

Advertisement

Answer

The code works fine. The error was caused by a mistake in my backend. The key of the sat-search result was in 3 digest, e.g. B03. The content in my field was in two digst, e.g. B3. That’s why the matching doesn’t worked.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement