I'm new to Django, and I tried my best to figure it out, but I still have a long way to go. I am working on a project in which I have to create a web page where I have to display data from these classes:
class team(models.Model): team_name = models.CharField(max_length = 40) def __unicode__(self): return self.team_name class metric(models.Model): team = models.ForeignKey(team) metric_name = models.CharField(max_length = 40) def __unicode__(self): return self.metric_name class members(models.Model): metric = models.ForeignKey(metric) member_ID = models.CharField(max_length = 40) member_name = models.CharField(max_length = 40, null=True, blank=True) def __unicode__(self): return self.member_ID
In addition, I want this data to be editable as well. So, there should be an “Edit” button, which, after clicking, will allow the user to edit these fields, and as soon as he saves, the database will automatically be updated.
Now, as I understand it. Will I need to display this data using some kind of table, and then, as soon as the user clicks the "Change" button, will I need to change the Tables into a form so that he can edit the data? and then update the database as soon as it clicks on save.
I'm not sure how to do this in Django. If someone could refer to me step by step on how to proceed further and possibly refer to some links. It helped me a lot.
Thanks:)
UPDATE: I forgot to mention this before. I already created a page where the user selects group_name .. Then he is redirected to another page where I want to show the table for this particular command. And I also want the page to be editable. If I use modelforms, then I will not be able to access one object of my command model.
UPDATE2: I still adhere to this. I can’t understand how to display only a few elements and variables of the model class, and not all. In addition, I cannot understand how to create a form that can receive input from a user for whom the database object must edit, and then show that some objects are subject to editing.