You still can reference the data:
class Foo(models.Model):
pass
class Bar(models.Model):
foo = models.ForeignKey(Foo, related_name='bars')
f = Foo()
b1 = Bar(foo=f)
b2 = Bar(foo=f)
f.bars.all() #
> On 9 Aug 2017, at 18:19, Thomas Hughes wrote:
>
>
Thank you for your reply.
I understand your third point. In this application though I have a many
images to a single detail structure.
For your first point "use `related_name` in your model fields to get pretty
backref names (so you don't have to use image_set everywhere)", how do I do
that
Whoops, looks like all dots are in place, my mistake. First and last points are
still valid, though.
> On 9 Aug 2017, at 16:08, Александр Христюхин (roboslone)
> wrote:
>
> Hi,
>
> First of all, you can use `related_name` in your model fields to get pretty
> backref
Hi,
First of all, you can use `related_name` in your model fields to get pretty
backref names (so you don't have to use image_set everywhere).
Second, you're missing dots in your template (`for detail in
project.projectdetail_set.all`).
And finally, your model is called ProjectDetailImage and
Just FYI - the issue was with using 'image.url' rather than
'image.image.url' in code labeled with 'do something with image' in the
HTML template above.
On Monday, August 7, 2017 at 3:52:15 PM UTC-4, Thomas Hughes wrote:
>
> I have a generic detail view serving content for 'project' to an HTML
I have a generic detail view serving content for 'project' to an HTML
template with the following code:
{% for detail in project.projectdetail_set.all %}
{% for image in detail.projectdetailimage_set.all %}
do something with image
{% endfor %}
{% endfor %}
and my models look
6 matches
Mail list logo