title: Adding custom JS to a django admin field
body: <p>In a django application I have the following model:</p>
  
  <pre><code>class Appointment(models.Model):
      #some other fields
      #address fields
      zipcode=models.CharField(max_length=5)
      address=models.CharField(max_length=120)
      latitude=models.FloatField()
      longitude=models.FloatField()
  </code></pre>
  
  <p>When I'm rendering an Appointment, I'm just putting a marker at the position specified by longitude and latitude with the address as text, however I need the latitude and longitude to do that.</p>
  
  <p>Currently, latitude and longitude have to be entered manually in the admin backend, but opening Google Maps/OSM, searching for the address and entering latitude and longitude is work that shouldn't have to be done by hand, so I want to retrieve it through the Google Maps API (keyword Geocoding).</p>
  
  <p>Ideally, I want a button "Get coordinates" next to the address, which, when pressed, starts a Geocoding request and fills in latitude and longitude when the address is unambiguous and presents a map with the results and fills in the coordinates when the user clicks on the right marker.</p>
  
  <p>I know how to do that, but I'm not sure how I should insert the markup and the code into the admin backend.</p>
  
  <p>Some things I already considered but don't want to do as they don't seem natural or seem to be too much work for such a simple task:</p>
  
  <ul>
  <li>putting the code in the address field's description in <code>field_options</code> in a class derived from <code>admin.ModelAdmin</code></li>
  <li>putting everything address related in a separate model and using a custom <code>form</code> (with a separate template</li>
  <li>create an address picker widget</li>
  <li>use GeoDjango</li>
  </ul>