django

History of Django's popularity

What sequence of events made Django the most popular Python web framework .. and still so? Even though several other frameworks exist. Note: This question is neither argumentative nor confrontational. I merely asked for (objective) "the sequence of events" that lead to its actual popularity. Being aware of the dynamics of software accep...

Django 1.0 Testing: how do I get a session to persist between test code and view being tested?

I am trying to test how a view behaves when there is certain data stored in the session. To do so I have created the session in the test method and invoked an interactive shell at the very beginning of the view: Test Method: def test_user_with_unused_tests(self): "User is given a test and sent to test start" # todo: insure that...

Using Django as a Backend for Cappuccino

I'm new to both Django and Cappuccino. I have a Django site setup and running through Apache via mod_wsgi. I want to use Django as the backend for a Cappuccino application, but a VirtualHost setup in Apache and mod_wsgi to serve a Django application serves static files out of a different location than the normal web root (e.g. http://exa...

Case insensitive urls for django?

It seems by default django's url solver perform case sensitive search for solving url and differentiate between '/Login' and 'login'. My url patterns are as follows. urlpatterns = patterns('', (r'^admin/(.*)', admin.site.root), (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT, 'show_...

What's the reason why Django has SmallIntegerField?

I'm wonder why it's provided. The field is database dependent, doesn't that make it totally unreliable to use? I want to store birth year in a model, kinda like class Person(models.Model): name = models.CharField(max_length=256) born = models.IntegerField() Of course this requires very little space, it should always be 4 "charact...

Django, from php to Django

I have a website done with Django, that was previously done with PHP and CodeIgniter. I've moved the website to Webfaction, changed the DNS and all other configurations, but now my email is full of errors like this: Error (EXTERNAL IP): /index.php/main/leer/7497 I don't know why the Django app is looking for pages from the PHP app, sp...

Sending Data To Server

I have a programm where i get the values of two variables for example x and y using javascript functions.How can i send them to the django server so as to do something(for example search in the database for matching values).How can i do this "SENDING" thing.Which language should i use for example? ...

Django, sorl-thumbnail crop picture head

Hi, guys, i would like to know if sorl-thumbnail have any option to crop from the bottom to the top... i have a litter problem, in some picture sorl-thumbnail is croping the head of the people in pictures. Thanks ...

In Django, how do I filter based on all entities in a many-to-many relation instead of any?

I have a model like this: class Task(models.model): TASK_STATUS_CHOICES = ( (u"P", u'Pending'), (u"A", u'Assigned'), (u"C", u'Complete'), (u"F", u'Failed') ) status = models.CharField(max_length=2, choices=TASK_STATUS_CHOICES) prerequisites = models.ManyToManyField('self', symmetrical=Fals...

Only showing year in django admin, a YearField instead of DateField?

I've got a model where I need to store birth year. I'm using django admin. The person using this will be filling out loads of people every day, and DateField() shows too much (not interested in the day/month). This is a mockup model showing how it is now: class Person(models.Model): name = models.CharField(max_length=256) born = mo...

Django: How to modify a text field before showing it in admin

I have a Django Model with a text field. I would like to modify the content of the text field before it's presented to the user in Django Admin. I was expecting to see signal equivalent of post_load but it doesn't seem to exist. To be more specific: I have a text field that takes user input. In this text field there is a read more sep...

Django - use reverse url mapping in settings

A few of the options in the django settings file are urls, for example LOGIN_URL and LOGIN_REDIRECT_URL. Is it possible to avoid hardcoding these urls, and instead use reverse url mapping? At the moment this is really the only place where I find myself writing the same urls in multiple places. ...

Django and python-twitter error

Hi guys, im trying to send my title post to twitter, in my local machine is working great!!!, but in remote i have this error from the snippet file: AttributeError: 'module' object has no attribute 'Api' im Using python-twitter and this snippet, i dont know why the error, i tested the python-twitter with commands like import twitter a...

List foreign keys linking to a model

How can I display objects that link to an object via a ForeignKey in Django (specifically in the admin interface). For example, if I click on an object, I'll not only see the object but also any other object that link to it. e.g. I have a model for "Manufacturer" and another one for "Model"...the "Model" model links to "Manufacturer" v...

django: Persist post request across a login

On logging in, the request's session key changes. This makes it hard to use sessions, for activities that should persist across login, such as, say a shopping cart, where the login is prompted only while check out. What is the best way to implement such a cart, which persists across login. One solution would be to have a table with ses...

Django - Parse XML, output as HTML fragments for iFrame?

heya, I've been asked to quickly put together a small system that takes a Yahoo XML feed, parses it, and creates a HTML fragment based on it. At the moment, I'm using Django to handle the URL routing, with some Python script, and outputting a bit of HTML in a (with hardcoded dimensions as inline CSS), that can hopefully be put into an...

Django ImageField / FileField custom upload_to function, and security

Hi. I have part of a model defined like this: logo_image = models.ImageField(upload_to=lambda i, fn: "logo_%s"%(fn), height_field="logo_image_height", width_field="logo_image_width") and had a question about the upload_to function. According to django's documentation for FileField.upload_to, the second paramater, filename is "The fil...

Google OpenID/federated login periodically fails

I'm developing a Django app that uses python-openid. The app is running on my development server at home. Similar to stackoverflow's login mechanism, I'd like users to login to my website using their Google credentials. The code I've implemented to do this, works well for a couple weeks, and then stops working. I get stuck during the ...

flup/fastcgi cpu usage under no-load conditions

I'm running Django as threaded fastcgi via flup, served by lighttpd, communicating via sockets. What is the expected CPU usage for each fastcgi thread under no load? On startup, each thread runs at 3-4% cpu usage for a while, and then backs off to around .5% over the course of a couple of hours. It doesn't sink below this level. Is thi...

Custom Django admin URL + changelist view for custom list filter by Tags

In django admin I wanted to set up a custom filter by tags (tags are introduced with django-tagging) I've made the ModelAdmin for this and it used to work fine, by appending custom urlconf and modifying the changelist view. It should work with URLs like: http://127.0.0.1:8000/admin/reviews/review/only-tagged-vista/ But now I get 'inval...