Python ModelMultipleChiceField-清除的\u数据没有值

Python ModelMultipleChiceField-清除的\u数据没有值,python,django-models,django-forms,choicefield,Python,Django Models,Django Forms,Choicefield,我想用帖子和标签制作一个简单的博客,但是我在从ModelMultipleEchoiceField添加标签时遇到了一个问题。。。调用.is_valid()后,已清理的_数据应具有选定的标记,但它不是 print(form.cleaned_data) 返回: {'description': u'xyz', 'title': u'xyz', 'haslo': u'', 'tags': None} 我尝试将其更改为简单的ChoiceField,并从表中进行初始选择,但结果相同 我的型号: 表格

我想用帖子和标签制作一个简单的博客,但是我在从ModelMultipleEchoiceField添加标签时遇到了一个问题。。。调用.is_valid()后,已清理的_数据应具有选定的标记,但它不是

print(form.cleaned_data) 
返回:

{'description': u'xyz', 'title': u'xyz', 'haslo': u'', 'tags': None}
我尝试将其更改为简单的ChoiceField,并从表中进行初始选择,但结果相同


我的型号:
表格:
和视图:
我刚从Django开始;/

即使是简单的HTML表单和从request.POST提取数据也不起作用。。。这是怎么回事?有人吗?某物
class Tag(models.Model):
    nazwa = models.CharField(max_length=24)

    def __str__(self):
        return self.nazwa

    def __unicode__(self):
        return self.nazwa

class Post(models.Model):
    tytul = models.CharField(max_length=200)
    skrocona_tresc = models.CharField(max_length=350, blank=True)
    tresc = models.TextField(blank=True)
    haslo = models.CharField(max_length=24, blank=True)
    data = models.DateTimeField(auto_now=False, auto_now_add=True)
    id_user = models.ForeignKey(User, on_delete=models.CASCADE)
    tags = models.ManyToManyField(Tag)
class PostAddForm(forms.ModelForm):
    title = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}),required=False)
    password = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control'}),required=False)
    description = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}),required=False)
    tags = forms.ModelMultipleChoiceField(queryset=Tag.objects.all(), required=False)
    class Meta:
        model = Post
        fields = [
            'title',
            'password',
            'description',
            'tags'
        ]
    def add_post(request):
    forma_PA = PostAddForm(request.POST or None)
    if request.is_ajax():
        if forma_PA.is_valid():
            post = forma_PA.save(commit=False)
            post.tresc = request.POST.get('html')
            post = Post(tytul=forma_PA.cleaned_data.get('title'),
                        id_user_id=request.user.id,
                        skrocona_tresc=forma_PA.cleaned_data.get('description'),
                        tresc=request.POST.get('html'),
                        haslo=forma_PA.cleaned_data.get('password'),
                        )
            post.save()
            tagi = forma_PA.cleaned_data['tags']
            print(forma_PA.cleaned_data)
            if(tagi):
                post.tags.add(tagi)
    context = {
        'form': forma_PA
    }
    return render(request, 'Blog/add_post.html', context)