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

19 lines
646 B
Python
Raw Normal View History

from django.db import connection
2021-08-29 22:09:22 +02:00
from django.forms import ModelForm
from characters.models import Character
from users.models import TenantUser
2021-08-29 22:09:22 +02:00
class CharacterForm(ModelForm):
class Meta:
model = Character
2022-06-19 14:37:32 +02:00
fields = ["name", "description_md", "aliases", "subtitle", "player", "faction", "location",
2022-06-19 13:53:21 +02:00
"archived", "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])