I was really excited about Rails. But however much it claims that it
follows the DRY convention, I unfortunately do find myself repeating
myself for things like the admin area of my site.

That's why the Admin interface of Django has now become ever so much
more appealing to me. Having spent a whole day looking into Django,
looks like it has everything I need to port my application over.

I started with my basic models, and they all works marvellously.
However, when I come to trying to implement the hardest feature in my
Rails app, a many-to-many polymorphic association (generic relation in
Django speak), I've hit the only hurdle stopping me from reaching the
finishing line.

I have my models (simplified here for this posting):

    from django.contrib.contenttypes.models import ContentType
    from django.contrib.contenttypes import generic

    class Article(models.Model):
        title = models.CharField(maxlength=300)
        ...

    class Assignable(models.Model):
        article = models.ForeignKey(Article)
        content_type = models.ForeignKey(ContentType)
        object_id = models.PositiveIntegerField()
        content_object = generic.GenericForeignKey()

    class Character(models.Model):
        name = models.CharField(maxlength=50)

        articles = generic.GenericRelation(Article)

    class Film(models.Model):
        title = models.CharField(maxlength=50)

        characters = models.ManyToManyField(Character)
        articles = generic.GenericRelation(Article)

Please let me stress that that isn't the full implementation (if you
want me to go into further detail, please let me know). Basically, I
want to be able to assign many different objects (of different model
types) to an Article.  I need to be able to do this via the Admin
interface in a user friendly way so that the people who write the
articles can do it easily.

The way I had this working in Rails was with a fancy controller method
and some Ajax.

For the Admin interface for the Articles, I basically want to be able
to have inline editing for adding new 'Assignables' (objects of
different model types). It would basically be two select boxes. The
first would contain the models that have a generic relation to the
Article model. Upon selecting one of those models, the second select
box is populated with the objects of that model type. You can then
assign that object to the Article. And you can assign as many objects
as you like to an Article.

Like I say, this is the one thing preventing me from moving over to
Django, and I'm so close!! It's torture. I really hate having to spend
all day coding the admin part of my Rails app, when I can do 80% of it
in Django in around 2 lines per model!!

Surely other people need this as well?  Has anyone found a solution?

Any help, direction or guidance would be very much appreciated.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to