Hey, Mark. I hope I'm not misunderstanding, but importing models from
one app to another is no problem.
For example, assume Django project is called 'project' and you have
two apps named 'people' and another named 'tagging'.
In your people/models.py:
from django.db import models
from project.tagging.models import Tag
class Person(models.Model):
name = models.CharField(maxlength=100)
tag = models.ManyToManyField(Tag)
With that said, certainly play around with this to learn, but I would
also recommend checking out django-tagging (http://code.google.com/p/
django-tagging/) for an awesome tagging app.
Branton
On Jun 4, 6:46 pm, marknca <[EMAIL PROTECTED]> wrote:
> I'll start off my fully admitting that I'm a Django noob and there's
> probably (hopefully!) an easy answer to this one.
>
> Problem:
>
> I have several apps in the same project. Each of these apps offers
> tagging of various models.
>
> Ideally I would like one Tag model in an app (e.g., a tagging app)
> that relates to various models in each of the other apps (e.g., page
> in the page app, movie in the movie app, book in the book app, etc.)
>
> Advantages:
>
> - follows the DRY principle
> - ensures no duplicate tags exist
> - makes searching for all material tagged very easy
>
> Roadblock:
>
> - According to the Django documentation on Many-to-One relationships
> "Note, however, that you can only use strings to refer to models in
> the same models.py file - you cannot use a string to reference a model
> in a different application, or to reference a model that has been
> imported from
> elsewhere.",http://www.djangoproject.com/documentation/model-api/#many-to-one-rel...
>
> - Importation of models from one app into another
>
> Questions:
>
> - Have I got the architecture layout (distinct apps for each area of
> the project) wrong?
> - Is the documentation accurate and I cannot setup a reference to a
> model in a different project?
> - Can I import models from one app into another?
>
> Nasty kludge to solve the problem:
> - Have an identical Tag model in each app
> - Manually (e.g., through a script + cron) sync tags across apps
> - Create an app to search Tags across all of the other apps
>
> Any help/insight would be greatly appreciated!
>
> Cheers,
>Mark
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---