| 1 | At the moment creating models.py is only achieved via models.py , dia2django let's you create a models.py from a UML [http://www.gnome.org/projects/dia/ dia] file. |
| 2 | |
| 3 | When you are creating a project that at the very beginning has a lot of tables and you want to have in mind the model having the opportunity to share it with your coleagues dia2django can help. |
| 4 | |
| 5 | Dia2django is not intended to be used as a syncing tool on your visual approach and your actual models.py. |
| 6 | |
| 7 | A dia model like : |
| 8 | http://devnull.li/~ikks/web.png |
| 9 | |
| 10 | attachment:web.png |
| 11 | |
| 12 | generates the following code : |
| 13 | |
| 14 | {{{ |
| 15 | #!python |
| 16 | from django.contrib.flatpages.models import * |
| 17 | |
| 18 | class InteresesVisita(models.Model) : |
| 19 | nombre = models.CharField(max_length=100) |
| 20 | |
| 21 | def __str__(self): |
| 22 | return "" |
| 23 | |
| 24 | def __unicode__(self): |
| 25 | return u"" |
| 26 | |
| 27 | |
| 28 | class Formulario(models.Model) : |
| 29 | ip = models.IPAddressField() |
| 30 | fecha = models.DatTimeField() |
| 31 | comentarios = models.CharField(max_length=2000, blank=True,null=True ) |
| 32 | |
| 33 | def __str__(self): |
| 34 | return "" |
| 35 | |
| 36 | def __unicode__(self): |
| 37 | return u"" |
| 38 | |
| 39 | |
| 40 | class FormularioSocial(Formulario) : |
| 41 | nombrepersona = models.CharField(max_length=150) |
| 42 | correopersona = models.EmailField() |
| 43 | cargo = models.CharField(max_length=100) |
| 44 | nombreinst = models.CharField(max_length=200) |
| 45 | nombremaximo = models.CharField(max_length=150) |
| 46 | telefonos = models.CharField(max_length=300) |
| 47 | direccion = models.CharField(max_length=300) |
| 48 | fax = models.CharField(max_length=200, null=True,blank=True ) |
| 49 | correoinst = models.CharField(max_length=200, null=True,blank=True ) |
| 50 | pagina = models.CharField(max_length=300, null=True,blank=True ) |
| 51 | |
| 52 | def __str__(self): |
| 53 | return "" |
| 54 | |
| 55 | def __unicode__(self): |
| 56 | return u"" |
| 57 | |
| 58 | |
| 59 | class Seccion(models.Model) : |
| 60 | nombre = models.CharField(max_length=30) |
| 61 | alt = models.CharField(max_length=100) |
| 62 | pagina = models.ForeignKey(FlatPage,null=True) |
| 63 | url = models.CharField(max_length=100, null=True ) |
| 64 | |
| 65 | def __str__(self): |
| 66 | return "" |
| 67 | |
| 68 | def __unicode__(self): |
| 69 | return u"" |
| 70 | |
| 71 | |
| 72 | class Caja(models.Model) : |
| 73 | pos = models.IntegerField() |
| 74 | nombre = models.CharField(max_length=30) |
| 75 | alt = models.CharField(max_length=100, null=True ) |
| 76 | peso = models.FloatField(default=0) |
| 77 | seccion = models.ForeignKey(Seccion) |
| 78 | pagina = models.ForeignKey(FlatPage,null=True) |
| 79 | url = models.CharField(max_length=100, null=True ) |
| 80 | |
| 81 | def __str__(self): |
| 82 | return "" |
| 83 | |
| 84 | def __unicode__(self): |
| 85 | return u"" |
| 86 | |
| 87 | |
| 88 | class Enlace(models.Model) : |
| 89 | nombre = models.CharField(max_length=30) |
| 90 | alt = models.CharField(max_length=100, null=True ) |
| 91 | peso = models.FloatField(default=0) |
| 92 | caja = models.ForeignKey(Caja) |
| 93 | pagina = models.ForeignKey(FlatPage,null=True) |
| 94 | url = models.CharField(max_length=100, null=True ) |
| 95 | |
| 96 | def __str__(self): |
| 97 | return "" |
| 98 | |
| 99 | def __unicode__(self): |
| 100 | return u"" |
| 101 | |
| 102 | |
| 103 | class FormularioVisita(Formulario) : |
| 104 | nombrepersona = models.CharField(max_length=150) |
| 105 | correopersona = models.EmailField() |
| 106 | cargo = models.CharField(max_length=100) |
| 107 | nombreinst = models.CharField(max_length=200) |
| 108 | nombremaximo = models.CharField(max_length=150) |
| 109 | expercompu = models.CharField(max_length=300) |
| 110 | direccion = models.CharField(max_length=300) |
| 111 | telefonos = models.CharField(max_length=300) |
| 112 | fax = models.CharField(max_length=200, null=True,blank=True ) |
| 113 | correoinst = models.CharField(max_length=200, null=True,blank=True ) |
| 114 | pagina = models.CharField(max_length=300, null=True,blank=True ) |
| 115 | intereses = models.ManyToManyField(InteresesVisita) |
| 116 | |
| 117 | def __str__(self): |
| 118 | return "" |
| 119 | |
| 120 | def __unicode__(self): |
| 121 | return u"" |
| 122 | |
| 123 | |
| 124 | class FormularioAspirante(Formulario) : |
| 125 | nombre = models.CharField(max_length=100) |
| 126 | grado = models.IntegerField() |
| 127 | telefonos = models.CharField(max_length=150) |
| 128 | direccion = models.CharField(max_length=150) |
| 129 | acudiente = models.CharField(max_length=200) |
| 130 | email = models.EmailField(null=True,blank=True) |
| 131 | |
| 132 | def __str__(self): |
| 133 | return "" |
| 134 | |
| 135 | def __unicode__(self): |
| 136 | return u"" |
| 137 | |
| 138 | |
| 139 | }}} |
| 140 | |
| 141 | = Download dia2code = |
| 142 | |
| 143 | = How to use dia2code = |
| 144 | |