Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ';ForeignRelatedObjectsDescriptor';对象没有属性';全部';_Python_Django - Fatal编程技术网

Python ';ForeignRelatedObjectsDescriptor';对象没有属性';全部';

Python ';ForeignRelatedObjectsDescriptor';对象没有属性';全部';,python,django,Python,Django,我正在将我的web应用程序移动到Django 1.7,我有一个非常奇怪的错误,也许你们中的一个知道正在发生 class Product(models.Model): title = models.CharField(max_lenght=100) slug = models.SlugField() content = models.TextField() class Gallery(models.Model): product = models.ForeignK

我正在将我的web应用程序移动到Django 1.7,我有一个非常奇怪的错误,也许你们中的一个知道正在发生

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收到以下错误消息:

'ForeignRelatedObjectsDescriptor' object has no attribute 'all'
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
尝试:

您需要在
产品
模型的特定实例上调用它,该实例应该是您的对象

context["galleries"] = self.object.images.all()