Giter Site home page Giter Site logo

Comments (7)

GeorgeLubaretsi avatar GeorgeLubaretsi commented on August 23, 2024

Try adding Ad model to related_models in Document's Meta class.

from django-elasticsearch-dsl.

codalprashant avatar codalprashant commented on August 23, 2024

Ya I did it. But it gives error in below function

def get_instances_from_related(self, related_instance):
return related_instance.car_set.all()

saying car_set is not the option.

Does anyone face this issue and solved it?

from django-elasticsearch-dsl.

codalprashant avatar codalprashant commented on August 23, 2024

@GeorgeLubaretsi Thanks for the reply.@GeorgeLubaretsi and @alex-dotdev can you help me out in this ? Whenever I am adding ads through django admin, It should be added under car type like manufacturer. But this is not happeing.

Error - 'Ad' object has no attribute 'car_set'

from django-elasticsearch-dsl.

 avatar commented on August 23, 2024

@codalprashant Returning self will resolve the submission errors in the Admin. But it's still not updating the index in Elastic.

@car.doc_type
class CarDocument(DocType):
    ads = fields.NestedField(properties={
        'title': fields.StringField(),
        'pk': fields.IntegerField(),
    })

    class Meta:
        model = Car
        related_models = [Ad]

    def get_instances_from_related(self, related_instance):
        return self

from django-elasticsearch-dsl.

 avatar commented on August 23, 2024

@codalprashant Testing via the Django shell with the settings above. car.save() works and updates the elastic index. It looks like the Signal aren't connect to the Admin panel. @sabricot Might been able to offer some advice quicker then myself.

from django-elasticsearch-dsl.

sabricot avatar sabricot commented on August 23, 2024

I have update the example app with a working example for this kind of relationship (when the foreign key is on the related model).
You can check here https://github.com/sabricot/django-elasticsearch-dsl/blob/master/example/test_app/documents.py.

from django-elasticsearch-dsl.

codalprashant avatar codalprashant commented on August 23, 2024

Finally Works. Thanks

from django-elasticsearch-dsl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.