Audiences

Audiences application: regions, countries, languages, segments, and personas.

Models

Audience segmentation models.

This module provides database models for: - Geographic segmentation: Regions, Countries, Languages - Compositional insights at each level (Region → Country → Language)

Models relocated from core app to establish dedicated audiences namespace.

class cw.audiences.models.Region(*args, **kwargs)[source]

Bases: Model

Cultural/market grouping with regional insights.

Examples: North America, Nordics, DACH, LATAM

Regional insights capture broad cultural patterns that apply across multiple countries in the region (e.g., Nordic minimalism, North American directness).

code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

insights

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

insights_as_markdown()[source]

Render structured insights as markdown.

Return type:

str

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

ad_units

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

countries

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

countryregion_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
personas

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class cw.audiences.models.Country(*args, **kwargs)[source]

Bases: Model

Political/regulatory entity with country-specific insights.

Examples: United States, Canada, Sweden, Switzerland

Country insights capture regulatory requirements and local cultural nuances specific to that country.

code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

default_language

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

insights

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

notes

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

regions

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

languages

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

insights_as_markdown()[source]

Render structured insights as markdown.

Return type:

str

get_primary_languages()[source]

Get languages marked as primary for this country.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

ad_units

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

countrylanguage_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

countryregion_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

default_language_id
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
personas

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

wvs_profiles

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class cw.audiences.models.Language(*args, **kwargs)[source]

Bases: Model

Language variant with locale code and LLM model recommendations.

Examples: en-US, fr-CA, de-CH, es-MX

Each language has locale-specific insights and recommended LLM models for generating content in that language variant.

code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

base_language

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

primary_model

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

alternative_models

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

insights

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

notes

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

insights_as_markdown()[source]

Render structured insights as markdown.

Return type:

str

get_all_models()[source]

Get primary model plus all alternatives as a queryset.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

ad_units

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

countries

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

countrylanguage_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

default_for_countries

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

languagealternativemodel_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

objects = <django.db.models.manager.Manager object>
personas

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

primary_model_id
class cw.audiences.models.CountryRegion(*args, **kwargs)[source]

Bases: Model

Many-to-many through table for Country ↔ Region relationship.

Allows countries to belong to multiple regions (e.g., Switzerland in both DACH and EU-WEST).

country

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

region

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

country_id
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
region_id
class cw.audiences.models.CountryLanguage(*args, **kwargs)[source]

Bases: Model

Many-to-many through table for Country ↔ Language relationship.

Tracks which languages are spoken in each country, with is_primary flag to indicate the default/official language.

country

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

language

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

is_primary

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

country_id
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

language_id
objects = <django.db.models.manager.Manager object>
class cw.audiences.models.LanguageAlternativeModel(*args, **kwargs)[source]

Bases: Model

Many-to-many through table for Language ↔ LLMModel alternatives.

Tracks alternative LLM models that can handle a specific language, separate from the primary model recommendation.

language

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

llmmodel

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

language_id
llmmodel_id
objects = <django.db.models.manager.Manager object>
class cw.audiences.models.Segment(*args, **kwargs)[source]

Bases: Model

Non-geographic audience segment (demographic, behavioral, psychographic).

Examples: - Demographic: Household Income → Middle-Income - Behavioral: Usage Pattern → First-Time Users - Psychographic: Emotional Driver → Nostalgia

Geographic segmentation uses existing Region/Country/Language models.

CATEGORY_CHOICES = [('DEMOGRAPHIC', 'Demographic'), ('BEHAVIORAL', 'Behavioral'), ('PSYCHOGRAPHIC', 'Psychographic')]
category

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

vector

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

insights

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

insights_as_markdown()[source]

Render structured insights as markdown.

Return type:

str

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_category_display(*, field=<django.db.models.fields.CharField: category>)
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
personas

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

personasegment_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class cw.audiences.models.Persona(*args, **kwargs)[source]

Bases: Model

Named collection of segments representing a target audience profile.

A Persona combines geographic segments (Region/Country/Language) with non-geographic segments (Demographic/Behavioral/Psychographic) to create a complete audience profile.

Example: “Budget-Conscious First-Timer” - Geographic: North America / United States / English (en-US) - Demographic: Household Income → Middle-Income - Behavioral: Usage Pattern → First-Time Users - Psychographic: Emotional Driver → Nostalgia

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

region

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

country

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

language

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

segments

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

segment_count()[source]

Count of attached non-geographic segments.

Return type:

int

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

ad_units

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

country_id
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

language_id
objects = <django.db.models.manager.Manager object>
personasegment_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

region_id
class cw.audiences.models.PersonaSegment(*args, **kwargs)[source]

Bases: Model

Many-to-many through table for Persona ↔ Segment relationship.

Explicit through table for future extensibility. Segments are automatically sorted by category and vector.

persona

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

segment

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
persona_id
segment_id
class cw.audiences.models.WVSProfile(*args, **kwargs)[source]

Bases: Model

Raw World Values Survey data for a country and wave.

Stores all WVS variable means as a JSON object, enabling dynamic lookups by theme. The pipeline can query specific variables based on script concept (e.g., environmental themes → V33, V34, V81).

The raw_data field holds {variable_code: mean_value} pairs for all ~945 variables in a given country-wave combination.

country

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

wave

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

raw_data

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property variable_count: int

Number of variables with non-null values.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

country_id
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>

Admin

Django admin configuration for audience segmentation models.

class cw.audiences.admin.InsightsWidgetMixin[source]

Bases: object

Mixin that replaces the insights JSONField with the structured editor.

formfield_for_dbfield(db_field, request, **kwargs)[source]
class cw.audiences.admin.LanguageAlternativeModelInline(model, admin_site)[source]

Bases: TabularInline

Inline for managing alternative LLM models for a language.

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

model

alias of LanguageAlternativeModel

extra = 1
autocomplete_fields = ['llmmodel']
verbose_name = 'Alternative Model'
verbose_name_plural = 'Alternative Models'
property media
class cw.audiences.admin.CountryRegionInline(model, admin_site)[source]

Bases: TabularInline

Inline for managing country-region relationships.

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

model

alias of CountryRegion

extra = 1
autocomplete_fields = ['country']
verbose_name = 'Country in Region'
verbose_name_plural = 'Countries in Region'
property media
class cw.audiences.admin.CountryLanguageInline(model, admin_site)[source]

Bases: TabularInline

Inline for managing country-language relationships.

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

model

alias of CountryLanguage

extra = 1
autocomplete_fields = ['language']
verbose_name = 'Language'
verbose_name_plural = 'Languages'
property media
class cw.audiences.admin.PersonaSegmentInline(model, admin_site)[source]

Bases: TabularInline

Inline for managing persona-segment relationships.

NOTE: This inline is kept for reference but not used in PersonaAdmin. PersonaAdmin uses the custom segment builder instead.

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

model

alias of PersonaSegment

extra = 1
autocomplete_fields = ['segment']
verbose_name = 'Segment'
verbose_name_plural = 'Segments'
fields = ['segment']
property media
class cw.audiences.admin.PersonaSegmentsSection(request, instance)[source]

Bases: TableSection

Expandable section displaying persona segments in a table.

Parameters:
  • request (HttpRequest)

  • instance (Model)

verbose_name = 'Segments'
related_name = 'personasegment_set'
fields = ['segment_category', 'segment_vector', 'segment_value', 'segment_description']
segment_category(instance)[source]

Display segment category with color badge.

segment_vector(instance)[source]

Display segment vector.

segment_value(instance)[source]

Display segment value.

segment_description(instance)[source]

Display segment description.

class cw.audiences.admin.LanguageAdmin(model, admin_site)[source]

Bases: InsightsWidgetMixin, ModelAdmin

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

list_display = ['name', 'code', 'base_language', 'primary_model', 'show_alternatives_count', 'show_active', 'updated_at']
list_filter = ['is_active', 'base_language', 'primary_model']
search_fields = ['name', 'code', 'base_language', 'notes']
readonly_fields = ['created_at', 'updated_at']
autocomplete_fields = ['primary_model']
inlines = [<class 'cw.audiences.admin.LanguageAlternativeModelInline'>]
fieldsets = (('Language', {'classes': ['tab'], 'fields': ('code', 'name', 'base_language', 'is_active')}), ('Models', {'classes': ['tab'], 'fields': ('primary_model',)}), ('Insights', {'classes': ['tab'], 'fields': ('insights',)}), ('Notes', {'classes': ['tab'], 'fields': ('notes',)}), ('Metadata', {'classes': ['tab'], 'fields': ('created_at', 'updated_at')}))
show_active(obj)[source]
show_alternatives_count(obj)[source]
property media
class cw.audiences.admin.RegionAdmin(model, admin_site)[source]

Bases: InsightsWidgetMixin, ModelAdmin

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

list_display = ['name', 'code', 'show_countries_count', 'show_active', 'updated_at']
list_filter = ['is_active']
search_fields = ['name', 'code', 'description']
readonly_fields = ['created_at', 'updated_at']
inlines = [<class 'cw.audiences.admin.CountryRegionInline'>]
fieldsets = (('Region', {'classes': ['tab'], 'fields': ('code', 'name', 'description', 'is_active')}), ('Insights', {'classes': ['tab'], 'description': 'Cultural patterns and characteristics for this region', 'fields': ('insights',)}), ('Metadata', {'classes': ['tab'], 'fields': ('created_at', 'updated_at')}))
show_active(obj)[source]
show_countries_count(obj)[source]
property media
class cw.audiences.admin.CountryAdmin(model, admin_site)[source]

