diff options
-rw-r--r-- | askbot/migrations/0156_add_message_model_in_new_django.py | 4 | ||||
-rw-r--r-- | askbot/models/__init__.py | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/askbot/migrations/0156_add_message_model_in_new_django.py b/askbot/migrations/0156_add_message_model_in_new_django.py index 950196fa..a962b2b4 100644 --- a/askbot/migrations/0156_add_message_model_in_new_django.py +++ b/askbot/migrations/0156_add_message_model_in_new_django.py @@ -5,13 +5,15 @@ from south.v2 import SchemaMigration from django.db import models, connection import django +DJANGO_VERSION = django.VERSION[:2] + def db_table_exists(table_name): return table_name in connection.introspection.table_names() class Migration(SchemaMigration): def forwards(self, orm): - if django.get_version() > '1.3.1' and not db_table_exists('auth_message'): + if DJANGO_VERSION > (1, 3) and not db_table_exists('auth_message'): db.create_table('auth_message', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='_message_set', to=orm['auth.User'])), diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index fd60590c..e7c85afa 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -66,9 +66,12 @@ from askbot.utils.diff import textDiff as htmldiff from askbot.utils.url_utils import strip_path from askbot import mail -from django import get_version as django_version +from django import VERSION -if django_version() > '1.3.1': +#stores the 1.X version not the security release numbers +DJANGO_VERSION = VERSION[:2] + +if DJANGO_VERSION > (1, 3): from askbot.models.message import Message def get_model(model_name): @@ -150,7 +153,7 @@ def user_get_and_delete_messages(self): message.delete() return messages -if django_version() > '1.3.1': +if DJANGO_VERSION > (1, 3): User.add_to_class('message_set', user_message_set) User.add_to_class('get_and_delete_messages', user_get_and_delete_messages) |