Ticket #14513: django-14513-e62b9ba4e02c.diff

File django-14513-e62b9ba4e02c.diff, 2.0 KB (added by vanschelven, 5 years ago)

Patch

  • django/core/management/validation.py

    # HG changeset patch -- Bitbucket.org
    # Project django-14513
    # URL http://bitbucket.org/vanschelven/django-14513/overview
    # User Klaas van Schelven <klaas@vanschelven.com>
    # Date 1287593945 -7200
    # Node ID e62b9ba4e02c09e71443d711946981adc30e0745
    # Parent  eada92bd16c9d21442b21b4fbfb49e811df20c50
    Fix for Ticket #14513, including test
    
    a b def get_validation_errors(outfile, app=N 
    257257                    continue
    258258                # Skip ordering in the format field1__field2 (FIXME: checking
    259259                # this format would be nice, but it's a little fiddly).
    260                 if '_' in field_name:
     260                if '__' in field_name:
    261261                    continue
    262262                try:
    263263                    opts.get_field(field_name, many_to_many=False)
  • tests/modeltests/invalid_models/models.py

    a b class UniqueFKTarget2(models.Model): 
    206206    """ Model to test for unique FK target in previously seen model: expect no error """
    207207    tgt = models.ForeignKey(FKTarget, to_field='good')
    208208
     209class NonExistingOrderingWithSingleUnderscore(models.Model):
     210    class Meta:
     211        ordering = ("does_not_exist",)
    209212
    210213model_errors = """invalid_models.fielderrors: "charfield": CharFields require a "max_length" attribute that is a positive integer.
    211214invalid_models.fielderrors: "charfield2": CharFields require a "max_length" attribute that is a positive integer.
    invalid_models.abstractrelationmodel: 'f 
    311314invalid_models.uniquem2m: ManyToManyFields cannot be unique.  Remove the unique argument on 'unique_people'.
    312315invalid_models.nonuniquefktarget1: Field 'bad' under model 'FKTarget' must have a unique=True constraint.
    313316invalid_models.nonuniquefktarget2: Field 'bad' under model 'FKTarget' must have a unique=True constraint.
     317invalid_models.nonexistingorderingwithsingleunderscore: "ordering" refers to "does_not_exist", a field that doesn't exist.
    314318"""
Back to Top