Luke Plant wrote:
> As I understand it, Django should be able to do this query no problem.
> I think there may be a mistake in what you posted though - IIRC, I
> would have expected the method name to be 'get_articles_list' not
> 'get_article_list', since you defined it as 'articles =
> meta.ManyToManyField(Article)'.  If you post the entire code for your
> models we may be able to find the problem.  Magic-removal branch
> doesn't really change what is possible here, it just changes the
> syntax.
>

hi Luke, Ivan!

I've migrated my new app to the m-r branch, it's AWESOME!

it's really simple to get things done:

[code]
gamesku = GameSku.objects.get(pk=gamesku_id)
article_list =
gamesku.articles.filter(article_type__name__exact=article_type).order_by('-submit_date')
[/code]

that's what I want :D

and, here is my **old** models definition, I don't know if it's
possible to do so with django trunk:

class ArticleType(meta.Model):
        name = meta.CharField(maxlength=128)
        display_name = meta.CharField(maxlength=128)
        display_order = meta.IntegerField(blank=False)
        description = meta.CharField(maxlength=2048)

class Article(meta.Model):
        user = meta.ForeignKey(auth.User)
        article_type = meta.ForeignKey(ArticleType)
        title = meta.CharField(_('title'), maxlength=255, blank=False)
        description = meta.TextField(_('description'), maxlength=500)
        content = meta.TextField(_('content'), maxlength=3000)
        submit_date = meta.DateTimeField(_('date/time submitted'),
auto_now_add=True)

class GameSku(meta.Model):
        game = meta.ForeignKey(Game)
        platform = meta.ForeignKey(GamingPlatform)
        developer = meta.ForeignKey(Company, verbose_name='Developer')
        publisher = meta.ForeignKey(Company, verbose_name='Publiser')
        name = meta.CharField(maxlength=128)
        articles = meta.ManyToManyField(Article)

the sql I wrote to get what I want is:

sql = "select distinct articles.id as id from articles, article_type,
game_sku_articles, game_sku where article_type.name =
'%(article_type)s' and articles.article_type_id = article_type.id and
game_sku.id = '%(gamesku_id)d' and game_sku_articles.gamesku_id =
game_sku.id and game_sku_articles.article_id = articles.id" % locals()

I was wondering how to "get a spefic type of articles of a gamesku
while gamesku & articles' relationship is many-to-many" in django
trunk..

BiG thanks to all you guys!

I used to be someone who didn't like django's ORM stuff, however, in
the new m-r branch, with brand-new ORM support and transaction support,
I'm LOVING it! 

Django rocks! :)

- nkeric


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

Reply via email to