django

Arguments disappear from a dictionary when passed to a function

In my function I read user's data from session and store them in a dictionary. Next I'm sending it to 'register' function from registration.backend but the function somehow get's it empty and a KeyError is thrown. Where are my data gone ? The code from function calling 'register' function : data = request.session['temp_data'] email = da...

django: ImageField, MEDIA_ROOT, MEDIA_URL, how to set correctly

How should MEDIA_ROOT and MEDIA_URL be set correctly in context of ImageField? How should I set upload_to parameter for an ImageField? Comments for MEDIA_ROOT and MEDIA_URL are scarce, so I would like to know, what are they used for and how to set them correctly. ...

Django multi-threaded and mod_wsgi

Hi, First of all my site is up and running OK. There is no critical issues. I want to understand a couple of things though. I'll start with an overview of my system. It's a django-powered site located on a CentOS 5.3 VPS with 256MB RAM, under apache with mod_wsgi. The django application runs as a Daemon process with 1 threads. What...

Django - Keeping save() based transactions short

As django model save() methods are not lazy, and as keeping transactions short is a general good practice, should saves be preferably deferred to the end of transaction blocks? As an example, would the code sample B hold a transaction open for less time than code sample A below? Code sample A: from django.db import transaction from my...

(Django) object is unsubscriptable

When I'm trying to create an extended user profile I'm getting UserProfile object is unsubscriptable. I've googled for solution, but 'your object is not a sequence' does not help here much. Here's the function I'm using, 'temp_data' is the data from my registration form : def create_user(request): data = request.session['temp_da...

Django - How to transform a QuerySet to a Q object?

Is there a way to transform a QuerySet to a Q object in django? My specific motivation: I would like to subtract one QuerySet (qs_A) from another QuerySet (qs_B). The only way I can think of is by using exclude() and a Q object equivalent of qs_A. Example: def my_function(qs_A, qs_B): # Here I need to transform qs_A to a Q object ...

IntegrityError when saving user with username=email

I have modified my application, so that when a new user is registered, it's username and email are the same. But when a new user is created, I'm getting IntegrityError : (1062, "Duplicate entry '[email protected]' for key 'username'"), still the user is created correctly. Function register_new in which a new user is created ('temp_data' is a ...

Django: Before a model is updated, I'd like to "look at" its previous attributes

When an update/create is performed on a Django model (.save()) I would like to be able to "step in" and compare some particular attributes to what they were set to previously (if they previously existed at all). I'm thinking Pre-Save Signals, with a look-up to the original model doing a .objects.get(instance.id), but that feels wastefu...

private chat in django

hi in my django based site i want users to communicate with each other with one to one chat like face book. i have checked many site and links and google project but all of the them are like broadcast type i want a private chat. is there any app so i can integrate it with my django site. or if i want to create like one what would be ...

Django DecimalField lookups with MySQL not working

I'm migrating data from a legacy database that has many tables with primary keys defined like: `id` decimal(26,0) The id column will contain values that look like: 20080313154354198004 20081217165552136057 2008080416222952067 20060510151423191000 20060510151423191000 20070710143455874025 200806239353171091 Doing queries like: Rel...

Filter foreignkey field from the selection of another foreignkey in django-admin?

hi, i have the next models class Region(models.Model): nombre = models.CharField(max_length=25) class Departamento(models.Model): nombre = models.CharField(max_length=25) region = models.ForeignKey(Region) class Municipio(models.Model): nombre = models.CharField(max_length=35) departamento = models.ForeignKey(Depar...

How does FeedJack fetches historical feeds

I am building a news aggregation website and I am looking for a way to fetch old feeds(of any particular website ) into the system. During this course, I stumbled on to Feedjack. It is said that it handles what I needed. So I started diving into the source code. (I dont want to plugit in my django project directly.) All I see is this lin...

Checking validity of email in django/python

I have written a function for adding emails to newsletter base. Until I've added checking validity of sent email it was working flawlessly. Now each time I'm getting "Wrong email" in return. Can anybody see any errors here ? The regex used is : \b[\w\.-]+@[\w\.-]+\.\w{2,4}\b and it is 100% valid (http://gskinner.com/RegExr/), but I may ...

How to prevent the browser from redirecting when a redirect response is sent via AJAX?

I'm trying to AJAX-ify the Django contact_form app using Django (1.4.2). I want to let Django do the heavy lifting when it comes to validation and template rendering so I can keep my templates consistent and server side. Therefore, I'm returning "partial" template renderings to inject into the DOM as the user submits the form. It almo...

How can I write this view efficiently?

Hi, I have a simple view in Django: @render_to('episode_list.html') def list_episodes(request, season): query = Episode.objects.filter(season=season) seasons = query[0].series.total_seasons return {'episodes': query, 'season': season, 'max_seasons':range(1,seasons + 1)} I'm trying to build t...

problem with installing mod_wsgi

Hi, Trying, to figure out why make fails while installin mod_wsgi getting following errors. Can anyone help me out with to figure out what is wrong ? mod_wsgi.c:13910: warning: parameter names (without types) in function declarati on mod_wsgi.c:13910: warning: data definition has no type or storage class mod_wsgi.c:13915: error:...

From Java to Python/Django

Possible Duplicates: Book and tutorial recommedations for Django 1.0 How to Learn Python Hi, I am a Java/JEE programmer and want to learn Python (finally the Django framework) to build web applications. I don't have any experience with scripting languages so this is going to be the first step into the scripting languages wo...

Using Django Cache Middleware causes contrib.auth unit tests to fail

Problem: When I add UpdateCacheMiddleware and FetchFromCacheMiddleware to my Django project, I get unittest failures. This is regardless of the CACHE_BACKEND I use (right now I am using locmem://, but the errors are the same when I use file:///path_to_cache) My Middleware: MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCache...

Is it possible to have one 'master' Django website and N satelite websites

I am thinking of a configuration where I have one master website at : www.masterdomain.com and N satelite domains where I can access the satelite domains as follows: www.masterdomain.com/some_url/satetlite1.html www.masterdomain.com/some_url/satetlite2.html ... www.masterdomain.com/some_url/satetliteN.html Is this possible? ...

How to filter (or replace) unicode characters that would take more than 3 bytes in UTF-8?

I'm using Python and Django, but I'm having a problem caused by a limitation of MySQL. According to the MySQL 5.1 documentation, their utf8 implementation does not support 4-byte characters. MySQL 5.5 will support 4-byte characters using utf8mb4; and, someday in future, utf8 might support it as well. But my server is not ready to upgrad...