django-modeladmin

Django - Get object id in render_change_form (ModelAdmin)

瘦欲@ 提交于 2019-12-04 20:32:09
I have these two models and modeladmin. When adding a new host in the list of available hostuser only appear hostusers that are not assigned to another host. The issue is if I edit an already created host its actual hostuser id is also filtered so I want to do is to exclude hostuser id that is currently assigned. How I can specify in the exclude the current id from the hostuser field? The statement that I need is written between * Thanks in advance Models.py class HostUser(models.Model): name = models.CharField(max_length=200) {..More Data..} class Host(models.Model): {..More Data..} hostuser