django

Django: What is the most ideal place to store project-specific middleware?

I'm aware I can "store it anywhere in my python path" and all, but what's an organized pattern I can use to store middleware classes for my project? I am appending my project root directory and project directory to the sys path through mod_wsgi: sys.path.append( '/srv/' ) sys.path.append( '/srv/workarounds/' ) The latter line being t...

What is an elegant way to create application access URLs for an existing web application?

I've been assigned to create an RESTful Android application for an existing web service which is built using Django. My current design idea is to have the Android application receive a JSON version of the data that would normally be sent to the Django template on each url. So my view would look like: #The site stores and organizes user...

(Django) prepopulate field, and forbid editing

How can I set a field in admin to be at the same time non-editable and prepopulated from other field ? ...

(Django) saving string to EmailField raises 'invalid literal for int() with base 10'

In my user's data edit form I have a boolean field, for adding/removing email from newsletter. I've written a custom save method for this form : def save(self, *args, **kwargs): mail = None if self.cleaned_data['inf_newsletter']: mail = NewsletterEmails(self.instance.user.email) mail.save() else: ...

How to distribute Python/Django App via RPM

I've read over this question and I think that is a great start, but I'm looking for more insight. I have written an application using Python 2.6 and Django 1.2.1. I would like to deploy this application on a system that does not have Python 2.6 or Django installed. The system itself doesn't have many things installed - sqlite3, pysqlite...

Django task processing

How would you process tasks in django, say there is an event only to processed once daily, weekly, monthly. (besides cron) ...

Why is checking if two passwords match in Django so complicated?

Am I doing something wrong, or is this seriously what the developers expect me to write every time I want to check if two fields are the same? def clean(self): data = self.cleaned_data if "password1" in data and "password2" in data: if data["password1"] != data["password2"]: self._errors["password2"] = self.e...

Scripting Django

Hi, what is the best way to write a python script (not to run within a Django server app) making use of Django settings, models, utilities etc and hence being able to operate on an app database from, say, a batch process? EDIT I need to use this within another server to make rather complex operations on the database, so solutions like ...

Should I place custom registration code in Views, Models or Managers?

I'm rolling my own custom registration module in Django based on django.contrib.auth. My registration module will have some extra functionality and help me reduce my dependency on other django modules that I'm currently using like django-registration and django-emailchange. I've run into a what-the-best-way-to-do-it problem here. Note: ...

Full text search: Whoosh Vs SOLR

Hi all, I am working on a Django project, where I need to implement full text search. I have seen SOLR and found some good comments for the same. But as its implemented in Java and would need java enviroment to be installed on the system along with Python. Looking for the python equivalent for SOLR, I have seen Whoosh but I am not sure ...

Why is using thread locals in Django bad?

I am using thread locals to store the current user and request objects. This way I can have easy access to the request from anywhere in the programme (e.g. dynamic forms) without having to pass them around. To implement the thread locals storage in a middleware, I followed a tutorial on the Django site: http://code.djangoproject.com/wi...

Is it possible to assign default display value when ForeignKey is None in Django?

I have ForeignKey in my Django model which can be null. group = models.ForeignKey(Group, null = True, blank = True) In case of null value assigned I want to render some specific text in templates (eg. "No grooup assigned"). I use default filter and it's OK except that I repeat this code in various templates. I am looking for solution...

Inserting language characters in Django

I am following the link http://code.google.com/p/django-multilingual-model/ Basically i am trying to insert hindi characters into mysql db I have created the files in the test directory as in the above said link and using django version 1.1 an dpython version is 2.4.3 I geta error message as the following. from testlanguages import ...

Grep 'hg incoming' result for specific files and save result - if there is files im looking for

Hi! I want to create a script that will do something if hg incoming -v contains specific file. Say if hg incoming -v | grep models.py > 0 than do ./manage.py resetdb. Something like this. How can i set a flag (in bash script) based on hg incoming -v | grep manage.py result? ...

Django CMS logo change

hey guys, i was wondering if there was a way to change the Django CMS logo, for my own company logo ? ...

Python images display Django

Since my last question here: http://stackoverflow.com/questions/3166221/python-images-display I understood that from all the answers I got the glob.glob could be the only one in the direction I need. However where I am stuck right now is here: I can create a list with all the filenames in my media directory by using glob.glob: all = ...

Custom unicode on already created object

I'm using permissions in my application. And in some case I need to create form only with permission field. I'm using ModelChoiceField and queryset with permission objects. permission = forms.ModelChoiceField(queryset = Permission.objects.all()) But permissions unicode is taking too much place in choice field. And it looks not so goo...

Django - How to reset model fields to their default value?

What would be the most elegant\efficient way to reset all fields of a certain model instance back to their defaults? ...

Popular Django App Libraries

I know there is some really good django app libraries out there (other than the builtin django.contrib.*) but for some reason, my google search abilities are failing me. I am thinking of one in particular that I cannot remeber the name of for the life of me. I keep wanting to call it pyrex or pixar or something. Obviously, neither of t...

HTTP Auth coordinated by web application rather than server

I'm working with Django on Linux and I have an application that integrates with Active Directory. I'm seeking opinions and advice about whether or not it would be feasible or reasonable to access the HTTP headers from within the application to coordinate HTTP authentication. The end goal would be to perform NTLM authentication without...