django-templates

Django {{ MEDIA_URL }} blank

I have banged my head over this for the last few hours. I can not get {{ MEDIA_URL }} to show up in settings.py .. MEDIA_URL = 'http://10.10.0.106/ame/' .. TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", "django.core.context_processors.media", ) .. in my view i have from django.shortcuts import ren...

How to get form field's id in Django?

Is there any way to get the id of a field in a template? In the HTML i get: <input name="field_name" id="id_field_name"... I know I can get the name with {{ field.html_name }}, but is there anything similar for getting the id? Or can I only get it like this: id_{{ field.html_name }}? ...

How do I write a Django template tag for access control?

I'm trying, in vain, to create a simple Django template tag to either show or hide a "delete" link next to a submitted comment on my site. In a nutshell, I want to pass the comment object to the template tag, determine if the currently logged in user is authorized to delete the comment and then either show or not show the link. The usa...

Django friends setup questions

Hi. I am trying to use django-friends in my app, with no luck. This app is not well documented and I cannot seem to find any real information about it out there. Has anyone used this app in their project before? Something that is not a PINAX project. Any links or ideas will be appreciated. ...

Django - how to dynamically generate a menu based on use privs

Does anyone know a good way to solve this other problem I have. My site shows menus based on a users privs. I have a function that returns the privs as a dictionary as below: return {"manage_entries":True, "manage_members":False, "manage_something_else":True} I passed in each priv to my base template that includes the navigation b...

How To Create A Form With Generic Relations In Django

Hi, How can I create a Form with normal form elements and generic elements together as ModelForm For using frontend CRUD. For example; Generic Model: class Todo(models.Model): user = models.ForeignKey(User, related_name="todo") title = models.CharField(max_length=100, unique=False) slug = models.SlugField(max_length=50) ...

Mako templates using Django template tags

Our Django site is built using Mako templates. We want to use a third party project called django-socialregistration, but its template tags use Django's templates. If we used Django templates we could just {% load facebook_tags %} {% facebook_button %} {% facebook_js %} How can I do the same thing in Mako? You can inline strait up py...

Problem with locating template

I'm trying to install django lfc on my server. Apart of zilions of different problems I've encountered now I'm struggling with TemplateDoesNotExist. In my settings file I have set TEMPLATE_DIRS variable like this : TEMPLATE_DIRS = ( "/home/snow4life/lfc/templates", "/home/snow4life/lfc_theme/templates" ...

Django TemplateSyntaxError

I am getting a TemplateSyntaxError, that is only happening on my dev server, but works fine on the django testing server locally. Here's the error Caught SyntaxError while rendering: invalid syntax (urls.py, line 1) and the html: <li><a href="{% url plan.views.profile %}">Plan Details</a></li> and here is the profile view: @login...

How do I reference a django variable in javascript?

Hello, I am working on a project that requires me to use a value contained in a variable from my view.py template. I need to use that variable in my javascript. Does anyone know a proper way to pass a variable from django to JS? Here is my function in views.py @login_required @never_cache_headers def user_feed(request, user=None, ext...

django: can we do loader.get_template('my_template.txt')?

Hi, I want to use django template to process plain text file, and tried this: from django.template import loader, Context t = loader.get_template('my_template.txt') however, it works for this: from django.template import loader, Context t = loader.get_template('my_template.html') Can we load txt files using django template loader? ...

How to replace all the Characters with * using Regular Expression

I am having a text like s = bluesky i want to get it as s = ******* (equal no of * as no of characters) I am searching for a regular expression for python. Plz help. Any help will be appreciated Edit 1 : b = '*'*len(s) How can we do it in Django Template ...

Is there any filter in Django to display asterisk(*) instead of text

I am eager to know whether any filter is available for displaying all the text as * like this mytext = 'raja' {{ mytext|password }} should show **** How can we do this. plz help ...

Passing named arguments to functions in Django templates

I have in my Django controller a function that is called as follows: trip.driverTrip.filter(status='pending') What it will be the equivalent of calling this in a template. If I just want to call the filter function, the following will suffice: {{trip.driverTrip.filter}} But is there a way to pass it arguments ? ...

Can you access a Django Model "property" from it's ModelForm?

I have a Django model class with a non-model-field property, ex: def _get(self): return "something" description = property(_get) I'm using the model class with in a ModelForm / ModelFormset. Is there any way to access the property from the form / formset? If not, what's best practice for including extra "display" data in a djang...

Can I access attributes of the first object in a list in Django templates?

I’ve got a Django template that’s receiving a list of objects in the context variable browsers. I want to select the first object in the list, and access one of its attributes, like this: <a class="{{ browsers|first.classified_name }}" href="">{{ browsers|first }}</a> However, I get a syntax error related to the attribute selection ....

Creating and rendering structure with years and months in django

In my blogging app I need a structure (created as a variable in context processor) that will store months number and corresponding year of 5 consecutive months till current one. So if current month is december, we will have year: 2010 and months: 12,11,10,9,8. If month will be january we will have years 2010: months: 1 and years: 2009 mo...

ImproperlyConfigured about template in django project

When I am trying to access my django site, it appeared the ImproperlyConfigured error say that "Module "django.template.loaders.filesystem" does not define a "Loader" callable template source loader". I use Bitnami Django Stack and this is not the first time I installed it, so I think that there is the conflict between the old and new o...

Displaying page content using django-page-cms

I would like to display some content located in my models in some of my template pages. I am using django-page cms In the documentation views are not used to display content. Instead ready made template tags are used. http://packages.python.org/django-page-cms/display-content.html I do not understand a word of this. Please Bear with ...

How to use {% with %} along with {% include %} -- Django

For example, I have a template file called: filter.html {{ title }} code... What I'd like to do is, on a separate template: {% with "Filter by Types" as title %} {% include "filter.html" %} {% endwith %} Currently it can't be done. Could someone explain why that is and an alternative way to achieve this? Background context: T...