Usage of latest() method with field types other than date field (Django)
<p>I have just learned about the <code>latest()</code> method. I went to the django's documentation to find out more about it. In the docs it is written:</p>
<blockquote>
<p><a href="https://docs.djangoproject.com/el/1.10/ref/models/querysets/#latest" rel="nofollow noreferrer"><strong>latest(field_name=None)</strong></a></p>
<p>Returns the latest object in the table, by date, using the <strong>field_name</strong> provided as the date field.</p>
</blockquote>
<p>However in the tutorial ,that I am following, this method is used together with field name for <code>models.PositiveIntegerField()</code> field(and the model does not specify <code>get_latest_by</code>). I have been trying to search for explanation and similar use of this method, where the <code>field_name</code> is different than date field.</p>
<p>I have found some information <a href="https://stackoverflow.com/questions/15675672/django-get-the-latest-record-with-filter">here</a> where it is said that:</p>
<blockquote>
<p>...it probably does work with other total-ordered types too, but not sure...</p>
</blockquote>
<p>and</p>
<blockquote>
<p>It does work with primary keys ...</p>
</blockquote>
<p>Also I have found similar case <a href="https://stackoverflow.com/questions/21077865/django-model-latest-method">here</a>, where the <code>latest()</code> method is used with <code>id</code> field.</p>
<p>However still I did not find an answer whether it is ok to use this method with something other than date field? Is there any other method which is more appropriate for this kind of task?</p>