Re: Custom joins on multiple columns with Q objects
Another thing i can't resolve is construct contraints based in another model other than the query original one. With 0.96 i just passed the Options object - "q_filter.get_sql (other_model._meta)". Now I've tried: class QJoin(object): ... def add_to_query(self, query, used_aliases): query.start_meta = self.model._meta for child in self.where.children: query.add_filter(child) query.start_meta = None But without success, the filters always apply to query.model._meta. I've in the last days reading and analyzing the "model.sql" code but probably i'm missing something. --~--~-~--~~~---~--~~ 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: Custom joins on multiple columns with Q objects
Malcolm Tredinnick wrote: > At some point in the future, multi-valued ON constraints might make an > appearance (for example, multi-column primary key queries are possibly > easier to write), but they might not, too. The slight preference for > doing so at some point is that there are a couple of cases on some > databases where join constraints are handled more efficiently than where > constraints. Well, that's what i am trying to do, only construct ON contraints for composite primary keys, nothing else. Anyway, thanks for your insightful reply. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Custom joins on multiple columns with Q objects
I'm using with Django 0.96 a custom Q object to make joins between models, here's an example: class Product(models.Model): group = models.IntegerField() # primary key code = models.CharField() # primary key name = models.CharField() ... class CartItem(models.Model): product_group = models.IntegerField() # product foreign key product_code = models.CharField() # product foreign key quantity = models.IntegerField() ... items = CartItem.objects.filter( QJoin(Product, 'p', Q(group='product_group', code='product_code'))).extra( select={ 'p.name': 'product__name' }) for this to work i've translated this: "Q(group='product_group', code='product_code')" into this: "ON (cartitem.product_group=p.group AND cartitem.product_code=p.code)" taking advantage of django.db.models.quey.Query._get_sql_clause method: if joins: sql.append(" ".join(["%s %s %s ON %s" % (join_type, table, alias, condition) for (alias, (table, join_type, condition)) in joins.items()])) Now on the new django.db.models.sql.query.BaseQuery i can add new joins with the "join" method, but on "get_from_clause" the joins construction does not allow me to construct a join on multiple columns, here's the code from this method: if join_type and not first: result.append('%s %s%s ON (%s.%s = %s.%s)' % (join_type, qn(name), alias_str, qn(lhs), qn2(lhs_col), qn(alias), qn2(col))) The solution i can think of is to subclass de BaseQuery and overwrite the "get_from_clause" method. --~--~-~--~~~---~--~~ 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: Cant access via fastcgi
Manuel Meyer wrote: > You don't have permission to access /home/myusername/public_html/ > ultimateWeimar/django.fcgi/ on this server. In my case it was permissions, the .fcgi must be executable. > IndexError: string index out of range I was getting this error too because we must call it like this django.fcgi/, note the trailing slash. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---