django

Best way to merge two Django projects' user tables?

I've got two Django projects on the same server. The first launched several months ago, and has since collected hundreds of user accounts. The second project is launching in a few days, and we'd like the second project to allow users of the first app to authenticate using the same credentials. At first, I was going to simply dump the ...

Is Django Development faster than ASP.NET for small/medium-size apps?

This is one of the things I've been hearing in Django VS ASP.NET discussion. I personally find it hard to believe but I never tried Django. So my question is: assuming that I am equally familiar with both python and the .NET framework but I do not know anything about Django or ASP.NET (with Visual Studio), is Django faster than ASP.NET ...

Python logging in Django

I'm developing a Django app, and I'm trying to use Python's logging module for error/trace logging. Ideally I'd like to have different loggers configured for different areas of the site. So far I've got all of this working, but one thing has me scratching my head. I have the root logger going to sys.stderr, and I have configured anoth...

How do I submit a form given only the HTML source?

I would like to be able to submit a form in an HTML source (string). In other words I need at least the ability to generate POST parameters from a string containing HTML source of the form. This is needed in unit tests for a Django project. I would like a solution that possibly; Uses only standard Python library and Django. Allows para...

Having problem importing the PIL image library

Hi, i am trying to do something with the PIL Image library in django, but i experience some problems. I do like this: import Image And then I do like this images = map(Image.open, glob.glob(os.path.join(dirpath, '*.thumb.jpg'))) But when i try to run this i get an error and it leeds me to think that its not imported correctly, a...

Looking for input in model design for Django Schools

Today I'm starting a little project to create a Django based school administration program. I'm currently designing the models and their corresponding relationships. Being rather new to Django and relational databases in general, I would like some input. Before I show you the current model layout, you need to have an idea of what the pr...

Django Admin's "view on site" points to example.com instead of my domain.

I added a get_absolute_url function to one of my models. def get_absolute_url(self): return '/foo/bar' The admin site picks it up and adds a "view on site" link to the detail page for that object (when I put a real URL there instead of "/foo/bar"). The problem is instead of going to http://localhost:8000/foo/bar, it goes to http:...

Django MTMField: limit_choices_to = other_ForeignKeyField_on_same_model?

I've got a couple django models that look like this: from django.contrib.sites.models import Site class Photo(models.Model): title = models.CharField(max_length=100) site = models.ForeignKey(Site) file = models.ImageField(upload_to=get_site_profile_path) def __unicode__(self): return self.title class Gallery...

Installation problems with django-tagging

I am having problems using django-tagging. I try to follow the documentation but it fails at the second step Once you've installed Django Tagging and want to use it in your Django applications, do the following: Put 'tagging' in your INSTALLED_APPS setting. Run the command manage.py syncdb. The syncdb command create...

Format numbers in django templates

I'm trying to format numbers. Examples: 1 => 1 12 => 12 123 => 123 1234 => 1,234 12345 => 12,345 It strikes as a fairly common thing to do but I can't figure out which filter I'm supposed to use. Edit: If you've a generic Python way to do this, I'm happy adding a formatted field in my model. ...

Get access to ForeignKey objects at parent save in Django

Hi, I am trying to make a combined image of all images added to a modell in django with inline editing and a ForeignKey. Ive got these models (simplified): class Modell(models.Model): title = models.CharField('beskrivelse', max_length=200) slug = models.SlugField() is_public = models.BooleanField('publisert', default=True)...

Django.contrib.flatpages without models

I have some flatpages with empty content field and their content inside the template (given with template_name field). Why I am using django.contrib.flatpages It allows me to serve (mostly) static pages with minimal URL configuration. I don't have to write views for each of them. Why I don't need the model FlatPage I leave the con...

How to test django caching?

Is there a way to be sure that a page is coming from cache on a production server and on the development server as well? The solution shouldn't involve caching middleware because not every project uses them. Though the solution itself might be a middleware. Just checking if the data is stale is not a very safe testing method IMO. ...

How do I find the "concrete class" of a django model baseclass

I'm trying to find the actual class of a django-model object, when using model-inheritance. Some code to describe the problem: class Base(models.model): def basemethod(self): ... class Child_1(Base): pass class Child_2(Base): pass If I create various objects of the two Child classes and the create a queryset con...

help needed with Lighttpd and Apache cofiguration with Django

I am using Django as web framework and then Apache and Lighttpd as web server and static media server respectively. Lighty serves all my static content well and good, but I need to configure it to serve the new files uploaded by the user. Lighttpd is running on a different machine from the Apache(Django) one. My django code of creating ...

How does Django Know the Order to Render Form Fields?

If I have a Django form such as: class ContactForm(forms.Form): subject = forms.CharField(max_length=100) message = forms.CharField() sender = forms.EmailField() And I call the as_table() method of an instance of this form, Django will render the fields as the same order as specified above. My question is how does Django ...

How to adding middleware to Appengine's webapp framework?

Im using the appengine webapp framework (link). Is it possible to add Django middleware? I cant find any examples. Im currently trying to get the firepython middleware to work (link). ...

Django dynamic OR queries

I have a MultipleChoiceField on a form holding car makes. I want to filter my database of cars to the makes that were checked but this causes a problem. How do I get all the Q(make=...) statements in dynamically? How I start: ['value1', 'value2', ...] How I want to end: Q(col='value1') | Q(col='value2') | ... I've couple of other meth...

Cleaner way to query on a dynamic number of columns in Django?

In my case, I have a number of column names coming from a form. I want to filter to make sure they're all true. Here's how I currently do it: for op in self.cleaned_data['options']: cars = cars.filter((op, True)) Now it works but there are are a possible ~40 columns to be tested and it therefore doesn't appear very efficient to ke...

Beginner: Trying to understand how apps interact in Django

I just got done working through the Djano tutorials for the second time, and am understanding things much more clearly now. However, I'm still unclear how apps inside a site interact with one another. For example, lets say I'm writing a blog application (a rather popular activity, apparently). Blog posts and comments tend to go together...