[Fixed]-Django – Multiple users assign different names for the same object

1👍

What you can do, is have another model, that maps Users to Schedulers, and have a name attribute there. That model would have user_id, scheduler_id and scheduler_name as attributes.

Otherwise, you can do that in the Product model, and point to the desired Scheduler indirectly.

0👍

I have suggested something similar to

SCHEDULER_TYPE = (
  (1, _('Type1')),
  (2, _('Type2')),

)

class Scheduler(models.Model):

    weekhours = models.ManyToManyField('WeekHour', related_name='schedulers')

    name = models.CharField(max_length=200, verbose_name=_('scheduler name'))

    type = models.PositiveIntegerField(_('scheduler type'), choices=SCHEDULER_TYPE, default=1)

The type of the scheduler will be saved in SCHEDULER_TYPE and won’t be afftected if user will change the name of the Scheduler instance.

Also if you need more data you can separate SchedulerCatergory and add additional category field into Scheduler:

category = models.ForeignKey(SchedulerCategory, blank=True, null=True)

In my undestanding when user chooses the type of Scheduler, he created new Scheduler instance of specific type. This Scheduler instance will be unique and won’t be affected by other users. It also means that you can easily save any name inside it.

In your words:

User creates a product and choose from allowed schedulers. When they
choose the scheduler they can assign some name to this scheduler.

In my opinon:
User create a product and choose not from allowed schedulers instances but from scheduler_types or scheduler_categories. Then new instance of Scheduler is created in which you can save name.

Leave a comment