from django.contrib import admin

from manoseimas.compatibility_test.models import CompatTest
from manoseimas.compatibility_test.models import Topic
from manoseimas.compatibility_test.models import TopicVoting
from manoseimas.compatibility_test.models import Argument
from manoseimas.compatibility_test.models import TestGroup


class VotingInline(admin.TabularInline):
    model = TopicVoting
    raw_id_fields = [
        'voting',
    ]


class ArgumentInline(admin.TabularInline):
    model = Argument


class TopicAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    list_filter = ('name',)
    inlines = [
        ArgumentInline,
        VotingInline
    ]


class TestGroupInline(admin.TabularInline):
    model = TestGroup


class CompatTestAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    list_filter = ('name',)
    inlines = [TestGroupInline]


class TestGroupAdmin(admin.ModelAdmin):
    list_display = ('name',)

admin.site.register(CompatTest, CompatTestAdmin)
admin.site.register(Topic, TopicAdmin)
admin.site.register(TestGroup, TestGroupAdmin)

from django.contrib import admin

from manoseimas.compatibility_test import models


class VotingInline(admin.TabularInline):
    model = models.TopicVoting
    raw_id_fields = [
        'voting',
    ]


class ArgumentInline(admin.TabularInline):
    model = models.Argument


class TopicAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    list_filter = ('name',)
    inlines = [
        ArgumentInline,
        VotingInline
    ]


class TestGroupInline(admin.TabularInline):
    model = models.TestGroup


class CompatTestAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    list_filter = ('name',)
    inlines = [TestGroupInline]


class TestGroupAdmin(admin.ModelAdmin):
    list_display = ('name',)

admin.site.register(models.CompatTest, CompatTestAdmin)
admin.site.register(models.Topic, TopicAdmin)
admin.site.register(models.TestGroup, TestGroupAdmin)

Fix really strange bug about conflicting models
Fix really strange bug about conflicting models

The bug:

    Failure: RuntimeError (Conflicting 'c' models in application 'nose': <class 'manoseimas.compatibility_test.admin.TestGroup'> and <class 'nose.util.C'>.) ... ERROR

    ======================================================================
    ERROR: Failure: RuntimeError (Conflicting 'c' models in application 'nose': <class 'manoseimas.compatibility_test.admin.TestGroup'> and <class 'nose.util.C'>.)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
    eggs/nose-1.3.7-py2.7.egg/nose/loader.py|523| in makeTest
        return self._makeTest(obj, parent)
    eggs/nose-1.3.7-py2.7.egg/nose/loader.py|568| in _makeTest
        obj = transplant_class(obj, parent.__name__)
    eggs/nose-1.3.7-py2.7.egg/nose/util.py|642| in transplant_class
        class C(cls):
    eggs/Django-1.8.5-py2.7.egg/django/db/models/base.py|309| in __new__
        new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
    eggs/Django-1.8.5-py2.7.egg/django/apps/registry.py|221| in register_model
        (model_name, app_label, app_models[model_name], model))
    RuntimeError: Conflicting 'c' models in application 'nose': <class 'manoseimas.compatibility_test.admin.TestGroup'> and <class 'nose.util.C'>.

Have no idea what is going on here, but it seems related to this bug report:

https://code.djangoproject.com/ticket/22280

To reproduce this bug it is enough to add this line:

    from manoseimas.compatibility_test.models import TestGroup

to `manoseimas/compatibility_test/admin.py`, some how it conflicts with `nose`,
but I'm not sure what `nose` has to do with Django apps and models?

Anyway changing the way how `TestGroup` is imported fixes the bug.

  from django.contrib import admin
  
- from manoseimas.compatibility_test.models import CompatTest
- from manoseimas.compatibility_test.models import Topic
+ from manoseimas.compatibility_test import models
- from manoseimas.compatibility_test.models import TopicVoting
- from manoseimas.compatibility_test.models import Argument
- from manoseimas.compatibility_test.models import TestGroup
  
  
  class VotingInline(admin.TabularInline):
-     model = TopicVoting
+     model = models.TopicVoting
      raw_id_fields = [
          'voting',
      ]
  
  
  class ArgumentInline(admin.TabularInline):
-     model = Argument
+     model = models.Argument
  
  
  class TopicAdmin(admin.ModelAdmin):
      list_display = ('name', 'description')
      list_filter = ('name',)
      inlines = [
          ArgumentInline,
          VotingInline
      ]
  
  
  class TestGroupInline(admin.TabularInline):
-     model = TestGroup
+     model = models.TestGroup
  
  
  class CompatTestAdmin(admin.ModelAdmin):
      list_display = ('name', 'description')
      list_filter = ('name',)
      inlines = [TestGroupInline]
  
  
  class TestGroupAdmin(admin.ModelAdmin):
      list_display = ('name',)
  
- admin.site.register(CompatTest, CompatTestAdmin)
+ admin.site.register(models.CompatTest, CompatTestAdmin)
- admin.site.register(Topic, TopicAdmin)
+ admin.site.register(models.Topic, TopicAdmin)
- admin.site.register(TestGroup, TestGroupAdmin)
+ admin.site.register(models.TestGroup, TestGroupAdmin)
  
Fix really strange bug about conflicting models
## Code Before:
from django.contrib import admin

from manoseimas.compatibility_test.models import CompatTest
from manoseimas.compatibility_test.models import Topic
from manoseimas.compatibility_test.models import TopicVoting
from manoseimas.compatibility_test.models import Argument
from manoseimas.compatibility_test.models import TestGroup


class VotingInline(admin.TabularInline):
    model = TopicVoting
    raw_id_fields = [
        'voting',
    ]


class ArgumentInline(admin.TabularInline):
    model = Argument


class TopicAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    list_filter = ('name',)
    inlines = [
        ArgumentInline,
        VotingInline
    ]


class TestGroupInline(admin.TabularInline):
    model = TestGroup


class CompatTestAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    list_filter = ('name',)
    inlines = [TestGroupInline]


class TestGroupAdmin(admin.ModelAdmin):
    list_display = ('name',)

admin.site.register(CompatTest, CompatTestAdmin)
admin.site.register(Topic, TopicAdmin)
admin.site.register(TestGroup, TestGroupAdmin)

## Instruction:
Fix really strange bug about conflicting models
## Code After:
from django.contrib import admin

from manoseimas.compatibility_test import models


class VotingInline(admin.TabularInline):
    model = models.TopicVoting
    raw_id_fields = [
        'voting',
    ]


class ArgumentInline(admin.TabularInline):
    model = models.Argument


class TopicAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    list_filter = ('name',)
    inlines = [
        ArgumentInline,
        VotingInline
    ]


class TestGroupInline(admin.TabularInline):
    model = models.TestGroup


class CompatTestAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    list_filter = ('name',)
    inlines = [TestGroupInline]


class TestGroupAdmin(admin.ModelAdmin):
    list_display = ('name',)

admin.site.register(models.CompatTest, CompatTestAdmin)
admin.site.register(models.Topic, TopicAdmin)
admin.site.register(models.TestGroup, TestGroupAdmin)
