def get_template_names(self, **kwargs):
        """
        Get a list of template names in order of precedence as used by the
        Django template engine. Keyword argument passed in are used during
        string formatting of the template names. This fails silently if a
        argument is specified in a template name but is not present in
        ``kwargs``.

        :rtype list: A list of template names (unicode).
        """
        if not self.template_name and not self.default_template_names:
            raise ImproperlyConfigured(
                _("No template name and default templates specified."))
        default_names = list(self.default_template_names)

        template_kwargs = {'module_name': self._meta.module_name}
        template_kwargs.update(kwargs)

        if self.template_name:
            default_names = [self.template_name] + default_names

        language_code = getattr(self, 'language_code', None)

        try:
            parent_code, __ = language_code.split('-')
        except (__HOLE__, ValueError):
            parent_code = None

        template_names = []
        for tmpl_name in default_names:
            try:
                tmpl_name = tmpl_name.format(**template_kwargs)
            except KeyError:
                pass

            basename, ext = tmpl_name.rsplit('.', 1)

            if language_code:
                template_names.append(
                    "{}_{}.{}".format(basename, language_code, ext))

            # add a fallback for the parent language if it is available
            # e.g. for 'en-gb' we want 'en' to be a fallback template
            if parent_code:
                template_names.append(
                    "{}_{}.{}".format(basename, parent_code, ext))

            template_names.append(tmpl_name)

        return template_names
dataset/ETHPy150Open tangentlabs/django-fancypages/fancypages/mixins.py/TemplateNamesModelMixin.get_template_names