Hi,

I'm sorry to bother you guys with this but I hit the wall on this one.

I'm creating a website for a tourist board and they have several
associates (like hotels, golf, spa, etc).
When I initially created the "Associates" application, instead of
creating a general "Associate" model and make every other model
("Hotel", "Restaurant", etc) inherit from the first one, I created
several independent models. Stupid, I know.

The problem is that now I need to create a "News" application and one
of the fields should get all the associates so I can pick a related
associate to a particular news item.

Of course a ManyToMany field won't work here because I can only
reference one model.

Here's my question:

Since it's now impossible to change the "Associates" application,
because several dozens of associates have already been inserted into
the database, and if I change it to inheritance I'll basically have to
re-insert every associate (or maybe there's an easy way?), is it
possible to get all the results from the models in the "Associates"
app and make those results available in the admin in a single list?

For example:

class NewsItem(models.Model):
    title = models.CharField()
    introduction = models.TextField()
    body = models.TextField()
    slug = models.SlugField()
    related_associates = models.ManyToManyField(Associates
    publication_date = models.DateField()

Where the related_associates would give out a list of every single
Hotel, SPA, Golf, etc.

Do I need to create a new field type? Can someone show me an example?

I was thinking about something like this:

def get_associates(request):
    hotels = Hotels.objects.all()
    golf = Golf.objects.all()
    ....

And then using that to populate a select box, like the ones Django
uses for M2M fields, with all the associates listed by 'title'. But I
don't really know how to do this.

Thank you very much =)

Frederico
--~--~---------~--~----~------------~-------~--~----~
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