I fiddled around with the django ImageField
,
and I got following models for example
class Card(models.Model):
name = models.TextField()
mana = models.IntegerField()
rarity = models.IntegerField(choices=RARITY_CHOICES)
card_class = models.IntegerField(choices=CLASS_CHOICES)
card_set = models.IntegerField(choices=SET_CHOICES)
card_type = models.IntegerField(choices=TYPE_CHOICES)
def __unicode__(self):
return self.name
class Weapon(Card):
damage = models.already created a deck with some cards in the django admin interface. Now finally I wanted to render it with a custom view in my template with this viewIntegerField()
durability = models.IntegerField()
image = models.ImageField(upload_to='/home/ubuntu/illuminated/media/images/weapons/')
class Deck(models.Model):
name = models.CharField(max_length=20)
spell_cards = models.ManyToManyField(Spell, blank=True)
weapon_cards = models.ManyToManyField(Weapon, blank=True)
minion_cards = models.ManyToManyField(Minion, blank=True)
I already created a deck with some cards in the django admin interface. Now finally I wanted to render it with a custom view in my template with this view
class ShowDeck(TemplateView):
template_name = 'hsguides/deck.html'
def get_context_data(self, **kwargs):
context = super(ShowDeck, self).get_context_data(**kwargs)
context['deck'] = Deck.objects.all()
return context
And this simple template already created a deck with some cards in the django admin interface. Now finally I wanted to render it with a custom view in my template with this view
{% for foo in deck.all %}
{{ foo.name }}
<br>
{% for weapon in foo.weapon_cards.all %}
{{ weapon.name }}
<img src="{{ weapon.image }}" height="{{ weapon.image.height }}" width="{{ weapon.image.width }}">
{% endfor %}
{% endfor %}
The names are getting rendered, and when I have a look at the page source the image url, width and height as well but the image simply does not show up.
When I click on View Image in my browser I see the following error
Using the URLconf defined in illuminated.urls, Django tried these URL patterns, in this order:
^admin/ ^account/ ^guides/
The current URL, home/ubuntu/illuminated/media/images/weapons/Truesilver_Champion_Gold_ktmWGK8.png, didn't match any of these
It currently looks like this
The page source looks like this
Basic Paladin
<br>
Truesilver Champion
<img src="/home/ubuntu/illuminated/media/images/weapons/Truesilver_Champion_Gold_ktmWGK8.png" height="396" width="289">
Any kind of help is highly appreciated!