django

How do you mark strings as "Safe" in a view (ot the template) in Jinja2?

Typically when you want to mark string output as safe in Jinja2 you do something like this: {{ output_string|safe() }} However, what if output_string is always safe? I don't want to repeat myself every time by using the safe filter. I have a custom filter called "emailize" that preps urls for output in an email. The ampersands always...

django unit testing and global fixtures

I'm working on a web project in Django, and I'm using the python unittest framework. For every app I have some fixtures. This means, that every app has some identical tables in fixtures. I would like to share fixtures between apps and testcases, because otherwise if I change a model, I will have to change all json fixtures where this con...

How to check the TEMPLATE_DEBUG flag in a django template?

Do you know if it is possible to know in a django template if the TEMPLATE_DEBUG flag is set? I would like to disable my google analytics script when I am running my django app on my development machine. Something like a {% if debug %} template tag would be perfect. Unfortunately, I didn't find something like that in the documentation. ...

How to get started with Sessions in Google App Engine / Django?

I'm new to Python / GAE / Django. I get that with GAE there are no in-memory sessions per se... but I think I want something equivalent. I read that Django sessions can be backed by BigTable or MemCache, but I never got them working. I guess what I'm asking is "Should I..." Persist with getting Django sessions working? Look at some oth...

Django comments framework

Hi I am quite new to Django and am trying to get to grips with a few things. I would like to know if the comments framework that is bundled with django can redirect to the refering page if the comment form contains errors? Also if I were to make a rating framework how would I go about achieving this functionality. Would I simply pass t...

django problem uploading and saving documents

Hello, I am working on a django app. One part would involve uploading files (e.g. spreadsheet or whatever). I am getting this error: IOError at /fileupload/ [Errno 13] Permission denied: 'fyi.xml' Where 'fileupload' was the django app name and 'fyi.xml' was the test document I was uploading. So, I used chmod and chown to make the ...

Django, The {% if %} tag evaluates

Well, im out my mind of what jeje .... how ill evaluate a variable with {% if %} in template? im trying this {% if variable > 0 %} or {% if variable != 0 %} but...i got errors :( Thanks ...

Why isn't assertRaises catching my Attribute Error using python unittest?

I'm trying to run this test: self.assertRaises(AttributeError, branch[0].childrennodes), and branch[0] does not have an attribute childrennodes, so it should be throwing an AttributeError, which the assertRaises should catch, but when I run the test, the test fails because it is throwing an AttributeError. Traceback (most recent call la...

Does django's Form class maintain state?

I'm building my first form with django, and I'm seeing some behavior that I really did not expect at all. I defined a form class: class AssignmentFilterForm(forms.Form): filters = [] filter = forms.ChoiceField() def __init__(self, *args, **kwargs): super(forms.Form, self).__init__(*args, **kwargs) self.filters.append(PatientFilter('A...

User-configurable signalling mechanism in Django

The question here is whether something like this already exists or, if not, whether there's a better way to achieve it than what I describe below. I need to allow an arbitrary Principal (User, Group, Site Admin) to add Event Sinks (like email addresses, Webhook URLs, etc.) to the system (through the web interface) and, for each one, spe...

How to use Staticgenerator with Django + Apache + mod_python

I have currently an enviroment with Django + Apache via mod_python. How can I use Staticgenerator without nginx, just with Apache and mod_python? Thank you. ...

Django logout(redirect to home page) .. Delete cookie?

I redirect the user to the home page after logout. In between I would like to delete all/or specific client cookies (I have previously set). def logoutuser(request): logout(request) return redirect('app.home.views.home') To call response.delete_cookie('user_location'), there is no response object. How do I do this? ...

Django : How can I see a list of urlpatterns?

How can I see the current urlpatterns that "reverse" is looking in? I'm calling reverse in a view with an argument that I think should work, but doesn't. Any way I can check what's there and why my pattern isn't? ...

how to access dictionary element in django template?

I have this code in template, which I would like to printout number of votes that each choice got. votes is just dictionary while choices are model object. {% for choice in choices %} {{choice.choice}} - {{votes[choice.id]}} <br /> {% endfor %} it raises an exception with this message "Could not parse the remainder" I googled it a...

Django, choices option field

Hi guys, i have a question about the choices option field. i have this field: SECUENCIA = ( ('1','1'), ('2','2'), ('3','3'), ) secuencia = models.IntegerField(max_length=1,choices=SECUENCIA) All is fine in my forms for add or update but in my show view (template display) the field just appear li...

Where to go to learn about web architecture? Youtube example?

I'm trying to build a web application that is similar to Youtube (it's not a knock off), but I guess I don't know how video is served on the internet very well. I know how to build regular database driven web applications, but nothing like the scalability of Youtube. All of the applications I have built before have all been run on one s...

Is there django auth backend to authorize by temporary links?

I am searching a backend to authorize users by email without password. This backend should send them temprary authentication links to an inbox. Is there any solution or I should write it myself? ...

Default image for ImageField in Django's ORM

I'm using an ImageField to store profile pictures on my model. How do I set it to return a default image if no image is defined? ...

In Django, is there an easy way to render a text field as a template, in a template ?

Can you think of an easy way to evaluate a text field as a template during the template rendering. I know how to do it in a view but I'm looking for a template Filter or a Tag ? Something like: {{ object.textfield|evaluate}} or {% evaluate object.textfield %} with object.textfield containing something like: a text with a {% Template...

Django, Overriding behavior Admin Model

Hi guys, in the django admin, in any app model, the diplay data (datagrid o view template, i dont know how call it), django show "all" the entry, but what happen if i want that django just show the entry with statu live or x status and not all entry with any status?. how, overriding initial behavior in admin model? Thanks ...