We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
老师,您好: 作者这个字段是不能为空的,所以PostInline 这个类,定义完之后,如果直接编辑标题和摘要就提交是会报错,owner_id 不能为空的。 我想要提交的时候直接能够把当前用户提交上去,但是在这个admin.TabularInline父类中是没有关于save方法的。
The text was updated successfully, but these errors were encountered:
在CategoryAdmin中添加以下函数代码:
def save_formset(self, request, form, formset, change): """ 修改关联对象数据 """ instances = formset.save(commit=False) for instance in instances: if not hasattr(instance, 'owner'): # 防止误修改其他文章的作者 instance.owner = request.user # 给owner字段赋值 instance.save() formset.save_m2m()
Sorry, something went wrong.
No branches or pull requests
老师,您好:
作者这个字段是不能为空的,所以PostInline 这个类,定义完之后,如果直接编辑标题和摘要就提交是会报错,owner_id 不能为空的。
我想要提交的时候直接能够把当前用户提交上去,但是在这个admin.TabularInline父类中是没有关于save方法的。
The text was updated successfully, but these errors were encountered: