Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion enumfields/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def refresh_from_db(instance, using=None, fields=None, *args, **kwargs):
cls.refresh_from_db = refresh_from_db

setattr(cls, name, CastOnAssignDescriptor(self))
post_save.connect(update_initial_field, sender=cls, weak=False)
self._update_initial_field = update_initial_field
post_save.connect(update_initial_field, sender=cls)

def to_python(self, value):
if isinstance(value, self.enum):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run_tests(self):

setup(
name='skip-django-choice-enumfields',
version='2.0.0',
version='2.0.1',
author='HZDG, Lubos Matl',
author_email='matllubos@gmail.com',
description='Real Python Enums for Django.',
Expand Down
17 changes: 17 additions & 0 deletions tests/test_migration_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import gc
import weakref

from django.db.migrations.state import ModelState, ProjectState

from .models import MyModel


def test_rendered_migration_state_is_released():
project_state = ProjectState()
project_state.add_model(ModelState.from_model(MyModel))
rendered_model = weakref.ref(project_state.apps.get_model('tests', 'MyModel'))

del project_state
gc.collect()

assert rendered_model() is None
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ envlist =

[testenv]
setenv = PYTHONPATH = {toxinidir}
commands = python setup.py test
commands = pytest tests
deps =
pytest
pytest-django
djangorestframework
pytz
django4.2: Django>=4.2,<5.0
Loading