I'm moving my web application to Django 1.7 and I have a very curious mistake, perhaps one of you know is happening.
class Product(models.Model):
title = models.CharField(max_lenght=100)
slug = models.SlugField()
content = models.TextField()
class Gallery(models.Model):
product = models.ForeignKey(Product, related_name="images")
original = models.ImageField()
class MyView(DetailView):
model = Product
def get_context_data(self, **kwargs):
....
# My error is here, when use this context and parse template
context["galleries"] = Product.images.all()
Givin the following error message:
'ForeignRelatedObjectsDescriptor' object has no attribute 'all'
response = wrapped_callback(request, *callback_args, **callback_kwargs)
Try:
context["galleries"] = self.object.images.all()
You'll want to call it on a specific instance of your Product
model, which should be your object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With