django-database

Why Django does not "really" support automatic table update?

Recently I have been trying to learn web development in Django and i am very happy about it... But, one thing is really annoying -especially when you get the idea about 'simplicity' philosophy behind django. It is that updating a table in django is really far away from simplicity as i just experienced. For example, just like the real ...

Caching of querysets and re-evaluation

Hi, I'm going to post some incomplete code to make the example simple. I'm running a recursive function to compute some metrics on a hierarchical structure. class Category(models.Model): parent = models.ForeignKey('self', null=True, blank=True, related_name='children', default=1) def compute_metrics(self, shop_object, metric_queryse...

Monitor database requests in Django, tied to line number

We've got some really strange extraneous DB hits happening in our project. Is there any way to monitor where the requests are coming from, possibly by line number? The SQL printing middleware helps, but we've looked everywhere those kinds of requests might be generated and can't find the source. If the above isn't possible, any pointers...

Database query across django ManyToManyField

I'd like to find how to select all objects whose ManyToMany field contains another object. I have the following models (stripped down) class Category(models.Model): pass class Picture(models.Model): categories = models.ManyToManyField(Category) visible = models.BooleanField() I need a function to select all the Pictures i...

[Django] Table with Million of rows

Hi at all. I have a project with 2 applications ( books and reader ). Books application has a table with 4 milions of rows with this fields: book_title = models.CharField(max_length=40) book_description = models.CharField(max_length=400) To avoid to query the database with 4 milions of rows, I am thinking to divide it by subject ( ...

Django and NoSQL, any ready-to-use library?

So far Django has good integration with several RDBMS. NoSQL, schema-less and document-oriented DBMS are picking up. What's the status of integration those on-trend and fashionable DBMSes with Django? Are there any production-ready or at least ready-to-use libraries for Django? So far I have these at hand: http://github.com/lethain/co...

Do unit tests on the 'live' database in settings.py while using Django's 'manage.py test'

If you've got a database setup in Django, how can you have the TestRunner use the 'live' database (per the DATABASE_* settings in settings.py) instead of running them on the ephemeral test database. For example, I'd like to run the following test on the live database that's specified in settings.py: import unittest from example import...

Generate a few models from existing database in Django

I know this exists django-admin.py inspectdb > models.py However, is there an easy way to limit it? Without manually deleting what I don't want. I'm connecting to a database that has over one hundred tables, but I only want models of about 4 or 5. Is there an easy way to generate models from a few given tables? They are quite big ta...

How to make Django work with unsupported MySQL drivers such as gevent-mysql or Concurrence's MySQL driver?

I'm interested in running Django on an async framework like Concurrence or gevent. Both frameworks come with its own async MySQL driver. Problem is Django only officially supports MySQLdb. What do I need to do to make Django work with the MySQL drivers that come with gevent or Concurrence? Is there a step-by-step guide somewhere that ...

How to make Django work with MySQL Connector/Python?

Has anyone made Django work with myconnpy? I've checked out http://github.com/rtyler/connector-django-mysql but the author said it's very outdated and not supported. If you've managed to make Django work with myconnpy, please share your experience. Thanks. ...

IntegrityError with Booleand Fields and Postgresql

I have this simple Blog model: class Blog(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True) body = models.TextField(_('body')) user = models.ForeignKey(User) is_public = models.BooleanField(_('is public'), default = True) When I insert a blog in admin interface, I get this err...

Could I use urlize filter in this way ?

Could I use urlize filter in this way? : from django.utils.html import urlize def save(self, force_insert=False, force_update=False): self.body = urlize(self.body) super(Post, self).save(force_insert, force_update) body is a TextField. ...

Models does not create tables when synched

I have some django models for my extended users profile. Problem is that this code does not create tables when syncdb is used (simply nothing happens. No validation errors). Why is that happening? (Also those models give import error elsewhere) : #!/usr/bin/env python # encoding: utf-8 from django.db import models from django.contrib.au...

Django 1.2 : Multiple database and Generic Content Types

I am working on one project with django 1.2. I have 2 databases : - First, for users, user's profile, session ... - Second is to store data from my specifics models like post of blog, pictures, files ... I made a router (dbrouter.py) to manage where each models are stored (instead of using 'using' for each queryset). When I sync my ...

Django v1.2 multi-db database debugging app?

Hi, anyone know if there's a django database debugging app which supports Django's multi-db API? I used to use django-debug-toolbar but it doesn't support multiple databases and the corresponding ticket is now open for 3 months. Are there any alternatives worth looking at? ...

Problems with django deployment

Im trying to deploy my django and I always get one of these erros: (they alternate as I refresh the page) The model Page has already been registered ( its from feincms, but i dont get this on my computer ) unable to open database file (the database is sqlite3 and was successfully created with syncdb on the server ) Any ideas on what ...

How do I delete an object in a django relation (While keeping all related objects)?

I have the following model: One name (Char) Many one (ForeignKey,blank=True,null=True) title (Char) I want to delete a One instance and all related objects should loose their relation to the One instance. At the moment my code looks like this: one=One.objects.get(<some criterion>) more=Many.objects.filter(one=one) for m ...

Django - how to specify a database for a model?

Is there a way to specify that a model (or app, even) should only ever use one particular database? I am working with a legacy database that I don't want to change. I have two databases - the 'default' is an sqlite one that could be used for admin etc, and the legacy one. I used inspectdb to create a model for (part of) the legacy datab...

Getting last created user to link user profile to in django

Hi, I've hit a bit of a wall when trying to add data to a UserProfile model created to hold user info beyond what is catered for in django's built in Auth component. My question is how do I get an instance of the user just registered in order to create the the UserProfile? I thought it would be something like below: # Registration for...

Django __in lowercase

Hi there, I'm using django-taggit, which handles the attachment of tags to arbitrary content types. I imported a large tag list, which contains many uppercase words, as well as lowercase words. Now, I' trying to get objects of another class containing a set of tags, but I want to compare case insensitively. When I do this: Media.objec...