Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add south introspection for TimeZoneField #19

Open
wants to merge 1 commit into from

1 participant

@treyhunner

This is another alternative style to pull request #13.

Another alternative in a more usual style for South introspection code (may be less appropriate for this project's style):

# Add south introspection for TimeZoneField
try:
    from south.modelsinspector import add_introspection_rules
except ImportError:
    pass
else:
    add_introspection_rules(rules=[(
        (TimeZoneField,),
        [],
        {
            "max_length": ["max_length", {"default": MAX_TIMEZONE_LENGTH}],
            "default": ["default", {"default": settings.TIME_ZONE}],
            "choices": ["choices", {"default": zones.PRETTY_TIMEZONE_CHOICES}],
        }
    )], patterns=["^timezones\.fields\."])

I think South introspection code always looks ugly, but some sort of introspection is necessary for South to work at all with TimeZoneFields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 20, 2012
  1. @treyhunner
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 0 deletions.
  1. +13 −0 timezones/fields.py
View
13 timezones/fields.py
@@ -155,3 +155,16 @@ def set_dtz_field(instance, dt):
## RED_FLAG: need to add a check at manage.py validation time that
## time_zone value is a valid query keyword (if it is one)
signals.class_prepared.connect(prep_localized_datetime)
+
+
+# Add south introspection for TimeZoneField
+try:
+ from south.modelsinspector import add_introspection_rules
+except ImportError:
+ pass
+else:
+ add_introspection_rules(rules=[((TimeZoneField,), [], {
+ "max_length": ["max_length", {"default": MAX_TIMEZONE_LENGTH}],
+ "default": ["default", {"default": settings.TIME_ZONE}],
+ "choices": ["choices", {"default": zones.PRETTY_TIMEZONE_CHOICES}],
+ })], patterns=["^timezones\.fields\."])
Something went wrong with that request. Please try again.