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
One always has time enough, if one will apply it well.
open.html
URL
forms.py
Django
forms.Form
form django import forms class UrlForm(forms.Form): url = forms.CharField() urls = forms.CharField(required=False, widget=forms.Textarea) def __unicode__(self): return self.url
widget
urls
CharField
forms.ModelForm
Model
ModelForm
from django import forms from .models import Url class UrlForm(forms.ModelForm): class Meta: model = Url fields = ('url', 'urls')
Url
TextField
views.py
HTTP
POST
from django.shortcuts import render from .forms import UrlForm def url_sql(request): if request.method == 'POST': form = UrlForm(request.POST) if form.is_valid(): url = form.save(commit=False) url.save() form.save() else: form = UrlForm() return render(request, 'sqliscan/open.html', {'form': form})
csrf_token
The text was updated successfully, but these errors were encountered:
No branches or pull requests
0x01 DSScan
open.html
URL
至数据库 ,所以新建forms.py
表单函数forms.py
Django
中表单提供了两种创建表单的方式forms.Form
widget
定义urls
为多行表单(默认CharField
为单行)forms.ModelForm
Model
,那么可以用forms.ModelForm
来节省大量代码(即:数据模型中的字段恰好都需要表单来提交时,使用ModelForm
即可节省代码)forms.ModelForm
也支持自定义表单的属性urls
即数据模型Url
函数中定义的TextField
,无需widget
定义多行URL
保存至数据库,用第一种方式自定义创建表单即可views.py
HTTP
以POST
方式提交,那么就将表单内容保存至数据库open.html
就需要显示这个表单open.html
csrf_token
The text was updated successfully, but these errors were encountered: