Conflict model when create custom Notification inherit from AbstractNotification.
See original GitHub issueLike document purpose, I already need to add category to filter notification based on category but when I create custom class inherit form AbstractNotification, django raise exceptions…
# models.py
from django.db import models
from django.utils.translation import gettext_lazy as _
from notifications.base.models import AbstractNotification
class Notification(AbstractNotification):
class Meta(AbstractNotification.Meta):
abstract = False
CHOICES_CATEGORY_EVENT = 'EVENT'
CHOICES_CATEGORY_WORK = 'WORK'
CHOICES_CATEGORY_COMMENT = 'COMMENT'
CHOICES_CATEGORY_URGENT = 'URGENT'
CHOICES_CATEGORY_COMPANY = 'COMPANY'
CHOICES_CATEGORIES = (
(CHOICES_CATEGORY_EVENT, _('Event')),
(CHOICES_CATEGORY_WORK, _('Work')),
(CHOICES_CATEGORY_COMMENT, _('Comment')),
(CHOICES_CATEGORY_URGENT, _('Urgent')),
(CHOICES_CATEGORY_COMPANY, _('Company')),
)
category = models.CharField(
max_length=63,
choices=CHOICES_CATEGORIES,
default=None,
null=True,
blank=True,
)
Exception from terminal:
bootstrap_django_dev | Exception in thread django-main-thread:
bootstrap_django_dev | Traceback (most recent call last):
bootstrap_django_dev | File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
bootstrap_django_dev | self.run()
bootstrap_django_dev | File "/usr/local/lib/python3.7/threading.py", line 870, in run
bootstrap_django_dev | self._target(*self._args, **self._kwargs)
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
bootstrap_django_dev | fn(*args, **kwargs)
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
bootstrap_django_dev | autoreload.raise_last_exception()
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
bootstrap_django_dev | raise _exception[1]
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
bootstrap_django_dev | autoreload.check_errors(django.setup)()
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
bootstrap_django_dev | fn(*args, **kwargs)
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
bootstrap_django_dev | apps.populate(settings.INSTALLED_APPS)
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
bootstrap_django_dev | app_config.import_models()
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
bootstrap_django_dev | self.models_module = import_module(models_module_name)
bootstrap_django_dev | File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
bootstrap_django_dev | return _bootstrap._gcd_import(name[level:], package, level)
bootstrap_django_dev | File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
bootstrap_django_dev | File "<frozen importlib._bootstrap>", line 983, in _find_and_load
bootstrap_django_dev | File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
bootstrap_django_dev | File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
bootstrap_django_dev | File "<frozen importlib._bootstrap_external>", line 728, in exec_module
bootstrap_django_dev | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
bootstrap_django_dev | File "/usr/src/dev/django/master/streams/models.py", line 5, in <module>
bootstrap_django_dev | class Notification(AbstractNotification):
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 320, in __new__
bootstrap_django_dev | new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
bootstrap_django_dev | File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 229, in register_model
bootstrap_django_dev | (model_name, app_label, app_models[model_name], model))
bootstrap_django_dev | RuntimeError: Conflicting 'notification' models in application 'notifications': <class 'notifications.models.Notification'> and <class 'master.streams.models.Notification'>.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:13 (5 by maintainers)
Top Results From Across the Web
python - When inheriting SQLAlchemy class from abstract ...
The Mytable class tries to inherit from BaseAbstract. The code throws the following exception: Message: metaclass conflict: the metaclass of a ...
Read more >Change Detection and Notifications - EF Core - Microsoft Learn
Detecting property and relationship changes using DetectChanges or notifications.
Read more >Observer - Refactoring.Guru
Observer is a behavioral design pattern that lets you define a subscription mechanism to notify multiple objects about any events that happen to...
Read more >Metaclass conflict when doing createmigrations in ModelState ...
I'm migrating my project from Django 1.6.x to 1.8.2, I found this bug and fix for it. In my project I'm using few...
Read more >Jobs - GitLab Docs
Control the inheritance of default keywords and global variables ... useful when you want to alter the execution of a job that uses...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You will need to define
app_label
inNotification
model, sinceapp_label
is defined inAbstractNotificatio.Meta
so you will have to explicitly define that. It should will be fixed in #284can this be updated in the docs? because it doesn’t mention you need
app_label
, else you get the error