Re: Relationships in Models across apps in the same project

2007-06-04 Thread Branton Davis

Hey, I've been doing the Django thing for a few months and only
recently have felt less noobish.  Of course, I was learning Python as
I went along too.  Anyhow, I'm glad it worked.

Also check out http://www.djangosnippets.org/snippets/83/ if you get
into django-tagging.

Branton


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



Re: Relationships in Models across apps in the same project

2007-06-04 Thread marknca

Branton,

Just to re-iterate I did say I was a Django noob!

You answer worked like a charm. I really appreciate it!

I'll check out the django-tagging app shortly.

Cheers,
   Mark

PS > I'll have to submit an update request to the documentation to
clarify the wording.


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



Re: Relationships in Models across apps in the same project

2007-06-04 Thread sansmojo

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