<commit_before>from django.conf import settings
from django.db import models
from django.contrib.sites.models import Site
from django.utils.translation import get_language, ugettext_lazy as _

from lemon.pages import fields as pages_fields
from lemon.publications.models import Publication


LANGUAGES = tuple((code, _(name)) for code, name in settings.LANGUAGES)


class URLPathField(models.CharField):

    def __init__(self, *args, **kwargs):
        kwargs['max_length'] = kwargs.get('max_length', 255)
        if 'db_index' not in kwargs:
            kwargs['db_index'] = True
        super(URLPathField, self).__init__(*args, **kwargs)

    def get_internal_type(self):
        return 'SlugField'

    def formfield(self, **kwargs):
        defaults = {'form_class': pages_fields.URLPathField}
        defaults.update(kwargs)
        return super(URLPathField, self).formfield(**defaults)


class Page(Publication):

    sites = models.ManyToManyField(Site, verbose_name=_(u'sites'))
    language = models.CharField(_(u'language'), max_length=10,
                                choices=LANGUAGES, default=get_language)
    slug = URLPathField(_(u'URL'), max_length=255)
    title = models.CharField(_(u'title'), max_length=255)
    content = models.TextField(_(u'content'))
    template = models.CharField(_(u'template'), max_length=255)

    class Meta:
        ordering = ['slug']
        verbose_name = _(u'text page')
        verbose_name_plural = _(u'text pages')

    def __unicode__(self):
        return u'%s (%s)' % (self.title, self.slug)

    def get_absolute_url(self):
        return self.slug


from django.conf import settings
if 'south' in settings.INSTALLED_APPS:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules(
        [(
            (URLPathField,), [],
            {'max_length': ['max_length', {'default': 255}],
             'db_index': ['db_index', {'default': True}]})],
        ['^lemon\.pages\.models\.URLPathField'])
<commit_msg>Create index for language in pages<commit_after>from django.conf import settings
from django.db import models
from django.contrib.sites.models import Site
from django.utils.translation import get_language, ugettext_lazy as _

from lemon.pages import fields as pages_fields
from lemon.publications.models import Publication


LANGUAGES = tuple((code, _(name)) for code, name in settings.LANGUAGES)


class URLPathField(models.CharField):

    def __init__(self, *args, **kwargs):
        kwargs['max_length'] = kwargs.get('max_length', 255)
        if 'db_index' not in kwargs:
            kwargs['db_index'] = True
        super(URLPathField, self).__init__(*args, **kwargs)

    def get_internal_type(self):
        return 'SlugField'

    def formfield(self, **kwargs):
        defaults = {'form_class': pages_fields.URLPathField}
        defaults.update(kwargs)
        return super(URLPathField, self).formfield(**defaults)


class Page(Publication):

    sites = models.ManyToManyField(Site, verbose_name=_(u'sites'))
    language = models.CharField(_(u'language'), max_length=10, db_index=True,
                                choices=LANGUAGES, default=get_language)
    slug = URLPathField(_(u'URL'), max_length=255)
    title = models.CharField(_(u'title'), max_length=255)
    content = models.TextField(_(u'content'))
    template = models.CharField(_(u'template'), max_length=255)

    class Meta:
        ordering = ['slug']
        verbose_name = _(u'text page')
        verbose_name_plural = _(u'text pages')

    def __unicode__(self):
        return u'%s (%s)' % (self.title, self.slug)

    def get_absolute_url(self):
        return self.slug


from django.conf import settings
if 'south' in settings.INSTALLED_APPS:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules(
        [(
            (URLPathField,), [],
            {'max_length': ['max_length', {'default': 255}],
             'db_index': ['db_index', {'default': True}]})],
        ['^lemon\.pages\.models\.URLPathField'])

{'fraction_non_alphanumeric': 0.12549407114624506, 'fraction_numerical': 0.008399209486166008, 'mean_word_length': 3.464167585446527, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3671077', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1205, 'n_words': 274}