bfirsh / django-shorturls

A URL shortening app for Django
BSD 3-Clause "New" or "Revised" License
406 stars 68 forks source link

Silent failure if model name is incorrect #28

Open andreyshipilov opened 5 years ago

andreyshipilov commented 5 years ago

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 commented 5 years ago

My bad. SHORTEN_MODELS key values should be lowercase.

SHORTEN_MODELS = {
    'E': 'experiences.photo', #  Not Photo.
}
bfirsh commented 5 years ago

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

andreyshipilov commented 5 years ago

@andreyshipilov Most likely, but not in templates.

bfirsh commented 5 years ago

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