Skip to main content

cognick-package

Reusable Django package for working with Cognick cognitive parameters.

Get Started

pip install cognick

Main Settings Configuration

Add the following settings to your Django settings.py:

# redis config
REDIS_HOST="<your_redis_host>"
REDIS_PORT="<your_redis_port>"
REDIS_SELECT_DB="<your_redis_db>"
COGNICK_COGNITIVE_CACHE_TIMEOUT="<redis_cache_timeout>" # optional (default=3600)

# cognitive parameters list url
COGNICK_COGNITIVE_URL="<your_cog_params_url>"

COGNICK_COGNITIVE_URL must point to the Cognick cognitive parameters list endpoint.


Usage

Use Cognick cognitive parameters directly in your Django models.

Model

from django.db import models
from cognick.cognitive.fields import CognitiveField, CognitiveArrayField


class Game(models.Model):
    ...
    primary_cognitive_parameter = CognitiveField()
    cognitive_parameters = CognitiveArrayField()
    ...

The values are stored as cognitive parameter IDs in the database, while the package resolves them to CognitiveParameter objects when accessed.

Serializer

Use CognitiveParameterSerializer to return the complete cognitive parameter data dynamically.

from rest_framework import serializers

from models import Game
from cognick.cognitive.serializers import CognitiveParameterSerializer

class GameSerializer(serializers.ModelSerializer):
    primary_cognitive_parameter = CognitiveParameterSerializer()
    cognitive_parameters = CognitiveParameterSerializer(many=True)
    
    class Meta:
        model = Game
        fields = '__all__'
        

The serializer is dynamic and returns the fields available in the Cognick API response.

You do not need to manually define fields such as name_fa, name_en, description_fa, etc.

Accessing Cognitive Parameters

Single Cognitive Parameter

game = Game.objects.get(id=1)

game.primary_cognitive_parameter.name_fa
game.primary_cognitive_parameter.name_en
game.primary_cognitive_parameter.description_fa

Release files for cognick 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cognick 0.0.1
File Size Uploaded
cognick-0.0.1.tar.gz 43.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cognick 0.0.1
File Interpreter ABI Platform
cognick-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 75.6 kB

Release files / cognick-0.0.1.tar.gz

Download URL cognick-0.0.1.tar.gz
Size 43.3 kB
Tags Source
SHA-256 checksum
How to use checksums
20336811705daf1c177b8ab38517393f219172035c4100e8fb2df5f9bf915351
BLAKE2b-256 checksum
How to use checksums
70657cb2881dfe86545e057a1b27021f32ae134c041966fb1591deaff24f1998
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / cognick-0.0.1-py3-none-any.whl

Download URL cognick-0.0.1-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
670a67ae7b01b22096e3f2073208871b68bc5e00ea49531e8b63d46304a57404
BLAKE2b-256 checksum
How to use checksums
cb2c5800f11270dc52b76a7338a5dab9dc85e653c7ae9a0f6adda32305538c03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page