from django.db import models


class Lease(models.Model):
    class Meta:
        db_table = 'autoreg'

    mac = models.CharField(max_length=17, db_index=True)
    ip = models.IntegerField(primary_key=True)
    date = models.IntegerField()

from django.db import models
from ipaddr import IPv4Address


class Lease(models.Model):
    class Meta:
        db_table = 'autoreg'

    mac = models.CharField(max_length=17, db_index=True)
    ip = models.IntegerField(primary_key=True)
    date = models.IntegerField()

    def __str__(self):
        return unicode(self).encode('ascii', 'replace')

    def __unicode__(self):
        return unicode(IPv4Address(self.ip)) + u' = ' + unicode(self.mac)

    def __repr__(self):
        return u'<Lease: ' + unicode(self) + u'>'

Add __str__, __unicode__, and __repr__
Add __str__, __unicode__, and __repr__

  from django.db import models
+ from ipaddr import IPv4Address
  
  
  class Lease(models.Model):
      class Meta:
          db_table = 'autoreg'
  
      mac = models.CharField(max_length=17, db_index=True)
      ip = models.IntegerField(primary_key=True)
      date = models.IntegerField()
  
+     def __str__(self):
+         return unicode(self).encode('ascii', 'replace')
+ 
+     def __unicode__(self):
+         return unicode(IPv4Address(self.ip)) + u' = ' + unicode(self.mac)
+ 
+     def __repr__(self):
+         return u'<Lease: ' + unicode(self) + u'>'
+ 
Add __str__, __unicode__, and __repr__
## Code Before:
from django.db import models


class Lease(models.Model):
    class Meta:
        db_table = 'autoreg'

    mac = models.CharField(max_length=17, db_index=True)
    ip = models.IntegerField(primary_key=True)
    date = models.IntegerField()

## Instruction:
Add __str__, __unicode__, and __repr__
## Code After:
from django.db import models
from ipaddr import IPv4Address


class Lease(models.Model):
    class Meta:
        db_table = 'autoreg'

    mac = models.CharField(max_length=17, db_index=True)
    ip = models.IntegerField(primary_key=True)
    date = models.IntegerField()

    def __str__(self):
        return unicode(self).encode('ascii', 'replace')

    def __unicode__(self):
        return unicode(IPv4Address(self.ip)) + u' = ' + unicode(self.mac)

    def __repr__(self):
        return u'<Lease: ' + unicode(self) + u'>'
