File: models.py

package info (click to toggle)
python-django-swapper 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 164 kB
  • sloc: python: 239; sh: 9; makefile: 4
file content (23 lines) | stat: -rw-r--r-- 496 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
from django.db import models

import swapper


class BaseType(models.Model):
    name = models.CharField(max_length=255)

    class Meta:
        abstract = True


class Type(BaseType):
    class Meta:
        swappable = swapper.swappable_setting("default_app", "Type")


class Item(models.Model):
    type = models.ForeignKey(
        swapper.get_model_name('default_app', "Type"), on_delete=models.CASCADE
    )
    name = models.CharField(max_length=255)
    description = models.TextField()