1
0
Fork 0
mirror of https://github.com/Findus23/RPGnotes.git synced 2024-09-19 15:43:45 +02:00
RPGnotes/characters/forms.py
2021-10-03 16:44:54 +02:00

18 lines
635 B
Python

from django.db import connection
from django.forms import ModelForm
from characters.models import Character
from users.models import TenantUser
class CharacterForm(ModelForm):
class Meta:
model = Character
fields = ["name", "description_md", "nickname", "subtitle", "player", "faction", "location", "color",
"token_image", "large_image"]
def __init__(self, *args, **kwargs):
super(CharacterForm, self).__init__(*args, **kwargs)
self.fields['player'].queryset = TenantUser.objects \
.filter(tenants=connection.get_tenant()) \
.exclude(pk__in=[1, 2])