django

Twisted(asynch server) vs Django(or any other framework)

I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for re...

Do I need to escape characters when sending emails?

I'm using Django Contact Form on a website to allow visitors to send emails. Currently, it's escaping characters, so single and double quotation marks are converted to ' and " respectively. The emails would be more readable if quotation marks were displayed as ' and ". I understand why I should never put unescaped input from ...

Django extends template

Hi to all , i have simple django/python app and i got 1 page - create.html. So i want to extend this page to use index.html. Everything work (no errors) and when the page is loaded all data from create.html and all text from index.html present but no formating is available - images and css that must be loaded from index.html is not load...

PicklingError: Can't pickle <class 'decimal.Decimal'>: it's not the same object as decimal.Decimal

This is the error I got today at filmaster.com: PicklingError: Can't pickle : it's not the same object as decimal.Decimal What does that exactly mean? It does not seem to be making a lot of sense... It seems to be connected with django caching. You can see the whole traceback here: Traceback (most recent call last): Fil...

Table borders in Pisa

I'm trying to have table borders in my pdf using pisa to generate the pdf from my html page. According to the documentation, I should use CSS to display borders in my table. However this is not working out. I can see the borders on my webpage, but on the generated pdf there's absent. Is there something I'm missing or doing wrong? I'm...

Is autoescape off in django safe?

I want to display some html in django 1.0 templates and to do that I have been doing something like this: {% autoescape off %}{{ var.text }}{% endautoescape %} and I am just wondering how safe this is? Am I still protected against sql injection and cross site scripting and other vulnerabilities like that? ===Edit ======= This text ...

Change list link to foreign key change page

When viewing the admin change list for a model, is it possible to make the columns that correspond to foreign keys links to their respective pages? A simple example is I have a Foo object which contains Bar as a foreign key. If I'm viewing the admin change list for Foo (and have it set to include Bar in the display_list columns), the m...

Associating two database tables which have ForeignKey relation in models.py in django templates

Hi all, I have problem about django template-db query relationship. For example, I created two tables in db (e.g. Menu & Submenu). Submenu, as you can guess, has a ForeignKey relationship with Menu. On the template side how can Ido db-query according to this relationship. I want to have a link for Menu such as: {% for menu in menu_li...

Should I refactor my Django object model?

For reasons it's not worth getting into, the object Model of the django application I am working on is now "wrong" insofar as a number of relations that are 1 to Many are represented as Many to Many. The application functions correctly and is most of the way through QA. It has never been deployed. My design OCD makes me want to refact...

Django not sending emails to admins

According to the documentation, if DEBUG is set to False and something is provided under the ADMINS setting, Django will send an email whenever the code raises a 500 status code. I have the email settings filled out properly (as I can use send_mail fine) but whenever I intentionally put up erroneous code I get my 500.html template but no...

Django: Aquiring form id from formset

Hello I am not sure if title describes what i want accurately. What i want is to achieve something like that: http://stackoverflow.com/questions/1405587/django-add-remove-form-without-multiple-submit/1406819#1406819. But i have not list of items i have formset and forms. The form of this formset does contain information i could use for...

Using safe filter in Django for rich text fields

I am using TinyMCE editor for textarea fileds in Django forms. Now, in order to display the rich text back to the user, I am forced to use the "safe" filter in Django templates so that HTML rich text can be displayed on the browser. Suppose JavaScript is disabled on the user's browser, TinyMCE won't load and the user could pass <script...

Django newbie - NoReverseMatch errors

Just started with Django but hit a bit of a wall - I decided to experiment with writing a simple blog engine while referring to the django-basic-apps library. In blog/urls.py, I have this entry to map to the actual post by date, e.g. blog/2009/aug/01/test-post urlpatterns = patterns('', url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<d...

Lighttpd, FastCGI, Django - how to restart automatically?

I am using Lighttpd + FastCGI + Django on a dev machine. I start FastCGI server via manage.py's command line option. Problem is that I do make changes to sources quite often and I need to get FastCGI to pick up those changes automatically, just as "./manage.py runserver" does. Is there a command-line option for that, perhaps, or any ot...

debugging a django app on a server running fcgi

I developed my django app on my local machine, however when I uploaded it to my server (dreamhost, runnig fcgi) I got some problems. How can I debug django on my dreamhost server that's running fcgi? ...

In the Django admin, how can I set up searching profiles by username?

Heyas I'd like to be able to search user profiles by username in the django admin. Essentially, in admin.py, I'd be doing something like: class UserProfileAdmin(admin.ModelAdmin): search_fields = ['username'] but this wont work since user is a foreign key in the my usual user profile set up. Is there a quick way to achieve this ...

Django, actual month in queryset

how ill, get my register based in the current (actual) month in my queryset?, i have a ModelManager(), that just show the LIVE register status, but now i want to show the register with LIVE status and in the current (actual) month, i know that ill make something like .filter(...), but i dont know how get the current month.. model.py #m...

Annotation incorrect with GenericRelation

I'm using a Vote model which can be generically linked to several different models (to allow you to vote on different things). In some of my code I use annotations to count up the total number of votes and the positive number of votes for a queryset. I've noticed that if I place a vote on a certain item, then the other types of models ...

Django options for making variables widely available

Every time I open a page I want to get the currently active project id. This will be done by chacking the subdomain and verifying the currently logged in user can view it. Once I reach my view I want to be able to do tasks = Task.objects.filter(project = current_project) WHere current_project (or CURRENT_PROJECT or current_project...

adding the same object twice to a ManyToManyField

I have two django model classes: class A(models.Model): name = models.CharField(max_length = 128) #irrelevant class B(models.Model): a = models.ManyToManyField(A) name = models.CharField(max_length = 128) #irrelevant What I want to do is the following: a1 = A() a2 = A() b = B() b.a.add(a1) b.a.add(a1) #I wan...