Closed karanveerm closed 8 years ago
Maybe https://github.com/django-guardian/django-guardian/commit/cf1c818d30abaa649eae2e5697e862c168d8b166 will be useful if somebody want fix that.
Hi, i pushed this branch with every tests passing for django 1.9 but i don't have a django 1.9 compatible app to make some integration tests, can you please test with your own app and tell me if everything runs smoothly ?
Hi. On this branch, I have error:
Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv self.execute(*args, **cmd_options) File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute output = self.handle(*args, **options) File "/usr/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 225, in handle emit_post_migrate_signal(created_models, self.verbosity, self.interactive, connection.alias) File "/usr/lib/python2.7/site-packages/django/core/management/sql.py", line 280, in emit_post_migrate_signal using=db) File "/usr/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 201, in send response = receiver(signal=self, sender=sender, **named) TypeError: es_syncdb_callback() takes exactly 3 arguments (1 given)
How to fix it, I don`t know. Can you help me?
Oh, sorry. I find solution. Change django_elasticsearch/models.py:
def es_syncdb_callback(sender, app=None, created_models=[], **kwargs):
for model in sender.get_models():
if issubclass(model, EsIndexable):
model.es.create_index()
Hi, nice catch and thanks for the fix, i pushed it in the django19 branch along with some tests but i'm not convinced they actually work the way i think they do :(
@lauxley, could you accept this request in your project?
Hi, Can somebody put here the link of pip install that is compatible with django 1.9?
@Dean-Christian-Armada I merged the associated PR so you can use pip install git+https://github.com/liberation/django_elasticsearch.git with django 1.9
Surprisingly I received this error when tried to run it in shell
This is the error:
(music_store)Deans-MacBook:music_store deanarmada$ python manage.py shell
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from store.models import *
>>> x = Artist.es.search("Tyga")
>>> x
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/deanarmada/.virtualenvs/music_store/lib/python2.7/site-packages/django_elasticsearch/query.py", line 76, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/Users/deanarmada/.virtualenvs/music_store/lib/python2.7/site-packages/django_elasticsearch/query.py", line 97, in __getitem__
self.do_search()
File "/Users/deanarmada/.virtualenvs/music_store/lib/python2.7/site-packages/django_elasticsearch/query.py", line 270, in do_search
r = es_client.search(**search_params)
File "/Users/deanarmada/.virtualenvs/music_store/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/Users/deanarmada/.virtualenvs/music_store/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 548, in search
doc_type, '_search'), params=params, body=body)
File "/Users/deanarmada/.virtualenvs/music_store/lib/python2.7/site-packages/elasticsearch/transport.py", line 329, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/Users/deanarmada/.virtualenvs/music_store/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 105, in perform_request
raise ConnectionError('N/A', str(e), e)
ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x10bd3f110>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x10bd3f110>: Failed to establish a new connection: [Errno 61] Connection refused)
This is my models.py
from __future__ import unicode_literals
from django.core.urlresolvers import reverse
from django.db import models
from django_elasticsearch.models import EsIndexable
# Create your models here.
class Artist(EsIndexable, models.Model):
name = models.CharField(max_length=50)
birth_date = models.DateField()
# https://docs.djangoproject.com/es/1.9/ref/models/instances/#get-absolute-url
# Used to pass a location header URL upon post
def get_absolute_url(self):
return reverse('artists-detail', kwargs={'artist_id':self.id})
def __unicode__(self):
return self.name
class Album(EsIndexable, models.Model):
artist = models.ForeignKey(Artist)
name = models.CharField(max_length=50)
description = models.TextField()
def get_absolute_url(self):
return reverse('albums-detail', kwargs={'artist_id':self.artist.id, 'album_id':self.id})
def __unicode__(self):
return self.name
class Song(EsIndexable, models.Model):
album = models.ForeignKey(Album)
name = models.CharField(max_length=50)
duration = models.DurationField()
ratings = models.IntegerField()
It is look like problem on connection. Django could not establish connection to elasticsearch instance.
Is the problem on my computer? Is there something that I forgot to install? Is it my django version?
I'm using MAC OS X El Capitan
These are my packages:
Django==1.9.8 django-braces==1.9.0 django-elasticsearch==0.5 django-filter==0.13.0 django-oauth-toolkit==0.10.0 djangorestframework==3.4.0 drfdocs==0.0.11 elasticsearch==2.3.0 Markdown==2.6.6 oauthlib==1.0.3 six==1.10.0 urllib3==1.16 wheel==0.24.0
Show your settings file. Elasticsearch instance responds to curl requests?
@Dean-Christian-Armada it is problem with connect to ElasticSearch. If it is your project settings, check that ElasticSearch instance are responding on your requests because
Failed to establish a new connection: [Errno 61] Connection refused
speaks for itself.
Try curl localhost:9200
for check responds.
Your issue is not related to the topic.
@onegreyonewhite .. Thank you so much for pointing it out, the cause is I have not ran ElasticSearch yet
@Dean-Christian-Armada: I'm also facing the exact same issue, can you please tell me how do I run ElasticSearch so that it should not give me that connection refused error on shell.
Currently I get this: