title: How to list unique values in drop down list for Django?
body: <p>Just for testing, I have a Python that scripts that enters IP addresses into the database.  </p>
  
  <p>I have the following values:  </p>
  
  <pre><code>127.0.0.1  
  127.0.0.1  
  10.42.1.42  
  10.42.1.42  
  10.42.1.42  
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>class Invalid(models.Model):
      access = models.DataTimeField()
      ip = models.CharField()
      login = models.CharField()
  </code></pre>
  
  <p>In the template, this is what I have for the drop down list:  </p>
  
  <pre><code>&lt;p&gt;Choose: 
  &lt;select&gt;
  {% for item in results %}
      &lt;option value="{{ item.ip }}"&gt;{{ item.ip }}&lt;/option&gt;
  {% endfor %}
  &lt;/select&gt;
  &lt;button type="button"&gt;Filter&lt;/button&gt;  
  &lt;/p&gt;  
  </code></pre>
  
  <p>However, the problem with this method is that it lists all the values. As far as I'm aware, there is no way to create an array/lists although I may be mistaken.  </p>
  
  <p>Is there any way to only have distinct values show up in the list, that is:  </p>
  
  <pre><code>127.0.0.1  
  10.42.1.42
  </code></pre>