I am using the Dev trunk as of Saturday with the models below:

#----------------------------------
class Repair(models.Model):

    tail_number = models.IntegerField(choices=AIRCRAFT_CHOICES)

    location = models.CharField(maxlength=30)
    damage_type = models.CharField(maxlength=50)

    class Admin:
        pass

Iclass Photo(models.Model):
    repair = models.ForeignKey(Repair, edit_inline=models.TABULAR,
num_in_admin=1)
    caption = models.CharField(maxlength=200, core=True, blank=True)
    filename = models.ImageField(upload_to="tam", blank=True,
null=True)
#----------------------------------

The following template works but does not handle more than one photo.

#----------------------------------
<form method="POST" action="." enctype="multipart/form-data" >
  <p>
    <label for="id_tail_number">tail number:</label>
    {{ form.tail_number }}
    {% if form.tail_number.errors %}
      *** {{ form.tail_number.errors|join:", " }}
    {% endif %}
  </p>
  <p>
    <label for="id_location">location:</label>
    {{ form.location }}
    {% if form.location.errors %}
      *** {{ form.location.errors|join:", " }}
    {% endif %}
  </p>
  <p>
    <label for="id_damage_type">damage type:</label>
    {{ form.damage_type }}
    {% if form.damage_type.errors %}
      *** {{ form.damage_type.errors|join:", " }}
    {% endif %}
  </p>
  <p>
    <label for="id_photo.0.caption">Photo Caption:</label>
    {{ form.photo.0.caption }}
    {% if form.photo.0.errors %}
      *** {{ form.photo.0.caption.errors|join:", " }}
    {% endif %}

    <label for="id_photo.0.filename_file">Photo Filename:</label>
    {{ form.photo.0.filename_file }}
    {% if form.photo.0.filename_file.errors %}
      *** {{ form.photo.0.filename_file.errors|join:", " }}
    {% endif %}

    {{ form.photo.0.filename }}

  </p>

<input type="submit" value="submit" />

</form>
#----------------------------------

Could someone please give me a push in the right direction on how I
would handle more than one photo. I tried to take a stab at it doing
this but it just failed silently...

#----------------------------------
    {% for photo in form.photo_set.all %}

        <label for="id_photo.{{ forloop.counter0 }}.caption">Photo
Caption:</label>
        {{ photo.caption }}
        {% if photo.caption.errors %}
          *** {{ photo.caption.errors|join:", " }}
        {% endif %}

        <label for="id_photo.{{ forloop.counter0
}}.filename_file">Photo Filename:</label>
        {{ photo.filename_file }}
        {% if photo.filename_file.errors %}
          *** {{ photo.filename_file.errors|join:", " }}
        {% endif %}

        {{ photo.filename }}

    {% endfor %}
#----------------------------------

I looked at the contrib/admin/templates, the wiki and docs and really
didn't come up with anything that describes how to handle this
situation. Any help will be greatly appreciated.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to