This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.views.generic import ListView | |
from django.template.defaultfilters import pluralize | |
from myapp.models.Product | |
class MyView(ListView): | |
queryset = Product.objects.all() | |
template_name = 'product.html' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ elasticsearch | |
[2014-05-14 08:15:05,257][INFO ][node ] [Aminedi] version[1.1.1], pid[46224], build[f1585f0/2014-04-16T14:27:12Z] | |
[2014-05-14 08:15:05,258][INFO ][node ] [Aminedi] initializing ... | |
[2014-05-14 08:15:05,271][INFO ][plugins ] [Aminedi] loaded [], sites [] | |
[2014-05-14 08:15:07,136][INFO ][node ] [Aminedi] initialized | |
[2014-05-14 08:15:07,136][INFO ][node ] [Aminedi] starting ... | |
[2014-05-14 08:15:07,211][INFO ][transport ] [Aminedi] bound_address {inet[/127.0.0.1:9300]}, publish_address {inet[/127.0.0.1:9300]} | |
[2014-05-14 08:15:10,262][INFO ][cluster.service ] [Aminedi] new_master [Aminedi][X4diAes4TrOMTk4eAdbhnA][mbp.home][inet[/127.0.0.1:9300]], reason: zen-disco-join (elected_as_master) | |
[2014-05-14 08:15:10,284][INFO ][discovery ] [Aminedi] elasticsearch/X4diAes4TrOMTk4eAdbhnA | |
[2014-05-14 08:15:10,298][INFO ][http ] [Aminedi] bound_address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install django-haystack | |
pip install pyelasticsearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add to installed apps | |
INSTALLED_APPS = ( | |
... | |
'haystack', | |
... | |
) | |
# haystack search using elasticsearch | |
HAYSTACK_CONNECTIONS = { | |
'default': { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /opt/elasticsearch-1.1.x/config/elasticsearch.yml | |
discovery.zen.ping.multicast.enabled: false | |
discovery.zen.ping.unicast.hosts: ["127.0.0.1"] | |
cluster.name: elasticsearch | |
network.host: 127.0.0.1 | |
http.port: 9200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# elasticsearch | |
export ES_HOME=/opt/elasticsearch-1.1.x | |
PATH=$ES_HOME/bin:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tail -f /opt/local/var/db/mysql56/out.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> SET GLOBAL general_log = 'OFF'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> SHOW VARIABLES LIKE "general_log%"; | |
+------------------+-----------------------------------+ | |
| Variable_name | Value | | |
+------------------+-----------------------------------+ | |
| general_log | OFF | | |
| general_log_file | /opt/local/var/db/mysql56/out.log | | |
+------------------+-----------------------------------+ | |
2 rows in set (0.00 sec) | |
mysql> SET GLOBAL general_log = 'ON'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
register = template.Library() | |
# truncate chars but leaving last word complete | |
@register.filter(name='smarttruncatechars') | |
def smart_truncate_chars(value, max_length): | |
if len(value) > max_length: |