question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in search backends when uploading an Image

See original GitHub issue

Issue Summary

So when I am uploading an image with postgres database, I get an error and get stuck on an Image Chooser

File "/usr/local/lib/python3.8/site-packages/wagtail/search/backends/database/postgres/postgres.py", line 126, in title
    for current_field, boost, value in self.prepare_field(self.obj, field):
File "/usr/local/lib/python3.8/site-packages/wagtail/search/backends/database/postgres/postgres.py", line 63, in prepare_field
    get_weight(field.boost),
File "/usr/local/lib/python3.8/site-packages/wagtail/search/backends/database/postgres/weights.py", line 59, in get_weight
    return weight
UnboundLocalError: local variable 'weight' referenced before assignment

I think it’s a quick fix, so no need to explain it more 😉

Technical details

  • Python version: 3.9.5.
  • Django version: 4.0.4.
  • Wagtail version: 3.0.
  • Browser version: Firefox 101

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
itekhicommented, Jun 21, 2022

Ohhhh… Found it! wagtail.search was not added to INSTALLED_APPS setting, so everything was falling apart. I tried to override CustomImages search_fields and got relation "wagtailsearch_indexentry" does not exist, so I wondered if wagtail.search is even installed…

0reactions
itekhicommented, Jun 21, 2022

No, I already used wagtail 3 with postgres database, everything is working as expected…

this would have come up many times before

Yeeah, that’s true, it was strange for me that I couldn’t find anything about this… I’m using a wagtail-pipit template for my project, so there’s a lot of code changes… Maybe a custom Image model is causing problems? But I didn’t yet change anything in it…

That’s a strange bug because nothing is changed about search… What can cause this?

Update: Custom Image model is not causing any problems 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting an error when uploading an image, using django ...
Getting an error when uploading an image, using django-storages ... I've seen several people submit issues with using the S3 backend but ...
Read more >
Uploading image throws error "The file received is not a valid ...
When uploading images via the API for some images an error 'The file received is not a valid image' is received. Uploading a...
Read more >
Image upload , File not getting uploaded to backend (no error ...
I am trying to upload an image in angular 2 , i have no error listed but there is no change in the...
Read more >
Error while uploading the backend table to sharepoint by wizard
I uploaded for the test purpose one my table having few records only (Table has a Numeric field called IDrecord - and set...
Read more >
HTTP Error when uploading images - WordPress.org
I've tried deactivating the latest plugin and cleared cache before trying to upload more images. That did not work. I did try uploading...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found