mirror of
https://github.com/Hopiu/django-select2.git
synced 2026-03-16 21:40:23 +00:00
53 lines
1.1 KiB
Python
53 lines
1.1 KiB
Python
# -*- coding:utf-8 -*-
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
from django import forms
|
|
|
|
from django_select2.fields import Select2MultipleWidget
|
|
|
|
from tests.testapp import models
|
|
from . import fields
|
|
|
|
|
|
class GenreModelForm(forms.ModelForm):
|
|
class Meta:
|
|
model = models.Genre
|
|
fields = (
|
|
'title',
|
|
)
|
|
|
|
|
|
class GenreForm(forms.Form):
|
|
title = forms.CharField(max_length=50)
|
|
|
|
|
|
class ArtistModelForm(forms.ModelForm):
|
|
test = forms.BooleanField('asdf')
|
|
class Meta:
|
|
model = models.Artist
|
|
fields = (
|
|
'title',
|
|
'genres',
|
|
)
|
|
widgets = {
|
|
'genres': Select2MultipleWidget
|
|
}
|
|
|
|
|
|
class ArtistForm(forms.Form):
|
|
title = forms.CharField(max_length=50)
|
|
genres = fields.GenreTagField()
|
|
|
|
|
|
class AlbumModelForm(forms.ModelForm):
|
|
class Meta:
|
|
model = models.Album
|
|
fields = (
|
|
'title',
|
|
'artist',
|
|
)
|
|
|
|
|
|
class AlbumForm(forms.Form):
|
|
title = forms.CharField(max_length=255)
|
|
artist = fields.ArtistField()
|