django

Django 1.2 : Multiple database and Generic Content Types

I am working on one project with django 1.2. I have 2 databases : - First, for users, user's profile, session ... - Second is to store data from my specifics models like post of blog, pictures, files ... I made a router (dbrouter.py) to manage where each models are stored (instead of using 'using' for each queryset). When I sync my ...

Django Admin Templating

Hi, I am learning django and building my own project. I want to change the admin section to my own interface, I have added sub-directory to the templates names "admin".And started change the base.html The problems are- I want to add my own css file, how I can do it?My css file is located on my MEDIA_ROOT directory.How I can do that? ...

Tiny mce breaking django own pop-up on raw_id_fields

Im using Tiny mce for my wysiwyg. Im using a subdomain to serving media files #settings.py: MEDIA_URL = 'http://media.mydomain.com/' ADMIN_MEDIA_PREFIX = 'http://media.mydomain.com/admin_media/' In my textareas.js i have this code: document.domain = 'mydomain.com'; tinyMCE.init({ .. And in my tiny_mce_popup.js I also have documen...

Manage separate translation files (.po) in Django

I am not an expert in Python or gettext utilities. I have a Django project in which I have several modules in the application. I need to maintain separate .po translation files for each module that will be merged in the time deployment. For instance, there is a Dictionary module beside the django-cms-2 module for both of which I want to ...

Mod_python on django and debug variable

Hi, I have a problem with my django application. On django developer server its work perfect, but when I switch it to apache something strange happening. Lets check the code: class Criteria(models.Model): district = models.ManyToManyField(District, verbose_name=u"Województwo", blank=True) respondents = models.ManyToManyField(Us...

Function expects 2 arguments when should only one

I have a function friend_exists like this: def friend_exists(request, pid): result = False try: user = Friend.objects.get(pid=pid) except Friend.DoesNotExist: pass if user: result = True return result I'm calling it from my other function like this: exists = friend_exists(form.cleaned_da...

display json text as a friendly list in django admin

I have a JSONField (http://djangosnippets.org/snippets/1478/) in a model and I'm trying to find out the best way to display the data to the admin user rather than json. Does anyone know the best way to do this in django admin? For instance, I would like {u'field_user_name': u'foo bar', u'field_email': u'[email protected]'} to display as...

Using crontab with django

I need to create a function for sending newsletters everyday from crontab. I've found two ways of doing this on the internet : First - file placed in the django project folder: #! /usr/bin/env python import sys import os from django.core.management import setup_environ import settings setup_environ(settings) from django.core.mail imp...

Threaded SOAP requests in Python (Django) application?

I'm working with an application that needs to be make some time consuming SOAP requests (using suds, as it were). There are several instances where a user will change the state of an object and in doing so trigger one or more SOAP requests that fetch some data. This could be done in the background, and right now the user has to wait whi...

Submitting form without redirects in Django

In my main page I have included a template with form for adding emails to newsletter. I'd like this form to add new emails without redirecting anywhere. How I can achieve that ? Here is my code, when I was using separate page for this : views : def newsletter_add(request): if request.POST: f = NewsletterForm(request.POST) ...

Django: How to define the models when parent model has two foreign keys come from one same model?

I want to define two model fields: created_by, modified_by in a parent model, they will be acting as common fields for the child models. class ExtendedModel(models.Model): created_by = models.ForeignKey(User,related_name='r_created_by') modified_by = models.ForeignKey(User,related_name='r_modified_by') class Meta...

making a call to add_postgis_srs before GeoDjango model tables get created

Here is my model definition for a model in a GeoDjango app (with a PostGIS 8.4 database) meant to represent a Chicago neighborhood boundary: class Neighborhoods(models.Model): objectid = models.IntegerField() pri_neigh_field = models.CharField(max_length=3) pri_neigh = models.CharField(max_length=50) sec_neigh_field = mo...

how to publish photos on facebook wall from an external ( django + python) application

Hello All , I want to publish my photos from django application to the facebook wall, i use photos.upload method I am not using graph API. but I am not able to publish it even i took permissions to publish photos as well but still not working...... Please help me how could i achieve it please give me some sample code that will help me ...

Django language codes

What is the link to find the list of languages i.e, language_code (Swedish,sv) (English,en) .......... Please provide the link Thanks.. ...

Problem getting preview from Django-MarkItUp in Admin interface

I am working on a custom markup formatter for Django and I wanted to interface it with MarkItUp. It is successfully being called when I save the field, which is of type MarkupField, but when I try to preview this field from the Admin interface using the default settings, all I get back in the preview box is plaintext. I am using the Ma...

Django: Saving an image file from a form

I want to save the image which as been uploaded via the PaletteGenForm as such: #Form class PaletteGenForm(forms.Form): im = forms.ImageField(required=True) #View def palette_gen_view(request): PATH_OF_IMAGE_TO_BE_PALETTED= MEDIA_ROOT+ "/tobesaved.png" if request.method == 'POST': form = PaletteGenForm(request.POST...

Kick off deamonized service using djangos manage.py custom command?

I got a custom command in my reusable django app which I want to kick off a deamonized service and then return, leaving the service running. I've implemented my service as a simple class with a start-method. When start is called it runs in an eternal loop, sleeping for 10 seconds, then using the django orm to check the database configur...

django-cms: PlaceholderAdmin breaks admin form (wymeditor doesn't work)

I'm using django-cms 2.1 and have a problem with rendering a form for a model that contains PlaceholderField: The article model is nothing unusual except it has: sidebar = PlaceholderField('sidebar', related_name="news_sidebar") Then I set wymeditor widget for html fields: class NewsArticleAdminModelForm(forms.ModelForm): body =...

Django - Selecting related set : how many times does it hit the database ?

I took this sample code here : http://stackoverflow.com/questions/853184/django-orm-selecting-related-set polls = Poll.objects.filter(category='foo') choices = Choice.objects.filter(poll__in=polls) My question is very simple : do you hit twice the database when you finally use the queryset choices ? ...

Good practices for a flexible search page - Django

Hi folks, I'm just wondering if there is any example I could take from others on the topic. I have a page within Django which uses filters, in order to perform searches. At the moment I'm doing a simple check for the GET parameters and adding a .filter() to a queryset accordingly: if color: query.filter(color=color) This feels ...