-
使用
CreateView
時,您可以訪問self.object
,這是正在創建的對象。如果尚未創建對象,則值為None
。
本文介紹 django.views.generic.edit.CreateView.object
的用法。
聲明
object
示例 myapp/views.py:
from django.views.generic.edit import CreateView
from myapp.models import Author
class AuthorCreateView(CreateView):
model = Author
fields = ['name']
示例 myapp/author_form.html:
<form method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save">
</form>
相關用法
- Python Tableau CSVRequestOptions用法及代碼示例
- Python Django ContentTypeManager用法及代碼示例
- Python Calendar itermonthdays2()用法及代碼示例
- Python Condition release()用法及代碼示例
- Python Collections.UserString用法及代碼示例
- Python Calendar monthdatescalendar()用法及代碼示例
- Python Condition notify()用法及代碼示例
- Python CSV轉JSON用法及代碼示例
- Python Django ContextMixin.get_context_data用法及代碼示例
- Python Django CustomUserManager.create_user用法及代碼示例
- Python Condition wait()用法及代碼示例
- Python Django Coalesce用法及代碼示例
- Python Calendar itermonthdates()用法及代碼示例
- Python Calendar iterweekdays()用法及代碼示例
- Python Django Client用法及代碼示例
- Python Django CustomUserManager.create_superuser用法及代碼示例
- Python Django Cot用法及代碼示例
- Python Calendar monthdayscalendar()用法及代碼示例
- Python Django Client.get用法及代碼示例
- Python Calendar itermonthdays3()用法及代碼示例
- Python Django Ceil用法及代碼示例
- Python Sympy Curve.translate()用法及代碼示例
- Python Collections.UserDict用法及代碼示例
- Python Django CursorWrapper.callproc用法及代碼示例
- Python Celsius轉Fahrenheit用法及代碼示例
注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.views.generic.edit.CreateView.object。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。