Hi guys, i would like to paginate my object list, im tring to use django-pagination, but is showing a 404 page no found when i try to navigate.
ulr.py
categoria_info = {
'queryset':Categoria.objects.all(),
}
urlpatterns = patterns('',
url(r'^$',
object_list,
...
Hi All,
I am currently writing a few custom template tags but for some reason they will not load. My directory structure is as follows:
MyProj
|
----MyApp
|
|----templatetags
|
|----myapp_tags.py
|----__init__.py
In myapp_tags.py
from django.template import Library, Node
from myproj.myapp.mo...
Does anyone know a way to switch the TEMPLATE_DIR in django dynamically.
I need to create a set of templates for a mobile version and would like the templates to sit inside there own dir instead of inside the root template dir ie: I would like 2 template dirs 'templates' and 'mobile_templates' and not have to use 'templates/mobile' for ...
I've got an existing Django site, with a largish variety of templates in use. We've agreed to offer a custom-skinned version of our site for use by one of our partners, who want the visual design to harmonize with their own website. This will be on a separate URL (which we can determine), using a subset of the functionality and data fr...
In Django, I have images stored in site_media like this :
/site_media/somepath/image.jpg
The urls.py file has been set up to server these using :
urlpatterns += patterns('',
(r'^site_media/(?P<path>.*)$', 'staticfiles.views.serve')
)
urlpatterns += patterns('',
(r'^site_media/(?P<path>.*)$', 'staticfiles.views.serve')
)
So...
Sorry if I am being a moron, but what happen with this if tag ?
view return:
return render_to_response('productos/por_estado.html', {'productos':productos},
context_instance=RequestContext(request))
#Im not returning 'estado' !
template:
{% if estado %}
{% block activos_active %}class="active"{% endblock %}
{% en...
Hi need some help, I looking to build a news archive in python/django, I have no idea where to start with it though. I need the view to pull out all the news articles with I have done I then need to divide them in months and years so e.g.
Sept 09
Oct 09
I then need in the view to some every time a new news article is created for a new...
I've got a filter currency, which takes a value in USD and converts it to a currency (either USD or GBP). The currency to convert to is stored in the session, but filters don't take RequestContext, so I can't grab it straight from there.
Is there a better way than passing the relevant session element into the template, and from the temp...
In view:
return render_to_response('template.html',
{'headers': list(sort_headers.headers()) },
context_instance=RequestContext(request))
In template:
{{ headers }}
<br />
{{ headers|slice:"1" }}
In browser:
[{'url': '?ot=desc&o=0', 'text': 'Nombre', 'class_attr': ' class="so...
I have a Doctor-model which has a field called first_created. It is just a DateField that is auto_add_now, hence it is not displayed when editing a doctor in the admin interface.
I want to display this field on the admin interface, at the top of the site as say, a static or something. It is supposed to ease the process of typing in dat...
i have a navigation element that is determined by values in a database.
no matter what view it is, i need to get these navigation objects out of the database.
where in the code can i tell it to set a template variable containing all the navigation objeccts without setting it in every view?
...
I must have missed something in setting up a custom template context as it's never getting called.
In settings:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django_authope...
I know there is a post here: http://stackoverflow.com/questions/1333189/django-template-system-calling-a-function-inside-a-model describing how you can make a custom template filter to achieve this, but from a programmer's standpoint this is a failure because that's hacking something that isn't meant for that. It seems almost ridiculous ...
I have an app called CMS with Category and Article. Quite simple.
I overwrite app_index.html to enable ajax-based drag-n-drop ordering and to move articles from one category to another.
Now I would like to redirect after saving/deleting an article or a category to cms' app_index.html instead of the model's change_list.html. How can thi...
I have a dictionary
data = {'sok': [ [1, 10] ], 'sao': [ [1, 10] ],'sok&sao':[ [2,20]] }
How Can I (Loop trough Dictionary ) present My data as (HTML) table to Django template.??
This format that as table
author qty Amount
sok 1 10
sao 1 10
sok...
In my admin, I have a text area where the user can input html:
<ul>
<li>blah</li>
</ul>
<p>
Stuffs
</p>
When I push the above to my template and I view the source of the page, I get:
<ul>
<li>blah</li>
</ul>
<p>
Stuffs
</p>
What should I do with my output so that I see actual html in the ...
how to know if checkbox is checked (True, 1) having just the {{ form.checkbox }} form-tag?
activo is True, 1 in db.
my template is:
{{ form.activo }}
RESULTS:
<input id="id_activo" type="checkbox" name="activo" checked="checked"/>
{{ form.activo.data }}
RESULTS:
False
{{ form.activo.value }}
RESULTS:
""
No 1 or True's :S
Any hint...
Hello,
My problem is a if condition.
I would like somethings like that but cannot figure out how to do it.
{% if restaurant.is_favorite_of(user) %}
<img src="{{MEDIA_URL}}images/favorite_on.png" alt="This restaurant is one of your favorite (Click to undo)" />
{% else %}
<img src="{{MEDIA_URL}}images/favorite_off.png" alt="Th...
Hi Guys,
I have a model with a bunch of choices, that are in the DB configured as below.
COL_CHOICES =(
(1, 'Not Applicable'),
(2, 'Black'),
)
COL2_CHOICES =(
(1, 'Green'),
(2, 'Blue'),
)
etc.
I want to display all these options as a menu in my templates, (to be used ...
I have 03 models book->target_readers and book has collection.
class Book(models.Model):
def __unicode__(self):
return "%s (%s)" % (self.title, self.reference)
reference = models.CharField(max_length=100)
title = models.CharField(max_length=200)
collection = models.ForeignKey(Collection)
class Collection(models....