There are models of Network and ARM
class ARM (models.Model): class Meta(): db_table = 'arm' arm_configuration_name = models.TextField() arm_network = models.ManyToManyField(Network) class Server (models.Model): class Meta(): db_table = 'server' server_name = models.TextField() Task: In the template you need to display only those workstations that are associated with the Network.
Tried to do it in the template itself:
{% for net in networks %} <div> {% for obj in net_id.arm_set %} <p>{{ obj.arm_configuration_name }}</p> {% endfor %} </div> {% endfor %} I also tried to write my own filter to use in the template. Created a file
from django import template from django.template.defaultfilters import stringfilter from test_app.models import Network register = template.Library() @register.filter @stringfilter def arms_in_network(value): network = Network.objects.get(id = value) arms = network.arm_set.all() return arms' But there is another problem - at startup it gives an error: django.core.exceptions.AppRegistryNotReady: Apps are not loaded yet. In this case, the application is written in settings INSTALLED_APPS. And I found out that this error was due to the import of the Network.
Please tell me how to solve the problem. I would be glad if you offer other solutions.