每一個,,我使用get_success_url()到底需要3個參數(給定2)
Django的註冊 - 終極版(1.4)
我的Django的註冊(Django的1.8), ,然而,,當我從未註冊的網絡將顯示錯誤
,但在form_valid中的views.py,第43行它是編輯功能,它似乎不是關於寄存器?
views.py
@login_required
def edit_thing(request, slug):
# grab the object...
thing = ProductsTbl.objects.get(slug=slug)
if thing.user != request.user:
raise Http404
# set the form we're using...
form_class = ProductsTblForm
if request.method == 'POST':
# grab the data from the submitted form
form = form_class(data=request.POST,files=request.FILES,instance=thing)#**line 43**
if form.is_valid():
# save the new data
form.save()
return redirect('thing_detail', slug=thing.slug)
# otherwise just create the form
else:
form = form_class(instance=thing)
# and render the template
return render(request, 'things/edit_thing.html', {
'thing': thing,
'form': form,
})
urls.py
from django.conf.urls import patterns, url,include
from django.contrib import admin
from django.views.generic import TemplateView
from designer import views
from designer.backends import MyRegistrationView
from django.conf import settings
from django.contrib.auth.views import (
password_reset,
password_reset_done,
password_reset_confirm,
password_reset_complete,
)
....
urlpatterns = [
....
url(r'^accounts/register/$', MyRegistrationView.as_view(), name='registration_register'),
....
]
registration_form.html
<h1>Registration Form</h1>
<form role="form" action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
{% endblock content %}
,,雖然得到這個錯誤,,我的數據庫的用戶名和密碼,,,仍然寫道。 任何一個可以告訴我,爲什麼我得到這個錯誤,,非常感謝你
backends.py
from registration.backends.simple.views import RegistrationView
class MyRegistrationView(RegistrationView):
def get_success_url(self, request, user):
# the named URL that we want to redirect to after # successful registration
return ('home')
請出示** **全面追蹤,如文本,而不是圖像。 – Alasdair
我只是加了backends.py –