does not display data using smart-select with chainedforeingkey

0

I have installed smart-selects and used in my models the chainedforeingkey but still does not display data, configure in my setting and url based on what I have read but does not deploy.

models.py

class Pais(models.Model):
    nombrepais= models.CharField(max_length=60)

    def __str__(self):
        return( self.nombrepais)

class Departamento(models.Model):
    nombredepto= models.CharField(max_length=60)
    pais=models.ForeignKey(Pais)

    def __str__(self):
        return (self.nombredepto)


class Municipio(models.Model):
    nombremun = models.CharField(max_length=60)
    departamento=models.ForeignKey(Departamento)

    def __str__(self):
        return (self.nombremun)

class clientes(models.Model):
    nombres=models.CharField(max_length=60)
    regiva=models.CharField(max_length=20)
    tipo_giro = (
        (1, 'Consumo Masivo'),
        (2, 'Servicio'),
        (3, 'Otros'),
    )
    giro=models.IntegerField(choices=tipo_giro)
    tipo_contrib = (
        (1, 'Gran Contribuyente'),
        (2, 'Mediano Contribuyente'),
        (3, 'Persona Natural'),
    )
    tcontrib=models.IntegerField(choices=tipo_contrib)
    nit=models.CharField(max_length=20)
    direccion=models.CharField(max_length=100)
    tipo_status = (
        (1, 'Activo'),
        (2, 'Inactivo'),
    )
    estatus=models.IntegerField(choices=tipo_status)
    pais = models.ForeignKey(Pais)
    departamento =ChainedForeignKey(Departamento,
                                    chained_field="pais",
                                    chained_model_field="pais",
                                    show_all=False,
                                    auto_choose=True)
    municipio =models.ForeignKey(Municipio)
    fechaIngreso=models.DateField(auto_now_add=True)
    contactocom=models.CharField(max_length=60)
    telfcontcom=models.CharField(max_length=12)
    emailcom=models.EmailField()
    contactolog = models.CharField(max_length=60)
    telfcontlog = models.CharField(max_length=12)
   class clientes(models.Model):
    nombres=models.CharField(max_length=60)
    regiva=models.CharField(max_length=20)
    tipo_giro = (
        (1, 'Consumo Masivo'),
        (2, 'Servicio'),
        (3, 'Otros'),
    )
    giro=models.IntegerField(choices=tipo_giro)
    tipo_contrib = (
        (1, 'Gran Contribuyente'),
        (2, 'Mediano Contribuyente'),
        (3, 'Persona Natural'),
    )
    tcontrib=models.IntegerField(choices=tipo_contrib)
    nit=models.CharField(max_length=20)
    direccion=models.CharField(max_length=100)
    tipo_status = (
        (1, 'Activo'),
        (2, 'Inactivo'),
    )
    estatus=models.IntegerField(choices=tipo_status)
    pais = models.ForeignKey(Pais)
    departamento =ChainedForeignKey(Departamento,
                                    chained_field="pais",
                                    chained_model_field="pais",
                                    show_all=False,
                                    auto_choose=True)
    municipio =models.ForeignKey(Municipio)
    fechaIngreso=models.DateField(auto_now_add=True)
    contactocom=models.CharField(max_length=60)
    telfcontcom=models.CharField(max_length=12)
    emailcom=models.EmailField()
    contactolog = models.CharField(max_length=60)
    telfcontlog = models.CharField(max_length=12)
     emaillog = models.EmailField()

forms.py

class ClientesForm(forms.ModelForm):        
     class Meta:
        model= clientes
        fields ='__all__'
        labels={
        'nombres':'Nombre de Empresa',
        'regiva':'Registro IVA',
        'giro':'Giro',
        'tcontrib':'Tipo Contribuyente',
        'nit':'NIT',
        'direccion': 'Direccion',
        'estatus':'Estatus Cliente',
        'pais':'Pais',
        'departamento':'Departamento',
        'municipio':'Municipio',
        'fechaIngreso': 'Fecha Ingreso',
        'contactocom' :'Contacto Comercial',
        'telfcontcom':'Telefono Comercial',
        'emailcom' :'Email Comercial',
        'contactolog':'Contacto Logistico',
        'telfcontlog' :'Telefono logistico',
        'emaillog' : 'Email Logistico',
      #  'foto': 'Foto',
    }
widgets={
         'nombres':forms.TextInput(attrs={'class':'form-control','size': '60'}),
        'regiva':forms.TextInput(attrs={'class':'form-control'}),
        'giro':forms.Select(attrs={'class':'form-control'}),
        'tcontrib':forms.Select(attrs={'class':'form-control'}),
        'nit':forms.TextInput(attrs={'class':'form-control'}),
        'direccion':forms.TextInput(attrs={'class':'form-control'}),
        'estatus':forms.RadioSelect(),
        'pais':forms.Select(attrs={'class':'form-control'}),
        'departamento': forms.Select(attrs={'class': 'form-control'}),
         'municipio':forms.Select(attrs={'class':'form-control'}),
        'fechaIngreso':forms.DateField(),
        'contactocom' :forms.TextInput(attrs={'class':'form-control'}),
        'telfcontcom':forms.TextInput(attrs={'class':'form-control'}),
        'emailcom' :forms.EmailField(required=True),
        'contactolog':forms.TextInput(attrs={'class':'form-control'}),
        'telfcontlog' :forms.TextInput(attrs={'class':'form-control'}),
        'emaillog' :forms.EmailField(required=True),
       # 'foto': forms.ImageField(),
}
en mi pagina clientes.html 
    <div class="form-group">
                           <label class="col-sm-2 control-label">Pais</label>
                              <div class="col-sm-2">
                               {{form.pais}}
                              </div>
                              <label class="col-sm-2 control-label">Departamento</label>
                               <div class="col-sm-4">
                                {{form.departamento}}
                               </div>
                           </div>
                             <div class="form-group">
                            <label  class="col-sm-2 control-label">Municipio</label>
                               <div class="col-sm-4">
                              {{form.municipio}}
                               </div>
                            </div>

settings

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sites',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
     'smart_selects',
     'ventas',
.....}

USE_DJANGO_JQUERY = True
JQUERY_URL = True

url
    url(r'^chaining/', include('smart_selects.urls')),

Really I do not know what else I need to configure because on my page I always do not deploy anything

    
asked by Susana Toledo 12.05.2018 в 19:53
source

0 answers