Hello all,

I have made a variation to an Item class in models.py and I think i got the 
template syntax right but apparently there are something wrong which i 
can't figure it out

Here is the model

class Item(models.Model):
    title = models.CharField(max_length=100)
    description = models.TextField()
    price = models.FloatField()
    slug = models.SlugField(unique=True)
    image = models.ImageField(blank=False, upload_to='approved designs')


    def __str__(self):
        return self.title

    class Meta:
        unique_together = ('title', 'slug')
class Variation(models.Model):
    item = models.ForeignKey(Item, on_delete=models.CASCADE)
    title = models.CharField(max_length=120)
    image = models.ImageField(null=True, blank=True)
    price = models.FloatField(null=True, blank=True)

    def __str__(self):
        return self.title

and here is the template

                        {% if item.variation_set.all %}
                        <select class='form-control' name='size'>
                            {% for items in item.variation_set.all %}
                            <option 
value='{item.variation|lower}'>{{title.title|capfirst}}</option>
                            {% endfor %}
                        </select>
                        {% endif %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4df44e82-6d21-4f41-be78-ba72d9d60c4f%40googlegroups.com.

Reply via email to