mirror of
https://github.com/Hopiu/django-notifications.git
synced 2026-03-16 21:30:24 +00:00
#356 Fix Django deprecation warnings
This commit is contained in:
parent
e2e74aa5a3
commit
db5d9215d4
5 changed files with 37 additions and 12 deletions
|
|
@ -9,5 +9,3 @@
|
|||
|
||||
# PEP 386-compliant version number: N.N[.N]+[{a|b|c|rc}N[.N]+][.postN][.devN]
|
||||
__version__ = "1.8.0"
|
||||
|
||||
default_app_config = "notifications.apps.Config" # pylint: disable=invalid-name
|
||||
|
|
|
|||
|
|
@ -2,6 +2,24 @@
|
|||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
from django.db.models import Index
|
||||
from django.utils import version
|
||||
|
||||
_version = version.get_version_tuple(version.get_version())
|
||||
if _version[0] >= 4 and _version[1] >= 2:
|
||||
_operations = [
|
||||
migrations.AddIndex(
|
||||
model_name="notification",
|
||||
index=Index(fields=("recipient", "unread"), name="recipient_unread_idx"),
|
||||
),
|
||||
]
|
||||
else:
|
||||
_operations = [
|
||||
migrations.AlterIndexTogether(
|
||||
name="notification",
|
||||
index_together={("recipient", "unread")},
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -10,9 +28,4 @@ class Migration(migrations.Migration):
|
|||
("notifications", "0007_add_timestamp_index"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterIndexTogether(
|
||||
name="notification",
|
||||
index_together={("recipient", "unread")},
|
||||
),
|
||||
]
|
||||
operations = _operations
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.2.11 on 2024-05-03 00:08
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("notifications", "0015_alter_notification_action_object_content_type_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameIndex(
|
||||
model_name="notification",
|
||||
new_name="notificatio_recipie_8bedf2_idx",
|
||||
old_fields=("recipient", "unread"),
|
||||
),
|
||||
]
|
||||
|
|
@ -116,7 +116,7 @@ class AbstractNotification(models.Model):
|
|||
abstract = True
|
||||
ordering = ("-timestamp",)
|
||||
# speed up notifications count query
|
||||
index_together = ("recipient", "unread")
|
||||
indexes = [models.Index(fields=["recipient", "unread"])]
|
||||
verbose_name = _("Notification")
|
||||
verbose_name_plural = _("Notifications")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
default_app_config = ( # pylint: disable=invalid-name
|
||||
"notifications.tests.sample_notifications.apps.SampleNotificationsConfig"
|
||||
)
|
||||
Loading…
Reference in a new issue