You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB
Python

from django import forms
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.snippets.models import register_snippet
from wagtail.images.models import Image
from wagtail.images.edit_handlers import ImageChooserPanel
from modelcluster.fields import ParentalManyToManyField
from wagtail.core.models import Page
class HomePage(Page):
profiles = ParentalManyToManyField('home.Profile', blank=True)
content_panels = [
FieldPanel('profiles', widget=forms.CheckboxSelectMultiple),
]
@register_snippet
class Profile(models.Model):
name = models.CharField(max_length=80)
profile_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
caption = models.CharField(max_length=255)
panels = [
FieldPanel('name'),
ImageChooserPanel('profile_image'),
FieldPanel('caption'),
]
def __str__(self):
return self.name
def __repr__(self):
return self.name
class Meta:
verbose_name = "Profile"
verbose_name_plural = "Profiles"