I am working with fields in a model in which the value of a field depend of a selected option in a previous field in a form (for the moment via django administrator), by which I am using django-smart-selects
I would share this video for a better understanding about of my question or situation and the reason about of ask the way of apply DEBUG or depuration in relation with the fields which I am working in this scenario.
The parent field
Segmento afectado
in the video let me select multiple choicesThe child field
Movimiento
in the video, detail the movements that a affected segment (selected in the parent field) can perform
My situation about it
In the video is detailed of a way clear that when I select only a affected segment in the parent field, the options of movements are deployed in the child field, and my log console of Django Server appear the
status code HTTP/1.1 200
with theGET
operation, indicating to me that was possible get and deploy successfully the movements that correspond to the affected segment selected in the parent fieldBut, when I select more than one affected segment in the parent field (If I select two or more segments in forward), inmediately my django server at the console show me the
status code HTTP/1.1 404
(Not Found
in yellow color), because not perform the second selection or the second affected segment that the user select, and due to this reason also don't deploy or appear in the child field the movements associated that these second affected segment can perform
I don't know how to address this situation, due to this form in which are the parent (Segmento Afectado
) and child (Movimiento
) fields are represented inside the django administrator.
I have a model named AffectedSegment
and another model named Movement
and through of functionality of ChainedManyToManyField
of django-smart-selects is the way in how to I get the values deployed in the child field accord to the selection in the parent field.
My models and the chaining of values for this behavior are:
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
And the way in which or I get that appear the movements in the child field accord to the selection on the parent field is perform of this way:
class RehabilitationSession(models.Model):
affected_segment = models.ManyToManyField(AffectedSegment,verbose_name='Segmento afectado')
movement = ChainedManyToManyField(
Movement, #Modelo encadenado
chained_field = 'affected_segment',
chained_model_field = 'corporal_segment_associated',
verbose_name='Movimiento'
)
class Meta:
verbose_name = 'Sesiones de Rehabilitación'
def __str__(self):
return "%s" % self.affected_segment
I don't know how to can I address this situation. What another alternatives can I have? JS, some framework forntend? Another django app?
Any support, orientation about it, will be highly appreciated
:D