Bases: InsightsWidgetMixin, ModelAdmin

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

list_display = ['name', 'code', 'default_language', 'show_regions_count', 'show_languages_count', 'show_active', 'updated_at']
list_filter = ['is_active', 'default_language']
search_fields = ['name', 'code', 'notes']
readonly_fields = ['created_at', 'updated_at']
autocomplete_fields = ['default_language']
inlines = [<class 'cw.audiences.admin.CountryLanguageInline'>]
fieldsets = (('Country', {'classes': ['tab'], 'fields': ('code', 'name', 'default_language', 'is_active')}), ('Insights', {'classes': ['tab'], 'description': 'Country-specific regulatory and cultural rules', 'fields': ('insights',)}), ('Notes', {'classes': ['tab'], 'fields': ('notes',)}), ('Metadata', {'classes': ['tab'], 'fields': ('created_at', 'updated_at')}))
show_active(obj)[source]
show_regions_count(obj)[source]
show_languages_count(obj)[source]
property media
class cw.audiences.admin.SegmentAdmin(model, admin_site)[source]

Bases: InsightsWidgetMixin, ModelAdmin

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

list_display = ['show_category_badge', 'vector', 'value', 'show_has_insights', 'show_active', 'updated_at']
list_filter = ['category', 'is_active', 'vector']
search_fields = ['vector', 'value', 'description']
readonly_fields = ['created_at', 'updated_at']
fieldsets = (('Segment', {'classes': ['tab'], 'fields': ('category', 'vector', 'value', 'description', 'is_active')}), ('Insights', {'classes': ['tab'], 'description': 'Structured insights for this segment', 'fields': ('insights',)}), ('Metadata', {'classes': ['tab'], 'fields': ('created_at', 'updated_at')}))
show_category_badge(obj)[source]
show_has_insights(obj)[source]
show_active(obj)[source]
property media
class cw.audiences.admin.PersonaAdmin(model, admin_site)[source]

Bases: ModelAdmin

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

form

alias of PersonaAdminForm

list_display = ['name', 'show_region', 'show_country', 'show_language', 'show_segment_count', 'show_active', 'updated_at']
list_filter = ['is_active', 'region', 'country', 'language']
search_fields = ['name', 'description']
readonly_fields = ['created_at', 'updated_at', 'segment_builder_display']
autocomplete_fields = ['region', 'country', 'language']
list_sections = [<class 'cw.audiences.admin.PersonaSegmentsSection'>]
fieldsets = (('Identity', {'classes': ['tab'], 'fields': ('name', 'description', 'is_active')}), ('Geographic', {'classes': ['tab'], 'description': 'Geographic dimensions of this persona', 'fields': ('region', 'country', 'language')}), ('Segments', {'classes': ['tab'], 'description': 'Build your persona by selecting demographic, behavioral, and psychographic segments.', 'fields': ('segment_builder_display',)}), ('Metadata', {'classes': ['tab'], 'fields': ('created_at', 'updated_at')}))
segment_builder_display(obj)[source]

Render the segment builder widget as a readonly field.

show_region(obj)[source]
show_country(obj)[source]
show_language(obj)[source]
show_segment_count(obj)[source]
show_active(obj)[source]
property media
class cw.audiences.admin.WVSProfileAdmin(model, admin_site)[source]

Bases: ModelAdmin

Parameters:
  • model (type[Model])

  • admin_site (AdminSite)

list_display = ['country', 'wave', 'show_variable_count', 'show_view_data_link', 'updated_at']
list_filter = ['wave']
search_fields = ['country__name', 'country__code']
readonly_fields = ['created_at', 'updated_at']
autocomplete_fields = ['country']
fieldsets = (('Profile', {'classes': ['tab'], 'fields': ('country', 'wave')}), ('Raw Data', {'classes': ['tab'], 'fields': ('raw_data',)}), ('Metadata', {'classes': ['tab'], 'fields': ('created_at', 'updated_at')}))
show_variable_count(obj)[source]
get_urls()[source]
view_data(request, object_id)[source]

Read-only formatted view of WVS raw data grouped by theme.

property media

Views

AJAX endpoints for cascading selectors and segment management.

AJAX views for audience admin interface.

cw.audiences.views.get_segment_vectors(request)[source]

Get unique vectors for a given segment category.

Used for cascading dropdown in persona segment builder.

cw.audiences.views.get_segment_values(request)[source]

Get segment values for a given category and vector.

Used for cascading dropdown in persona segment builder. Returns full segment data (id, value, description).

cw.audiences.views.add_segment_to_persona(request)[source]

Add a segment to a persona.

Used by the segment builder to attach segments.

cw.audiences.views.remove_segment_from_persona(request)[source]

Remove a segment from a persona.

Used by the segment builder to detach segments.