0

i want make an extend of the User Model with field from another class (structure in models.py in immob app) in django ,i will show you my project this is my project structure

+INVEST_APP
settings.py
urls.py
views.py
wsgi.py
>compte
>immob
>static
>staticfiles
>templates
__init__.py
manage.py

and this is my immob model

class structure(models.Model):
    structure_code=models.CharField(max_length=1)
    structure_desig=models.CharField(max_length=350)

class service(models.Model):
    structure_id=models.ForeignKey(structure,
    on_delete=models.CASCADE,default=0)
    service_desig=models.CharField(max_length=350)

class immob(models.Model):
    immo_code=models.CharField(max_length=7)
    immo_desig=models.CharField(max_length=150)
    immo_qte=models.FloatField(default=1)
    immo_datemes=models.DateTimeField()
    immo_cptimmob=models.CharField(max_length=10)
    immo_dureevie=models.IntegerField(default=7)
    immo_numaut=models.CharField(max_length=4)
    immo_origine=models.CharField(max_length=1)
    immo_fournisseur=models.CharField(max_length=150)
    immo_nufact=models.CharField(max_length=20)
    immo_datefact=models.DateTimeField()
    immo_valht=models.DecimalField(max_digits=18,decimal_places=2)
    immo_monaie=models.CharField(max_length=3)
    immo_tauxcvt=models.DecimalField(max_digits=18,decimal_places=2)
    immo_tauxctrval=models.DecimalField(max_digits=18,decimal_places=2)
    immo_frais=models.DecimalField(max_digits=18,decimal_places=2)
    immo_coutacq=models.DecimalField(max_digits=18,decimal_places=2)
    immo_refcmde=models.CharField(max_length=35)
    immo_datecmde=models.DateField()
    immo_journee=models.CharField(max_length=10)
    immo_cptanal=models.CharField(max_length=9)
    immo_local=models.CharField(max_length=45)
    immo_mode_amort=models.CharField(max_length=1)
    immo_code_r=models.CharField(max_length=2)
    immo_val_amort=models.DecimalField(max_digits=18,decimal_places=2)
    immo_status=models.CharField(max_length=1)
    immo_code_bar=models.CharField(max_length=25)
    service_id=models.ForeignKey(service, on_delete=models.CASCADE,default=0)

finaly i want get this in signup.html

   username:........
   password:.......
   structure:...... 

(the field structure is dblookup combobox it means i want read it from database) thank you

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
Az_Geek88
  • 21
  • 8
  • Post your models.py and what you are trying to do? – Astik Anand Jul 21 '19 at 18:54
  • i have two apps in my project is compte and immob , i poste /immob/models.py and i want extend user model in /compte/modesl.py for using it in signup because my menu in signup will be like this: username:........ password:................... structure :............... submit return – Az_Geek88 Jul 21 '19 at 20:19
  • 1
    Have you read [this post](https://stackoverflow.com/q/44109/4744341)? I suppose it may contain the information you need. – natka_m Jul 21 '19 at 20:26
  • i see it but is complicated for me i don't understand it is so difficult i hope have help in my example to understand how i do it because you know is hard work to extend user model – Az_Geek88 Jul 21 '19 at 20:28
  • From `field structure is dblookup combobox it means i want read it from database` it sounds like you might be looking for a `ForeignKey.limit_choices_to`? https://stackoverflow.com/a/252087/1101109 – pzrq Jul 22 '19 at 01:19
  • yes it is like that i will give you and example : username :Franky password :azerty structure : electronical departement so i want get structure designation in combobox – Az_Geek88 Jul 22 '19 at 12:55

0 Answers0