Field injection problem

179 views
Skip to first unread message

Josh Cartmell

unread,
Jan 1, 2014, 12:21:53 AM1/1/14
to mezzani...@googlegroups.com
I'm having issues creating migrations for injected fields when Django 1.6.1 is installed (running python 2.7.5 and Mezzanine 3.0.4 on OS X 10.9).

I have this:

EXTRA_MODEL_FIELDS = (
    (
        "mezzanine.blog.models.BlogPost.featured_video",
        "TextField",
        ("Featured video",),
        {"blank": True},
    ),
)

and when I run schemamigration I get:

  File "manage.py", line 29, in <module>
    execute_from_command_line(sys.argv)
  File ".../site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File ".../site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ".../site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ".../site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File ".../site-packages/south/management/commands/schemamigration.py", line 158, in handle
    action = action_class(**params)
  File ".../site-packages/south/creator/actions.py", line 232, in __init__
    is_null = self.field.null
AttributeError: 'RelatedObject' object has no attribute 'null'

I also tried one of the fields that is present but commented out in the default settings:
EXTRA_MODEL_FIELDS = (
    (
        "mezzanine.pages.models.Page.another_field",
        "IntegerField", # 'django.db.models.' is implied if path is omitted.
        ("Another name",),
        {"blank": True, "default": 1},
    ),
)
it produces the same error.

If I downgrade to Django 1.5.5 I can create the migration and once the migration is created I can run it with 1.5.5 or 1.6.1.  It's also a little odd that the migration that gets created by south alters rating, keywords and comments on blogpost.

Does anyone have any ideas about that?

Stephen McDonald

unread,
Jan 1, 2014, 12:42:25 AM1/1/14
to mezzani...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Stephen McDonald
http://jupo.org

Stephen McDonald

unread,
Jan 1, 2014, 12:45:16 AM1/1/14
to mezzani...@googlegroups.com
Um that second commit was unrelated, it was these two:


Basically there were a bunch of south hacks in mezzanine.generic that allowed those fields to be included in migrations, and as I understood some time ago this was necessary and all worked fine. With all the generic relation field changes in Django 1.6.x though, these now break with South when trying to create new migrations. The fix was to go back and edit those migrations manually. I've also removed the old hacks that kept that working, and I've been able to detect when invalid migrations (still containing those fields) are being used, which you'll see in the first commit provides a big warning.

Josh Cartmell

unread,
Jan 1, 2014, 1:23:57 PM1/1/14
to mezzani...@googlegroups.com
As always, thanks Steve.  I haven't had a chance to try this out yet but hope to later on today.

Sam Kingston

unread,
Jan 7, 2014, 1:06:27 AM1/7/14
to mezzani...@googlegroups.com, st...@jupo.org
Great explanation and example, and I've done this however still getting the exception.

Just to confirm, if any of our app's migrations reference the 3 fields 'KeywordsField|CommentsField|RatingField' we can simply comment them out in models dict and it should magically work after that?

Mine's not.. will look into further :(

Stephen McDonald

unread,
Jan 7, 2014, 1:09:23 AM1/7/14
to mezzani...@googlegroups.com
On Tue, Jan 7, 2014 at 5:06 PM, Sam Kingston <s...@sjkwi.com.au> wrote:
Great explanation and example, and I've done this however still getting the exception.

Just to confirm, if any of our app's migrations reference the 3 fields 'KeywordsField|CommentsField|RatingField' we can simply comment them out in models dict and it should magically work after that?

That's what worked for me.

Sam Kingston

unread,
Jan 7, 2014, 1:17:31 AM1/7/14
to mezzani...@googlegroups.com
On 7 January 2014 16:09, Stephen McDonald <st...@jupo.org> wrote:

On Tue, Jan 7, 2014 at 5:06 PM, Sam Kingston <s...@sjkwi.com.au> wrote:
Great explanation and example, and I've done this however still getting the exception.

Just to confirm, if any of our app's migrations reference the 3 fields 'KeywordsField|CommentsField|RatingField' we can simply comment them out in models dict and it should magically work after that?

That's what worked for me.

Did you test with Cartridge in INSTALLED_APPS?

master!wfsltd * $> egrep -r 'KeywordsField|CommentsField|RatingField' ../lib/python2.7/site-packages/cartridge/shop/ | wc -l
95

(I haven't tried the same fix there just wondering if that could be the issue)

Stephen McDonald

unread,
Jan 7, 2014, 1:19:58 AM1/7/14
to mezzani...@googlegroups.com
I just commented them out from migrations, I didn't remove them:



--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sam Kingston

unread,
Jan 7, 2014, 1:21:49 AM1/7/14
to mezzani...@googlegroups.com

Great that fixes it I had only upgraded mezzanine to latest commit, not cartridge.

Sorry for the noise

You received this message because you are subscribed to a topic in the Google Groups "Mezzanine Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mezzanine-users/MZy_1S740aw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mezzanine-use...@googlegroups.com.

Stephen McDonald

unread,
Jan 7, 2014, 1:22:18 AM1/7/14
to mezzani...@googlegroups.com
No prob!
Reply all
Reply to author
Forward
0 new messages