title: Having trouble using JWT with a custom User model in Django
body: <p>I've started a new Django project and like the documentation recommends I've created a custom user model just in case it's needed and made sure to set <code>AUTH_USER_MODEL</code> in settings.</p>
  
  <pre><code>from django.contrib.auth.models import AbstractUser
  
  class User(AbstractUser):
      pass
  </code></pre>
  
  <p>I notice that when you do this you cannot run <code>python manage.py makemigrations</code> you actually have to specify the app the custom user model is in <code>python manage.py makemigrations &lt;appname&gt;</code>. Once I do that I'm able to start the server. </p>
  
  <p>I followed this post to integrate JWT into my new project: <a href="https://medium.com/@dakota.lillie/django-react-jwt-authentication-5015ee00ef9a" rel="nofollow noreferrer">Django React JWT</a></p>
  
  <p>Without the custom user model the post works great but once I add in a custom user model I start getting these errors:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/django/core/handlers/exception.py", line 35, in inner
      response = get_response(request)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/django/core/handlers/base.py", line 128, in _get_response
      response = self.process_exception_by_middleware(e, request)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/django/core/handlers/base.py", line 126, in _get_response
      response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
      return view_func(*args, **kwargs)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/django/views/generic/base.py", line 69, in view
      return self.dispatch(request, *args, **kwargs)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/views.py", line 483, in dispatch
      response = self.handle_exception(exc)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/views.py", line 443, in handle_exception
      self.raise_uncaught_exception(exc)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/views.py", line 480, in dispatch
      response = handler(request, *args, **kwargs)
    File "/Users/repos/api/core/views.py", line 30, in post
      if serializer.is_valid():
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/serializers.py", line 236, in is_valid
      self._validated_data = self.run_validation(self.initial_data)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/serializers.py", line 434, in run_validation
      value = self.to_internal_value(data)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/serializers.py", line 482, in to_internal_value
      fields = self._writable_fields
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/django/utils/functional.py", line 36, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/serializers.py", line 370, in _writable_fields
      field for field in self.fields.values() if not field.read_only
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/serializers.py", line 363, in fields
      for key, value in self.get_fields().items():
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/serializers.py", line 1019, in get_fields
      info = model_meta.get_field_info(model)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/utils/model_meta.py", line 39, in get_field_info
      forward_relations = _get_forward_relationships(opts)
    File "/Users/.local/share/virtualenvs/api-RqAznZCl/lib/python3.7/site-packages/rest_framework/utils/model_meta.py", line 96, in _get_forward_relationships
      not field.remote_field.through._meta.auto_created
  AttributeError: 'NoneType' object has no attribute '_meta'
  </code></pre>
  
  <p>Seems like ti has something to do with the serializer as I used pdb to trace and the token was being generated but the user object that is passed back isn't being serialized properly...</p>