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

18 lines
615 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", "aliases", "player", "faction", "location",
"archived", "color", "token_image", "large_image"]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['player'].queryset = TenantUser.objects \
.filter(tenants=connection.get_tenant()) \
.exclude(pk__in=[1, 2])