Hello,
I have a base template file which is base.html and every other template extends to it and generates content using its blocks.
Now, at my base.html file I want to include a variable that will be using some variable such as querylist.
In example:
assume I hav some NavigationObject model and at the base.html
I want to loop throug...
Hello,
I would like to make a custom admin page for one of my application with django. I've created a change_form.html and fieldset.html in admin/myapp/mymodel of my template folder. I am now able to customize the page.
mymodel has an ImageField and I would like to display this image on the page. I guess this is possible because the Im...
I have a form with an email property.
When using {{ form.email }} in case of some validation error, django still renders the previous value in the input tag's value attribute:
<input type="text" id="id_email" maxlength="75" class="required" value="[email protected]" name="email">
I want to render the input tag myself (to add some javascr...
Maybe i'm missing something but i'm looking to add a float number, something like this:
{%floatnumber|add:3.4%}
Filter add round my result so I don't want to write my filter, but if is the only way, i'll copy add filter
Now i'm doing this:
def addf(value, arg):
"""Adds the arg to the value."""
return float(value) + float(ar...
I have the following django model:
RESOURCE_DIR = os.path.join(settings.MEDIA_ROOT, 'resources')
class Resource(models.Model):
title = models.CharField(max_length=255)
file_name = models.FilePathField(path=RESOURCE_DIR, recursive=True)
and I want to give the URL to the file in a template so that the user can view it or downlo...
Hello,
Is there a way in Django to group some fields from a ModelForm? For example, if there's a model with fields like: age, gender, dob, q1, q2, q3 and a form is created based in such Model, can I group the fields like: info_fields = (age, gender, dob) and response_fields = (q1, q2, q3). This would be helpful to display all fields in ...
Hello, I have a weird problem, I want to add a global query using context processors.
This is how I did it by following:
made a processor.py in my app as such:
from myproject.myapp.models import Foo
def foos(request):
return {'foos': Foo.objects.all()}
and at the end of my setting.py I have added this:
TEMPLATE_CONTEXT_PROCESS...
Let's say I have 3 django apps, app Country, app Social and app Financial.
Country is a 'master navigation' app. It lists all the countries in a 'index' view and shows details for each country on its 'details' view.
Each country's details include their Social details (from the social app) and their Financial details (from the financia...
I have django objects:
class Event(models.Model):
title = models.CharField(max_length=255)
event_start_date = models.DateField(null=True, blank='true')
...
class RegistrationDate(models.Model):
event = models.ForeignKey(tblEvents)
date_type = models.CharField(max_length=10, choices=registration_date_type)
start_dat...
I am storing my templates in the database and I don't have any path to provide for the template.render method.
Is there any exposed method which accepts the template as a string?
Is there any workaround?
...
In my model i have a method like so:
class Content(models.Model):
#...
def get_file(self):
file = open('path/to/file','r')
return File(file)
I am attempting to access this method and the file object in my template like so:
{{ content.get_file.url }}
I am not getting any error but I am also not getting any ou...
Let's say I have a django site, and a base template for all pages with a footer that I want to display a list of the top 5 products on my site. How would I go about sending that list to the base template to render? Does every view need to send that data to the render_to_response? Should I use a template_tag? How would you do it?
...
I can override edit_inline/tabular.html if I save it in my overall template directory ( let's say mysite/templates/admin/edit_inline/tabular.html ) , but when I try to save it with other admin template, like change_form.html ( in mysite/myapp/templates/admin/myapp/mymodel/change_form.html, it doesn't work.
Any thoughts?
Thanks!
...
Hi,
I'm trying to move from django 1.0.2 to 1.1 and I am getting the
following error in one of my templates:
Request Method: GET
Request URL: http://localhost:8000/conserv/media_assets/vod/
Exception Type: TemplateSyntaxError
Exception Value: Caught an exception while rendering: 'NoneType'
object has no attribute ...
My model is returning a Decimal(1234567.50), I can't seem to display the Decimal with a thousands separator. Does Django have a way to do this? Do I need to create my own template filter?
Thanks.
...
HI,
I am writing a bunch of template tags for a Django application, that need a certain javascript library.
Each of those template tags could exist multiple times on the same Template.
I was wondering if there is a smart way that I could add the Javscript library in the templatetag templates?
Here is an example TemplateTagA uses cust...
Hello Django Gods..
I am trying to simply access a the values and names of a Many to Many Model in a template by name. Can someone show me what I'm doing wrong.
I have a model called IP. This model can have several attributes. I want to call the "value" of a a particular attribute.
For example:
I have an IP Block named Foo. Foo ...
In chapter 8 of the Django book there is an example showing a fundamental view wrap method, which receives another view method passed in from any single arbitrary URLconf:
def requires_login(view):
def new_view(request, *args, **kwargs):
if not request.user.is_authenticated():
return HttpResponseRedirect('/accoun...
I'm writing a Google App Engine application using the WebApp framework. I'd like the various django filters to use the user-agent requested language (and culture) and not the default (English). I'm mainly interested in timesince, timeuntil, and date.
Side-question: how can I enable the filters provided by django.contrib.markup inside We...
When using the register.inclusion_tag() shortcut on a Custom Template Tag, assuming you define the template as 'some_fragment.html', in what directories/order does Django try to find that template?
Assume as many 'defaults' as is reasonable.
The Custom Template Tag portion of the documentation doesn't list anything specific, except t...