Changes between Initial Version and Version 2 of Ticket #26953


Ignore:
Timestamp:
Jul 27, 2016, 1:52:33 PM (8 years ago)
Author:
Tim Graham
Comment:

There's no crash in Django 1.10 as of ed0ff913c648b16c4471fc9a9441d1ee48cb5420, however, I'm not certain about the correct resolution of this ticket. For example, should we add an additional test for this case?

I edited the description to leave only the minimal code necessary to reproduce the issue.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26953

    • Property Cc Loic Bistuer added
  • Ticket #26953 – Description

    initial v2  
    11The unthinkable happened!
    2 {{{
     2{{{ 
    33Traceback (most recent call last):
    44  File "manage.py", line 14, in <module>
     
    3030My model and manager setup
    3131
    32 {{{
    33 
    34 # encoding=utf-8
    35 from __future__ import unicode_literals, print_function
    36 
     32{{{#!python
    3733from django.db import models
    3834from django.db.models.manager import BaseManager
    3935from django.db.models.query import QuerySet
    40 from django.utils.translation import ugettext_lazy as _
    41 from django.core.exceptions import ValidationError
    42 
    4336
    4437class ExpenseQuerySet(QuerySet):
    45 
    46     def all(self):
    47         return super(ExpenseQuerySet, self).all().filter(deleted=False)
    48 
    49     def delete(self):
    50         return self.update(deleted=True)
    51 
     38   pass
    5239
    5340class ExpenseManager(BaseManager.from_queryset(ExpenseQuerySet)):
    5441    pass
    5542
    56 
    57 def validate_period(value):
    58     if value not in [x[0] for x in Expense.PERIODS]:
    59         raise ValidationError(_("Period not in choices.")) 
    60 
    61 
    6243class Expense(models.Model):
    63 
    64     PERIODS = (
    65         ('monthly', _("Monthly")),
    66         ('quarterly', _("Quarterly")),
    67         ('yearly', _("Monthly"))
    68     )
    69 
    70     period = models.CharField(verbose_name=_("Period"), choices=PERIODS, max_length=10,
    71                               validators=[validate_period])
    72    
    73     amount = models.FloatField(verbose_name=_("Amount"))
    74     description = models.CharField(max_length=255, verbose_name=_("Description"))
    75     valid_from = models.DateField(verbose_name=_("Valid from"), null=True)
    76     valid_to = models.DateField(verbose_name=_("Valid to"), null=True)
    77 
    78     deleted = models.BooleanField(default=False, verbose_name=_("Deleted"))
    79 
    8044    objects = ExpenseManager()
    81 
    82     def delete(self, **kwargs):
    83         Expense.objects.filter(pk=self.pk).update(deleted=True)
    84 
    85     class Meta:
    86         verbose_name = _("Expense")
    87         verbose_name_plural = _("Expenses")
    88         permissions = (
    89             ('list_expenses', _("Can list expenses")),
    90         )
    91 
    9245}}}
    93 
    94 
Back to Top