django

Can multiple Django sites share memory?

I'm using Apache + mod_wsgi daemon mode for running a Django site. When another site is added (new virtualhost), a second daemon appears. Is there any way to let those sites share the same proces / memory? It seems to wasteful to have ~20MB persistently in use per site. Bonus points: how does this compare to PHP hosting? (especially Dr...

Problem adding to solr index from Django using zc.buildout

I'm trying to get Apache Solr running inside my zc.buildout environment. I've defined a simple model: class NewsItem(models.Model): title = models.CharField(blank=False, max_length=255, help_text=u"Title of this news item") slug = models.SlugField(blank=False, help_text=u"Slug will be automatically generated from the title") ...

Why can't django load multiple pages simultaneously ?

I have a django aplication with an admin panel. When i add some item (it takes about 10 seconds to add it), i can't load any other page. The page is waiting for the first page to load, and then it load itself. ...

How to clean a certain field in a InlineFormSet ?

I need to clean a specific field in an inline formset, and I can't figure out how to do it. I've tried with the formsets def clean(self) method but don't know where to save the cleaned value. If I try to set the cleaned value to forms[0].data['field'] I get "This QueryDict instance is immutable" error. In "normal" forms it works by us...

How would I go about downloading a file from a submitted link then reuploading to my server for streaming?

I'm working on a project where a user can submit a link to a sound file hosted on another site through a form. I'd like to download that file to my server and make it available for streaming. I might have to upload it to Amazon S3. I'm doing this in Django but I'm new to Python. Can anyone point me in the right direction for how to do th...

Django template inclusion

The template inheritance page on the django site doesn't really solve my problem (Django 1.2). My base page looks like: ... <div class="grid_12" id="content"> {% block content %}{% endblock %} </div> ... {% block javascript %}{% endblock %} I have another template that defines content for these: {% block content %} animated si...

Django+Haystack+Whoosh: how to deal with language inflection

Many languages in Europe are inflectional. This means that one word can be written in multiple forms in text. For example, word 'computer' in polish "komputer" has multiple forms: "komputera", "komputerowi", "komputerem", "komputery" , etc.. How should I use django+haystack+whoosh properly to deal with language inflection? Whenever I...

Django - delete an object without deleting its related objects.

What I mean is I have: class Client(models.Model): some_field = models.CharField() class Ticket(models.Model): client = models.ForeignKey(Client) Tickets are FOREVER in my system, but I want users to be able to delete clients they don't want anymore. Currently it'll delete all the tickets created by the Client. Is this a ba...

How to deal with temporary storage of uploaded files

In my django application I have a multi step registration, with few conditional parameters. Because of this I figured out to store data from forms in session. Unfortunatelly sessions serialize data using pickle, which doesn't support file serialization and causes PicklingError: Can't pickle <type 'cStringIO.StringO'>: attribute lookup cS...

Django, error with custom admin commands when executing with absolute path

I have a custom admin command named temperature.py which is under /home/user/project/monitor/management/commands. If I change directory to /home/user/ and execute: user@localhost:~/project$ ./manage.py temperature It runs ok, and its listed in the available commands. But if I try running it with the absolute path: user@localhost:/$ /...

Django initial_data.json memory issues

I have a huge (400MB) initial_data.json file. Django's eating up all my memory trying to load this file. Suggestions? Surely someone out there has large initial_data files they use. I'd consider converting this into an xml file, but I don't know if Django will try to load all that into memory as well, and I'm not yet ready to try it ...

How is pip install using git different that just cloning a repository?

I'm a beginner with Django and I'm having trouble installing django-basic-apps using pip. If I do this... $ cat requirements.txt git+git://github.com/nathanborror/django-basic-apps.git $ pip install -r requirements.txt I end up with lib/python2.6/site-packages/basic/blog that does NOT have a templates directory. If I do this.....

django multiple relations to single data model

my example (I know it's not technically correct, it's just an example): class ipAddy(models.Model): network=models.ForeignKey(network) ipAddy=models.IPAddressField(foo) class device(models.Model): hostname=models.CharField(foo) foo=models.CharField(bar) bar=models.CharField(foo) class Meta: abstract = T...

Django DB design to glob words quickly

I need to quickly look up words for a web application that I am writing in Django. I was thinking of putting each character of the word in an integerfield of its own, indexed by position. class Word(models.Model): word = models.CharField(max_length=5) length = models.IntegerField() c0 = models.IntegerField(blank=True, null...

Using django filter() with a querset as args or kwargs

Hello djangoists. How to I make the following possible? models.py class Article(models.Model): #... regions = models.ManyToManyField(Region) elsewhere... regions = Region.objects.all() articles = Article.objects.filter(regions=regions) Currently, the 'articles' retrieved are only from a match with the first region in the ...

How to test Models in Django with Foriegn Keys

I want to make sure I am testing Models/Objects in isolation and not as one huge system. If I have an Order object and it has Foreign Keys to Customers, Payments, OrderItems, etc. and I want to test Order functionality, I need to create fixtures for all of that related data, or create it in code. I think what I really need to be doing i...

Best way to suppress exceptions raised when third-party service is unavailable?

I've written a Django application which interacts with a third-party API (Disqus, although this detail is unimportant) via a Python wrapper. When the service is unavailable, the Python wrapper raises an exception. The best way for the application to handle such exceptions is to suppress them so that the rest of the page's content can st...

When Rails require mod_rails, what about Django, TurboGears, Symfony, CakePHP? Can they deploy using mod_python and mod_php?

When Rails applications seem hard to deploy (or used to be), what about Django, TurboGears, Symfony, CakePHP -- can they be simply deployed using mod_python or mod_php? Actually, won't it need something like a mod_django so that the code can run in a "Django" environment? (Just like Rails' script/console or Rails 3's rails console) ...

Anyone knows a good hack to make django-registration use emails as usernames?

I am planning to do email-registration-activation on my site which will be launched very soon. I have just started looking at django-registration and I am open to other email-registration-activation system available on django. My only requirement is that for my site, I don't actually use usernames. Rather, user logs in with their email...

Django ORM equivalent for this SQL..calculated field derived from related table

I have the following model structure below: class Master(models.Model): name = models.CharField(max_length=50) mounting_height = models.DecimalField(max_digits=10,decimal_places=2) class MLog(models.Model): date = models.DateField(db_index=True) time = models.TimeField(db_index=True) ...