If you need 5 files related to a Tarea instance you just create 5 ArchivoTarea instances, one for each file which you save using the archivo FileField, all of them pointing to the same task. I'm not sure what you mean by "path to the file". The CategoriaTarea is debatable, not sure what it's supposed to represent really, mix of location and time? If you're going to add more to it why not. With those foreign keys you'll have to do an unnecessary join every time you query a task on both those tables just to get its state and type, and the interface is worse: isn't fun to just check what type your task is. I'd say TipoTarea and EstadoTarea should just be Charfields with defined choices on your main Tarea model. Where should I store the files path, in a separate table or in the json field? (Each task or update, should have maximum 5 files. I'm trying to use a jsonfield, to store differentiation parameters, but I'm having trouble formatting the keys I want to store. Is this the best approach? or am I just complicating things? Tarea = models.ForeignKey(Tarea, on_delete=models.CASCADE)Īrchivo = models.FileField(upload_to=upload_reporte_file_to) # TASK FILES SHOULD I USE THE EXTRAS FIELD (JSONFIELD) IN TASKS MODEL TO STORE THE PATH TO THE FILES? Modificado_por = models.ForeignKey(User, blank=True, null=True, default=None, on_delete=models.CASCADE, related_name='modificador') Modificado = models.DateTimeField(auto_now=True) Parent = models.ForeignKey('self', on_delete=models.CASCADE, related_name="actualizaciones", null=True, blank=True) Tipo = models.ForeignKey(TipoTarea, on_delete=models.CASCADE, related_name = 'tarea')Ĭategoria = models.ForeignKey(CategoriaTarea, on_delete=models.CASCADE, related_name = 'tarea')ĭescripcion = models.CharField(max_length=500)įecha = models.DateField(default=)Įstado = models.ForeignKey(EstadoTarea, default= 1, on_delete=models.CASCADE)Ĭreado_por = models.ForeignKey(User, on_delete=models.CASCADE, related_name='creador')Ĭreado = models.DateTimeField(auto_now_add=True) # TASK PARENT WOULD BE USED FOR UPDATES, BUT HOW CAN REASIGNMENTS BE CLASSIFIED # REASIGNED STATE, CREATES A NEW TASK WITH A DIFFERENT CATEGORY # TASK STATE (CREATED, IN PROCESS, COMPLETED, REASIGNED) Tiempo_atencion = models.IntegerField(default=2) # TASK CATEGORY (TOPIC AND THE AREA WHO IS BEING DIRECTED TO)Īrea = models.ForeignKey(Area, on_delete=models.CASCADE) Nombre = models.CharField(max_length=50, unique=True) Now, I'm trying to have a polymorphic model, as shown below: # TASK TYPE (TASK, UPDATE) (Those tables, had almost the same fields) Originally, I was using separate models for reports, updates, report files, update files. Those reports I want them to be tasks, to broaden the spectrum of use to all of the organization. I'm trying to upscale a project that originally was used by an area to assign reports to their respective departments.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |