小编BCA*_*BCA的帖子

VS 2015中的Stackoverflow异常但VS2010中却没有如何?

几年前在VS2010中编写了一个web服务项目,问题是所有代码完全相同(同样的PC,使用相同的代码对vs2010和2015进行测试),但在vs2015中,它在调试模式下出错.选项>"项目和解决方案"设置都相同.我接受了这个错误并定义了它;

System.Runtime.Serialization.dll中发生了未处理的"System.StackOverflowException"类型异常

System.StackOverflowException未处理消息:mscorlib.dll中发生未处理的类型'System.StackOverflowException'异常

任何人都有这个想法,我很高兴关注.我不能共享代码,因为它有近30,000行.

c# stack-overflow web-services visual-studio-2010 visual-studio-2015

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

Django将请求数据传递给Forms.py

场景;

我们有一个from字段,在窗体的内部有一个组合框,其中填充有项目。

我们有租约,每个用户都有TenantID,所以当A1用户(tenantid 1)调用创建表单时,我们需要使用查询过滤来过滤该组合框以仅过滤A1 UserItem。

其他租户也是如此。

我该如何通过那充满活力的tenantid。

顺便说一句,存储在抽象类django核心USER中的每个用户tenantid添加了新字段tenantid。我对此有任何建议,谢谢您的关注。

状态:解决!

Forms.py

class ItemForm(forms.ModelForm):
    class Meta:
        model = Items
        fields = ('id', 'item', 'start', 'end')
        widgets = {
            'start': DateTimePickerInput(format='%Y-%m-%d %H:%M'),
            'end': DateTimePickerInput(format='%Y-%m-%d %H:%M'),
        }

    def __init__(self, *args, **kwargs):
        super(ItemForm, self).__init__(*args, **kwargs)
        self.fields['item'].queryset = Items.objects.filter(tenantid=int(User.tenantid))
Run Code Online (Sandbox Code Playgroud)

views.py

@login_required()
def create_item_record(request):
    if request.method == 'POST':
        form = ItemForm(request.POST)
    if request.method == 'GET':
        tenantidX = request.user.tenantid
        form = ItemForm()
    return save_item_form(request, form, 'items_create_partial.html')
Run Code Online (Sandbox Code Playgroud)

django django-models django-forms python-3.x

4
推荐指数
2
解决办法
122
查看次数