Reputation: 63
I Want to add Redis Database in Django-1.9, so i followed this documents for integration https://niwinz.github.io/django-redis/latest/ But i didn't find any clue on how to mention Database name in the settings, Here i want to mention Redis as a database on behalf Sqlite3, If uncommented this line django is throwing an Error of DATABASE not found
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'sqlite3'),
}
}
Thanks in Advance for your solution
Upvotes: 3
Views: 6274
Reputation: 142
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/0",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient"
}
}
}
To use the redis database in django you need to add this code to your settings file,based on your requirement you can change the value of the database at the end of LOCATION value like ("redis://127.0.0.1:6379/1") for database '1'. You can also check here: https://niwinz.github.io/django-redis/latest/#_configure_as_cache_backend
Upvotes: 2
Reputation: 470
By default Django provides no support for non-relational database backends. However, if you intend to use Redis as your primary database, you can take a look at Django non-rel.
Upvotes: 1
Reputation: 53734
django-redis is a BSD Licensed, full featured Redis cache/session backend for Django.
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker
Essentially that means django-redis is a django package that allows you to replace the default memcache as django's cache backend and also allows you to replace the DB as the default session storage. However django-redis does not implement features required to use it as a replacement for sqlite3 or any other database.
Upvotes: 5