ORM performance

2014-09-03 Thread msoulier
Hi, I am looking at Django's performance with respect to modifying large numbers of objects, each in a unique way that cannot be batched. If I make a simple change to one of my Django models and save(), and then do the same thing in sqlalchemy, I notice a performance difference of about 48 time

Re: relative URLs in redirects

2013-11-01 Thread msoulier
Damn. Missed that. Thanks. On Thursday, October 31, 2013 12:56:11 PM UTC-4, Tom Evans wrote: > > The Location header must always be a fully qualified URI, according to > every single version of the HTTP RFC from RFC 1945 onwards. > > Cheers > > Tom > -- You received this message because you

relative URLs in redirects

2013-10-31 Thread msoulier
Hi, If I return an HttpRedirect() with a relative URL in it, I notice that Django fully qualifies the redirect with a hostname and scheme. ie. Location /foo/bar/ goes to Location https:myserver.mysite.com/foo/bar/ Is there a reason to fully qualify like this? I've found relative URLs much m

TemporaryFileUploadHandler leaving tempfiles behind on disk

2013-03-04 Thread msoulier
Hi, I'm using a ModelForm to upload a large file that ends up being written to a tempfile on disk. When I call form.save(), the file gets copied to the final filename, but the tempfile is left behind on disk. I am using a custom handler, which is a TemporaryFileUploadHandler subclass, but each me

Re: unable to save ModelForm with primary key change

2012-11-01 Thread msoulier
On Nov 1, 1:27 pm, Tom Evans wrote: > >> Please show the definition of MyForm. > > Please do show it. Sorry, the model was in the previous email, here's the form. class McdLoadForm(forms.ModelForm): VERSIONPAT = re.compile(r'^(\d+\.){3}\d+$') class Meta: model = McdLoad

unable to save ModelForm with primary key change

