Seriously. Im reading and reading, but cant understand much or i just
dont find good examples.
What i have is model structure like this :

I have language model, which holds website generic data like language
parameter, encoding, website titles, metainfo and so on

Then i have bit more complex poll system with models like:
poll, question, choices and translation.

Translation model is like this :
class Trans(models.Model):
        keel = models.ForeignKey(lang) #for knowing to which language this
translation belongs to
        content_type = models.ForeignKey(ContentType) # this and 2 lines
below it are for generic relations as good as i understand them
        object_id = models.PositiveIntegerField()
        content_object = generic.GenericForeignKey()
        name= models.CharField(max_length=500) # for the translation itself
        def __unicode__(self):
                return self.name

Other models are like this :
class Poll(models.Model):
        name = generic.GenericRelation(Trans)
        pub_date = models.DateTimeField('date published')
        active = models.BooleanField()
        def __unicode__(self):
                return self.name
        def was_published_today(self):
                return self.pub_date.date() == datetime.date.today()

class Question(models.Model):
        TYPE_CHOICES = (
                ('1', 'single answer'),
                ('2', 'multiple choices'),
                ('3', 'Textfield'),
        )
        poll = models.ForeignKey(Poll)
        nr = models.IntegerField()
        name = generic.GenericRelation(Trans)
        qtype = models.CharField(max_length=1, choices = TYPE_CHOICES)
        def __unicode__(self):
                return self.name
        def get_choices(self):
                choices = Choice.objects.filter(Question = self).order_by('id')
                if len(choices) == 0:
                        return []
                return choices

class Choice(models.Model):
        name = generic.GenericRelation(Trans)
        question = models.ForeignKey(Question)
        nr = models.IntegerField()
        def __unicode__(self):
                return self.name

I have other necessary models too, but i think they are irrelevant
here.

The point of it is that, when i change website language (which now
works thanks to fixing urlconf in my previous thread), i get poll,
with all its questions/choices, in different language.

What i have not been able to figure out is how to change admin view in
a way that when i open poll (for adding a new one)it loops through
languages and gives me X fields where to enter poll name (depending on
how many languages the site has).

Poll in admin.py is like this:

class PollAdmin(admin.ModelAdmin):
        list_display = ('name', 'pub_date', 'was_published_today')

and when i go to poll section in admin i get field for publishing date
and thats it. As it seems i lack understanding in several areas : how
to set up admin view so i can set necessary fields and how to use
those generic relations and i have even have created models in a way
that i must create them if i want to achieve my goals.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to