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:
ModelCultural/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.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelPolitical/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.parentis aForwardManyToOneDescriptorinstance.
- 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelLanguage 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.parentis aForwardManyToOneDescriptorinstance.
- 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelMany-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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelMany-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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelMany-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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelNon-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.
- 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelNamed 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelMany-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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelRaw 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_datafield 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.parentis aForwardManyToOneDescriptorinstance.
- 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.
- 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:
objectMixin that replaces the insights JSONField with the structured editor.
- class cw.audiences.admin.LanguageAlternativeModelInline(model, admin_site)[source]
Bases:
TabularInlineInline 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:
TabularInlineInline 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:
TabularInlineInline 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:
TabularInlineInline 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:
TableSectionExpandable section displaying persona segments in a table.
- Parameters:
request (HttpRequest)
instance (Model)
- verbose_name = 'Segments'
- fields = ['segment_category', 'segment_vector', 'segment_value', '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')}))
- 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')}))
- 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')}))
- 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')}))
- 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')}))
- 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')}))
- 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).