File: compat.py

package info (click to toggle)
python-django-parler 2.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,012 kB
  • sloc: python: 4,291; makefile: 164; sh: 6
file content (23 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Django compatibility features
"""
from django.db import models

__all__ = ("HideChoicesCharField",)


class HideChoicesCharField(models.CharField):
    # Hide the 'choices' for a field.

    def deconstruct(self):
        name, path, args, kwargs = models.CharField.deconstruct(self)

        # Hide the fact this model was used.
        if path == __name__ + ".HideChoicesCharField":
            path = "django.db.models.CharField"
        try:
            del kwargs["choices"]
        except KeyError:
            pass

        return name, path, args, kwargs