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

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.4
File Size Uploaded
cognick-0.0.4.tar.gz 43.3 kB Details

Built distribution (wheel)

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

Total release size: 75.7 kB

Release files / cognick-0.0.4.tar.gz

Download URL cognick-0.0.4.tar.gz
Size 43.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2b557d4ca6bc49e74ea4321a2503b678b5abeeb2213158fdb676e6c1bdd80493
BLAKE2b-256 checksum
How to use checksums
3e1eb24308a5dc10de8aa0bcfb64123e62cb55d4057d8108c378d614a88aa8e8
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.4-py3-none-any.whl

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

This release

0.0.4 This release

2 release files

0.0.3

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