class Order(models.Model):
order_id = models.AutoField('ID', primary_key=True)
group = models.ForeignKey(Group, verbose_name='Территория', on_delete=models.CASCADE)
pynkt = models.ForeignKey(Pynkt, verbose_name='Пункт', on_delete=models.CASCADE)
@admin.register(Order)
class AdminOrder(admin.ModelAdmin):
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "pynkt":
kwargs["queryset"] = Pynkt.objects.filter(group_id=?????)
return super(AdminOrder, self).formfield_for_foreignkey(db_field, request, **kwargs)