diff options
| author | Tom Christie | 2011-05-16 14:11:36 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-05-16 14:11:36 +0100 |
| commit | 1e04790d505a1174f9e3c4481288982f9e7fd6c0 (patch) | |
| tree | 09c5b29acdc820dc3fc1108f3503cde03d725eb9 /examples/modelresourceexample/models.py | |
| parent | e92002ddde31fcc4ba3dee0f4a92a114c3c3a959 (diff) | |
| download | django-rest-framework-1e04790d505a1174f9e3c4481288982f9e7fd6c0.tar.bz2 | |
Fixing some of the last blocking issues
Diffstat (limited to 'examples/modelresourceexample/models.py')
| -rw-r--r-- | examples/modelresourceexample/models.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/examples/modelresourceexample/models.py b/examples/modelresourceexample/models.py index 16047524..ff0179c8 100644 --- a/examples/modelresourceexample/models.py +++ b/examples/modelresourceexample/models.py @@ -7,17 +7,13 @@ class MyModel(models.Model): 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) - - class Meta: - ordering = ('created',) def save(self, *args, **kwargs): - """For the purposes of the sandbox, limit the maximum number of stored models.""" + """ + For the purposes of the sandbox limit the maximum number of stored models. + """ super(MyModel, self).save(*args, **kwargs) while MyModel.objects.all().count() > MAX_INSTANCES: - MyModel.objects.all()[0].delete() - - @models.permalink - def get_absolute_url(self): - return ('my-model-resource', (self.pk,)) + MyModel.objects.all().order_by('-created')[0].delete() + |
