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.

Registering models with django-watson

See original GitHub issue

I dont understand where i need to add this thanks to help me

from django.apps import AppConfig
import watson

class YourAppConfig(AppConfig):
    name = "your_app"
    def ready(self):
        YourModel = self.get_model("YourModel")
        watson.register(YourModel)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
hellvixcommented, Feb 21, 2016

I tried the master branch and it did not work. I still go the same problem.

Furthermore, maybe it would be nice to include the init.py thing in the documentation. I don’t think it is there.

0reactions
hellvixcommented, Feb 22, 2016

Oh. I that’s true. I’ll update it 😃

Den mandag den 22. februar 2016 skrev Dave Hall notifications@github.com:

No worries! Feel free to tweak the wiki if you think anything needs clarifying. 😃 On Sun, 21 Feb 2016 at 21:04, hellvix <notifications@github.com <javascript:_e(%7B%7D,‘cvml’,‘notifications@github.com’);>> wrote:

Sorry for my ignorance. I read this part in the documentation and started using the results as the object itself.

2016-02-21 18:01 GMT-03:00 Dave Hall <notifications@github.com <javascript:_e(%7B%7D,‘cvml’,‘notifications@github.com’);>>:

search_entry.meta should be a dictionary of string keys mapped to string values. So if you had an image field, you can access it in your template as search_entry.meta.field_name

However, it can often be simpler to just access search_entry.object, which will be an actual instance of your model. You can then use any model fields, or methods, you wish.

On Sun, 21 Feb 2016 at 15:26 hellvix <notifications@github.com <javascript:_e(%7B%7D,‘cvml’,‘notifications@github.com’);>> wrote:

Master worked. Thanks.

Another thing: metadata seems fuzzy for some particular kinds of object. I have a related table that stores images for a post and a post can have several images. If I use metadata to access all of this information, I get back a huge string with the images’ address. Extracting only one image, for example can be a bit complicated if it is inside of a template. Any suggestions? Also, dates are stored in strings? I have non-naive objects stored. I have to cast them? Is there any api to work with dates on watson?

— Reply to this email directly or view it on GitHub <

https://github.com/etianen/django-watson/issues/130#issuecomment-186843318

.

— Reply to this email directly or view it on GitHub <

https://github.com/etianen/django-watson/issues/130#issuecomment-186915216

.

— Reply to this email directly or view it on GitHub < https://github.com/etianen/django-watson/issues/130#issuecomment-186916437

.

— Reply to this email directly or view it on GitHub https://github.com/etianen/django-watson/issues/130#issuecomment-187153073 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

This is why you should use Django-Watson
After installing watson, you need to do register the models you want to be searchable using watson. To do this open the apps.py...
Read more >
django-watson - PyPI
django -watson is a fast multi-model full-text search plugin for Django. It is easy to install and use, and provides high quality search...
Read more >
Model registration that uses a django.contrib.sites.models.Site ...
I'm having a problem when trying to use a Site object (from django.contrib.sites) in one of my Watson model registrations. The problem line...
Read more >
django-watson does not work properly - Stack Overflow
CharField(_('title'), max_length=255) content = models.TextField(_('content')). Registration: from django.apps import AppConfig from watson ...
Read more >
django-watson - Bountysource
0001_initial...System check identified some issues: app_1 | app_1 | WARNINGS: app_1 | watson.SearchEntry: (models.W042) Auto-created primary key used when not ...
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