django

Django URL user id versus userprofile id problem

I have a mini comunity where each user can search and find another user's profile. Userprofile is a class model, indexed differently compared to user model class (user id is not equal to userprofile id). But I cannot see a user profile by typing in the URL the corresponding id. I only see the profile of the currently logged in user. Wh...

Overriding initial value in ModelForm

Hi, in my Django (1.2) project, I want to prepopulate a field in a modelform, but my new value is ignored. This is the snippet: class ArtefactForm(ModelForm): material = CharField(widget=AutoCompleteWidget('material', force_selection=False)) def __init__(self, *args, **kwargs): super(ArtefactForm, self).__init__(*args,...

What is better for web development Python+Django or PHP+Symfony ?

What is better for web development Python+Django or PHP+Symfony ? And why? ...

Django: How to write the reverse function for the following

The urlconf and view is as follows: url(r'^register/$', register, { 'backend': 'registration.backends.default.DefaultBackend' }, name='registration_register'), def register(request, backend, success_url=None, form_class=None, ...

Facebook authentication with extended permission request

Hi there, I'm wondering which authentication method to use if i need extended permissions (e.g. if i want to use the users photos in my application). The methods are either the single-sign on using JavaScript SDK or by using the OAuth 2.0 protocol. Both methods are explained here: Authentication - Facebook developers. The JS SDK would b...

How do I TRUNCATE TABLE using Django orm?

Hello! To empty database table, I use this SQL Query: TRUNCATE TABLE `books` How to I Truncate table using Django models and orm? I've tried this, but it doesn't work: Book.objects.truncate() ...

use of ajax in django problem with the code

I am new to ajax and using Django for web development. Now My Template contains : sample.html <html> <body> <script language="javascript" type="text/javascript"> //Browser Support Code function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safar...

Open/Close database connection in django

I am using Django and Postgresql as my DBMS. I wish to set a setting that enables to enable/disable database connection. When the connection is set to closed (in settings.py) the site will display a message such as "meintanence mode" or something like that. Django will not show any db connection error message (or mail them to admins). I...

django forms instance

hello, i have a method where i am saving the data from users, but each user has to have a single profile, so each time he saves, the data should be overwritten. first i verify if he already has a profile data, and in this case i add an instance to the form. if not, (this is his first registration), i simply add data into DB my code is: ...

Building a formset dynamically

I initially wrote code to build a form dynamically, based on data from the DB, similar to what I described in my previous SO post. As SO user Daniel Roseman points out, he would use a formset for this, and now I've come to the realization that he must be completely right. :) My approach works, basically, but I can't seem to get valida...

django: after upgrade to 1.2 CSRF raises 403 though I don't have CSRF protection enabled

I have just upgraded to Django 1.2 and I am trying to run my project. After I login I get Forbidden (403) CSRF verification failed. Request aborted. which is strange because I haven't enabled CSRF protection previously. Do I have to configure something else to have my project work? ...

jQuery AutoComplete with three levels of suggestions?

I am building a django based application and its time to add the DHTML stuff. One of my fields represent a database field with this format databaseName.tableName.fieldName I would like to have javascript autocompletion in three levels, say once I type part of the database names I get a list of all matching databases, one that is select...

Remove value from GET dictionary and redirect to new URL

I want to have a view in my app that allows the user to remove one of many filters from the GET list, then redirect using the remaining variables in the list. How can I achieve this? Possibly having one filter-remove view that works for all the variables the user can set in the filter. ...

Filtering rows withing Admin using a Queryset - Django

Hi folks, I'm trying to find a way to filter down rows of objects within Django Admin, using a queryset. e.g. Person.objects.filter(Q(name='John')|Q(surname='Doe')) I'm finding quite complicated to figure out. Any ideas? ...

Custom rendering a radioselect in django form / accessing single element?

I have a form like this: CHOICES = [ ('a', 'a_value'), ('b', 'b_value'), ('c', 'c_value') ] self.fields["choice"] = forms.ChoiceField( widget=RadioSelect(), choices=CHOICES, ) How can I select a single element of this form field in my template? I want to be able to do somet...

specify group by field in django 1.2

Hi, I want to use annotate to count the number of occurances in my model, however it is not using the right field in the group by statment. instead of using the field i want (i.e. the one specified in the count function) it uses the primary key of the model. e.g. ObjectHistory.objects.annotate(revisions=Count('resource')) produces s...

review on django book vs django tutorial

going through both the django book and tutorial, am a bit confused to the differences in approach (aren't they both written by the same people?) can anyone who has experience in both give a short review on them? i have decent python skills (largely untested though), but no experience at all in web apps and am trying to decide which one...

How to auto insert the current user when creating an object in django admin?

Hi all, I have a database of articles with a submitter = models.ForeignKey(User, editable=False) Where User is imported as follows: from django.contrib.auth.models import User. I would like to auto insert the current active user to the submitter field when a particular user submits the article. Anyone have any suggestions? ...

Where should I put the code for a Django admin action for a third party app?

Hi, I'm new to Django. I am writing my own administrative action for a third party app/model, similar to this: http://mnjournal.com/post/2009/jul/10/adding-django-admin-actions-contrib-apps/ It's a simple snippet of code. I'm just wondering where people suggest that I put it. I don't want to put in the third party app because I might ne...

Using upload_data on Google AppEngine doesn't let me update entities with id based keys

This seems so basic - I must be missing something. I am trying to download my entities, update a few properties, and upload the entities. I'm using the Django nonrel & appengine projects, so all the entities are stored as id rather than name. I can download the entities to csv fine, but when I upload (via appcfg.py upload_data ...), t...