Re: Relations accros multiple apps
Hi Fabien. > App User: > class User: > #some fields > > App Blog > class Blog: > author = models.ForeignKey(User.user) > > Is-it possible to do that ? Sure. Models are regular python classes, all you must do is to import it's module before using it. Like: from django.contrib.auth.models import User (now you can use the User model on you bloggin app) If you want to import the Blog model from another app ,you can do the same: form myproject.blog.models import Blog # here myproject is the name where the blog app sits. One caveat though. If you are importing the user model, you can be sure that i will be on every django install and you already know the path to it. If you plan to "plug" you blog app into other projects, you have no way to know where on the path it will be (for example it could be on fabienapps.blog or myclient.blog). in this case you can find out where the app lives : from django.db.models.loading import get_app blog = get_app('blog') from blog.models import Blog cheers arthur > -- > Fabien SCHWOB > _ > Derrière chaque bogue, il y a un développeur, un homme qui s'est trompé. > (Bon, OK, parfois ils s'y mettent à plusieurs). --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Relations accros multiple apps
Hello Fabien Schwob! On Fri, 16 Jun 2006 17:01:32 +0200 you wrote: > Hello, > > I'm about to create my first Django apps and I would like to know if > it's possible to have relationships between models accross multiple > apps. For example I would like to have : > > App User: > class User: > #some fields > > App Blog > class Blog: > author = models.ForeignKey(User.user) > > Is-it possible to do that ? > It is possible. http://www.djangoproject.com/documentation/models/many_to_one/ -- ÷ÓÅÇÏ ÎÁÉÌÕÞÛÅÇÏ! greg [at] anastasia [dot] ru çÒÉÇÏÒÉÊ. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Relations accros multiple apps
Hello, I'm about to create my first Django apps and I would like to know if it's possible to have relationships between models accross multiple apps. For example I would like to have : App User: class User: #some fields App Blog class Blog: author = models.ForeignKey(User.user) Is-it possible to do that ? Thanks -- Fabien SCHWOB _ Derrière chaque bogue, il y a un développeur, un homme qui s'est trompé. (Bon, OK, parfois ils s'y mettent à plusieurs). --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---