Looking deeper, Mezzanine seems to be simply looking for the field type, 
then passing the arguments into the Django method contribute_to_class for 
the sender model. (See 
http://blog.jupo.org/2011/11/10/django-model-field-injection/). I'm going 
to pursue this further, but it looks like Django itself may be broken when 
it comes to ManyToManyField.



On Tuesday, March 17, 2015 at 12:12:55 AM UTC-6, Alexander Kominek wrote:
>
> I'm seeing the same thing, trying to ad a ManyToManyField to all pages. 
> From my settings.py:
>
> EXTRA_MODEL_FIELDS = (
>     (
>          "mezzanine.pages.models.Page.blog_categories", #let blog posts 
> be displayed below content on pages
>          "ManyToManyField",
>          ("blog.BlogCategory",),
>          {"related_name":'pages',
>           "blank":True,
>           "null":True,},
>      ),
> )
>
> When I run python manage.py schemamigration pages --auto I get the 
> following error:
>
> Traceback (most recent call last):
>   File "/path/to/myproject/manage.py", line 28, in <module>
>     execute_from_command_line(sys.argv)
>   File "/path/to/python2.7/django/core/management/__init__.py", line 399, 
> in execute_from_command_line
>     utility.execute()
>   File "/path/to/python2.7/django/core/management/__init__.py", line 392, 
> in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/path/to/python2.7/django/core/management/base.py", line 242, in 
> run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/path/to/python2.7/django/core/management/base.py", line 285, in 
> execute
>     output = self.handle(*args, **options)
>   File "/path/to/python2.7/south/management/commands/schemamigration.py", 
> line 159, in handle
>     action.add_forwards(forwards_actions)
>   File "/path/to/python2.7/south/creator/actions.py", line 39, in 
> add_forwards
>     forwards.append(self.forwards_code())
>   File "/path/to/python2.7/south/creator/actions.py", line 524, in 
> forwards_code
>     "left_field": self.field.m2m_column_name()[:-3], # Remove the _id part
> TypeError: 'NoneType' object has no attribute '__getitem__'
>
>
> I've tried 
>
> On Tuesday, February 3, 2015 at 11:34:20 AM UTC-7, [email protected] 
> wrote:
>>
>>
>> Hi everyone,
>>
>> I'm getting the same error exactly while running the schemamigration 
>> command:
>>
>> TypeError: 'NoneType' object has no attribute '__getitem__'
>>
>>
>> In my case the model is cartridge.shop.models.Product but the situation 
>> is really really close:
>>
>> EXTRA_MODEL_FIELDS = (
>>     # Four-item sequence for one field injected.
>>     (
>>         # Dotted path to field.
>>         "cartridge.shop.models.Product.tags",
>>         # Dotted path to field class.
>>         "ManyToManyField",
>>         # Positional args for field class.
>>         ('theme.Tag', ),
>>         # Keyword args for field class.
>>         {"related_name": "products", "blank": True, "null": True},
>>     ),
>> )
>>
>> And the theme.Tag model is:
>>
>> class Tag(models.Model):
>>     """
>>     """
>>     nome = models.CharField(_("Nome"), blank=True, max_length=100)
>>
>>
>> Has anyone found the problem or what's wrong with this setup?
>>
>> Thank you,
>> Maurizio
>>
>>
>> Il giorno venerdì 1 agosto 2014 16:59:19 UTC+2, Ryan Sadwick ha scritto:
>>>
>>> Make sure you run a south schemamigration on the blog app itself:
>>>
>>> Something like:
>>> manage.py schemamigration blog --auto
>>>
>>>
>>>
>>>
>>>
>>> On Tuesday, July 29, 2014 10:14:18 AM UTC-4, Beau Severson wrote:
>>>>
>>>> I was also wondering the answer to this. I'm trying to add a new M2M 
>>>> field to the BlogPost model and I keep getting the exact same error. Is 
>>>> this a bug for mezzanine using south? My EXTRA_MODEL_FIELDS contains the 
>>>> following:
>>>>
>>>>     (
>>>>         "mezzanine.blog.models.BlogPost.industry",
>>>>         "ManyToManyField",  # type of field to add
>>>>         ("users.Industry",),
>>>>         {"blank": True, "null": True},
>>>>     ),
>>>>
>>>> Everytime I attempt the migration though I get the same error you are 
>>>> seeing.
>>>>
>>>> On Friday, January 11, 2013 8:40:05 AM UTC-6, Sam wrote:
>>>>>
>>>>>
>>>>> Hello,
>>>>>
>>>>> In the admin interface i would like it to be possible to select 
>>>>> multiple genres for blogposts. These genres are from a different model so 
>>>>> I 
>>>>> used the technique described in the manual.
>>>>>
>>>>> I try to add a custom ManyToManyField to the blog app using the 
>>>>> following syntax in my settings.py:
>>>>>
>>>>> (
>>>>>     "mezzanine.blog.models.BlogPost.genre",
>>>>>     "ManyToManyField",
>>>>>     ('blog_custom.Genre',),
>>>>>     {"null":True, "blank": True,},
>>>>> ),
>>>>>
>>>>> I started a custom app called blog_custom where I'd like to store the 
>>>>> migrations. I have defined my Genre model as follows:
>>>>>
>>>>> class Genre(models.Model):
>>>>>   name = models.CharField(max_length=300)
>>>>>
>>>>> Given the fact that I use South in this project, I have to perform a 
>>>>> migration at which point I get the following error:
>>>>> TypeError: 'NoneType' object has no attribute '__getitem__'
>>>>>
>>>>> After some investigation I found out that this issue might actually be 
>>>>> related to South, or related to the way the arguments are passed on from 
>>>>> mezzanine to South. If I, for example, create the intermediare table that 
>>>>> should have been created with the migration manually, and run the 
>>>>> migration 
>>>>> after this fact, it does complete since south does not have to create it. 
>>>>> The problem with this approach is that Django will not use this 
>>>>> intermediary model in the admin interface, which is what I need.
>>>>>
>>>>> Any thoughts?
>>>>>
>>>>> Thanks
>>>>>
>>>>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to