hovel/pybbm — pull request #118 by Ryochan7 (2014-02-17 23:05:43+00:00)
Title: Fixed method of finding profile model on Django 1.6.1.

PyBBM did not work for me initially when I tried testing it. I couldn't even sync the models to the database without errors occurring when the admin.py or the forms.py files were being imported. It seems that the \_meta.get_field_by_name method that was being used to obtain the Profile class has changed in Django 1.6 because the field does not get returned from that method. I found a different way to obtain the Profile class from the field specified in defaults.PYBB_PROFILE_RELATED_NAME. Here is a traceback of the main error that I was getting.

````
Traceback (most recent call last):
File "manage.py", line 28, in
execute_from_command_line(sys.argv)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/mezzanine/core/management/__init__.py", line 15, in
from mezzanine.utils.tests import copy_test_to_media
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/mezzanine/utils/tests.py", line 18, in
User = get_user_model()
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 127, in get_user_model
user_model = get_model(app_label, model_name)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/db/models/loading.py", line 271, in get_model
self._populate()
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in _populate
self.load_app(app_name)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app
models = import_module('%s.models' % app_name)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/debug_toolbar/models.py", line 63, in
patch_root_urlconf()
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/debug_toolbar/models.py", line 51, in patch_root_urlconf
reverse('djdt:render_panel')
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/core/urlresolvers.py", line 480, in reverse
app_list = resolver.app_dict[ns]
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/core/urlresolvers.py", line 310, in app_dict
self._populate()
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/core/urlresolvers.py", line 262, in _populate
for pattern in reversed(self.url_patterns):
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/core/urlresolvers.py", line 346, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/core/urlresolvers.py", line 341, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/home/ryochan7/Projects/asylum/urls.py", line 10, in
admin.autodiscover()
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/mezzanine/boot/__init__.py", line 77, in autodiscover
django_autodiscover(*args, **kwargs)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 29, in autodiscover
import_module('%s.admin' % app)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/pybb/admin.py", line 145, in
if util.get_pybb_profile_model() == Profile:
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/pybb/util.py", line 71, in get_pybb_profile_model
return get_user_model()._meta.get_field_by_name(defaults.PYBB_PROFILE_RELATED_NAME)[0].model
File "/home/ryochan7/.virtualenvs/asylum/lib/python2.7/site-packages/django/db/models/options.py", line 377, in get_field_by_name
% (self.object_name, name))
django.db.models.fields.FieldDoesNotExist: User has no field named u'pybb_profile'
````