order_by function gets error if the field name or json key, has a dash.

2019-01-13 Thread Jonathan Espinal
order_by function gets error if the field name or json key, has a dash.


I know Django use a dash for asc or desc methods. but in this case the dash 
is in the middle.


EXAMPLE:

MyTable.objects.all().order_by('myfield__en-us')

I have a jsonb field like:

{
"es": "Casa",
"en-us": "House"
}



Does anybody know how to fix it?
I can't change de json structure :(


Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9cd9ae56-5529-4915-b91a-5703926e58de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I have a question with "ModelForm"

2013-10-27 Thread Jonathan Espinal
I have a question with "ModelForm", I have a accounts model with a 
foreignkey on users model, when I try to save a record using "ModelForm", 
the SQL "debug_toolbar" show my 2 aditionals query:

"SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", 
"auth_user"."is_superuser", "auth_user"."username", 
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", 
"auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" 
FROM "auth_user" WHERE "auth_user"."id" = 1"

and

"SELECT (1) AS "a" FROM "auth_user" WHERE "auth_user"."id" = 1 LIMIT 1"

Could I avoid that, or what am i doing wrong ?

Thanks...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f793e8c5-11db-4f2a-9e97-a16abc51c5ae%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.