VeryApt / django-phone-field

Lightweight model and form field for phone numbers in Django
GNU General Public License v3.0
52 stars 13 forks source link

Unhashable type #13

Closed simondrabble closed 4 years ago

simondrabble commented 4 years ago

Django 3.0.5

Attempting to save a phone number field in the admin, defined like so:

number = PhoneField(null=False, blank=False, unique=True)

I receive this:

unhashable type: 'PhoneNumber'

va-andrew commented 4 years ago

Hi! Can you please reply with the full stack trace?

simondrabble commented 4 years ago
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 607, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/sites.py", line 231, in inner
    return view(request, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1641, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "/usr/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1522, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1564, in _changeform_view
    if all_valid(formsets) and form_validated:
  File "/usr/lib/python3.8/site-packages/django/forms/formsets.py", line 464, in all_valid
    valid &= formset.is_valid()
  File "/usr/lib/python3.8/site-packages/django/forms/formsets.py", line 308, in is_valid
    self.errors
  File "/usr/lib/python3.8/site-packages/django/forms/formsets.py", line 288, in errors
    self.full_clean()
  File "/usr/lib/python3.8/site-packages/django/forms/formsets.py", line 356, in full_clean
    self.clean()
  File "/usr/lib/python3.8/site-packages/django/forms/models.py", line 677, in clean
    self.validate_unique()
  File "/usr/lib/python3.8/site-packages/django/forms/models.py", line 710, in validate_unique
    if row_data in seen_data:
TypeError: unhashable type: 'PhoneNumber'