r4fek / django-cassandra-engine

Django Cassandra Engine - the Cassandra backend for Django
BSD 2-Clause "Simplified" License
365 stars 84 forks source link

syncdb only creates a keyspace #5

Closed lrhazi closed 10 years ago

lrhazi commented 10 years ago

Following the 4 steps in the wiki, when I run syncdb I only see: Creating keyspace avesterra_db..

Should there be something else created, given the one example model ?

r4fek commented 10 years ago

You have to add at least one CQL model in django application, which has to be added to INSTALLED_APPS. Then run syncdb and your model(s) should be synced automatically. Good luck!

lrhazi commented 10 years ago

I believe I did that... I added the model as in the wiki : class ExampleModel(Model)

Is that not what you mean?

lrhazi commented 10 years ago

In case it matters:

➜ ~ sudo pip list |egrep -i 'cass|djan' cassandra-driver (2.1.0) Django (1.7) django-cassandra-engine (0.0.6) django-celery (3.1.16) django-celery-with-redis (3.0) django-jinja (1.0.4) djangorestframework (2.4.3) djangotoolbox (1.6.2)

r4fek commented 10 years ago

Could you paste your models.py here? Are you sure this app is in INSTALLED_APPS?

lrhazi commented 10 years ago

It's same as the wiki, and my app was added to INSTALLED_APPS automatically by PyCharm... I did double check :)

myapp/models.py

import uuid from cqlengine import columns from cqlengine.models import Model

class ExampleModel(Model): read_repair_chance = 0.05 # optional - defaults to 0.1 example_id = columns.UUID(primary_key=True, default=uuid.uuid4) example_type = columns.Integer(index=True) created_at = columns.DateTime() description = columns.Text(required=False)

r4fek commented 10 years ago

You're doing something wrong. Take a look at testproject in this repo. It works for sure on Django 1.7. We're using this engine in many projects without any problems..

lrhazi commented 10 years ago

I am sure I am.. I'll try and start from the test project. Thanks a lot.

r4fek commented 10 years ago

No problem. Let me know when you solve it. Good luck!

r4fek commented 10 years ago

@lrhazi have you resolved your issue?

lrhazi commented 10 years ago

sorry know. have not had time to dig into it further. feel free to close since nobody else seems to be reproducing my issues.

wryfi commented 10 years ago

I had this issue as well, until I looked at the example and noticed that django_cassandra_engine was the very last app in INSTALLED_APPS. After adjusting my list accordingly, syncdb created the tables defined in my app. This ordering dependency should perhaps be more explicitly stated in the docs.

r4fek commented 10 years ago

@wryfi but it is! The docs says: IMPORTANT: This app should be last on INSTALLED_APPS list.

shunkit commented 10 years ago

I had this issue. But I solved it. Please try ./manage.py syncdb --database cassandra. cassandra is your cassandra database name in settings.py. My code is below.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    },
    'cassandra': {
        'ENGINE': 'django_cassandra_engine',
        'NAME': 'db',
        'TEST_NAME': 'test_db',
        'HOST': '127.0.0.1',
        'OPTIONS': {
            'replication': {
                'strategy_class': 'SimpleStrategy',
                'replication_factor': 1
            }
        }
    }
}
ghost commented 7 years ago

http://r4fek.github.io/django-cassandra-engine/faq/

The doc says it should be first application. But for me neither making it first or last working.