I want to reduce the choice option in the admin panel if it is selected once.
admin.py
class MyModelForm(forms.ModelForm):
LOC = [('op1', 'op1'), ('op2', 'op2'),...]
location = forms.ChoiceField(choices=LOC)
class DataModelAdmin(admin.ModelAdmin):
form = MyModelForm
list_display = ('location',)
search_fields = ['location']
def get_ordering(self, request):
return ['location']
admin.site.register(DataModel, DataModelAdmin)
model.py
class DataModel(models.Model):
location = models.CharField(max_length=50, unique=True)
def __str__(self):
return self.location
I am trying to do but it removes the selected option on restarting the server