title: How to get the value of the counter of an AutoField?
body: <p>How to get the value of the counter of an <code>AutoField</code>, such as the usual <code>id</code> field of most models?</p>
  
  <p>At the moment, I do:</p>
  
  <pre><code>MyModel.objects.latest('id').id
  </code></pre>
  
  <p>But that does not work when all the objects have been deleted from the database.</p>
  
  <p>Of course, a database-agnostic answer would be best.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The accepted answer in <a href="https://stackoverflow.com/questions/579957/model-next-available-primary-key">Model next available primary key</a> is not very relevant to my question, as I do not intend to use the counter value to create a new object. Also I don't mind if the value I get is not super accurate.</p>