django

MySQL vs PostgreSQL? Which should I choose for my Django project?

My Django project is going to be backed by a large database with several hundred thousand entries, and will need to support searching (I'll probably end up using djangosearch or a similar project.) Which database backend is best suited to my project and why? Can you recommend any good resources for further reading? ...

What are good ways to upload bulk .csv data into a webapp using Django/Python?

I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. Are there good to...

limit choices to foreignkey using middleware

I'm looking to do something like this: http://stackoverflow.com/questions/160009/django-model-limitchoicestouser-user with some differences. Some models may explain: class Job(models.Model): name = models.CharField(max_length=200) operators = models.ManyToManyField(User) class Activity(models.Model): job = models.Foreign...

Django model default sort order using related table field

Is it possible to set the default sort order for a model to a field from a related model (rather than the integer key) i.e. something that yields a SQL order by clause with a field from both models? If so, how? I can do this via query_by but I can't figure out how to set it by default. Thanks. class Foo(models.Model): name = models....

Is there a Django apps pattern equivalent in Google App Engine?

Django has a very handy pattern known as "apps". Essentially, a self-contained plug-in that requires a minimal amount of wiring, configuring, and glue code to integrate into an existing project. Examples are tagging, comments, contact-form, etc. They let you build up large projects by gathering together a collection of useful apps, ra...

Django: How to redirect to an external URL?

[Django 1.0.2] I have a view set up like this: (r'^redirect/(?P<object_id>\d+)/(?P<url>.*)/$', 'django.views.generic.simple.redirect_to', {'content_type': SiteType}, 'clickout'), When I get the following URL, two different things happen on local development server and on remote mod_wsgi server: # GET "/redirect/2/http://www....

How can I query a model by if there is a subclass instance?

I have these two simple models, A and B: from django.db import models class A(models.Model): name = models.CharField(max_length=10) class B(A): age = models.IntegerField() Now, how can I query for all instances of A which do not have an instance of B? The only way I found requires an explicitly unique field on each subclass, wh...

Django - designing models with virtual fields?

Hi fellow stackers, I'd like to ask about the most elegant approach when it comes to designing models with virtual fields such as below in Django... Let's say we're building an online store and all the products in the system are defined by the model "Product". class Product(models.Model): # common fields that all products share ...

In a django site I want to let users create other users that are tied to their accounts.

I want to let a logged-in and registered user create extra user accounts that he will be the admin of. These accounts will be special "subordinate" accounts that are tied to the user creating them. He should be able to add/modify/delete these accounts kind of like the theory of how a Google apps administrator manages the accounts for h...

Fixing the auth_permission table after renaming a model in Django

Every now and then, you have the need to rename a model in Django (or, in one recent case I encountered, split one model into two, with new/different names). Yes, proper planning helps to avoid this situation, but sometimes reality intervenes. After renaming corresponding tables in the db and fixing affected code, one problem remains: ...

Teleport - django custom tag

Help please with a django custom tag. Analize it please! Idea: In any template (parent or child), we installing a tag {{ telepoint "head" }}, with a name, such putters could be more than one. At other side, we have block {{ teleputter "head" "unique-name" }} some html {{ teleputterend }} Content of this block goes to telepoint wit...

Is it possible to run Apache and IIS on the same machine with one IP-Address (and different ports ?)

The "main" one should be IIS. Is there an option to address the Apache without typing in the port-number The reason for this is: I cannot get Django to work on IIS Any ideas will be appreciated ...

Adding data to many-to-many field of a modelform within a view

class Person(models.Model): name = models.CharField(max_length=100) class Entry(models.Model): text = models.CharField(max_length=100) person = models.ManyToManyField(Person, blank=True, null=True) class MyModelForm(forms.ModelForm): class Meta: model = Entry In my view, I need to add pk id's to a submitted fo...

Testing document uploads in Development server using json files

I just built a small application(using Django) which will accept any jobseeker resumes. So any jobseeker uploads his/her resume in the form provided. How do I test this using testcases. I am used to writing fixtures for my initial data using json files. How would I have the same sort of a thing with doc files? So simply I want to run my ...

What SHOULDN'T Django's admin interface be used for?

I've been applying Django's automatic administration capabilities to some applications who had previously been very difficult to administer. I'm thinking of a lot of ways to apply it to other applications we use (including using it to replace some internal apps altogether). Before I go overboard though, is there anything in particular ...

How to pass information using an http redirect (in Django)

I have a view that accepts a form submission and updates a model. After updating the model, I want to redirect to another page and I want a message such as "Field X successfully updated" to appear on this page. How can I "pass" this message to the other page? HttpResponseRedirect only accepts a url. I've seen this done before on othe...

Newbie Django Question : Can't find data I thought I preset in a Form

I'm still getting to grips with Django and, in particular, Forms. I created MyForm which subclasses forms.Form in which I define a field like this : owner = forms.CharField(widget=forms.HiddenInput) When I create a new, blank instance of the Form I want to prefill this with the creator's profile, which I'm doing like this : form = My...

How to test for use of a django template block?

I would like to do: {% if appnav %} <hr /> <div id="appnav"> <ul class="tabs"> {% block appnav %}{% endblock %} </ul> </div> {% endif %} ...however, testing for the present use of a block by templates further down the inheritance chain doest seem to work. Is there some other conditional that might do this? ...

Should I use GeoDjango for mapping a floor plan?

I want to create a floor plan map of an interior space that has clickable regions. My first thought was to investigate GeoDjango since its the mapping app for Django. But considering the dependencies, the learning curve and overall complexity, I'm concerned that I may be trying to swat a fly with a bazooka. Should I use GeoDjango for ...

Store last created model's row in memory

I am working on ajax-game. The abstract: 2+ gamers(browsers) change a variable which is saved to DB through json. All gamers are synchronized by javascript-timer+json - periodically reading that variable from DB. In general, all changes are stored in DB as history, but I want the recent change duplicated in memory. So the problem is:...