Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. class Image(models.Model):
  2. image = models.ImageField(
  3. upload_to='images/',
  4. height_field='height',
  5. width_field='width'
  6. )
  7. credit = models.CharField(max_length=50, blank=True)
  8. caption = models.TextField(blank=True)
  9. article = models.ForeignKey(Article)
  10. width = models.PositiveIntegerField(
  11. blank = True, null = True,
  12. editable = False,
  13. default = 0
  14. )
  15. height = models.PositiveIntegerField(
  16. blank = True, null = True,
  17. editable = False,
  18. default = 0
  19. )
  20.  
  21. <ul>
  22. {% for image in article.image_set.all %}
  23. <li>Caption: "{{image.caption}}", Credit: "{{image.credit}}", URL: "{{image.url}}"</li>
  24. {% endfor %}
  25. </ul>
  26.  
  27. <ul>
  28.  
  29. <li>Caption: "here's an image caption", Credit: "some photographer", URL: ""</li>
  30.  
  31. <li>Caption: "Another caption here", Credit: "Another photographer", URL: ""</li>
  32.  
  33. </ul>
  34.  
  35. <ul>
  36. {% for image in article.image_set.all %}
  37. <li>Caption: "{{ image.caption }}", Credit: "{{ image.credit }}", URL: "<a href ='/{{ image.image }}'{{ image.image }}</a>"</li>
  38. {% endfor %}
  39. </ul>
  40.  
  41. STATICFILES_DIRS = (
  42. os.path.join(BASE_DIR, 'static'),
  43. )
  44.  
  45. BASE_DIR = os.path.dirname(os.path.dirname(__file__))
  46.  
  47. {% static image.image.url %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement