Django

Code

Changeset 1323

Show
Ignore:
Timestamp:
11/20/05 19:45:15 (2 years ago)
Author:
adrian
Message:

Fixed #861 -- Model validator now validates unique_together

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management.py

    r1314 r1323  
    678678                except StopIteration: 
    679679                    pass 
     680 
     681            # Check unique_together. 
     682            for ut in opts.unique_together: 
     683                for field_name in ut: 
     684                    try: 
     685                        f = opts.get_field(field_name, many_to_many=True) 
     686                    except meta.FieldDoesNotExist: 
     687                        e.add(opts, '"unique_together" refers to %s, a field that doesn\'t exist. Check your syntax.' % field_name) 
     688                    else: 
     689                        if isinstance(f.rel, meta.ManyToMany): 
     690                            e.add(opts, '"unique_together" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name) 
    680691    return len(e.errors) 
    681692