title: How to represent Django money field with currency symbol in list template and plain decimal for edits?
body: <p>When I display money in a list template or detail (read-only) template I would like to be able to display a pretty version of the field's value which includes the currency symbol: "$100.00"</p>
  
  <p>However, when the record is being edited, I would like to display "100.00" in the TextInput box without any currency symbol.</p>
  
  <p>I made a custom models.DecimalField class and forms.DecimalField class to represent money in my Django application.  </p>
  
  <p>So I'm trying to come up with a way to have an alternate version of the field's value in the template that is pretty (i.e. properly formatted for viewing but not ideal for editing).  I know there are template filters that let you accomplish this, but I believe that would prevent me from iterating through the fields in a form and displaying their values. </p>
  
  <p>If I can add a pretty attribute to my custom field class, I can check if it exists in the template and display it.  So far I tried this:</p>
  
  <pre><code>class MoneyFormField(forms.DecimalField):
      def __init__(self, *args, **kwargs):
          # I plan to add symbol localization code here
          self.symbol= '$'
  
      def prepare_value(self, value):
          # assign pretty value to an attribute that template can access
          self.pretty = self.pretty_value(value)            
          try:
              return round(Decimal(value),2)
          except:
              return 0
  
      def pretty_value(self, value):
          if not value:
              value = 0
          return self.symbol + str(round(Decimal(value),2))
  </code></pre>
  
  <p>The problem is that in order to access the pretty value in the template, I have to access the original value first so that prepare_value() is called.</p>
  
  <p>If I try to print the pretty value in a template like this...</p>
  
  <pre><code>{% for field in payment_form %}
      {{ field.field.pretty }} {{ field.value }} {{ field.field.pretty }} 
  {% endfor %}
  </code></pre>
  
  <p>then the first pretty is ignored, but the last pretty prints. </p>
  
  <p>If I can get this to work then I would display a pretty value (or default value if pretty doesn't exist) in a template like this:</p>
  
  <pre><code>{% if field.field.pretty %}
      {{ field.field.pretty}}
  {% else %}
      {{ field.value }}
  {% endif %}
  </code></pre>
  
  <p>Does anyone have any suggestions for making an alternate representation of a field available to a template?</p>
  
  <p>TL;DR- How can I access the field's value in the form field's <strong>init</strong> ?</p>