So, I want to log the searches which people make (oh noes, I'm the NSA, and all). To that end, I have this Search model:
class Search(models.Model):
search_string = models.CharField(max_length=40)
ip_record = models.GenericIPAddressField()
date_searched = models.DateTimeField(default=datetime.now())
Then, I have this form:
class SearchForm(ModelForm):
class Meta:
model = Search
fields = '__all__'
How do I make it that there is only the search_string
displayed? I have tried setting editable=False
and using only the search_string
field as a singleton list provided to fields
, but that doesn't populate the other fields and creates an integrity error:
IntegrityError at /endos/
NOT NULL constraint failed: backend_search.ip_record
How should I be creating this form? And how do I create it with only one field and with the other fields being populated by computer?