1

I want to set a 'app_id'of application model as a foreign key for interviewstable's app_id

class application(models.Model):
    app_id = models.IntegerField(max_length=200)
    job_title = models.CharField(max_length=200)
    odesk_id = models.CharField(max_length=200)
    client_spent = models.CharField(max_length=200)
    job_type = models.CharField(max_length=200)
    notes_type = models.CharField(max_length=500)



class interviewtable(models.Model):
    app_id = models.IntegerField(max_length=200)
    interview = models.CharField(max_length=200)
    interview_on = models.CharField(max_length=200)
    interview_notes = models.CharField(max_length=200) 
1
  • 5
    How about doing Django's official tutorial (and reading the doc) before you have too much bad code to maintain ? Commented Aug 27, 2013 at 8:40

1 Answer 1

4

Like this:

class interviewtable(models.Model):
    app = models.ForeignKey(application)
    interview = models.CharField(max_length=200)
    interview_on = models.CharField(max_length=200)
    interview_notes = models.CharField(max_length=200) 

Django with automatically add id thus app would be app_id.

Also, you don't want to use max_length on integer field. If you want big integer use BigIntegerField() Read the documentation properly: https://docs.djangoproject.com/en/1.5/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.