mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
./examples/modelresourceexample/models.py
This commit is contained in:
parent
aad7eacce6
commit
60206e5288
|
@ -1 +1,19 @@
|
||||||
# Just to keep things like ./manage.py test happy
|
""""""
|
||||||
|
from django.db import models
|
||||||
|
from django.contrib.auth import Permission, User
|
||||||
|
|
||||||
|
class PermissionSet(models.Model):
|
||||||
|
""""""
|
||||||
|
name = models.CharField(unique=True, max_length=64)
|
||||||
|
description = models.CharField(max_length=512)
|
||||||
|
permissions = models.ManyToManyField(Permission, blank=True)
|
||||||
|
|
||||||
|
|
||||||
|
class UserToken(models.Model):
|
||||||
|
""""""
|
||||||
|
token_key = models.CharField(max_length=30, unique=True)
|
||||||
|
token_secret = models.CharField(max_length=256)
|
||||||
|
user = models.ForeignKey(User)
|
||||||
|
permission_set = models.ForeignKey(PermissionSet, null=True, blank=True, help_text="If set then determines the subset of permissions that are granted by this token, rathen than granting full user permissions.")
|
||||||
|
expiry = models.DateTimeField(default=None, blank=True, null=True, help_text="If set then determines when the token will no longer be treated as valid. If left empty the token will not expire.")
|
||||||
|
is_active = models.BooleanField(default=True)
|
||||||
|
|
|
@ -9,7 +9,7 @@ Django REST framework
|
||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Django REST framework aims to make it easy to build well-connected, self-describing Web APIs.
|
Django REST framework aims to make it easy to build well-connected, self-describing RESTful Web APIs.
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from django.db import models
|
||||||
MAX_INSTANCES = 10
|
MAX_INSTANCES = 10
|
||||||
|
|
||||||
class MyModel(models.Model):
|
class MyModel(models.Model):
|
||||||
foo = models.BooleanField()
|
foo = models.BooleanField(required=False)
|
||||||
bar = models.IntegerField(help_text='Must be an integer.')
|
bar = models.IntegerField(help_text='Must be an integer.')
|
||||||
baz = models.CharField(max_length=32, help_text='Free text. Max length 32 chars.')
|
baz = models.CharField(max_length=32, help_text='Free text. Max length 32 chars.')
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user