title: Rename Model that is used as a superclass in another model
body: <p>I have a class <code>FirstName</code> that I need to rename to <code>SecondName</code>, but this class is also used as a base class for other models.</p>
  
  <pre><code># file 1
  class FirstName(models.Model):
      pass # stuff
  
  
  # file 2
  from firstfile.models import FirstName
  
  class ProxyModel(FirstName):
      pass # stuff
  </code></pre>
  
  <p>I tried updating the model name and all references to it...</p>
  
  <pre><code># file 1
  class SecondName(models.Model):
      pass # stuff
  
  
  # file 2
  from firstfile.models import SecondName
  
  class ProxyModel(SecondName):
      pass # stuff
  
  
  # migration
  operations = [
      migrations.RenameModel(
          old_name='FirstName',
          new_name='SecondName',
      ),
  ]
  </code></pre>
  
  <p>But when I run <code>makemigrations</code> or 'migrate' I get an error:</p>
  
  <blockquote>
  <pre><code>django.db.migrations.exceptions.InvalidBasesError: Cannot resolve
  bases for [&lt;ModelState:
  'my_app.ProxyModel'&gt;] This can happen if you are
  inheriting models from an app with migrations (e.g. contrib.auth)  in
  an app with no migrations;
  </code></pre>
  </blockquote>
  
  <p>It seems I cannot import the renamed base model before migration, but I cannot migrate until I resolve the base class issue... </p>
  
  <p>I did already try using the previous model name for the Proxy base class, but get model not found error. I also tried to comment out the proxy model, but still got the error (I think because of the migrations already run for that proxy model).</p>
  
  <p>How can I get around this rename dependency loop? </p>
  
  <p>Python 2.7, Django 1.11</p>