1. Ben Firshman
  2. south

Commits

Andrew Godwin  committed 791ae6c

Stop crashes with unfound fields

  • Participants
  • Parent commits a22b475
  • Branches default

Comments (0)

Files changed (2)

File south/management/commands/startmigration.py

View file
  • Ignore whitespace
                     del model['Meta']
                 # Warn about undefined fields
                 elif fielddef is None:
-                    print "WARNING: Cannot get definition for '%s' on '%s'. Please edit the migration manually." % (
+                    print "WARNING: Cannot get definition for '%s' on '%s'. Please edit the migration manually to define it, or add the south_field_triple method to it." % (
                         fieldname,
                         modelname,
                     )
     Given the defualt app, the field class,
     and the defn triple (or string), make the definition string.
     """
+    # It might be None; return a placeholder
+    if triple is None:
+        return FIELD_NEEDS_DEF_SNIPPET
     # It might be a defn string already...
     if isinstance(triple, (str, unicode)):
         return triple

File south/modelsinspector.py

View file
  • Ignore whitespace
         # Does it define a south_field_triple method?
         if hasattr(field, "south_field_triple"):
             if NOISY:
-                print "Nativing field: %s" % field.name
+                print " ( Nativing field: %s" % field.name
             field_defs[field.name] = field.south_field_triple()
         # Can we introspect it?
         elif can_introspect(field):
         # Hmph. Is it parseable?
         elif parser_fields.get(field.name, None):
             if NOISY:
-                print "Parsing field: %s" % field.name
+                print " ( Parsing field: %s" % field.name
             field_defs[field.name] = parser_fields[field.name]
         # Shucks, no definition!
         else:
             if NOISY:
-                print "Nodefing field: %s" % field.name
+                print " ( Nodefing field: %s" % field.name
             field_defs[field.name] = None
     
     return field_defs