I am working with django-smart-selects via django admin form. The idea that I have is try a model chaining or deployment of value fields accord to previous value in a previous separate field.
Accord to the first option value selected in the first field, I want that in the second field some values be deployed and which be of selection multiple. In fact, this idea I got it accomplished.
I have the following small level design approach for this:
The code that is related to the above design is this:
class AffectedSegment(models.Model): SEGMENTO_ESCAPULA = 'ESCAPULA' SEGMENTO_HOMBRO = 'HOMBRO' SEGMENTO_CODO = 'CODO' SEGMENTO_ANTEBRAZO = 'ANTEBRAZO' SEGMENTO_CARPO_MUNECA = 'CARPO_MUNECA' SEGMENTO_MANO = 'MANO' SEGMENTO_CHOICES = ( (SEGMENTO_ESCAPULA, u'Escápula'), (SEGMENTO_HOMBRO, u'Hombro'), (SEGMENTO_CODO, u'Codo'), (SEGMENTO_ANTEBRAZO, u'Antebrazo'), (SEGMENTO_CARPO_MUNECA, u'Carpo/Muñeca'), (SEGMENTO_MANO, u'Mano'), ) affected_segment = models.CharField( max_length=12, choices=SEGMENTO_CHOICES, blank=False, verbose_name='Segmento afectado' ) class Meta: verbose_name = 'Segmentos corporale' def __str__(self): return "%s" % self.affected_segment class Movement(models.Model): type = models.CharField( max_length=255, verbose_name='Tipo de movimiento' ) corporal_segment_associated = models.ManyToManyField( AffectedSegment, blank=False, verbose_name='Segmento corporal asociado' ) class Meta: verbose_name = 'Movimiento' def __str__(self): return "%s" % self.type class RehabilitationSession(models.Model): affected_segment = models.ManyToManyField( AffectedSegment, verbose_name='Segmento afectado' ) movement = ChainedManyToManyField( Movement, #chaining model chained_field = 'affected_segment', chained_model_field = 'corporal_segment_associated', verbose_name='Movimiento' )
affected_segment
in AffectedSegment
model and ManyToManyField
in RehabilitationSession
model) , after I going to this row or rehabilitation sessions instance via admin and the movement that I select before is not selected, despite of that this is saved and I can explore via transitivity relationship the value inside my postgresql database.In this video, I've been exploring the database records and showing the behavior of my form in which is denoted my inconvenient
I can see that this bug/error/issue or inconvenient was happen to others https://github.com/digi604/django-smart-selects/issues/112
2. Other inconvenient is that when I select more of than one affected segment, in the movements field. just are deployed the values related with the first affected segment selected and the movements associated to the second selected are not deployed ...
When I select one second affected segment (segmento afectado
field, CODO option in the red square number one), I want that the movements/exercises associated to these second affected segment that it's CODO
Currently, just are deployed the movements of Descenso
,Elevación
, Protracción
y Retracción
(options shown in the green square number two) and these are only or correspond to the first option of affected segment selected which is ESCÁPULA
in the red square number one
In this video I show you this in detail.
How I can do this I want?
In some sense, in the AffectedSegment
model .. should be able to know the option (something seem to get_element_by_id
in html?) is selected for know when one second option is selected and shown the movements of together options (affected segments selected)?
I hope that post a videos don't be a problem or inconvenient
Any support or orientation would be appreciated
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0da4f87a-1e05-4277-a926-0f6f2f2b56b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment