title: Is there a workaround for Django's `ModelDoesNotExist` error in a situation like this?
body: <p>So I get a <code>ModelDoesNotExist</code> error when I run <code>manage.py runserver</code> because in a file in my directory, I make a query to a table which has not been populated yet.</p>
  <pre><code>def __init__(self):
      self.spotify_object = SocialToken.objects.get(account__provider=&quot;spotify&quot;)
  </code></pre>
  <p>The above is a class instantiated to perform some sort of authentication and the <code>SocialToken</code> table gets populated only after I login. Now, I was wondering if there was a way to escape the error by triggering this part of the code only after I login? I only use the class in an endpoint, and during that period, the table would have been populated but the fact that it is not populated before running the server is causing a <code>DoesNotExist</code> error. Is there a solution to this?</p>
  <p><code>Traceback</code></p>
  <pre><code>File &quot;C:\Users\Kwaku Biney\Desktop\sparison-1\project\Sparison\views.py&quot;, line 4, in &lt;module&gt;
  from .authentication import SparisonCacheHandler
  File &quot;C:\Users\Kwaku Biney\Desktop\sparison-1\project\Sparison\authentication.py&quot;, line 43, in 
  &lt;module&gt;
  cache_handler = SparisonCacheHandler() ,
   File &quot;C:\Users\Kwaku Biney\Desktop\sparison-1\project\Sparison\authentication.py&quot;, line 25, 
  in __init__
  self.spotify_object = SocialToken.objects.get(account__provider=&quot;spotify&quot;)
  File &quot;C:\Users\Kwaku Biney\Desktop\sparison-1\project\venv\lib\site- 
  packages\django\db\models\manager.py&quot;, line 85, in manager_method
  return getattr(self.get_queryset(), name)(*args, **kwargs)
  File &quot;C:\Users\Kwaku Biney\Desktop\sparison-1\project\venv\lib\site- 
  packages\django\db\models\query.py&quot;, line 429, in get
  raise self.model.DoesNotExist(
  allauth.socialaccount.models.DoesNotExist: SocialToken matching query does not exist.
  </code></pre>
  <p>In my <code>views.py</code>, I import the class which has the query and the error comes up.</p>