I am attempting to make the leap from Node+Mongo to Django+Sqlite (better fits my needs) but I am having trouble creating the models for my database in Django.
In my Node app, my collections are modeled as such:
{
"username": "someuser",
"password": "passwordhash",
"email": "test@email.com",
"friends": [
"friend1",
"friend2",
"friend3"
]
}
But each user also had a status, which was in a different collection:
{
"username": "someuser",
"status": "happy"
}
Right away I see the 1-to-1 relationship between status and user using foreign keys but the part that has me confused is creating the array of friends. How would I represent that in my model?
This is what I have so far:
class User(models.Model):
username = models.CharField(max_length=32);
password = models.CharField(max_length=200);
email = models.EmailField();
# what goes for the friends?
class CurrentStatus(models.Model):
username = models.ForeignKey(User);
status = models.CharField(max_length=32);
EDIT I found this answer (http://stackoverflow.com/a/14715454/2068709) helpful but it doesn't answer my question because I don't want the relationships to be symmetrical.