What I have currently is a CharField for clients which of course might pose issues in the future when I'm not the only person entering job data. I don't want to misspell a client name and mess up my web app, additionally, if a client changes their name I'd want the app to automatically change the name of the client on previous jobs.
I created a new model
class Clients(models.Model):
client = models.CharField(max_length=120, blank=False, null=True)
def __unicode__(self): #python 3.3. is __str__
return self.client`
and added all of the clients to it. I want to be able to now have
from django.db import models
a = allclients #pseudocode
class Jobs(models.Model):
client = models.CharField(max_length=120,choices=a,blank=True, null=True)#testing
How do I get 'a' to actually populate and how do I make sure that if a client name is changed in Clients(models.Model) that it updates everything I'm doing with my Jobs(models.Model)?
EDIT
I have attempted to add a foreign key. By doing
class Jobs(models.Model):
# ... other stuff
client = models.ForeignKey('Clients')
I flushed my database and started over because I was having issues migrating and I'm now getting an error that says:
Exception Value:
no such column: SiteTwo_jobs.client_id