← Back
Editing: models.cpython-311.pyc
� �|�e � � � d dl mZ d dlmZ d dlmZ d dlmZ G d� dej � � Z G d� dej � � Zd S ) � )�defaultdict)�apps)�models)�gettext_lazyc �Z � � e Zd ZdZ� fd�Zd� Zd� Zd� Zdd�Zdd�d�Z d � Z d � Zd� Z� xZ S ) �ContentTypeManagerTc �H �� t � � j |i |�� i | _ d S �N)�super�__init__�_cache)�self�args�kwargs� __class__s ��D/usr/lib/python3/dist-packages/django/contrib/contenttypes/models.pyr zContentTypeManager.__init__ s, �� ������$�)�&�)�)�)� ����� c �� � | j | j ||f }nB# t $ r5 | � ||�� � }| � | j |� � Y nw xY w|S )N�� app_label�model�r �db�KeyError�get� _add_to_cache)r r r �cts r �get_by_natural_keyz%ContentTypeManager.get_by_natural_key sv � � ,���T�W�%�y�%�&8�9�B�B��� ,� ,� ,����I�U��;�;�B����t�w��+�+�+�+�+� ,���� � s � �<A�Ac �, � |r|j j }|j S r )�_meta�concrete_model)r r �for_concrete_models r � _get_optszContentTypeManager._get_opts s � �� /��K�.�E��{�r c �N � |j |j f}| j | j | S r )r � model_namer r )r �opts�keys r �_get_from_cachez"ContentTypeManager._get_from_cache s$ � ��~�t��/���{�4�7�#�C�(�(r c �l � | � ||� � } | � |� � S # t $ r Y nw xY w | � |j |j �� � }n9# | j j $ r' | � |j |j �� � \ }}Y nw xY w| � | j |� � |S )z� Return the ContentType object for a given model, creating the ContentType if necessary. Lookups are cached so that subsequent lookups for the same model don't hit the database. r )r# r( r r r r% r �DoesNotExist� get_or_creater r )r r r"