在泛型“create\u object”视图后操纵对象(python/Django)

2024-04-23 23:19:04 发布

您现在位置:Python中文网/ 问答频道 /正文

是否可以手动将字段条目添加到使用常规视图创建的对象中?你知道吗

例如

from django.views.generic.create_update import create_object

def create_thing(request):

    queryset = Things.objects.all()

    #Somehow pass something to tell the view to
    #assign Thing.author=request.user...

    return create_object(
        request,
        queryset,
        form_class = ThingForm,
        template_name = 'thing_template.html',
        )

助教!你知道吗


Tags: to对象djangofrom视图objectrequestcreate
1条回答
网友
1楼 · 发布于 2024-04-23 23:19:04

抱歉,没有。你必须写你自己的观点。你知道吗

Here's the source-您可以看到没有回调或任何东西,也没有任何东西可以传递给请求双方(因此您可以访问请求用户)以及可以重写以执行赋值的新对象。你知道吗

相关问题 更多 >