How to let user create fields and save records as choice lists? - Django rest frameworkHow to disable admin-style browsable interface of django-rest-framework?Django REST framework: non-model serializerDjango REST Framework: adding additional field to ModelSerializerHow to change field name in Django REST FrameworkDjango Rest Framework: Dynamically return subset of fieldsSerializing custom related field in DRFDjango-Rest-Framework - How to serialize queryset from an unrelated model as nested serializerHow to implement update_or_create inside create method of ModelSerializerHow to check if Django Signal works?

What is the source of the fear in the Hallow spell's extra Fear effect?

What are some countries where you can be imprisoned for reading or owning a Bible?

Are buttons really enough to bound validities by S4.2?

Bidirectional Dictionary

What's this constructed number's starter?

Is the Levitate spell supposed to basically disable a melee-based enemy?

Would you recommend a keyboard for beginners with or without lights in keys for learning?

In-universe, why does Doc Brown program the time machine to go to 1955?

What is the majority of the UK Government as of 2019-09-04?

Mute single speaker?

Global variables and information security

'Hard work never hurt anyone' Why not 'hurts'?

Low quality postdoc application and deadline extension

Tying double knot of garbarge bag

Do we know what "hardness" of Brexit people actually wanted in the referendum, if there had been other choices available?

What's the difference between a share and a stock?

Solve the given inequality below in the body.

Tiny image scraper for xkcd.com

If I sell my PS4 game disc and buy a digital version, can I still access my saved game?

Dissuading my girlfriend from a scam

Comparing elements in a nested list to generate a new list

How to find better food in airports

Was Rosie the Riveter sourced from a Michelangelo painting?

In the DC universe, which characters assumed the identity of the Red Hood?



How to let user create fields and save records as choice lists? - Django rest framework


How to disable admin-style browsable interface of django-rest-framework?Django REST framework: non-model serializerDjango REST Framework: adding additional field to ModelSerializerHow to change field name in Django REST FrameworkDjango Rest Framework: Dynamically return subset of fieldsSerializing custom related field in DRFDjango-Rest-Framework - How to serialize queryset from an unrelated model as nested serializerHow to implement update_or_create inside create method of ModelSerializerHow to check if Django Signal works?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I would like to create a Management System, when I create a Project, project contains many TaskGroup such as "To do", "Doing" and "Done", and which is the default type of TaskGroup called DefaultTaskGroup, and Admin can create some other TaskGroup with different fields CharField, TextField, DateTimeField, Single or Multiple Choice.,etc, which will be save as TaskGoup1 with new field 1 and new field 2, TaskGroup2 with new field 3 and new field 4, if I created a new task, I can choose the type of TaskGroup from taskgroup lists(Default Task Group, TaskGroup1 and TaskGroup2).



I created partial models as below, they are not right, but I am puzzled about the database structure. Thank for reading and any advice will be highly appreciate.



class TaskGroupType(models.Model):
name = models.CharField(max_length=58, null=True)

def __str__(self):
return self.name


class Project(models.Model):
created = models.DateTimeField(auto_now_add=True)
owner = models.ForeignKey(
UserProjectOwners, null=True, blank=True,
on_delete=models.CASCADE, related_name='Owner'
)
name = models.CharField(max_length=100)
desc = models.CharField(max_length=200, null=True, blank=True)
category = models.CharField(max_length=100, null=True, blank=True)
members = models.ForeignKey(
UserProjectTeam, null=True, blank=True,
on_delete=models.CASCADE, related_name="project"
)
tasktype = models.ManyToManyField(TaskType)

class Meta:
ordering =['created']
verbose_name = "User Table"
verbose_name_plural = verbose_name

def __str__(self):
return self.name

class TaskGroup(models.Model):
created = models.DateTimeField(auto_now_add=True)
name = models.CharField(max_length=280, blank=True)
order = models.IntegerField(null=True, blank=True)
project = models.ForeignKey(
Project,
related_name='taskgroups', null=True, blank=True,
on_delete=models.CASCADE
)

class Meta:
ordering =['created']
verbose_name = "Task Group"
verbose_name_plural = verbose_name

def __str__(self):
return self.name

