Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

order_by("hit_count_generic__hits") gives django.db.utils.ProgrammingError #90

Closed
ansuman13 opened this issue Mar 5, 2020 · 11 comments
Closed

Comments

@ansuman13
Copy link

ansuman13 commented Mar 5, 2020

Following from the issue #51,
i am running Python 3.6 with Django 2.2
I have a model Product
class Product(models.Model, HitCountMixin): ...
hit_count_generic = GenericRelation( HitCount, object_id_field='object_pk', related_query_name='hit_count_generic_relation')

when using
Product.objects.order_by('hit_count_generic__hits')
gives ->
... return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: operator does not exist: integer = text LINE 1: ... "hitcount_hit_count" ON ("pharmacy_product"."id" = "hitcoun... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts.

How to solve this.

@rafrasenberg
Copy link

I have the same problem.

@letsgogeeky
Copy link

If you're using PostgreSQL you'll be facing this problem because the Postgre engine does not perform implicit type conversion.

To fix the problem you have 2 options with PostgreSQL:
1- Change your model primary key to TextField and manage it manually (Not recommended)
2- Take a copy of hitcount and modiify HitCount model by changing object_pk type to be:
object_pk = models.AutoField() or object_pk = models.UUIDField() according to your own model setup.

@mnsrknp
Copy link

mnsrknp commented Apr 17, 2020

@letsgogeeky

object_pk = models.PositiveIntegerField() worked for me.

@MotasemAghbar
Copy link

@ansuman13 @webconexus
I've faced the same issue, I've solved it by downgrade hit count to 1.3.0 version.

@bashu
Copy link
Collaborator

bashu commented Apr 30, 2020

will fix it in 1.3.3 / 2.0

@100KG-AFRY
Copy link

Just +1ing this issue. Downgrading to 1.3.0 (or any other version for that matter) or downloading a copy and changing the types did not work.

@ajohnclark
Copy link

Same 1.3.0 downgrade didn't work either, will wait for next version. Thanks for the great simple hit counting tool regardless.

@bashu bashu closed this as completed in be7f27a Jul 4, 2020
@sowinski
Copy link

Please release 1.3.3 :)

@bashu
Copy link
Collaborator

bashu commented Jul 25, 2020

to @ajohnclark and @sowinski can you try #98 ?

@ajohnclark
Copy link

to @ajohnclark and @sowinski can you try #98 ?

Migrates with latest wagtail/django/Postgresql and also functions properly. Thank you!

@bashu
Copy link
Collaborator

bashu commented Jul 26, 2020

to @ansuman13 , @webconexus , @letsgogeeky, @mnsrknp , @MotasemAghbar , @100KG-AFRY , @ajohnclark run

pip install -U django-hitcount

ofekih pushed a commit to The-Ofek-Foundation/hitcount that referenced this issue May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants