1 | Index: management.py
|
---|
2 | ===================================================================
|
---|
3 | --- management.py (revisión: 5724)
|
---|
4 | +++ management.py (copia de trabajo)
|
---|
5 | @@ -1180,16 +1180,21 @@
|
---|
6 | pass
|
---|
7 |
|
---|
8 | # Check unique_together.
|
---|
9 | + from types import ListType, TupleType
|
---|
10 | for ut in opts.unique_together:
|
---|
11 | - for field_name in ut:
|
---|
12 | - try:
|
---|
13 | - f = opts.get_field(field_name, many_to_many=True)
|
---|
14 | - except models.FieldDoesNotExist:
|
---|
15 | - e.add(opts, '"unique_together" refers to %s, a field that doesn\'t exist. Check your syntax.' % field_name)
|
---|
16 | - else:
|
---|
17 | - if isinstance(f.rel, models.ManyToManyRel):
|
---|
18 | - e.add(opts, '"unique_together" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)
|
---|
19 | -
|
---|
20 | + ut_type = type(ut)
|
---|
21 | + if ut_type == ListType or ut_type == TupleType:
|
---|
22 | + for field_name in ut:
|
---|
23 | + try:
|
---|
24 | + f = opts.get_field(field_name, many_to_many=True)
|
---|
25 | + except models.FieldDoesNotExist:
|
---|
26 | + e.add(opts, '"unique_together" refers to %s, a field that doesn\'t exist. Check your syntax.' % field_name)
|
---|
27 | + else:
|
---|
28 | + if isinstance(f.rel, models.ManyToManyRel):
|
---|
29 | + e.add(opts, '"unique_together" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)
|
---|
30 | + else:
|
---|
31 | + e.add(opts, '"unique_together" refers to %s, they must be tuples not strings in a tuple' % str(opts.unique_together))
|
---|
32 | + break
|
---|
33 | return len(e.errors)
|
---|
34 |
|
---|
35 | def validate(outfile=sys.stdout, silent_success=False):
|
---|