if file and not file._committed: AttributeError: 'Template' object has no attribute '_committed'

Viewed 19

Here I want to create or get an entry from DB. The problem is when I'm referring to the template inside media/templates/emails/nice.html. I'm unable to get that and getting the error mentioned in the title.

my template settings in setting.py is following;

TEMPLATE_DIR = BASE_DIR / 'media/templates' 
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR,],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

Next I;m working in accounts/test.py

 # CREATE Template
        data = {
            "user":user,
            "platform_subscriber":project,
            "name": "Test one",
            "html_template": loader.get_template("emails/nice.html")
        }
        email_template, created = EmailTemplate.objects.custom_get_or_create(data)
        print("The key",email_template)
        self.email_template  = email_template.id

error;

    if file and not file._committed:
AttributeError: 'Template' object has no attribute '_committed'

----------------------------------------------------------------------
Ran 1 test in 3.440s
0 Answers
Related