请解释if语句中我从朋友的项目中提取的三行内容。
from django import forms
from posts import models
class PostForm(forms.ModelForm):
class Meta:
fields = ("message", "group")
model = models.Post
def __init__(self, *args, **kwargs):
user = kwargs.pop("user", None)
super().__init__(*args, **kwargs)
if user is not None:
self.fields["group"].queryset = (
models.Group.objects.filter(
pk__in=user.groups.values_list("group__pk")
)
)