Skip to content

Commit

Permalink
Set default value for description fields.
Browse files Browse the repository at this point in the history
With field.null set, non-existing descriptions (all of them
after the upgrade) render as 'None' in the HTML. On SQLite,
South is anable to add the new column correctly with
field.empty, but setting the default like this works.
  • Loading branch information
friedelwolff committed May 22, 2012
1 parent 0336702 commit 4fa2dc3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions local_apps/pootle_misc/dbupdate.py
Expand Up @@ -210,16 +210,18 @@ def update_tables_22000():
logging.info("Updating existing database tables") logging.info("Updating existing database tables")
from south.db import db from south.db import db


# For the sake of South bug 313, we set the default for these fields here:
# See http://south.aeracode.org/ticket/313
from pootle_store.models import Suggestion from pootle_store.models import Suggestion
table_name = Suggestion._meta.db_table table_name = Suggestion._meta.db_table
field = Suggestion._meta.get_field('translator_comment_f') field = Suggestion._meta.get_field('translator_comment_f')
field.null = True field.default = u''
db.add_column(table_name, field.name, field) db.add_column(table_name, field.name, field)


from pootle_language.models import Language from pootle_language.models import Language
table_name = Language._meta.db_table table_name = Language._meta.db_table
field = Language._meta.get_field('description') field = Language._meta.get_field('description')
field.null = True field.default = u''
db.add_column(table_name, field.name, field) db.add_column(table_name, field.name, field)


save_pootle_version(22000) save_pootle_version(22000)
Expand Down

0 comments on commit 4fa2dc3

Please sign in to comment.