Open Ace314159 opened 9 years ago
What's your django settings.py say? It should be something like:
DATABASES = {
'default': {
'ENGINE': 'djangocassandra.db.backends.cassandra',
'NAME': 'DATABASE NAME',
'USER': '',
'PASSWORD': '',
'HOST': 'YOUR DATABASE HOST',
'CONTACT_POINTS': ('YOUR DATABASE HOST',),
'PORT': 9042,
'DEFAULT_KEYSPACE': 'YOUR KEYSPACE NAME',
'KEYSPACES': {
'YOUR KEYSPACE NAME':{
'durable_writes': True,
'strategy_class': 'SimpleStrategy',
'replication_factor': 3
}
}
}
}
The documentation is a little lacking.
Thanks for the especially quick reply. I changed the settings.py and it worked properly. Also, I am trying to use the included AutoFieldUUID, but the documentation does not clearly explain what to import. I tried to import djangocassandra, but I get the error message OSEror: zipimport: can not open file PythonDir/lib/site-packages/django-cassandra-0.1.7-py3.4.egg
EDIT: Sorry. I fixed it. I was running the import from interactive mode. It works in code. Thanks for this amazing engine!
Sure!
That setting is:
CUSTOM_AUTOFIELD_CLASS = 'djangocassandra.db.fields.AutoFieldUUID'
For debug purposes, you may try not using the CUSTOM_AUTOFIELD_CLASS and this will make all the pk fields to be integers (I think).
What version of python are you using?
Oops, didn't see your comment. I use Python 3.4. I tried CUSTOM_AUTOFIELD_CLASS
, but that didn't work out, so I'm going to stick with importing djangocassandra.db.fields
.
Cool. Good luck.
I have another problem now. I installed the Knotis Fork of Django, added the CUSTOM_AUTOFIELD_CLASS
setting, but now I get this: cassandra.cqlengine.models.ModelDefinitionException: At least 1 primary key is required.
I already defined a AutoField(primary_key=True)
field.
Hmm... What's your model look like?
The project isn't tested with Python 3.4. If you run the test suite (nose test
I believe) do you get a similar result?
I didn't setup any tests yet so I don't know how to run nose test
. My models.py is:
#search/models.py
from django.db import models
import uuid
class Person(models.Model):
pID = models.AutoField(primary_key=True, default=uuid.uuid4, unique=True)
pFname = models.CharField(max_length=100)
pMname = models.CharField(max_length=100)
pSname = models.CharField(max_length=100)
pAge = models.IntegerField(max_length=3)
pSex = models.CharField(max_length=1)
pEd = models.CharField(max_length=100)
pIncome = models.DecimalField(max_length=100, decimal_places=10, max_digits=100)
pNet = models.DecimalField(max_length=100, decimal_places=10, max_digits=100)
pStreetNum = models.IntegerField(max_length=100)
pStreet = models.CharField(max_length=100)
pSuburb = models.CharField(max_length=100)
pCity = models.CharField(max_length=100)
pDistrict = models.CharField(max_length=100)
pState = models.CharField(max_length=2)
pPin = models.BigIntegerField()
pLat = models.DecimalField(max_length=1000, decimal_places=20, max_digits=1000)
pLong = models.DecimalField(max_length=1000, decimal_places=20, max_digits=1000)
if(pSex == "F"):
gender = "female"
pronoun = "She"
else:
gender = "male"
pronoun = "He"
def __str__(self):
return "{0} {1} {2} is a {3} who is {4} years old. {5} has completed {6}, earns {7}, and has a networth of {8}. {5} \
lives in {9}, {10}, {11}, {12}, {13}, {14}, {15} ({16} degress North, {17} degrees East). ID: {18}".format(self.pFname, self.pMname, \
self.pSname, self.gender, self.pAge, self.pronoun, self.pEd, self.pIncome, self.pNet, self.pStreetNum, self.pStreet, self.pSuburb, self.pCity, self.pDistrict, self.pPin, self.pState, self.pLat, self.pLong, self.pID)
EDIT: Also, the error occurs even when my app is not installed.
It's possible that the dependencies in the setup.py are not as specific as they need to be and something has been updated or changed underneath this project.
I'm making some improvements to the library today and I'll ship a new working version.
Oh I read all the comments now and I'm not sure this library supports python3 as I have not tested it. I have a feeling that you are running into compatibility issues somewhere either in this library or the supporting ones.
Here's the documentation about how to configure the AutoUUID field: https://djangocassandra.readthedocs.org/en/latest/usage.html#usage
oh and the import for the example is:
from djangocassandra.db.fields import AutoFieldUUID
I installed djangocassandra and djangotoolbox, but when I run
python manage.py migrate
. I getKeyError: 'DEFAULT_KEYSPACE'