
from django.db import models

from django.contrib.auth.models import User
from django.utils.translation import ugettext as _

class WeightEntry(models.Model):
    """Model for a weight point
    """
    creation_date = models.DateField(_('Creation date'))
    weight = models.FloatField(_('Weight'))
    user = models.ForeignKey(User, verbose_name = _('User'))

    
    def __unicode__(self):
        """Return a more human-readable representation
        """
        return "%s: %s kg" % (self.creation_date, self.weight)


from django.db import models

from django.contrib.auth.models import User
from django.utils.translation import ugettext as _

class WeightEntry(models.Model):
    """Model for a weight point
    """
    creation_date = models.DateField(_('Creation date'))
    weight = models.FloatField(_('Weight'))
    user = models.ForeignKey(User, verbose_name = _('User'))

     # Metaclass to set some other properties
    class Meta:
        ordering = ["creation_date", ]
    
    def __unicode__(self):
        """Return a more human-readable representation
        """
        return "%s: %s kg" % (self.creation_date, self.weight)

Add default ordering to weight entries
Add default ordering to weight entries

  
  from django.db import models
  
  from django.contrib.auth.models import User
  from django.utils.translation import ugettext as _
  
  class WeightEntry(models.Model):
      """Model for a weight point
      """
      creation_date = models.DateField(_('Creation date'))
      weight = models.FloatField(_('Weight'))
      user = models.ForeignKey(User, verbose_name = _('User'))
  
+      # Metaclass to set some other properties
+     class Meta:
+         ordering = ["creation_date", ]
      
      def __unicode__(self):
          """Return a more human-readable representation
          """
          return "%s: %s kg" % (self.creation_date, self.weight)
  
Add default ordering to weight entries
## Code Before:

from django.db import models

from django.contrib.auth.models import User
from django.utils.translation import ugettext as _

class WeightEntry(models.Model):
    """Model for a weight point
    """
    creation_date = models.DateField(_('Creation date'))
    weight = models.FloatField(_('Weight'))
    user = models.ForeignKey(User, verbose_name = _('User'))

    
    def __unicode__(self):
        """Return a more human-readable representation
        """
        return "%s: %s kg" % (self.creation_date, self.weight)

## Instruction:
Add default ordering to weight entries
## Code After:

from django.db import models

from django.contrib.auth.models import User
from django.utils.translation import ugettext as _

class WeightEntry(models.Model):
    """Model for a weight point
    """
    creation_date = models.DateField(_('Creation date'))
    weight = models.FloatField(_('Weight'))
    user = models.ForeignKey(User, verbose_name = _('User'))

     # Metaclass to set some other properties
    class Meta:
        ordering = ["creation_date", ]
    
    def __unicode__(self):
        """Return a more human-readable representation
        """
        return "%s: %s kg" % (self.creation_date, self.weight)
