Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Image(models.Model):
- image = models.ImageField(
- upload_to='images/',
- height_field='height',
- width_field='width'
- )
- credit = models.CharField(max_length=50, blank=True)
- caption = models.TextField(blank=True)
- article = models.ForeignKey(Article)
- width = models.PositiveIntegerField(
- blank = True, null = True,
- editable = False,
- default = 0
- )
- height = models.PositiveIntegerField(
- blank = True, null = True,
- editable = False,
- default = 0
- )
- <ul>
- {% for image in article.image_set.all %}
- <li>Caption: "{{image.caption}}", Credit: "{{image.credit}}", URL: "{{image.url}}"</li>
- {% endfor %}
- </ul>
- <ul>
- <li>Caption: "here's an image caption", Credit: "some photographer", URL: ""</li>
- <li>Caption: "Another caption here", Credit: "Another photographer", URL: ""</li>
- </ul>
- <ul>
- {% for image in article.image_set.all %}
- <li>Caption: "{{ image.caption }}", Credit: "{{ image.credit }}", URL: "<a href ='/{{ image.image }}'{{ image.image }}</a>"</li>
- {% endfor %}
- </ul>
- STATICFILES_DIRS = (
- os.path.join(BASE_DIR, 'static'),
- )
- BASE_DIR = os.path.dirname(os.path.dirname(__file__))
- {% static image.image.url %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement