my code follwing : in views.py:
class projectdetailview(generic.detailview): model = project template_name = 'project_details.html' class projectcreate(createview): model = project fields = ['project_name'] template_name = 'project_form.html' def create_invite(request): if request.method == "post": invite_form = inviteform(data=request.post) if invite_form.is_valid(): email1 = invite_form.cleaned_data['email1'] email2 = invite_form.cleaned_data['email2'] email3 = invite_form.cleaned_data['email3'] email4 = invite_form.cleaned_data['email4'] email5 = invite_form.cleaned_data['email5'] in invite_form.cleaned_data: invite = invitation.create(i) invite.send_invitation(request) print("the mail went") return reverse('website:projectdetails', kwargs = {'pk' : project.pk} ) else: print("your form not valid") else: invite_form = inviteform() return render(request, 'team_invite.html', {'invite_form': invite_form})
in form.py:
from django import forms class inviteform(forms.form): email1 = forms.emailfield(label='email 1') email2 = forms.emailfield(label='email 2') email3 = forms.emailfield(label='email 3') email4 = forms.emailfield(label='email 4') email5 = forms.emailfield(label='email 5')
urls.py:
from django.conf.urls import url website import views app_name = 'website' urlpatterns = [ url(r'^candidateindex/$', views.candidateindex.as_view(), name='candidate_index'), url(r'^hrcreate/$', views.projectcreate.as_view(), name='hr_create'), url(r'^project/(?p<pk>[0-9]+)/$',views.projectdetailview.as_view(), name='projectdetails'), url(r'^project/add/$',views.projectcreate.as_view(), name='addproject'), url(r'^invite/$',views.create_invite, name='addteam'), ]
like can see: have form send email invites user. using form have 2 issues :
1) seems instead of taking value in input email, seems take variable email1 or email2 ect..
2) when try redirect detail page using project pk error:
django.urls.exceptions.noreversematch: reverse 'projectdetails' keyword arguments '{'pk': <property object @ 0x10ecf79a8>}' not found. 1 pattern(s) tried: ['website/project/(?p<pk>[0-9]+)/$']
any ideas ?
Comments
Post a Comment