Hi everyone,

I've encountered a problem where, in my admin, when I upload an image,
I get another slot to upload, but once I upload, the new image
replaces the original image I created. I tried searching for a
solution to this, but to no avail. Can someone explain to me why this
happens and how I can fix this?

My model is:

class Project(models.Model):
  pict = models.ImageField(upload_to='images/')
  title = models.CharField(maxlength=50)
  overview = models.TextField()

  class Admin:
    list_display = ('title', 'overview',)

class Picture(models.Model):
  project = models.ForeignKey(Project, edit_inline=models.TABULAR)
  picture = models.ImageField(upload_to='images/')
  caption = models.CharField(maxlength=50)

Also, it would be great if you guys could show me a more efficient way
to do this: for each project, I would like to more than 10 pictures
and a caption associated with each picture. Then I want to display it
2 by 2. I passed to my template the context proj
(get_object_or_404(Project, id=object_id)) and pict
(get_object_or_404(Picture, id=object_id)). In my template, I wrote a
for loop that'd display images like so:

<table>
  <tr>
{% for picture in proj.picture_set.all %}
  <td>
    <img src="{{picture.get_picture_url}}" width=80% height=80% /><br /
>
    {{pict.caption}}
  </td>
  {% ifequal forloop.counter 2 %}
    </tr><tr>
  {% endifequal %}
{% endfor %}
  </tr>
</table>

As you can see, I want to end the table row everytime the
forloop.counter is even, but I cannot write code for this is a .html
template file, so I have to temporarily settle for this fix. That's 1
problem, the other is that only one caption gets displayed for all
images shown, and I can see why because pict.caption never iterates.
How can I display images along with their distinct caption?

Thank you in advance,

robo.


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

Reply via email to