Using a foreign key in Model search_fields?

212 pagtingin
Lumaktaw sa unang mensaheng hindi pa nababasa

step

hindi pa nababasa,
Peb 17, 2014, 10:48:21 PM2/17/14
para kaymezzani...@googlegroups.com
Hey guys, I can't figure this out.  I figured this might be something worth resolving on the mailing list as a reference.  
I'm trying to use a foreignkey in a Model's search_fields (search using a foreignkey).

Anyone have any idea?

settings.py
-----
(
    # Dotted path to field.
    "cartridge.shop.models.Product.artist",
    # Dotted path to field class.
    "ForeignKey",
    # Positional args for field class.
    ("app.Artist",),
    # Keyword args for field class.
    {"blank": False},
)

OPTION 1.

patches.py
----
Product.search_fields = {'keywords_string': 10, 'title': 5, 'artist': 5}

results in
----
"Related Field got invalid lookup: icontains"


OPTION 2

patches.py
----
Product.search_fields = {'keywords_string': 10, 'title': 5, 'artist__title': 5}

results in
----
"'Product' object has no attribute 'artist__title'"

Stephen McDonald

hindi pa nababasa,
Peb 18, 2014, 12:11:47 AM2/18/14
para kaymezzani...@googlegroups.com
Don't hoard your tracebacks, set them out free into the world!

(please paste your full tracebacks somewhere)


--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Stephen McDonald
http://jupo.org

step

hindi pa nababasa,
Peb 18, 2014, 8:06:44 AM2/18/14
para kaymezzani...@googlegroups.com, st...@jupo.org

Right, that those would be helpful :)  Here they are

http://dpaste.com/1633572/

http://dpaste.com/1633594/

- S

step

hindi pa nababasa,
Peb 18, 2014, 8:46:23 AM2/18/14
para kaymezzani...@googlegroups.com, st...@jupo.org
And this would be:
Django==1.6.2
Mezzanine==3.0.9
Cartridge@d49b00c1c48c01adcdaa5fc91df57b600db30627

On Tuesday, February 18, 2014 12:11:47 AM UTC-5, Stephen McDonald wrote:

step

hindi pa nababasa,
Peb 25, 2014, 3:18:33 PM2/25/14
para kaymezzani...@googlegroups.com
I couldn't get this to work :(

Path of least resistance was to just add the field data to self.description

Lucian Corduneanu

hindi pa nababasa,
Mar 4, 2014, 4:42:22 AM3/4/14
para kaymezzani...@googlegroups.com
I have the exact same problem. Stephen is there any other solution different from just copying it to keywords/description or even one custom text field? (redundant)
However this may slightly increase DB storage, but in terms of performance it will be a bit faster, not having to join the extra table when searching.

Stephen McDonald

hindi pa nababasa,
Mar 11, 2014, 3:53:57 PM3/11/14
para kaymezzani...@googlegroups.com

Lucian Corduneanu

hindi pa nababasa,
Mar 11, 2014, 7:43:17 PM3/11/14
para kaymezzani...@googlegroups.com, st...@jupo.org
Nice :) Thank you!
Tumugon sa lahat
Sumagot sa may-akda
Ipasa
0 bagong mensahe