擅长:python、mysql、java
<p>处理get请求时,可以按以下方式执行:</p>
<pre><code>@login_required
def hero_detail_create_view(request):
if request.method == "POST":
form = HeroCreateModelForm(request.POST or None)
if form.is_valid():
obj = form.save(commit=False)
slugCreate = str.lower(form.cleaned_data.get('name') + "-" + form.cleaned_data.get('nickname'))
obj.slug = slugCreate.replace(" ","")
obj.user = request.user
obj.save()
return redirect('your_home_page')
else:
form = HeroCreateModelForm()
return render(request, 'form.html', {'form':form})
</code></pre>