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

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

Built distribution (wheel)

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

Total release size: 75.6 kB

Release files / cognick-0.0.2.tar.gz

Download URL cognick-0.0.2.tar.gz
Size 43.3 kB
Tags Source
SHA-256 checksum
How to use checksums
68618e394cbf7f18a807eeefbcaf39f390a507447068caa53e76681f06472768
BLAKE2b-256 checksum
How to use checksums
c67b78904e57d9c33954a57c14808ff6e1d4a0d44e6dd87f55e2c8b4b436bccd
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.2-py3-none-any.whl

Download URL cognick-0.0.2-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8181e6371c3cc54c8c606b63a36bf9edff92f30ed884dd3b7547b6faded3981
BLAKE2b-256 checksum
How to use checksums
df5981d92c0b14f5df2854ab8d983e58e756faf9e2fc319c950929de44c09e60
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

This release

0.0.2 This release

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