Django Invitation app链接到其他模特

时间:2017-09-07 07:39:02

标签: django django-models django-forms django-templates django-rest-framework

) 我正在尝试安装和配置允许发送邮件邀请的外部应用程序(https://github.com/bee-keeper/django-invitations)。我的目标是通过向他们发送邮件加入应用程序的邀请,邀请团队成员加入我的应用团队。

我管理(帮助)使其工作并发送电子邮件,我希望现在将这些邮件附加到另一个模型,即团队模型并创建一个新团队。 事情已经发生 - 直到团队成员登录才有我的应用程序的用户...所以我不知道如何让它工作..

这是我的views.py

from django.shortcuts import render
from django.views.generic import TemplateView
from .forms import InviteForm
from invitations.models import Invitation

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']
            for i in invite_form.cleaned_data:
                invite = Invitation.create(i)
                invite.send_invitation(request)
            print("The mail was went")
        else:
            print("Your form is not valid")
    else:
        invite_form = InviteForm()
    return render(request, 'HRIndex.html', {'invite_form': invite_form}) 

这是我的model.py

来自django.db导入模型

class Team(models.Model):
    team_name = models.CharField(max_length=150)


class TeamMembers(models.Model):
    team = models.ForeignKey(Team)
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)
    email = models.EmailField()

非常感谢你的帮助

0 个答案:

没有答案