summaryrefslogtreecommitdiff
path: root/tests/django_test_app/models.py
blob: 5f790b43c21ed606451578c906a0b86d4fef8111 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
# Copyright (c) The python-semanticversion project

try:
    from django.db import models
    django_loaded = True
except ImportError:
    django_loaded = False


if django_loaded:
    from semantic_version import django_fields as semver_fields

    class VersionModel(models.Model):
        version = semver_fields.VersionField(verbose_name='my version')
        spec = semver_fields.SpecField(verbose_name='my spec')
        npm_spec = semver_fields.SpecField(syntax='npm', blank=True, verbose_name='npm spec')

    class PartialVersionModel(models.Model):
        partial = semver_fields.VersionField(partial=True, verbose_name='partial version')
        optional = semver_fields.VersionField(verbose_name='optional version', blank=True, null=True)
        optional_spec = semver_fields.SpecField(verbose_name='optional spec', blank=True, null=True)

    class CoerceVersionModel(models.Model):
        version = semver_fields.VersionField(verbose_name='my version', coerce=True)
        partial = semver_fields.VersionField(verbose_name='partial version', coerce=True, partial=True)