from django.db import models
from django.contrib.auth.models import User


class Tag(models.Model):
    description = models.TextField()


class Position(models.Model):
    company = models.TextField()
    job_title = models.TextField()
    description = models.TextField()
    tags = models.ManyToManyField(Tag)


class Application(models.Model):
    user = models.ForeignKey(User)
    position = models.ForeignKey(Position)

    APPLIED = 'APP'
    REJECTED = 'REJ'
    INTERVIEWING = 'INT'
    NEGOTIATING = 'NEG'
    STATUS_CHOICES = (
        (APPLIED, 'Applied'),
        (REJECTED, 'Rejected'),
        (INTERVIEWING, 'Interviewing'),
        (NEGOTIATING, 'Negotiating'),
    )
    status = models.CharField(max_length=3, choices=STATUS_CHOICES, default=APPLIED)

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

from django.db import models
from django.contrib.auth.models import User


class Tag(models.Model):
    description = models.TextField()

    def __unicode__(self):
        return self.description


class Position(models.Model):
    company = models.TextField()
    job_title = models.TextField()
    description = models.TextField()
    tags = models.ManyToManyField(Tag)

    def __unicode__(self):
        return u'%s at %s' % (self.job_title, self.company)


class Application(models.Model):
    user = models.ForeignKey(User)
    position = models.ForeignKey(Position)

    APPLIED = 'APP'
    REJECTED = 'REJ'
    INTERVIEWING = 'INT'
    NEGOTIATING = 'NEG'
    STATUS_CHOICES = (
        (APPLIED, 'Applied'),
        (REJECTED, 'Rejected'),
        (INTERVIEWING, 'Interviewing'),
        (NEGOTIATING, 'Negotiating'),
    )
    status = models.CharField(max_length=3, choices=STATUS_CHOICES, default=APPLIED)

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

Add unicode representations for tags/positions
Add unicode representations for tags/positions

  from django.db import models
  from django.contrib.auth.models import User
  
  
  class Tag(models.Model):
      description = models.TextField()
  
+     def __unicode__(self):
+         return self.description
+ 
  
  class Position(models.Model):
      company = models.TextField()
      job_title = models.TextField()
      description = models.TextField()
      tags = models.ManyToManyField(Tag)
+ 
+     def __unicode__(self):
+         return u'%s at %s' % (self.job_title, self.company)
  
  
  class Application(models.Model):
      user = models.ForeignKey(User)
      position = models.ForeignKey(Position)
  
      APPLIED = 'APP'
      REJECTED = 'REJ'
      INTERVIEWING = 'INT'
      NEGOTIATING = 'NEG'
      STATUS_CHOICES = (
          (APPLIED, 'Applied'),
          (REJECTED, 'Rejected'),
          (INTERVIEWING, 'Interviewing'),
          (NEGOTIATING, 'Negotiating'),
      )
      status = models.CharField(max_length=3, choices=STATUS_CHOICES, default=APPLIED)
  
      created_at = models.DateTimeField(auto_now_add=True)
      updated_at = models.DateTimeField(auto_now=True)
  
Add unicode representations for tags/positions
## Code Before:
from django.db import models
from django.contrib.auth.models import User


class Tag(models.Model):
    description = models.TextField()


class Position(models.Model):
    company = models.TextField()
    job_title = models.TextField()
    description = models.TextField()
    tags = models.ManyToManyField(Tag)


class Application(models.Model):
    user = models.ForeignKey(User)
    position = models.ForeignKey(Position)

    APPLIED = 'APP'
    REJECTED = 'REJ'
    INTERVIEWING = 'INT'
    NEGOTIATING = 'NEG'
    STATUS_CHOICES = (
        (APPLIED, 'Applied'),
        (REJECTED, 'Rejected'),
        (INTERVIEWING, 'Interviewing'),
        (NEGOTIATING, 'Negotiating'),
    )
    status = models.CharField(max_length=3, choices=STATUS_CHOICES, default=APPLIED)

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

## Instruction:
Add unicode representations for tags/positions
## Code After:
from django.db import models
from django.contrib.auth.models import User


class Tag(models.Model):
    description = models.TextField()

    def __unicode__(self):
        return self.description


class Position(models.Model):
    company = models.TextField()
    job_title = models.TextField()
    description = models.TextField()
    tags = models.ManyToManyField(Tag)

    def __unicode__(self):
        return u'%s at %s' % (self.job_title, self.company)


class Application(models.Model):
    user = models.ForeignKey(User)
    position = models.ForeignKey(Position)

    APPLIED = 'APP'
    REJECTED = 'REJ'
    INTERVIEWING = 'INT'
    NEGOTIATING = 'NEG'
    STATUS_CHOICES = (
        (APPLIED, 'Applied'),
        (REJECTED, 'Rejected'),
        (INTERVIEWING, 'Interviewing'),
        (NEGOTIATING, 'Negotiating'),
    )
    status = models.CharField(max_length=3, choices=STATUS_CHOICES, default=APPLIED)

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
