如何为石墨烯-django中的react-relay创建一个查看器字段?这并不像预期的那样工作。我使用的是石墨烯-django v.2.2。Django 2.1。React-relay v1.7.0-rc.1。
// landingpage.schema.py
class CollectionNode(DjangoObjectType):
class Meta:
model = Collection
interfaces = (relay.Node, )
class Viewer(graphene.ObjectType):
class Meta:
inter
我使用django和django石墨烯来生成graphql。
在我的应用程序中,我使用reactJS和。React引导表期望我为它传递一个对象数组,但不支持。
我在schema.py中创建了查询
class ApplicationNode(DjangoObjectType):
class Meta:
model = Application
filter_fields = ['name', 'sonarQube_URL']
interfaces = (relay.Node,)
class Query(Obj
我有一个Django Log模型,它具有多对一的User。
from django.db import models
class Log(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
...
我有一个Log的Django表单
from django.forms import ModelForm
class LogForm(ModelForm):
class Meta:
model = Log
exclude = ("user
我正在使用石墨烯- Django,我想创建四个接口,每个接口都代表Django中的模型,我将从一个模型开始:
class TestInterface(graphene.Interface):
items = graphene.Field(models.Test)
但是我不断地发现这个错误:
AttributeError: type object 'Test' has no attribute 'name'
有什么想法吗?
我想测试我的graphql突变,它应该只设置一个HTTP cookie。
我使用石墨烯-django
class CookieTest(GraphQLTestCase):
def test_set_cookie(self):
response = self.query(...) # This should return WSGIRequest
cookie = response.COOKIES.get('myCookie') # This line throws an attrib error
self.assertIsNotNone(cookie)
我使用石墨烯和石墨烯-mongo。我的graphql模式有一个类似如下的类型: type Report {
id:ID!
name:String!
} 我针对这种类型的石墨烯类是 class Product(MongoengineObjectType):
class Meta:
model = MongoProduct 而mongoengine类是 class MongoProduct(mng.DynamicDocument):
name = mng.fields.StringField(required=True) 如何将该字段
我正在为GraphQL使用石墨烯-django框架。除外键外,我可以检索的所有字段
# models.py
from django.db import models
from django.contrib.auth.models import User
from users.models import UserProfile
class Video(models.Model):
title = models.TextField()
description = models.TextField()
author = models.ForeignKey(User, on
我正在用中继从:进行过滤的石墨烯教程,其中用户仅限于查询他们以前创建的对象。我使用石墨烯2,django 2和django-过滤器1.11.
class AnimalFilter(django_filters.FilterSet):
# Do case-insensitive lookups on 'name'
name = django_filters.CharFilter(lookup_expr=['iexact']) #changed this to work
class Meta:
model = Animal
我正在使用石墨烯处理以django为后端的应用程序中的突变。我写了以下突变:
import graphene
from django.db import transaction
from graphql_jwt.decorators import login_required
from app1.enums import SomeOptions
from app1.models import SomeModel
from app2.utils.some_api import SomeApi
class SetOtherAppConfig(graphene.Mutation):
u
我正在尝试使用graphene-django,并且对"six“包有一些问题。它已经安装了,但它是作为自己的软件包安装的,而且graphene-django似乎希望在django.utils下安装它 File "C:\Users\mjnic\.virtualenvs\phoenix-demo-C42C_PgQ\lib\site-packages\graphene_django\settings.py", line 18, in <module>
from django.utils import six
ImportError: cannot im
我阅读了关于如何在解析器中使用和其他装饰器的说明。但是,如果不使用显式解析器(而是使用默认解析器),如何实施类似的访问控制?
在我的例子中,我将石墨烯与Django用户模型一起使用。我有以下几点:
class UserNode(DjangoObjectType):
class Meta:
model = User
filter_fields = ['first_name', 'last_name', 'id', 'email']
interfaces = (Node, )