Thank you for your suggestion. And sorry fro delayed answer.

My hunch is saying same thing but I want to be sure about it.

Kind Regards,
Sencer Hamarat

3 Mart 2020 Salı 12:24:34 UTC+3 tarihinde Naveen Arora yazdı:
>
> Hi, 
>
> Can't the error be resolved ? Still, if error has to occur then you can 
> put conditions instead of try blocks for better functioning.
>
> Regards
> Naveen Arora
>
>
> On Monday, 2 March 2020 18:25:15 UTC+5:30, Sencer Hamarat wrote:
>>
>> Hello, 
>>
>> The project I'm working on has it's custom template context_processor.
>> And when unavailable URL request arrives to Django (Eg. "/wp-login.php"), 
>> the context_processor is throwing AttributeError.
>>
>> Which way should I use to prevent from context processor from throwing 
>> errors?
>> Is it ok to wrapping return with try block and returning empty dictionary 
>> if AttributeError raised?
>>
>> def resolver_context_processor(request):
>>     return {
>>         'app_name': request.resolver_match.app_name,
>>         'namespace': request.resolver_match.namespace,
>>         'url_name': request.resolver_match.url_name
>>     }
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4c876117-f16b-4603-8d7b-d3609420093a%40googlegroups.com.

Reply via email to