i can’t make first get post function
Hard to assist with so few details. Please state exactly what you are trying to do, which steps you’ve taken, what is going wrong, and any other relevant info as needed.
If you are using the django-scylla
Pypi, you may also want to check out their own docs and ask in their discord server. See django-scylla · PyPI
thanks for replaying to me
from rest_framework import serializers
from .models import *
class BlogPostSerializer(serializers.ModelSerializer):
class Meta:
model = BlogPost
fields = ‘all’
def create(self):
return BlogPost.title
from django.shortcuts import render
from django.http import JsonResponse
from rest_framework import status, generics,request
from rest_framework.decorators import api_view
from rest_framework.response import Response
from .models import BlogPost
from .serializers import *
Create your views here.
class BlogPostListCreate(generics.ListCreateAPIView):
serializer_class = BlogPostSerializer
def get_queryset(self):
# Fetch all blog posts using Cassandra's querying system
# Cassandra may not support .all() in the same way as Django ORM.
return BlogPost.objects.all()
def get(self, request, *args, **kwargs):
queryset = self.get_queryset()
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)
def post(self, request, *args, **kwargs):
return self.create(request, *args, **kwargs)
import uuid
from datetime import datetime
from django.db import models
from cassandra.cqlengine import columns
from django_cassandra_engine.models import DjangoCassandraModel
class BlogPost(DjangoCassandraModel):
id = columns.UUID(primary_key=True, default=uuid.uuid4)
title = columns.Text(required=True)
content = columns.Text()
created_at = columns.DateTime(default=datetime.now)
class Meta:
app_label = ‘galo’
DATABASES = {
‘default’: {
‘ENGINE’: ‘django_cassandra_engine’,
‘NAME’: ‘my_keyspace’, # Keyspace in ScyllaDB
‘HOST’: ‘127.0.0.1’, # ScyllaDB instance
‘PORT’: ‘9042’,
‘USER’: ‘’, # Leave empty if no authentication
‘PASSWORD’: ‘’,
‘OPTIONS’: {
‘replication’: {
‘strategy_class’: ‘SimpleStrategy’,
‘replication_factor’: 1
}
}
}
}
There’s no error, so we still can’t crystal ball this
gives me keysapce problem
i forget to tell i solved it for a while