7
isinstance
also compare module location, response.context['form']
class’ module is forms
where SomeForm module is app.forms
you check this by inspecting respectively __class__.__module__
and __module__
.
To make isinstance work you can:
- fix the import in the views.py (recommended)
- alter sys.path in form_testse.py to be able to import the form as from forms import SomeForm
- try intrapackage references
0
one possible hack is to check the __name__
attribute of the types, although unless you fix it the Right way, you might run into other issues
def sharetypename(obj1, obj2):
if isinstance(obj1, type):
c1 = obj1.__name__
else:
c1 = type(obj1).__name__
if isinstance(obj2, type):
c2 = obj2.__name__
else:
c2 = type(obj2).__name__
return c1 == c2
- [Django]-Error running manage.py syncdb for first time on Heroku: "You need to specify NAME in your Django settings file"
- [Django]-Overwrite an Existing Template Tag method in Django 1.8
- [Django]-Relational DatabaseError in django postgresql database after deploying project to bitnami
- [Django]-Django modelform with bootstrap
Source:stackexchange.com