2012-11-01 Thread msoulier
Hi, I'm trying to modify a model instance, specifically the field which is the model's primary key. When I save, nothing seems to happen. Everything in cleaned_data is good, but the model is not updated. No exception is thrown, the field isn't updated, nothing. All I'm doing is form = MyForm(req

Re: inconsistent fixture behaviour

2012-04-12 Thread msoulier
On Apr 12, 1:44 pm, msoulier wrote: > > class Service(models.Model): >     name = models.CharField(max_length=256) *sigh* I should have had primary_key=True on this. Red Herring, sorry. Mike -- You received this message because you are subscribed to the Google Groups "Django us

inconsistent fixture behaviour

2012-04-12 Thread msoulier
ice", "fields": { "description": "An FTP service for blah blah blah", "enabled": false, "access": "private", "username": "mcd", "password&quo

validation in fields with custom forms

2010-09-16 Thread msoulier
I have a custom field with takes an ipv4/v6 address or an fqdn, or a list of same, comma-separated. I'm using it in a form where I then have a custom validator for that field. ie. class SipTrunkForm(forms.Form): remote_addr = twcustomfields.SockaddrListField() remote_port = forms.IntegerF

debugging template inheritance

2010-08-05 Thread msoulier
Hi, I have a framework on a product that allows new django projects to make use of an existing project's code, so new projects can reduce duplication. It does this in templates by some trickery with the TEMPLATE_DIRS. For example, I have a base project here /var/www/django/base/templates/base.ht

Re: cascade deletion happens before pre_delete signal is sent?

2010-05-05 Thread msoulier
On Apr 3, 6:23 pm, Tomasz Zieliński wrote: > I believe that this question was asked on this group a long time ago, > and the answer was that pre_delete signal was fired *before* actual > deletion occured, > but *after* objects were collected for deletion (i.e. after list of > objects that were to

cascade deletion happens before pre_delete signal is sent?

2010-04-03 Thread msoulier
I have a model A, which has a ForeignKey to model B. A --> B When B is deleted I want to save the As that are pointing at B by repointing them at a different B if possible. To do this I have a pre_delete signal registered for B models. Unfortunately does doesn't work. Django follows the rela

models and inheritance

2010-02-05 Thread msoulier
Hi, I have an existing model that I've used for some time, and just recently I had to break it up into two related models that share a great deal, but have some difference, so I used inheritance to create two subclasses. I notice that syncdb is smart enough to not create an sql table for the base

unique_together across foreign keys

2010-02-03 Thread msoulier
Hi, So I currently have two models model Foo(models.Model): model Bar(models.Model): foo = models.ForeignKey(Foo) address = models.IPAddress() class Meta: unique_together(('address', 'foo'),) and this works fine to ensure that the address is unique across each instance of f

use a model signal to affect the model's program flow

2010-02-03 Thread msoulier
Hi, I wrote my current Django app in the 0.96 timeframe and have since upgraded, and now I have these cool signals available. I have some model code, like overriding the delete() method to prevent deletion of certain rows in the table, and I'm curious as to whether that can be done with the pre_sa

Re: auth unit tests fail because sites isn't used

2010-01-07 Thread msoulier
On Jan 7, 7:25 am, Tomasz Zieliński wrote: > I'm also getting this, so I'm only running my own tests (by passing > app names to test). Ok, I suppose that's one solution, but it seems like this test makes bad assumptions and should first check to see if the sites contrib is even in the installed a

auth unit tests fail because sites isn't used

2010-01-06 Thread msoulier
I can't find anywhere in the django docs where it says that django.contrib.auth uses django.contrib.sites, but when I run my unit tests I get this == ERROR: test_current_site_in_context_after_login (django.contrib.auth.tests.views

Re: Session ID generated each time web server is restarted

2009-05-26 Thread msoulier
On May 15, 11:42 am, Spk wrote: > It seems that everytime I restart the web server, I get a new session > ID which is why it thinks that there is data to be commited. The > browser still has the cookie for the previous session ID, and it is > stored in the database, so why is Django generating a

Re: file upload docs obsolete?

2009-05-14 Thread msoulier
On May 14, 3:51 pm, msoulier wrote: > I looked here > > http://docs.djangoproject.com/en/dev/topics/http/file-uploads/ > > and it mentions request.FILES being a dictionary, but the 1.0 porting > guide here > > http://docs.djangoproject.com/en/dev/releases/1.0-porting-g

file upload docs obsolete?

2009-05-14 Thread msoulier
I looked here http://docs.djangoproject.com/en/dev/topics/http/file-uploads/ and it mentions request.FILES being a dictionary, but the 1.0 porting guide here http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/ says otherwise. Was this overlooked? I think the page needs an update.

Re: custom sql with sqlite causes backtrace

2009-04-18 Thread msoulier
On Apr 18, 1:42 pm, msoulier wrote: >         cursor.execute(""" >             BEGIN; >             UPDATE clients >             SET connected = 'false' >             WHERE connected = 'true' >             AND tugid <> %s; >    

custom sql with sqlite causes backtrace

2009-04-18 Thread msoulier
eback. Traceback (most recent call last): File "", line 1, in ? File "/home/msoulier/work/mitel-msl-tug/root/etc/e-smith/web/django/ teleworker/clients/models.py", line 43, in disconnectAll cursor.execute(""" File "/home/msoulier/work/bin/msl8/li

Re: PositiveIntegerField returning a string?

2009-03-16 Thread msoulier
On Mar 14, 1:35 am, Russell Keith-Magee wrote: > It's possible that this is a known bug that has been fixed since v0.96 > was released. Where exactly did metrics object come from? Is is a > newly created object, or was it obtained as the result of a query? It was created as a result of a query.

PositiveIntegerField returning a string?

2009-03-13 Thread msoulier
Hi, Django 0.96 (yes, I know, we'll be at 1.0.2. soon), and I have a model full of PositiveIntegerField attributes. One of them is returning a string. >>> metrics.user_licenses_ca '315' >>> type(metrics.user_licenses_ca) PostgreSQL backend I thought that the PositiveIntegerField would enforc

Re: transactions and locking in postgreSQL

2008-12-06 Thread msoulier
On Dec 5, 10:43 pm, Jeffrey Straszheim <[EMAIL PROTECTED]> wrote: > I took a quick glance at transaction.py (where the TransactionMiddleware > class is defined), and it appears you are correct. However, it should > be pretty easy to roll your own transaction class that skips the > is_dirty check.

transactions and locking in postgreSQL

2008-12-05 Thread msoulier
Looking at the transaction middleware that wraps a transaction around every HTTP request, I've found that it only commits if the transaction is "dirty" (you change something). So, if you use this middleware unconditionally, then in view functions that only read, the transaction will never be comm

Re: django table locking

2008-12-05 Thread msoulier
On Dec 3, 2:16 pm, msoulier <[EMAIL PROTECTED]> wrote: > So one process was waiting to acquire an AccessExclusiveLock, and > there was already an AccessShareLock on it (the clients table). I've tried Django's transaction middleware, but I'm not sure that a commit is t

Re: django table locking

2008-12-03 Thread msoulier
On Nov 18, 7:46 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > Django doesn't do any explicit table locking, although there are > transactions involved. However, that shouldn't be affecting this. So Django is not safe to use in a concurrent environment? Well, it is if you don't mind two user

django table locking

2008-11-18 Thread msoulier
Hello, I have a daemon process running using the Django ORM API to access/ modify tables in PostgreSQL. I just ran into an issue where it looks like the process is keeping read-locks on the tables that it is reading, which is preventing a subsequent write lock from granting. Does the ORM API nor

Re: handling database restarts

2008-09-06 Thread msoulier
On Sep 3, 3:44 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > Hi Mike, > > Assuming that the DB restarts are rare, consider surrounding your > processing loop with a try..except block. When the exception occurs, > close the current connection so that the next iteration of your loop > gets a fresh

handling database restarts

2008-09-03 Thread msoulier
I have a long-running process that, to save on code, is using the Django models used in the web app to access the database. ie. os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings' sys.path.append(os.path.abspath('/path/to/django/project')) from myapp.subapp.models import MyModel This work

sending large downloads

2008-06-23 Thread msoulier
Hello, I saw some posts on this but not many useful responses. Apologies if there's already a known solution. For a web-based backup, I need to send a large file, basically the output of a tar process, to the browser. We have legacy Perl code doing this now but I'd like to use Django. Is there a

Re: error with custom sql

2008-06-03 Thread msoulier
On May 15, 2:23 pm, msoulier <[EMAIL PROTECTED]> wrote: > So, custom SQL in Django can't include a LIKE statement with a % > unless it's escaped? I'm > looking in the docs and I can't seem to find anything that mentions > that. In fact, I've replaced

get_decoded in django shell results in SuspiciousOperation exception

2008-05-20 Thread msoulier
I'm trying to inspect the session data in the db. >>> from django.contrib.sessions.models import Session >>> q = Session.objects.all() >>> for s in q: ...print s.get_decoded() ... Traceback (most recent call last): File "", line 2, in ? File "/var/tmp/django-0.96.2-root/usr/lib/python2.3/

Re: error with custom sql

2008-05-15 Thread msoulier
On May 15, 2:13 pm, msoulier <[EMAIL PROTECTED]> wrote: > Actually, it fails in the Django shell, and there only, regardless of > the db backend. Oh, scratch that. I just got it to fail consistently in a simple script that runs only that code. So, custom SQL in Django can'

Re: error with custom sql

2008-05-15 Thread msoulier
On May 14, 10:27 pm, msoulier <[EMAIL PROTECTED]> wrote: > This seems to work in production with postgreSQL, but on my laptop > with sqlite I'm seeing an issue. Actually, it fails in the Django shell, and there only, regardless of the db backend. Can anyone th

error with custom sql

2008-05-14 Thread msoulier
27;%SIP' """) This seems to work in production with postgreSQL, but on my laptop with sqlite I'm seeing an issue. Traceback (most recent call last): File "", line 1, in File "/home/msoulier/work/mitel-msl-tug/root/etc/e-smith/web/django/ teleworker

Re: Logging framework (like log4j)?

2008-05-08 Thread msoulier
On May 8, 2:54 pm, ydjango <[EMAIL PROTECTED]> wrote: > Is there a application level logging framework/utility in django or > python that I can use in views to log to file and/or database. > Something similar to log4j in java. I'm using the Python standard library's logging module. Works fine. M

Re: The connection was reset

2008-05-05 Thread msoulier
On May 5, 2:01 pm, msoulier <[EMAIL PROTECTED]> wrote: > Seems like an issue with the built-in web server. In fact, if I modify handlers/wsgi.py, and print the request object before it gets to get_response(), suddenly it's fine. try: request = WSGIR

The connection was reset

2008-05-05 Thread msoulier
Hi, I'm currently playing with my Django web interface on a windows XP box with Python 2.5, Django 0.96. Sometimes when I send a redirect in view code, Firefox says, "The connection was reset while the page was loading." Seems like an issue with the built-in web server. Sample code: elif r

Re: using Q() with relations

2008-05-01 Thread msoulier
On May 1, 11:39 am, msoulier <[EMAIL PROTECTED]> wrote: > So, I narrowed it down to the OR of the resultant querysets. Ah, it's an inner join, so this likely wouldn't work for any database. >>> p.pprint(q3._get_sql_clause()) ( [ '"clients_client"

Re: using Q() with relations

2008-05-01 Thread msoulier
On May 1, 11:16 am, msoulier <[EMAIL PROTECTED]> wrote: > I have a case where I'm trying to OR several conditions together in a > query, and I'm including a query against a field in a foreign key > field. > > queryset = queryset.filter( >

Re: concatenation of querysets

2008-05-01 Thread msoulier
On May 1, 11:20 am, msoulier <[EMAIL PROTECTED]> wrote: > I looked in the docs and I've failed to find, so I apologize if it's > freakin' obvious, but how does one concatenate two querysets? Doh! http://groups.google.ca/group/django-users/browse_thread/thread/

concatenation of querysets

2008-05-01 Thread msoulier
I looked in the docs and I've failed to find, so I apologize if it's freakin' obvious, but how does one concatenate two querysets? ie. q1 = Client.objects.filter(name__icontains='foo') q2 = Client.objects.filter(description__icontains='bar') q3 = q1 + q2 ?? How would I merge these? They behave

using Q() with relations

2008-05-01 Thread msoulier
I have a case where I'm trying to OR several conditions together in a query, and I'm including a query against a field in a foreign key field. queryset = queryset.filter( Q(clientid__icontains=filter) | Q(description__icontains=filter) | Q(icp__name=fil

Re: "data" is a reserved field in newforms?

2008-04-30 Thread msoulier
On Apr 30, 9:26 pm, Doug Van Horn <[EMAIL PROTECTED]> wrote: > Seehttp://www.djangoproject.com/documentation/newforms/#accessing-clean-..., > check the 'Note' section. Ah, that explains much. Many thanks. Mike --~--~-~--~~~---~--~~ You received this message becau

"data" is a reserved field in newforms?

2008-04-30 Thread msoulier
A coworker of mine created a form with a field called "data". ie. data = forms.CharField() This resulted in an exception being thrown when is_valid() was called on the form: form error - 'dict' is not callable The exception occurs at line 180 in \lib\site-packages\django\newforms\forms.py

ensuring uniqueness in newforms

2008-03-31 Thread msoulier
If I have a field, for example a CharField named 'name', which must be unique, what's the best way to ensure uniqueness whether creating a new entry or editing an existing one? By default, the form won't know if it is being used to edit or create, so if you look for duplicates in the db, how woul

Re: obeying the DRY principle in views

2008-03-31 Thread msoulier
On Mar 31, 10:04 pm, Michael <[EMAIL PROTECTED]> wrote: > Not really a DRY issue moreover there is an easier logic to your code: Sad that I didn't see that. Thanks, Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Group

obeying the DRY principle in views

2008-03-31 Thread msoulier
I find myself doing this a lot in view code if request.method == 'GET': form = MyForm(initial=data) return render_to_response('template.html', RequestContext(request, { 'foo': foo, 'bar': bar })) elif request.method == 'POST': form = MyForm(request.POST)

Re: problems with url tag

2008-03-06 Thread msoulier
On Mar 5, 6:50 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > In the meantime, use the url(...) form for your url patterns and give > each one that might cause confusion a unique name. That way you can > refer to them uniquely in the {% url ... %} tag. Ok, I'll do that when the next Django r

problems with url tag

2008-03-04 Thread msoulier
So, my urlconf is urlpatterns = patterns('teleworker.clients.views', (r'create/$', 'create'), (r'modify/(?P\d+)/$', 'modify'), (r'delete/(?P\d+)/$', 'delete'), (r'page/(?P\d+)/(?P\w+)/(?P\w+)/$', 'list'), (r'page/(?P\d+)/$', 'list'), (r'^$', 'list'), ) The list function i

Re: loaddata on big fixture doesn't seem to end

2008-02-22 Thread msoulier
On Feb 21, 10:57 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > I've logged this as #6643. I'm hoping to have some time tonight to > look at a few outstanding fixture tickets; I'll add this one to the > list. Thanks, you guys rock. Mike --~--~-~--~~~---~--~---

loaddata on big fixture doesn't seem to end

2008-02-21 Thread msoulier
Hi, I'm loading a fixture with 2500 objects in it into postgres 7.4. For some reason, loaddata is looking in a lot of additional places than the file I'm handing it. [EMAIL PROTECTED] teleworker]# PYTHONPATH=.. python manage.py loaddata /root/clients.json Loading '/root/clients.json' fixtures..

Re: backtrace trying to get django deployed with apache and mod_python

2008-02-17 Thread msoulier
On Feb 16, 8:37 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > Are you trying to use mod_python 2.7.X on Apache 1.3 by chance? Indeed I am. > From memory ap_auth_type attribute may only be in Apache 2.X and thus > you need to be using mod_python 3.X, preferably 3.3.1, on Apache 2.X. Ok, than

Re: DATABASE_PORT ignored?

2008-02-16 Thread msoulier
On Feb 16, 3:41 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > Instead, you need to use 127.0.0.1 to force the connection to go via > TCP/IP. I'm pretty sure, without having tested it, that Django will be > fine with that (setting the HOST string to an IP address). We just pass > that informa

backtrace trying to get django deployed with apache and mod_python

2008-02-16 Thread msoulier
I'm trying to move an existing site to another server, and I'm getting this error when I access the new site. Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/local/python-2.5/lib/python2.5/site-packages/mod_python/ apache.py", lin

Re: manage.py help message seems inaccurate

2008-02-16 Thread msoulier
On Feb 11, 8:02 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > This is correct - SQL for data fixtures won't be dumped. The error > message is a little misleading in this respect, as it refers to > initial data, not custom SQL. I've clarified the text in [7106]. > > As for the --interactiv

DATABASE_PORT ignored?

2008-02-16 Thread msoulier
I have a site where I need to use the mysql tcp port of 3306 instead of the unix domain socket, to talk to mysql. So, I did this in my settings.py DATABASE_HOST = 'localhost' DATABASE_PORT = 3306 Unfortunately, it seems to be ignored. _mysql_exceptions.OperationalError: (2002, "Can't connect to

manage.py help message seems inaccurate

2008-02-11 Thread msoulier
syncdb [--verbosity] [--interactive] Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created. python manage.py syncdb --interactive manage.py: error: no such option: --interactive sqlall [appname ...] Prints the CREATE TABLE, initial-da

Re: ForeignKey _id not so transparent

2008-01-27 Thread msoulier
On Jan 27, 12:46 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > You can assign a numeric ID of a TugInstance object to 'instance_id' > on a Client object. > > You can assign an actual honest-to-goodness TugInstance object to > 'instance' on a Client object. Ah, that helps. The docs don't seem t

ForeignKey _id not so transparent

2008-01-26 Thread msoulier
So, I have a Client model that includes an instance field instance = models.ForeignKey(TugInstance) When my form is submitted, I am assigning client.instance = form.clean_data['instance_id'] But this isn't working. I get an error on save() that 'instance_id' cannot be NULL. If I change my cod

Re: templating javascript code

2007-12-17 Thread msoulier
On Dec 2, 8:27 pm, Darryl Ross <[EMAIL PROTECTED]> wrote: > I've done this is CSS files before, so it should work just fine. Just > make sure you set the correct Content-Type header in your JS view. FTR, this works fine. I couldn't use render_to_response() as I had to supply the mimetype, but oth

django requires db access to dump sql that it would use in syncdb

2007-12-17 Thread msoulier
I'm trying to write db initialization code for an existing db framework on a product that I work on. To do this I'm "asking" django to show SQL that it would use to create its db, so I can copy it into the initialization code. I can't though, as I haven't created the db yet, and for some reason i

templating javascript code

2007-12-02 Thread msoulier
Hi, I'm adding some Ajax effects to my Django site, and there are some things in the javascript that I'd like to template. Currently my javascript is inline in my index.html file, so I can template things like var debug = {{ debug }}; var refreshtime = {{ refreshtime }}; That way, settings in m

questions about form_for_model

2007-10-12 Thread msoulier
I am using Django stable (0.96). When I use form_for_model on a model that includes CharFields that have choices attributes, the resulting form field is not a ChoiceField as specified in the documentation. Is this simply a bug in 0.96? Also, if I wish to return a different field type, not based

Re: using multiple databases

2007-09-18 Thread msoulier
On Sep 17, 11:00 pm, "Ben Ford" <[EMAIL PROTECTED]> wrote: > Hi Mike, > There is a branch that supports multiple databases in the repository. It's > quite out of date in the SVN repo but Koen put in some stirling work over > the period of the sprint and produced a patch against trunk at around r61

using multiple databases

2007-09-17 Thread msoulier
I was hoping to use Django in a web management UI for a server that I support, where new UIs are added as new applications are installed. Due to this plugin requirement, I had planned to model that with one large Django project, where each new plugin was a Django application. Unfortunately it wou