class Task(models.Model):
SORT_TYPE = (
(1, "Normal"),
(2, "Urgent"),
(3, "Very Urgent"),
)
createDate = models.DateTimeField(auto_now_add=True)
tasklist = models.ForeignKey(
TaskList,
related_name='tasks', null=True, blank=True,
on_delete=models.CASCADE
)
completed = models.BooleanField(default=False)
accomplished = models.DateTimeField(null=True, blank=True)
desc = models.CharField(max_length=380, blank=True)
name = models.CharField(max_length=180, blank=True)
performer = models.ForeignKey(
User,
related_name='Task', null=True, blank=True,
on_delete=models.CASCADE
)
participant = models.ManyToManyField(
User,
related_name='+'
)
startDate = models.DateTimeField(null=True, blank=True)
dueDate = models.DateTimeField(null=True, blank=True)
priority = models.CharField(max_length=100, choices=SORT_TYPE, null=True, blank=True)
order = models.IntegerField(null=True, blank=True)
remark = models.CharField(max_length=400, null=True, blank=True)

class Meta:
ordering =['createDate']
verbose_name = "Task Table"
verbose_name_plural = verbose_name

def __str__(self):
return self.name









share|improve this question
































    0















    I would like to create a Management System, when I create a Project, project contains many TaskGroup such as "To do", "Doing" and "Done", and which is the default type of TaskGroup called DefaultTaskGroup, and Admin can create some other TaskGroup with different fields CharField, TextField, DateTimeField, Single or Multiple Choice.,etc, which will be save as TaskGoup1 with new field 1 and new field 2, TaskGroup2 with new field 3 and new field 4, if I created a new task, I can choose the type of TaskGroup from taskgroup lists(Default Task Group, TaskGroup1 and TaskGroup2).



    I created partial models as below, they are not right, but I am puzzled about the database structure. Thank for reading and any advice will be highly appreciate.



    class TaskGroupType(models.Model):
    name = models.CharField(max_length=58, null=True)

    def __str__(self):
    return self.name


    class Project(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    owner = models.ForeignKey(
    UserProjectOwners, null=True, blank=True,
    on_delete=models.CASCADE, related_name='Owner'
    )
    name = models.CharField(max_length=100)
    desc = models.CharField(max_length=200, null=True, blank=True)
    category = models.CharField(max_length=100, null=True, blank=True)
    members = models.ForeignKey(
    UserProjectTeam, null=True, blank=True,
    on_delete=models.CASCADE, related_name="project"
    )
    tasktype = models.ManyToManyField(TaskType)

    class Meta:
    ordering =['created']
    verbose_name = "User Table"
    verbose_name_plural = verbose_name

    def __str__(self):
    return self.name

    class TaskGroup(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    name = models.CharField(max_length=280, blank=True)
    order = models.IntegerField(null=True, blank=True)
    project = models.ForeignKey(
    Project,
    related_name='taskgroups', null=True, blank=True,
    on_delete=models.CASCADE
    )

    class Meta:
    ordering =['created']
    verbose_name = "Task Group"
    verbose_name_plural = verbose_name

    def __str__(self):
    return self.name

    class Task(models.Model):
    SORT_TYPE = (
    (1, "Normal"),
    (2, "Urgent"),
    (3, "Very Urgent"),
    )
    createDate = models.DateTimeField(auto_now_add=True)
    tasklist = models.ForeignKey(
    TaskList,
    related_name='tasks', null=True, blank=True,
    on_delete=models.CASCADE
    )
    completed = models.BooleanField(default=False)
    accomplished = models.DateTimeField(null=True, blank=True)
    desc = models.CharField(max_length=380, blank=True)
    name = models.CharField(max_length=180, blank=True)
    performer = models.ForeignKey(
    User,
    related_name='Task', null=True, blank=True,
    on_delete=models.CASCADE
    )
    participant = models.ManyToManyField(
    User,
    related_name='+'
    )
    startDate = models.DateTimeField(null=True, blank=True)
    dueDate = models.DateTimeField(null=True, blank=True)
    priority = models.CharField(max_length=100, choices=SORT_TYPE, null=True, blank=True)
    order = models.IntegerField(null=True, blank=True)
    remark = models.CharField(max_length=400, null=True, blank=True)

    class Meta:
    ordering =['createDate']
    verbose_name = "Task Table"
    verbose_name_plural = verbose_name

    def __str__(self):
    return self.name









    share|improve this question




























      0












      0








      0








      I would like to create a Management System, when I create a Project, project contains many TaskGroup such as "To do", "Doing" and "Done", and which is the default type of TaskGroup called DefaultTaskGroup, and Admin can create some other TaskGroup with different fields CharField, TextField, DateTimeField, Single or Multiple Choice.,etc, which will be save as TaskGoup1 with new field 1 and new field 2, TaskGroup2 with new field 3 and new field 4, if I created a new task, I can choose the type of TaskGroup from taskgroup lists(Default Task Group, TaskGroup1 and TaskGroup2).



      I created partial models as below, they are not right, but I am puzzled about the database structure. Thank for reading and any advice will be highly appreciate.



      class TaskGroupType(models.Model):
      name = models.CharField(max_length=58, null=True)

      def __str__(self):
      return self.name


      class Project(models.Model):
      created = models.DateTimeField(auto_now_add=True)
      owner = models.ForeignKey(
      UserProjectOwners, null=True, blank=True,
      on_delete=models.CASCADE, related_name='Owner'
      )
      name = models.CharField(max_length=100)
      desc = models.CharField(max_length=200, null=True, blank=True)
      category = models.CharField(max_length=100, null=True, blank=True)
      members = models.ForeignKey(
      UserProjectTeam, null=True, blank=True,
      on_delete=models.CASCADE, related_name="project"
      )
      tasktype = models.ManyToManyField(TaskType)

      class Meta:
      ordering =['created']
      verbose_name = "User Table"
      verbose_name_plural = verbose_name

      def __str__(self):
      return self.name

      class TaskGroup(models.Model):
      created = models.DateTimeField(auto_now_add=True)
      name = models.CharField(max_length=280, blank=True)
      order = models.IntegerField(null=True, blank=True)
      project = models.ForeignKey(
      Project,
      related_name='taskgroups', null=True, blank=True,
      on_delete=models.CASCADE
      )

      class Meta:
      ordering =['created']
      verbose_name = "Task Group"
      verbose_name_plural = verbose_name

      def __str__(self):
      return self.name

      class Task(models.Model):
      SORT_TYPE = (
      (1, "Normal"),
      (2, "Urgent"),
      (3, "Very Urgent"),
      )
      createDate = models.DateTimeField(auto_now_add=True)
      tasklist = models.ForeignKey(
      TaskList,
      related_name='tasks', null=True, blank=True,
      on_delete=models.CASCADE
      )
      completed = models.BooleanField(default=False)
      accomplished = models.DateTimeField(null=True, blank=True)
      desc = models.CharField(max_length=380, blank=True)
      name = models.CharField(max_length=180, blank=True)
      performer = models.ForeignKey(
      User,
      related_name='Task', null=True, blank=True,
      on_delete=models.CASCADE
      )
      participant = models.ManyToManyField(
      User,
      related_name='+'
      )
      startDate = models.DateTimeField(null=True, blank=True)
      dueDate = models.DateTimeField(null=True, blank=True)
      priority = models.CharField(max_length=100, choices=SORT_TYPE, null=True, blank=True)
      order = models.IntegerField(null=True, blank=True)
      remark = models.CharField(max_length=400, null=True, blank=True)

      class Meta:
      ordering =['createDate']
      verbose_name = "Task Table"
      verbose_name_plural = verbose_name

      def __str__(self):
      return self.name









      share|improve this question
















      I would like to create a Management System, when I create a Project, project contains many TaskGroup such as "To do", "Doing" and "Done", and which is the default type of TaskGroup called DefaultTaskGroup, and Admin can create some other TaskGroup with different fields CharField, TextField, DateTimeField, Single or Multiple Choice.,etc, which will be save as TaskGoup1 with new field 1 and new field 2, TaskGroup2 with new field 3 and new field 4, if I created a new task, I can choose the type of TaskGroup from taskgroup lists(Default Task Group, TaskGroup1 and TaskGroup2).



      I created partial models as below, they are not right, but I am puzzled about the database structure. Thank for reading and any advice will be highly appreciate.



      class TaskGroupType(models.Model):
      name = models.CharField(max_length=58, null=True)

      def __str__(self):
      return self.name


      class Project(models.Model):
      created = models.DateTimeField(auto_now_add=True)
      owner = models.ForeignKey(
      UserProjectOwners, null=True, blank=True,
      on_delete=models.CASCADE, related_name='Owner'
      )
      name = models.CharField(max_length=100)
      desc = models.CharField(max_length=200, null=True, blank=True)
      category = models.CharField(max_length=100, null=True, blank=True)
      members = models.ForeignKey(
      UserProjectTeam, null=True, blank=True,
      on_delete=models.CASCADE, related_name="project"
      )
      tasktype = models.ManyToManyField(TaskType)

      class Meta:
      ordering =['created']
      verbose_name = "User Table"
      verbose_name_plural = verbose_name

      def __str__(self):
      return self.name

      class TaskGroup(models.Model):
      created = models.DateTimeField(auto_now_add=True)
      name = models.CharField(max_length=280, blank=True)
      order = models.IntegerField(null=True, blank=True)
      project = models.ForeignKey(
      Project,
      related_name='taskgroups', null=True, blank=True,
      on_delete=models.CASCADE
      )

      class Meta:
      ordering =['created']
      verbose_name = "Task Group"
      verbose_name_plural = verbose_name

      def __str__(self):
      return self.name

      class Task(models.Model):
      SORT_TYPE = (
      (1, "Normal"),
      (2, "Urgent"),
      (3, "Very Urgent"),
      )
      createDate = models.DateTimeField(auto_now_add=True)
      tasklist = models.ForeignKey(
      TaskList,
      related_name='tasks', null=True, blank=True,
      on_delete=models.CASCADE
      )
      completed = models.BooleanField(default=False)
      accomplished = models.DateTimeField(null=True, blank=True)
      desc = models.CharField(max_length=380, blank=True)
      name = models.CharField(max_length=180, blank=True)
      performer = models.ForeignKey(
      User,
      related_name='Task', null=True, blank=True,
      on_delete=models.CASCADE
      )
      participant = models.ManyToManyField(
      User,
      related_name='+'
      )
      startDate = models.DateTimeField(null=True, blank=True)
      dueDate = models.DateTimeField(null=True, blank=True)
      priority = models.CharField(max_length=100, choices=SORT_TYPE, null=True, blank=True)
      order = models.IntegerField(null=True, blank=True)
      remark = models.CharField(max_length=400, null=True, blank=True)

      class Meta:
      ordering =['createDate']
      verbose_name = "Task Table"
      verbose_name_plural = verbose_name

      def __str__(self):
      return self.name






      database dataframe data-structures model django-rest-framework






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 6:22







      Elsa

















      asked Mar 28 at 3:33









      ElsaElsa

      165 bronze badges




      165 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          As per my understanding of your project




          1. User can create Project

          2. Project can have multiple Task

          3. Each task belongs to a TaskGroup

          4. Each project can have multiple members.



          If the above use case is appropriate. Here is my model instances.



          class TaskGroup(models.Model):
          name = models.CharField()
          ...

          class Task(models.Model):
          task_group = models.ForeignKey(TaskGroup)
          name = models.CharField()
          ...

          class Project(models.Model):
          owner = models.ForeignKey(User)
          name = models.CharField()
          ...

          class ProjectTask(models.Model):
          project = models.ForeignKey(Project)
          task = models.ForeignKey(Task)
          ...

          # You can use Many field in Project model for Task reference if this model is not needed

          class ProjectMember(models.Model):
          project = models.ForeignKey(Project)
          member = models.ForeignKey(User)
          ...

          # You can use Many field in Project model instead if this model is not required


          Having separate model for association adds in flexibility to control each association separately and extra parameters can be added.



          Example only contains association.






          share|improve this answer

























          • Hi, thanks fo much for the answers, but I also need a TaskGroupType to save different TaskGroup templates, refer to the pics as link d.pr/free/i/j3VO3z the first pic has default TaskGoup, and I can click Type to select different TaskGroup template, the third pic has three new fields more than the first pic.

            – Elsa
            Mar 29 at 8:38











          • You can extend the association accordingly. create a TaskGroupType model with foreign key to TaskGroup. Then you can get TaskGroupType for each TaskGroup.

            – Anuj TBE
            Mar 29 at 10:04











          • Hi, I really wanted to accept your answer, but I am really sorry it still doesn't solve my question, when user add a template with 3-6 default fields, he also can add some custom fields, do you know how to make that default template with custom fields? d.pr/free/i/40eZQM d.pr/free/i/0RdJy4

            – Elsa
            May 9 at 2:08












          • are these the form fields? Do you want to dynamically add form fields?

            – Anuj TBE
            May 9 at 2:13











          • I don't know whether they are the form fields, those fields can add and change somewhere, so I think they are form fields, yes, I want to dynamically add form fields, but I don't know how to add and save field and templates.

            – Elsa
            May 9 at 12:17










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389770%2fhow-to-let-user-create-fields-and-save-records-as-choice-lists-django-rest-fr%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0
















          As per my understanding of your project




          1. User can create Project

          2. Project can have multiple Task

          3. Each task belongs to a TaskGroup

          4. Each project can have multiple members.



          If the above use case is appropriate. Here is my model instances.



          class TaskGroup(models.Model):
          name = models.CharField()
          ...

          class Task(models.Model):
          task_group = models.ForeignKey(TaskGroup)
          name = models.CharField()
          ...

          class Project(models.Model):
          owner = models.ForeignKey(User)
          name = models.CharField()
          ...

          class ProjectTask(models.Model):
          project = models.ForeignKey(Project)
          task = models.ForeignKey(Task)
          ...

          # You can use Many field in Project model for Task reference if this model is not needed

          class ProjectMember(models.Model):
          project = models.ForeignKey(Project)
          member = models.ForeignKey(User)
          ...

          # You can use Many field in Project model instead if this model is not required


          Having separate model for association adds in flexibility to control each association separately and extra parameters can be added.



          Example only contains association.






          share|improve this answer

























          • Hi, thanks fo much for the answers, but I also need a TaskGroupType to save different TaskGroup templates, refer to the pics as link d.pr/free/i/j3VO3z the first pic has default TaskGoup, and I can click Type to select different TaskGroup template, the third pic has three new fields more than the first pic.

            – Elsa
            Mar 29 at 8:38











          • You can extend the association accordingly. create a TaskGroupType model with foreign key to TaskGroup. Then you can get TaskGroupType for each TaskGroup.

            – Anuj TBE
            Mar 29 at 10:04











          • Hi, I really wanted to accept your answer, but I am really sorry it still doesn't solve my question, when user add a template with 3-6 default fields, he also can add some custom fields, do you know how to make that default template with custom fields? d.pr/free/i/40eZQM d.pr/free/i/0RdJy4

            – Elsa
            May 9 at 2:08












          • are these the form fields? Do you want to dynamically add form fields?

            – Anuj TBE
            May 9 at 2:13











          • I don't know whether they are the form fields, those fields can add and change somewhere, so I think they are form fields, yes, I want to dynamically add form fields, but I don't know how to add and save field and templates.

            – Elsa
            May 9 at 12:17















          0
















          As per my understanding of your project




          1. User can create Project

          2. Project can have multiple Task

          3. Each task belongs to a TaskGroup

          4. Each project can have multiple members.



          If the above use case is appropriate. Here is my model instances.



          class TaskGroup(models.Model):
          name = models.CharField()
          ...

          class Task(models.Model):
          task_group = models.ForeignKey(TaskGroup)
          name = models.CharField()
          ...

          class Project(models.Model):
          owner = models.ForeignKey(User)
          name = models.CharField()
          ...

          class ProjectTask(models.Model):
          project = models.ForeignKey(Project)
          task = models.ForeignKey(Task)
          ...

          # You can use Many field in Project model for Task reference if this model is not needed

          class ProjectMember(models.Model):
          project = models.ForeignKey(Project)
          member = models.ForeignKey(User)
          ...

          # You can use Many field in Project model instead if this model is not required


          Having separate model for association adds in flexibility to control each association separately and extra parameters can be added.



          Example only contains association.






          share|improve this answer

























          • Hi, thanks fo much for the answers, but I also need a TaskGroupType to save different TaskGroup templates, refer to the pics as link d.pr/free/i/j3VO3z the first pic has default TaskGoup, and I can click Type to select different TaskGroup template, the third pic has three new fields more than the first pic.

            – Elsa
            Mar 29 at 8:38











          • You can extend the association accordingly. create a TaskGroupType model with foreign key to TaskGroup. Then you can get TaskGroupType for each TaskGroup.

            – Anuj TBE
            Mar 29 at 10:04











          • Hi, I really wanted to accept your answer, but I am really sorry it still doesn't solve my question, when user add a template with 3-6 default fields, he also can add some custom fields, do you know how to make that default template with custom fields? d.pr/free/i/40eZQM d.pr/free/i/0RdJy4

            – Elsa
            May 9 at 2:08












          • are these the form fields? Do you want to dynamically add form fields?

            – Anuj TBE
            May 9 at 2:13











          • I don't know whether they are the form fields, those fields can add and change somewhere, so I think they are form fields, yes, I want to dynamically add form fields, but I don't know how to add and save field and templates.

            – Elsa
            May 9 at 12:17













          0














          0










          0









          As per my understanding of your project




          1. User can create Project

          2. Project can have multiple Task

          3. Each task belongs to a TaskGroup

          4. Each project can have multiple members.



          If the above use case is appropriate. Here is my model instances.



          class TaskGroup(models.Model):
          name = models.CharField()
          ...

          class Task(models.Model):
          task_group = models.ForeignKey(TaskGroup)
          name = models.CharField()
          ...

          class Project(models.Model):
          owner = models.ForeignKey(User)
          name = models.CharField()
          ...

          class ProjectTask(models.Model):
          project = models.ForeignKey(Project)
          task = models.ForeignKey(Task)
          ...

          # You can use Many field in Project model for Task reference if this model is not needed

          class ProjectMember(models.Model):
          project = models.ForeignKey(Project)
          member = models.ForeignKey(User)
          ...

          # You can use Many field in Project model instead if this model is not required


          Having separate model for association adds in flexibility to control each association separately and extra parameters can be added.



          Example only contains association.






          share|improve this answer













          As per my understanding of your project




          1. User can create Project

          2. Project can have multiple Task

          3. Each task belongs to a TaskGroup

          4. Each project can have multiple members.



          If the above use case is appropriate. Here is my model instances.



          class TaskGroup(models.Model):
          name = models.CharField()
          ...

          class Task(models.Model):
          task_group = models.ForeignKey(TaskGroup)
          name = models.CharField()
          ...

          class Project(models.Model):
          owner = models.ForeignKey(User)
          name = models.CharField()
          ...

          class ProjectTask(models.Model):
          project = models.ForeignKey(Project)
          task = models.ForeignKey(Task)
          ...

          # You can use Many field in Project model for Task reference if this model is not needed

          class ProjectMember(models.Model):
          project = models.ForeignKey(Project)
          member = models.ForeignKey(User)
          ...

          # You can use Many field in Project model instead if this model is not required


          Having separate model for association adds in flexibility to control each association separately and extra parameters can be added.



          Example only contains association.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 29 at 5:39









          Anuj TBEAnuj TBE

          1,9362 gold badges37 silver badges107 bronze badges




          1,9362 gold badges37 silver badges107 bronze badges















          • Hi, thanks fo much for the answers, but I also need a TaskGroupType to save different TaskGroup templates, refer to the pics as link d.pr/free/i/j3VO3z the first pic has default TaskGoup, and I can click Type to select different TaskGroup template, the third pic has three new fields more than the first pic.

            – Elsa
            Mar 29 at 8:38











          • You can extend the association accordingly. create a TaskGroupType model with foreign key to TaskGroup. Then you can get TaskGroupType for each TaskGroup.

            – Anuj TBE
            Mar 29 at 10:04











          • Hi, I really wanted to accept your answer, but I am really sorry it still doesn't solve my question, when user add a template with 3-6 default fields, he also can add some custom fields, do you know how to make that default template with custom fields? d.pr/free/i/40eZQM d.pr/free/i/0RdJy4

            – Elsa
            May 9 at 2:08












          • are these the form fields? Do you want to dynamically add form fields?

            – Anuj TBE
            May 9 at 2:13











          • I don't know whether they are the form fields, those fields can add and change somewhere, so I think they are form fields, yes, I want to dynamically add form fields, but I don't know how to add and save field and templates.

            – Elsa
            May 9 at 12:17

















          • Hi, thanks fo much for the answers, but I also need a TaskGroupType to save different TaskGroup templates, refer to the pics as link d.pr/free/i/j3VO3z the first pic has default TaskGoup, and I can click Type to select different TaskGroup template, the third pic has three new fields more than the first pic.

            – Elsa
            Mar 29 at 8:38











          • You can extend the association accordingly. create a TaskGroupType model with foreign key to TaskGroup. Then you can get TaskGroupType for each TaskGroup.

            – Anuj TBE
            Mar 29 at 10:04











          • Hi, I really wanted to accept your answer, but I am really sorry it still doesn't solve my question, when user add a template with 3-6 default fields, he also can add some custom fields, do you know how to make that default template with custom fields? d.pr/free/i/40eZQM d.pr/free/i/0RdJy4

            – Elsa
            May 9 at 2:08












          • are these the form fields? Do you want to dynamically add form fields?

            – Anuj TBE
            May 9 at 2:13











          • I don't know whether they are the form fields, those fields can add and change somewhere, so I think they are form fields, yes, I want to dynamically add form fields, but I don't know how to add and save field and templates.

            – Elsa
            May 9 at 12:17
















          Hi, thanks fo much for the answers, but I also need a TaskGroupType to save different TaskGroup templates, refer to the pics as link d.pr/free/i/j3VO3z the first pic has default TaskGoup, and I can click Type to select different TaskGroup template, the third pic has three new fields more than the first pic.

          – Elsa
          Mar 29 at 8:38





          Hi, thanks fo much for the answers, but I also need a TaskGroupType to save different TaskGroup templates, refer to the pics as link d.pr/free/i/j3VO3z the first pic has default TaskGoup, and I can click Type to select different TaskGroup template, the third pic has three new fields more than the first pic.

          – Elsa
          Mar 29 at 8:38













          You can extend the association accordingly. create a TaskGroupType model with foreign key to TaskGroup. Then you can get TaskGroupType for each TaskGroup.

          – Anuj TBE
          Mar 29 at 10:04





          You can extend the association accordingly. create a TaskGroupType model with foreign key to TaskGroup. Then you can get TaskGroupType for each TaskGroup.

          – Anuj TBE
          Mar 29 at 10:04













          Hi, I really wanted to accept your answer, but I am really sorry it still doesn't solve my question, when user add a template with 3-6 default fields, he also can add some custom fields, do you know how to make that default template with custom fields? d.pr/free/i/40eZQM d.pr/free/i/0RdJy4

          – Elsa
          May 9 at 2:08






          Hi, I really wanted to accept your answer, but I am really sorry it still doesn't solve my question, when user add a template with 3-6 default fields, he also can add some custom fields, do you know how to make that default template with custom fields? d.pr/free/i/40eZQM d.pr/free/i/0RdJy4

          – Elsa
          May 9 at 2:08














          are these the form fields? Do you want to dynamically add form fields?

          – Anuj TBE
          May 9 at 2:13





          are these the form fields? Do you want to dynamically add form fields?

          – Anuj TBE
          May 9 at 2:13













          I don't know whether they are the form fields, those fields can add and change somewhere, so I think they are form fields, yes, I want to dynamically add form fields, but I don't know how to add and save field and templates.

          – Elsa
          May 9 at 12:17





          I don't know whether they are the form fields, those fields can add and change somewhere, so I think they are form fields, yes, I want to dynamically add form fields, but I don't know how to add and save field and templates.

          – Elsa
          May 9 at 12:17








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389770%2fhow-to-let-user-create-fields-and-save-records-as-choice-lists-django-rest-fr%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript