django-shorturls icon indicating copy to clipboard operation
django-shorturls copied to clipboard

Silent failure if model name is incorrect

Open andreyshipilov opened this issue 7 years ago • 4 comments
trafficstars

I have an object in the context named experience and all the attributes from this objects are shown correctly on the page. Although this:

{% load shorturl %}

{% shorturl experience %}

Produces an empty result. shorturls is in INSTALLED_APPS and url('^short/', include('shorturls.urls')) is in urls.py. The object has get_absolute_url() method which works correctly.

Am I missing something?

andreyshipilov avatar Nov 04 '18 01:11 andreyshipilov

My bad. SHORTEN_MODELS key values should be lowercase.

SHORTEN_MODELS = {
    'E': 'experiences.photo', #  Not Photo.
}

andreyshipilov avatar Nov 04 '18 02:11 andreyshipilov

Hm - this should probably throw an error though, shouldn't it?

bfirsh avatar Nov 04 '18 04:11 bfirsh

@andreyshipilov Most likely, but not in templates.

andreyshipilov avatar Nov 04 '18 04:11 andreyshipilov

Indeed... it should probably validate the configuration on bootup to make sure the models actually exist.

bfirsh avatar Nov 04 '18 04:11 bfirsh