Wednesday, March 2, 2016

Re: Absolute beginner question -- recipes

Inspired by Mike Dewhirsts suggestion on building hierachical structures, I've made up another model:
class Part(models.Model):
    parts
= models.ForeignKey('Part', null=True, blank=True, default=None, related_name='pieces')
    name
= models.CharField(max_length=200)

Then I made my view:
class PartsView(generic.ListView):
    context_object_name
='parts'
    model
=Part

But how should I design my template now?
<h1>Parts</h1>

<ul>
{% for part in parts %}
 
<li></li>
{% endfor %}
</ul>

I already found different answers on the net reaching from 'impossible' to 'with-tag' or 'install some add-ons'. According to Mikes former suggestion, I expected something easy and elegant here ...

regards, Simon


--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/abcfeada-4bd6-496f-a3f8-4678b08d8440%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment