ceys / django-tracking

Automatically exported from code.google.com/p/django-tracking
MIT License
0 stars 0 forks source link

Feature request: Setting for template name in active_visitor_map.html #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
We use django-tracking as an svn external so that we automatically get new
updates, however this means that we cannot commit changes that we would
like applied between projects.  It would be very useful if the template
name could be extracted into a setting so that this could be easily
customised per project (we usually use admin/base.html).

Original issue reported on code.google.com by n...@itsnotworking.co.uk on 26 Jun 2009 at 9:15

GoogleCodeExporter commented 8 years ago
Fantastic suggestion!  I opted to use a few different methods that people seem 
to
appreciate:

- setting the `extends_template` in the extra_context in your URLconf
- setting the `template_name` in the extra_context in your URLconf
- specifying a value for `DEFAULT_TRACKING_TEMPLATE` in your settings.py

For example, you could override which template the stock 
tracking/visitor_map.html
extends by doing something like this:

urlpatterns = patterns('',
    (r'^tracking/map/$', 'tracking.views.display_map', {'extends_template':
'admin/base.html'),
    (r'^tracking/$', include('tracking.urls')),
)

If you don't change the tracking/visitor_map.html template for anything other 
than to
specify which template to extend, this would be useful.  If you customize that
template, however, you can either do something like this:

urlpatterns = patterns('',
    (r'^tracking/map/$', 'tracking.views.display_map', {'template_name':
'tracking/custom_visitor_map.html'),
    (r'^tracking/$', include('tracking.urls')),
)

...or you could just define DEFAULT_TRACKING_TEMPLATE in your settings file as 
such:

DEFAULT_TRACKING_TEMPLATE = 'tracking/custom_visitor_map.html'

...and leave the URLconf alone.

You can use any combination of these additions to make things as confusing or as
logical as you'd like :)

Thanks for the suggestion!

Original comment by wheaties...@gmail.com on 26 Jun 2009 at 3:56

GoogleCodeExporter commented 8 years ago
6 hours, that's impressive! I have a couple more thoughts I'll get them added :D

Nick

Original comment by n...@itsnotworking.co.uk on 26 Jun 2009 at 4:04

GoogleCodeExporter commented 8 years ago
Nick,

Yeah, I figured I ought to smash things like this quickly, otherwise it would 
just
sink to the back of my memory..  For the record, it would have been done 
sooner, but
you posted it about an hour after I went to sleep last night. ;)

I'm interested in your other suggestions!

Original comment by wheaties...@gmail.com on 26 Jun 2009 at 4:09

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Ignore last message I thought your examples were editing tracking.urls lol. 
Should
learn to read properly.

Nick

Original comment by n...@itsnotworking.co.uk on 29 Jun 2009 at 11:19

GoogleCodeExporter commented 8 years ago
Nick,

I'm glad you got it sorted!  I probably should have noted that the urlpatterns 
code
above would be in your own urls.py file. ;)

Original comment by wheaties...@gmail.com on 29 Jun 2009 at 2:44