I have been learning django for like 1 month now and i felt the best way is to do a project. i settled on a simple school management project but I am kind of stacked. This project has different categories of users i.e students and administrator. the school administrator should log in and add new students, the students should also log in and may be edit their profile. I created a nother app UserProfile with User as foreignKey and category
class Category(models.Model):
name=models.CharField(max_length=200)
def __unicode__(self):
return self.name
class UserProfile(models.Model):
user=models.OneToOneField(User)
category=models.ForeignKey(Category)
def __unicode__(self):
return "%s "%(self.category.name)
I added sample users from the admin site and am so far able to redirect the school administrator to his frontend dashboard where he should be adding new student. the students also are redirected to the students page upon login. i have a common login form. my first question is, should i have user as foreigkey in the student model like below?
class Student(models.Model):
user=models.OneToOneField(User)
regNum=models.CharField(max_length=200, unique=True)
lastName=models.CharField(max_length=200)
otherNames=models.CharField(max_length=200)
dateOfBirth=models.DateField()
idNo=models.IntegerField(default=123456)
email=models.EmailField()
contact=models.IntegerField(default=071234567)
HomeTown=models.CharField(max_length=200)
- How can i handle add new student so that the administrator is able to add student details including the students login password and at the same time assign a category to the student. please note that am new in django. thanks