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.3

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.3
File Size Uploaded
cognick-0.0.3.tar.gz 43.4 kB Details

Built distribution (wheel)

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

Total release size: 75.8 kB

Release files / cognick-0.0.3.tar.gz

Download URL cognick-0.0.3.tar.gz
Size 43.4 kB
Tags Source
SHA-256 checksum
How to use checksums
28263eeaeb665cc6ae947c0ad235e09349e0014dd2105ed8ca3e9572c4c53bf3
BLAKE2b-256 checksum
How to use checksums
acb7277a6b4780433abf6f2be89b8b5fdb3b8aedad1f09a9e34e93ab51cb4043
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.3-py3-none-any.whl

Download URL cognick-0.0.3-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
622dc37faf20f98c39e1f3b93198bd4d81ff7f041f6d6746764a7d90e0fe5d40
BLAKE2b-256 checksum
How to use checksums
b5bf897e488761dc1d2cb2aa575e5bdbbfb41045b9a9e89da56017d0e8c4ebc6
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

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

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