django

Django - Template tags in javascript and css files

Is there any way to add template tags into javascript and css files? I would use it for anything from passing in urls to media url links (image paths, etc) to conditional javascript based on user permissions. I just had a thought that maybe I can serve it up as if it were a template but have the url as my javascript file. Is that the o...

Django, restrict access to registration success page.

This is something I've wondered about in a couple of frameworks that I've messed around with. Assuming I don't want to automatically log a user in when they register (I want them to activate) how can I make it so a user can't just visit the "register-success" page? Right now, here's what I have: def register(request): if request....

mail address validation in python/django

We are developing our website in django framework and with python. currently we are looking for an api/a tool to validate the physical addres the user enters. It doesn't need to be vey sophisticated. We just need to avoid spam registrations. For this step, we need to verify if country, state, city, and zipcode are belong to each other. F...

jquery ui dialog and csrf protection

I am using jquery ui dialog to display form. Unfortunately, this function clears hidden input with csrf token inside my form. Can I somehow force dialog not to clear this field or do I have to store this token somewhere and set the proper field myself? ...

Django - Compare Model Code to Database

I maintain a Django project with a database that has several model constraints that have fallen out of sync with the actual database. So, for example, some model fields have null=False set, but the database permits NULLs for the corresponding database column. I'm curious if there is a utility, either in Django or a third-party Python sc...

How to check value transition in Django (django-admin)? (Revisited)

I was wondering about how to control transitions in model data. I found the solution at http://stackoverflow.com/questions/867120/how-to-check-value-transition-in-django-django-admin but when I tried to implement it within my code, something went wrong (I am able to change the status with impunity): Here is the relevant portion of my ...

Using Protovis with Django

Hi, I am trying to get Protovis working in my Django site. Here is my sample code: <html> <head> <script type="text/javascript" src="protovis-r3.2.js"></script> </head> <body> <script type="text/javascript+protovis"> new pv.Panel().width(150).height(150).anchor("center") .add(pv.Label) ...

How to disable formatting for FloatField in template for Django

Hi everyone, i just can't seem to find a definitive answer to this issue, and django's irc needs auth to services... So my question is : how can you force some kind of formatting for FloatFields in template when you're using Django ? The problem is simple i need simple dot separated numbers like this : 42547.34 And i end up with comma ...

Django: How to get the permissions of a list of users

So in my application, users can assign basic privs to other users who don't have privs and also make take them away. However, anybody who has these basic privs may not grant or revoke admin privs. So, in my template where I iterate over the list of site_users (for site_user in site_users), how do I get the privs of site_user? I can only...

How do I handle blocking IO in mod_wsgi/django?

I am running Django under Apache+mod_wsgi in daemon mode with the following config: WSGIDaemonProcess myserver processes=2 threads=15 My application does some IO on the backend, which could take several seconds. def my_django_view: content=... # Do some processing on backend file return HttpResponse(content) It appears tha...

Using list_filter with an InLine model in Django

Hello, We are having problems getting the filtering in the admin interface working the way we would like it to. We have the following: models.py: class Person(models.Model): first_name = models.CharField(blank=True) last_name = models.CharField(blank=True) class Affiliation(models.Model): person = models.ForeignKey(Person) a...

Django, automatic HTML "sanitizing" when putting HTML to template, how to stop it?

I'm kind of confused by this because it seems that Django templates have optional HTML filters but this seems to be happening automatically.. I am making this demo app where the user will do an action that calls a python script which retrieves a url, I then want to display this in a new window.. its all fine except when the display comes...

Get Value Of Selected Option ModelChoiceField

Without using Ajax is there a way to get the value of a selected item. So for example, if I have the below drop down list: <select name="controllers" id="id_controllers"> <option value="" selected="selected">---------</option> <option value="1">http://przemeklach.com/api/firstOrder/przemeksController&lt;/option&gt; <option value="5">ht...

How can I make a URL link in django that will go to the referring view?

I want to be able to create a back link to the referring URL, if the referrer was a view, and if it was not a view, a back link to a default page (Don't ask... it's kind of a weird requirement). Basically, if the user came to the page in question from another view on the same django site, the back link should be a return to that view. ...

Flash + pyAMF + Django session cookie security

First off, if there is a true, official way of having flash/flex's NetConnections usurp the session/cookie state of the surrounding web page, so that if the user has already logged in, they don't need to provide credentials again just to set up an AMF connection, please stop me now and post the official answer. Barring that, I'm assumin...

Refresh template in Django

Hi. I have a view like this: def form1(request): if request.method == 'POST': form = SyncJobForm(request.POST) if form.is_valid(): # do something in_progress = True return render_to_response('form1.html', {'in_progress': in_progress}) I would like to know how to set it to refresh the templat...

Django / Python, using variablized object names

I'm confused on how to do this, I'm passing in a dictionary with different values, such as "app" which is the name of the app (so that I can better decouple code for easier modularization).. so this is just a simplified example and its not working so I'm wondering how to use the variable "app" within the string that is calling the models...

Is having everything in Django models sensible?

I've just inherited a Django project for maintenance and continuous development. While I'm a fairly proficient programmer (also Python) I have next to no experience with Django, therefore I need a bit of saneness-checking for my ideas ;) The current problem is this: the project contains a custom install.sh file, which does three things:...

django checkbox select all by jquery

I want to select all checkbox when i click the top check, below is my code: run.html <script language="JavaScript" src="media/js/jquery-1.4.2.min.js"></script> <script language="javascript"> $("#selectAll").change(function() { $(".xxx:checkbox").attr('checked', this.checked); }); </script> Select All: <input type="checkbox" id="sele...

Django Flatpages Variables

Is it possible to enter {{ variable }} into a django flatpage and if so, how? Thanks! ...