Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update extension app to include a M2M
- Loading branch information
1 parent
d519cdd
commit a0f030c
Showing
1 changed file
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
from cms.extensions import PageExtension, TitleExtension | ||
from cms.extensions.extension_pool import extension_pool | ||
from django.contrib.auth.models import User | ||
from django.db import models | ||
|
||
class MyPageExtension(PageExtension): | ||
extra = models.CharField(blank=True, default='', max_length=255) | ||
favorite_users = models.ManyToManyField(User, blank=True, null=True) | ||
|
||
def copy_relations(self, other, language): | ||
for favorite_user in other.favorite_users.all(): | ||
favorite_user.pk = None | ||
favorite_user.mypageextension = self | ||
favorite_user.save() | ||
|
||
extension_pool.register(MyPageExtension) | ||
|
||
|
||
class MyTitleExtension(TitleExtension): | ||
extra_title = models.CharField(blank=True, default='', max_length=255) | ||
|
||
|
||
extension_pool.register(MyTitleExtension) |