> Hi,
>
> I try to use raw sql in admin site, it is possible somehow?
>
> I use postresql and have some problem with ordering.
>
> I have in database something like:
> Category(id=1, name='first', parent_category=None,
> materialised_path='1')
> Category(id=2, name='child1 of first', parent_category=1,
> materialised_path='1.2')
> Category(id=1, name='child2 of first', parent_category=1,
> materialised_path='1.3')
> ...
> Category(id=10, name='second', parent_category=None,
> materialised_path='10')
>
> and now if i use normal sql 'select name, materialised_path from
> category order by materialised_path'
> and i get:
> first 1
> second 10
> child1 of first 1.2
> child2 of first 1.3
>
> but i need:
> first 1
> child1 of first 1.2
> child2 of first 1.3
> second 10
>
> because postgres is set to use utf collate, so in this moment i try
> use ~<~ operator in raw query:
>
> categories = models.Category.objects.raw('''SELECT "category"."id",
> "category"."name", "category"."idname", "category"."prio",
> "category"."description", "category"."materialised_path",
> "category"."parent_category_id", "category"."category_container_id"
> FROM "category ORDER BY materialised_path using ~<~''')
>
> of course in def queryset(self, request) of CategoryAdmin.
>
> But I get database error, I think admin not supports raw query or I
> use it not correct in this place.
>
> Do You know how can I use "~<~" in admin site?
>
> regards
Can you show the exact code you are currently using to try and use
this query in the admin, and the actual error you get?
--
DR.
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment