小编2 8*_*2 8的帖子

如何在django中为我的模型设置两个字段主键

我有这样的模型:

class Hop(models.Model):
    migration = models.ForeignKey('Migration')
    host = models.ForeignKey(User, related_name='host_set')
Run Code Online (Sandbox Code Playgroud)

我想迁移和托管两者是主键.

python django model primary-key django-models

47
推荐指数
3
解决办法
4万
查看次数

在QML中为其他QML文件声明全局属性

我想在配置文件中声明一个全局属性,并在其他文件中使用它.例如声明mainbg:

Style.qml:

property color mainbg: 'red'
Run Code Online (Sandbox Code Playgroud)

并在其他QML文件(如view.qmlmain.qml)中使用它.我该怎么做这个工作?

variables qt scope global-variables qml

24
推荐指数
4
解决办法
3万
查看次数

withRef被删除.要访问包装的实例,请在连接的组件上使用ref

我想使用ref从连接组件调用一个函数,所以我之前withRef: true在连接组件中使用过:

export default connect(
  mapStateToProps,
  mapDispatchToProps, null, {withRef: true})(InviteReceiverForm)
Run Code Online (Sandbox Code Playgroud)

并在表示部分:

<ExampleComponent ref={
   cmp => { if (cmp) { this.invdividualSenderFormRef = cmp.getWrappedInstance() } } />
Run Code Online (Sandbox Code Playgroud)

更新到react-redux6后,我收到此错误:

 withRef is removed. To access the wrapped instance, use a ref on the connected component
Run Code Online (Sandbox Code Playgroud)

如何在react-redux 6中使用ref?

javascript reactjs redux react-redux

24
推荐指数
2
解决办法
1万
查看次数

在QML中加载页面时运行javascript函数

我想像这样运行js函数

function setPersonalInfoValue(){
        console.debug("setPersonalInfoValue()");
    }
Run Code Online (Sandbox Code Playgroud)

当页面加载QML时.

我试过这个:

Rectangle {
    id: page2
    width: 100
    height: 62

    function setPersonalInfoValue(){
        console.debug("setPersonalInfoValue()");
    }
}
Run Code Online (Sandbox Code Playgroud)

我想在第1页到第2页之间切换时运行setPersonalInfoValue()函数.我该怎么做?

javascript qt qml

16
推荐指数
2
解决办法
1万
查看次数

unrar如何用python文件

如果file是a .zip和unrar文件,如果我的文件类型是,我可以解压缩文件.rar.我如何使用python 2.7完成这项工作?

python unzip unrar python-2.7

11
推荐指数
4
解决办法
4万
查看次数

IntegrityError:"city_id"列中的空值违反非空约束

我两个型号:

class City(models.Model):
    name = models.CharField(max_length=50)
    country = models.OneToOneField(Country)

    def __unicode__(self):
        return self.name 


class UserProfile(models.Model):
    user = models.OneToOneField(User)
    city = models.OneToOneField(City)
Run Code Online (Sandbox Code Playgroud)

当我syncdb并创建管理员用户时:

IntegrityError: null value in column "city_id" violates not-null constraint
Run Code Online (Sandbox Code Playgroud)

我怎么能修复这个错误?

python django models

9
推荐指数
1
解决办法
2万
查看次数

ReferenceError:QML中未定义"something"

我有这样的Main.qml文件:

import QtQuick 2.0    

Rectangle {
    color: ggg.Colors.notificationMouseOverColor
    width: 1024
    height: 768
}
Run Code Online (Sandbox Code Playgroud)

在python文件中,我有这个(我使用形式PyQt5):

App = QGuiApplication(sys.argv)
View = QQuickView()
View.setSource(QUrl('views/sc_side/Main.qml'))
Context = View.rootContext()

GlobalConfig = Config('sc').getGlobalConfig()
print (GlobalConfig, type(GlobalConfig))
Context.setContextProperty('ggg', GlobalConfig)

View.setResizeMode(QQuickView.SizeRootObjectToView)
View.showFullScreen()
sys.exit(App.exec_())
Run Code Online (Sandbox Code Playgroud)

这个python代码打印这个配置:

{'Colors': {'chatInputBackgroundColor': '#AFAFAF', 'sideButtonSelectedColor': '#4872E8', 'sideButtonTextColor': '#787878', 'sideButtonSelectedTextColor': '#E2EBFC', 'sideButtonMouseOverColor': '#DDDDDD', 'buttonBorderColor': '#818181', 'notificationMouseOverColor': '#383838', }} <class 'dict'>
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,我的矩形颜色正确更改,但我有这个错误:

file:///.../views/sc_side/Main.qml:6: ReferenceError: ggg is not defined
Run Code Online (Sandbox Code Playgroud)

但我不知道为什么会发生这种错误,我怎么能解决这个错误?

python qt qml python-3.3 pyqt5

9
推荐指数
2
解决办法
7076
查看次数

uWSGI错误hr_instance_read():由对等方重置连接

我使用uWSGI和NGINX作为反向代理部署了一个烧瓶Web应用程序.应用程序响应时间平均约为9毫秒,但在一批请求后,我的工作程序崩溃,并且我在uWSGI日志中记录了这个日志:

[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 24488] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 4059] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 46764] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 9951] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 9449] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: …
Run Code Online (Sandbox Code Playgroud)

python nginx uwsgi

9
推荐指数
1
解决办法
624
查看次数

对象没有属性'__getitem__'

我有两个这样的模型:

class School(models.Model):
    name = models.CharField(max_length = 50)

    def __unicode__(self):
        return self.name 

class Education(models.Model):
    user_profile = models.ForeignKey(UserProfile, related_name='Education')
    school = models.OneToOneField(School)

    def __unicode__(self):
        return self.school
Run Code Online (Sandbox Code Playgroud)

当我想用django管理员向userprofile添加教育这个错误eccour:

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper
  372.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
  202.             return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
  25.             return …
Run Code Online (Sandbox Code Playgroud)

python django model admin

8
推荐指数
1
解决办法
3万
查看次数

可插拔的跨平台软件设计,用于本机反应和本机反应

我想设计一个可跨平台(Android,iOS和Web)插件的软件,这意味着每个人都可以轻松地为其开发插件,并且用户可以从市场上选择插件并进行安装。每个插件都可以:

  • 与核心应用程序在后端共享数据
  • 在Apps和Web中拥有一个自定义UI,理想情况下,它使用标准UI-kit来保持一致性(例如Shopify polaris

在后端,在软件设计中有许多最佳实践,例如OAuth。但是在前端,问题并不简单:

  1. 是否有任何跨平台的UI-kit用于react和react-native?例如,使用Expo v33 +或ReactNativeWeb,我们可以为android / ios和web构建代码,但是我找不到任何跨平台的UI-kit。(NativeBaseElements或类似的跨平台UI- kit仅适用于Android和iOS)

  2. 在前端中,插件如何使用react和react-native(或理想情况下跨平台的UI套件)共享UI,以某种方式动态呈现在内核中(无需任何更新,例如,插件提供一个端点并返回一个react / native组件,核心将渲染它)

软件架构

architecture software-design reactjs react-native expo

8
推荐指数
1
解决办法
204
查看次数