﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22839	Many to many hasattr check fails with python 3	web-chib@…	nobody	"Example model:


{{{
class CommentModel(models.Model):
    users_liked = models.ManyToManyField(UserModel, blank=True, null=True)
    text = models.CharField(max_length=200)
}}}

With python 2 it's ok:
{{{
hasattr(CommentModel(text='hello'), 'users_liked')  # => True
}}}

With python 3 it fails:
{{{
hasattr(CommentModel(text='hello'), 'users_liked')

Traceback (most recent call last):
  File ""tests.py"", line 33, in test_should_use_default_saving_without_partial
    hasattr(CommentModel(text='hello'), 'users_liked')
  File "".tox/django1.6.2/lib/python3.4/site-packages/django/db/models/fields/related.py"", line 825, in __get__
    through=self.field.rel.through,
  File "".tox/django1.6.2/lib/python3.4/site-packages/django/db/models/fields/related.py"", line 522, in __init__
    (instance, source_field_name))
ValueError: ""<CommentModel: CommentModel object>"" needs to have a value for field ""commentmodel"" before this many-to-many relationship can be used.
}}}

As i understood `ValueError` is caught somewhere in python 2, but not caught in python 3."	Cleanup/optimization	closed	Database layer (models, ORM)	1.6	Normal	invalid		Kevin Brown cmawebsite@…	Accepted	0	0	0	0	0	0
