Hi,
I need to make a links section for a django project that show only the non active links, ie. if i'm at home, the section only shows the about link and not the home link.
Im using something like this in my template:
{% ifequal item.url request.path %}
<a href = "{{item.url}}" > {{item.name}} </a>
{% endifequal %}
it works fine bu...
What is the correct way to do conditional formatting in Django?
I have a model that contains a date field, and I would like to display a list of records, but colour the rows depending on the value of that date field. For example, records that match today's date I want to be yellow, records that is before today I want green and ones afte...
Say I have a template
<html>
<div>Hello {{name}}!</div>
</html>
While testing it, it would be useful to define the value of the variable without touching the python code that invokes this template. So I'm looking for something like this
{% set name="World" %}
<html>
<div>Hello {{name}}!</div>
</html>
Does something like this e...
Like a good little coder, all of my Django templates inherit from a base.html. Now I would like to add some functionality to the base to always show some interesting things. Some user statistics, or random posts, or feeds, etc.
All of my views look like this:
def viewname(request) :
template_vales = {}
// Stuff
return rend...
How can I pass a variable value from a template using JavaScript without using a form (GET OR POST)?
...
I'm building a django app and I can't get the templates to see the CSS files... My settings.py file looks like:
MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media')
MEDIA_URL = '/media/'
I've got the CSS files in /mysite/media/css/ and the template code contains:
<link rel="stylesheet" type="text/css" href=...
In projects/urls.py I have:
urlpatterns = patterns('bizteen.projects.views',
url(r'^browse/$', 'browse', name='projects-browse-main'),
url(r'^browse/(\d+)/$', 'browse', name='projects-browse'),
url(r'^create/$', 'create', name='projects-create'),
url(r'^(\d+)/$', 'view_project', name='projects-view'),
)
And in a templa...
Hi
I have made a custom formwizard and incorporated it into my admin interface.
Basically I have taken the change_form.html and left it under the admin interface url:
(r'^admin/compilation/evaluation/add/$', EvaluationWizard([EvaluationForm1, EvaluationForm2])),
It works, but the admin "session" is not kept. I can access the pag...
In my Django templates, I have a couple pieces of code that are like this:
<a href="{% url root %}">Root</a>
They work properly when rendering the template. However, whenever I run my unit tests using Django's unit testing framework, I get the following error:
NoReverseMatch: Reverse for 'mysite.root' with arguments '()' and keywo...
Hi,
This is related to this question:
how-can-i-port-a-legacy-java-j2ee-website-to-a-modern-scripting-language
but with a narrower focus.
We're pretty much rewriting our legacy Java app from the ground up for a variety of reasons, but attempting to keep the user interface pretty much the same.
In one of the answers, someone said:
...
I have a model:
from django.db import models
CHOICES = (
('s', 'Glorious spam'),
('e', 'Fabulous eggs'),
)
class MealOrder(models.Model):
meal = models.CharField(max_length=8, choices=CHOICES)
I have a form:
from django.forms import ModelForm
class MealOrderForm(ModelForm):
class Meta:
model = MealOrder
A...
Does something like the python
if "a" in ["a", "b", "c"]:
pass
exist in Django templates?
If not, is there an easy way to implement it?
...
How do I write a numeric for loop in a Django template? I mean something like
for i = 1 to n
...
I currently have two apps:
app1/
app2/
templates/
app1.html
app2.html
In app1.html, I'm including app2.html:
<!-- app1.html -->
{% include "app2.html" %}
app2 has some dynamic content:
<!-- app2.html -->
{% app2_value %}
When I display app1.html, the value app2_value doesn't show up. What's the best way to handle the abo...
I'd like to display all available feeds on one page, but I don't want to hard code each feed. Something like sending in a queryset of feeds would be perfect, like:
{% for feed in feeds %}
{{ feed.link }}
{{ feed.name }}
{{ feed.description }}
{% endfor %}
From what I understand, Feeds in the Django Syndication Framework are created as ...
I just started using django for development. At the moment, I have the following issue: I have to write a page template able to represent different categories of data. For example, suppose I have a medical record of a patient. The represented information about this patient are, for example:
name, surname and similar data
data about cur...
Hi all,
I've got a django model that contains a manytomany relationship, of the type,
class MyModel(models.Model):
name = ..
refby = models.ManyToManyField(MyModel2)
..
class MyModel2(..):
name = ..
date = ..
I need to render it in my template such that I am able to render all the mymodel2 objects that refer to mymodel. Cu...
I want to make a static page which will be shown to the user only if he/she clicks on a link provided in one of my models. I can do this by making a Python page alone and calling it, but I want it be called from Django. The user interface should constructed using the Django API only.
Any suggestions?
...
I tried to use an image file in my HTML template. But when I run the server and open it in the browser the image is not getting loaded. But if I run the HTML file individually it's working fine. I mentioned the path of images folder in file settings.py, MEDIA_ROOT, also. Still it is not working.
settings.py:
MEDIA_ROOT = 'C:/Users/Vick...
Is there a simple way to make Django render {{myform.name}} as
John Smith
instead of
<input id="id_name" name="name" value="John Smith" />
inside <form> tags? Or am I going about this the wrong way?
...