mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
BlogPosts > 10 rotation implemeneted
Latest Modelresource example is broken. Required attribute should be set to form, not model. Is fixed.
This commit is contained in:
parent
bba89cbcf1
commit
177e666fc2
|
@ -38,6 +38,9 @@ class BlogPost(models.Model):
|
|||
def save(self, *args, **kwargs):
|
||||
self.slug = slugify(self.title)
|
||||
super(self.__class__, self).save(*args, **kwargs)
|
||||
for obj in self.__class__.objects.order_by('-pk')[10:]:
|
||||
obj.delete()
|
||||
|
||||
|
||||
|
||||
class Comment(models.Model):
|
||||
|
|
|
@ -3,7 +3,7 @@ from django.db import models
|
|||
MAX_INSTANCES = 10
|
||||
|
||||
class MyModel(models.Model):
|
||||
foo = models.BooleanField(required=False)
|
||||
foo = models.BooleanField()
|
||||
bar = models.IntegerField(help_text='Must be an integer.')
|
||||
baz = models.CharField(max_length=32, help_text='Free text. Max length 32 chars.')
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django import forms
|
||||
|
||||
class MyForm(forms.Form):
|
||||
foo = forms.BooleanField()
|
||||
foo = forms.BooleanField(required=False)
|
||||
bar = forms.IntegerField(help_text='Must be an integer.')
|
||||
baz = forms.CharField(max_length=32, help_text='Free text. Max length 32 chars.')
|
||||
|
|
Loading…
Reference in New Issue
Block a user