Wednesday, August 21, 2013

Re: Populate choices from model

example of what im doing

<code>

from django.db import models

from django.contrib.auth.models import User

from django.contrib.sites.models import Site



# Create your models here.


       

# formulier keuze databases


class Kleurogen_data (models.Model):

    name = models.CharField(max_length=255)

    

    def __unicode__(self):

        return self.name


class Haarkleur_data (models.Model):

    name = models.CharField(max_length=255)

    

    def __unicode__(self):

        return self.name

    

class Lengtehaar_data (models.Model):

    name = models.CharField(max_length=255)

    

    def __unicode__(self):

        return self.name

    

class Landen (models.Model):

    slug = models.CharField(max_length=255)

    name = models.CharField(max_length=255)

    

    def __unicode__(self):

        return self.name


class Regio (models.Model):

    slug = models.CharField(max_length=255)

    name = models.CharField(max_length=255)

    land = models.ForeignKey(Landen)

    

    def __unicode__(self):

        return self.name


    

# sitedeals


class Sitedetails(models.Model):

    JANEE = (

    ('Y','Ja'),

    ('N','Nee'),              

    )

    

    TAAL = (

    ('Nederlands','Nederlands'),

    ('Engels','Engels'),              

    )

        

    site = models.ForeignKey(Site)

    pub_date = models.DateTimeField('date published')

    

    sitetekst = models.TextField()

    beschrijving = models.TextField()

    keywords = models.TextField()

    google = models.TextField()

    

    adult = models.CharField(max_length=2, choices=JANEE, default='N')

    sitetaal = models.CharField(max_length=2, choices=TAAL, default='Nederlands')

        

    dailxsid = models.CharField(max_length=255)   

    smtploc = models.CharField(max_length=255)

    smtpuser = models.CharField(max_length=255)

    smtppass = models.CharField(max_length=255)

    

    ontvangen = models.IntegerField(default=0)

    verzonden = models.IntegerField(default=0)

    aanmeldingen = models.IntegerField(default=0)

    afmeldingen = models.IntegerField(default=0)

    views = models.IntegerField(default=0)

    profielen = models.IntegerField(default=0)

    

    

    class Meta:

        unique_together = ["site"]

        verbose_name_plural = "Sitedetails"

        app_label = 'sites'

        

        def __unicode__(self):

            return self.keywords

      

      

      

class Profielen(models.Model):

    JANEE = (

    ('Y','Ja'),

    ('N','Nee'),              

    )

    

    GENDER = (

    ('Man','Man'),

    ('Vrouw','Vrouw'),              

    )

    

  

    

    profielnaam = models.CharField(max_length=255)

    leeftijd = models.CharField(max_length=3)

    

    issoort = models.CharField(max_length=10, choices=GENDER, default='Man')

    zoektsoort = models.CharField(max_length=10, choices=GENDER, default='Vrouw')

    adult = models.CharField(max_length=2, choices=JANEE, default='N')

    partner = models.CharField(max_length=2, choices=JANEE, default='N')

    

    regio = models.ForeignKey(Regio, default='Amsterdam')

    land = models.ForeignKey(Landen, default='Nederland')

    

    

    kleurogen = models.ManyToManyField(Kleurogen_data, blank=False, null=False)

    haarkleur = models.ManyToManyField(Haarkleur_data, blank=False, null=False)

    lengtehaar = models.ManyToManyField(Lengtehaar_data, blank=False, null=False)



    postuur = models.CharField(max_length=255)

    gewicht = models.CharField(max_length=255)

    afkomst = models.CharField(max_length=255)

    gebjaar = models.CharField(max_length=255)

    gebmaand = models.CharField(max_length=255)

    gebdag = models.CharField(max_length=255)

    lengte = models.CharField(max_length=255)

    burgelijkestaat = models.CharField(max_length=255)

    opleidingsniveau = models.CharField(max_length=255)

    levensstijl = models.CharField(max_length=255)

    ikvoelme = models.CharField(max_length=255)

    inter = models.CharField(max_length=255)

    haarstijl = models.CharField(max_length=255)

    relatie = models.CharField(max_length=255)

    cupmaat = models.CharField(max_length=255)

    geaardheid = models.CharField(max_length=255)

    sterrenbeeld = models.CharField(max_length=255)   

    uiterlijkekenmerken = models.TextField()

    belangstellingvoor = models.TextField()

    beschrijving = models.TextField()

    omschrijving = models.TextField()

    algemenevoorkeuren = models.TextField()

    sexvoorkeuren = models.TextField()

    bdsmvoorkeuren = models.TextField()

    sexkenmerken = models.TextField()

    belangstelling = models.TextField()

    omschrijvingengels = models.TextField()

    beschrijvingengels = models.TextField()

    likes = models.IntegerField(default=0)

    views = models.IntegerField(default=0)

    user = models.ForeignKey(User) 

     
     class Meta:

       verbose_name_plural = "Profielen"


    def __unicode__(self):
        return self.profielnaam


class
Favorieten(models.Model):

    user = models.ForeignKey(User)
    favoriet = models.ForeignKey(Profielen)
    pub_date = models.DateTimeField('date published')

   

</code>

--
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 http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate