Exemple #1
0
class Property(models.Model):
    FRACTURE_CHOICES = (
        ("CF", _("conchoidal")),
        ("EF", _("earthy")),
        ("HF", _("hackly")),
        ("SF", _("splintery")),
        ("UF", _("uneven")),
    )

    LUSTRE_CHOICES = (
        ("AM", _("adamantine lustre")),
        ("DL", _("dull lustre")),
        ("GR", _("greasy lustre")),
        ("MT", _("metallic lustre")),
        ("PY", _("pearly lustre")),
        ("SL", _("silky lustre")),
        ("SM", _("submetallic lustre")),
        ("VT", _("vitreous lustre")),
        ("WY", _("waxy lustre")),
    )

    density = DecimalRangeField(null=True, blank=True, verbose_name=_("density"))
    fracture = ArrayField(
        models.CharField(max_length=2, choices=FRACTURE_CHOICES,),
        null=True,
        verbose_name=_("fracture"),
    )
    lustre = ArrayField(
        models.CharField(max_length=2, choices=LUSTRE_CHOICES, verbose_name=_("lustre")),
        null=True,
        verbose_name=_("lustre"),
    )
    mohs_scale = DecimalRangeField(null=True, blank=True, verbose_name=_("mohs scale"))
    normal_color = models.CharField(max_length=100, verbose_name=_("normal color"))
    streak = models.CharField(max_length=100, verbose_name=_("streak"))
    mineral_type = models.OneToOneField(
        MineralType,
        verbose_name=_("mineral type"),
        related_name="property",
        on_delete=models.CASCADE
    )
    cleavage_text = models.TextField(null=True, verbose_name=_("Cleavages"))

    class Meta:
        verbose_name = _("Property")
        verbose_name_plural = _("Properties")
Exemple #2
0
class Person(models.Model):
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
    #  Jards Macalé is an amazing brazilian musician! =]
    enjoy_jards_macale = models.BooleanField(default=True)
    like_metal_music = models.BooleanField(default=False)
    name = models.CharField(max_length=30)
    nickname = models.SlugField(max_length=36)
    age = models.IntegerField()
    bio = models.TextField()
    birthday = models.DateField()
    birth_time = models.TimeField()
    appointment = models.DateTimeField()
    blog = models.URLField()
    occupation = models.CharField(max_length=10, choices=OCCUPATION_CHOICES)
    uuid = models.UUIDField(primary_key=False)
    name_hash = models.BinaryField(max_length=16)
    days_since_last_login = models.BigIntegerField()
    duration_of_sleep = models.DurationField()
    email = models.EmailField()
    id_document = models.CharField(unique=True, max_length=10)

    try:
        from django.db.models import JSONField

        data = JSONField()
    except ImportError:
        # Skip JSONField-related fields
        pass

    try:
        from django.contrib.postgres.fields import ArrayField, HStoreField
        from django.contrib.postgres.fields import JSONField as PostgresJSONField
        from django.contrib.postgres.fields.citext import (
            CICharField,
            CIEmailField,
            CITextField,
        )
        from django.contrib.postgres.fields.ranges import (
            BigIntegerRangeField,
            DateRangeField,
            DateTimeRangeField,
            IntegerRangeField,
        )

        if settings.USING_POSTGRES:
            acquaintances = ArrayField(models.IntegerField())
            postgres_data = PostgresJSONField()
            hstore_data = HStoreField()
            ci_char = CICharField(max_length=30)
            ci_email = CIEmailField()
            ci_text = CITextField()
            int_range = IntegerRangeField()
            bigint_range = BigIntegerRangeField()
            date_range = DateRangeField()
            datetime_range = DateTimeRangeField()
    except ImportError:
        # Skip PostgreSQL-related fields
        pass

    try:
        from django.contrib.postgres.fields.ranges import FloatRangeField

        if settings.USING_POSTGRES:
            float_range = FloatRangeField()
    except ImportError:
        # Django version greater or equal than 3.1
        pass

    try:
        from django.contrib.postgres.fields.ranges import DecimalRangeField

        if settings.USING_POSTGRES:
            decimal_range = DecimalRangeField()
    except ImportError:
        # Django version lower than 2.2
        pass

    if BAKER_GIS:
        geom = models.GeometryField()
        point = models.PointField()
        line_string = models.LineStringField()
        polygon = models.PolygonField()
        multi_point = models.MultiPointField()
        multi_line_string = models.MultiLineStringField()
        multi_polygon = models.MultiPolygonField()
        geom_collection = models.GeometryCollectionField()