Re: Django 1.5 with uwsgi(threaded)/mysql seems to magically cache querysets

2013-04-09 Thread Andy Dustman
You know, I had another report of this, which seemed completely improbable:
https://plus.google.com/u/0/101898908470597791359/posts/AuMJdgEo93k

Maybe it's related to a bug in Django 1.5 that was fixed in 1.5.1?
https://www.djangoproject.com/weblog/2013/mar/28/django-151/


On Thu, Apr 4, 2013 at 1:42 PM,  wrote:

> I would say its definitely not isolation level, as restarting the django
> instance made this issue go away for a few hours.  I would setup a test for
> this, but don't really know if there already exist any per thread tests for
> django sanity I could look at for examples.
>
>
> The caching change is about related models, this doesn't use any real
> related models, it does use them through the .values() call.  Maybe this is
> a side affect of that caching, but that mentions nothing about the caching
> persisting past a single request.  If that actually happens, i'm sure many
> people using django 1.5 are going to run into all kinds of data loss
> scenarios.
>
>
> On Tuesday, April 2, 2013 11:09:19 AM UTC-6, Alan Johnson wrote:
>>
>> It's tough to know what the deal is without any info on your code or
>> database, but two things come to mind. One is some of the new caching in
>> Django 1.5 for related models (https://docs.djangoproject.**
>> com/en/dev/releases/1.5/#**caching-of-related-model-**instances),
>> and the other is database isolation level (e.g. for Postgres: http://www.
>> **postgresql.org/docs/9.1/**static/transaction-iso.html
>> )
>>
>> On Monday, April 1, 2013 9:40:08 AM UTC-4, budl...@gmail.com wrote:
>>>
>>> So I have some stats reports that I run that it almost seems as if each
>>> thread has its own queryset cached.  Each time I refresh they change.  I'm
>>> going to revert back to 1.4 due to this bug.  I wish I could come up with a
>>> simple example, to demonstrate this, the problem is that the underlying
>>> database needs to change between the time each thread serves a request.
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Question the answers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [gripe] Pain on OSX

2011-07-28 Thread Andy Dustman
My development setup is:

Snow Leopard
X-Code
MacPorts
Python-2.6 via MacPorts
MySQLdb via MacPorts
MySQL server on an Ubuntu VM (mimics production)
Django-1.3 via virtualenv easy_install
WingIDE or Django internal HTTP server

Production (and pre-production testing) is on Ubuntu Lucid, Apache, mod_wsgi.

On Thu, Jul 28, 2011 at 9:35 AM, Kolbe  wrote:
> Is it just me, or is it that painful just to get Django running on
> OSX?
>
> During development, I had problems with Mysql_db. More or less got
> that solved, and been reading postgre is more or less the preferred
> choice? Anyway, for most of development, I've been just using sqlite.
>
> Now I have problems with Apache - trying to install mod_wsgi and I
> need to first download developer tools to get gcc and etc...
>
> Then there's the problem of a good hosting provider. You'd probably
> just want a hosting provider to have the server all ready and all
> you'd need to do is upload the files and off you go!
>
> *gripe*
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Question the answers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ImportError: No module named site

2011-06-30 Thread Andy Dustman
On Thu, Jun 30, 2011 at 4:54 AM, bruno desthuilliers
 wrote:
> On Jun 29, 7:32 pm, Kyle Latham  wrote:
> (snip)
>> I have no idea what is going wrong, but here is all my code thus far
>> (I'm following the tutorial to create my own app that will display
>> various material measurements)
>>
>> ---
>> models.py
>> ---
>> from django.db import models
>>
>> # Create your models here.
>> class adhesive(models.Model):
>>     measurement_id = models.CharField(max_length = 200)
>>     material_id = models.CharField(max_length = 200)
>>     program_name = models.CharField(max_length = 200)
>>     date = models.DateField()
>>     measurement_method = models.CharField(max_length = 30)
>>     frequency_low = models.IntegerField()
>>     frequency_high = models.IntegerField()
>>
>> class ceramic(models.Model):
>>     measurement_id = models.CharField(max_length = 200)
>>     material_id = models.CharField(max_length = 200)
>>     program_name = models.CharField(max_length = 200)
>>     date = models.DateField()
>>     measurement_method = models.CharField(max_length = 30)
>>     frequency_low = models.IntegerField()
>>     frequency_high = models.IntegerField()
>>
>> class composite(models.Model):
>>     measurement_id = models.CharField(max_length = 200)
>>     material_id = models.CharField(max_length = 200)
>>     program_name = models.CharField(max_length = 200)
>>     date = models.DateField()
>>     measurement_method = models.CharField(max_length = 30)
>>     frequency_low = models.IntegerField()
>>     frequency_high = models.IntegerField()
>>
>
> Totally unrelated to your question, but: why on earth are you creating
> 3 distincs models with the exact same fields ??? You just need one
> single model, and add a "material_type" field (eventually passing in a
> choices list of "Composite", "Ceramic" and "Adhesive").

Another possibility is to make a Material abstract base class, and
have Adhesive, Ceramic, and Composite inherit from it. Or, have a
non-abstract Material base class. Doing either of these things really
only makes sense if you have extra fields to add to the subclasses. I
tend to think doing what Bruno suggests (adding a material type field)
will work better.

Reference; 
https://docs.djangoproject.com/en/1.3/topics/db/models/#model-inheritance

-- 
Question the answers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mach-o, but wrong architecture

2011-06-24 Thread Andy Dustman
Only thing I can think of is maybe ports itself or some other port is
not up-to-date.

On Fri, Jun 24, 2011 at 5:45 PM, John  wrote:
> I think I am still missing something, guess I am not overly familiar
> with the Port syntax.
>
> I have python2.7 installed, but not using Port, I get this problem if
> I try and select python27, it seems like a chicken and egg situation
>
> John-Paynes-MacBook-Pro:~ jpayne$ sudo port select python python27
> Selecting 'python27' for 'python' failed: The specified group 'python'
> does not exist.
>
> John-Paynes-MacBook-Pro:~ jpayne$ sudo port install python27
> --->  Computing dependencies for python27
> Error: Dependency 'python_select' not found.
> Error: Status 1 encountered during processing.
> To report a bug, see <http://guide.macports.org/#project.tickets>
>
>
> On Jun 24, 5:03 pm, Andy Dustman  wrote:
>> I think this is the 
>> answer:http://stackoverflow.com/questions/6152765/macports-didnt-place-pytho...
>>
>>
>>
>>
>>
>> On Fri, Jun 24, 2011 at 4:42 PM, John  wrote:
>> > I don't seem to be able to take a trick on this one.
>> > Tried using MacPorts to install python27 and py27-mysql (had to
>> > reinstall XCode for some reason) and it tells me that it cant find a
>> > dependency of python_select, but apparently python_select has been
>> > deprecated.
>>
>> > Do you know a way around this?
>>
>> > On Jun 23, 5:50 pm, Andy Dustman  wrote:
>> >> Did you make sure you completely cleaned out the build directory
>> >> between attempts? I.e. manually remove it. Also see (if you haven't
>> >> already)http://stackoverflow.com/questions/3061277/python-mysql-wrong-archite...
>>
>> >> I don't know exactly why it's so hard to build on Mac OS X, and I
>> >> wrote the package... I do know the MacPorts route works, because
>> >> that's why I'm using. The only thing MacPorts seems to do is change
>> >> the name of mysql_config to mysql_config5 (because of the way they do
>> >> MySQL package versioning). But with MacPorts, you end up building
>> >> MySQL itself for your architecture, rather than the fat binary
>> >> packages which mysql.com provides.
>>
>> >> On Thu, Jun 23, 2011 at 5:00 PM, John  wrote:
>> >> > O.K.  I know that there are a lot of suggestions out there for this
>> >> > problem, I think I have tried all of them but I am still getting the
>> >> > dreaded error in the subject line loading the MySQLdb module.
>>
>> >> > Everything was working fine, but I was having problems with a
>> >> > LocMemCache so I decided to upgrade from Django 1.2.3 to Django 1.3.
>> >> > At the same time I decided to move to Python 2.6 to Python 2.7.  This
>> >> > is on Mac SnowLeopard on a MacBook Pro.
>>
>> >> > I have tried build and install of the MySQL-python-1.2.3 connector
>> >> > using ARCHFLAGS="-arch i386", "-arch -686", "-arch x86-64" and "-arch
>> >> > x86-32".  I get the same error in all cases.  I can see that the
>> >> > module being loaded is the one that was built and installed in each
>> >> > case.
>>
>> >> > ALso, since it was mentioned as the reason for moving to Django 1.3,
>> >> > does anyone have any suggestions for solving my cache problem?  I am
>> >> > trying to save a rather large dictionary of financial calculation
>> >> > numbers to a LocMemCache.  In the debug environment it works just fine
>> >> > but when I deploy to an Apache http server the cache seems to get
>> >> > cleared between each HTTP request.  Via logging I can confirm that the
>> >> > object is serialized to the cache and can be immediately retrieved
>> >> > form the cache but the object no longer exists when the next HTTP
>> >> > request comes in on the same session.
>>
>> >> > Thank you for your asistance.
>>
>> >> > --
>> >> > You received this message because you are subscribed to the Google 
>> >> > Groups "Django users" group.
>> >> > To post to this group, send email to django-users@googlegroups.com.
>> >> > To unsubscribe from this group, send email to 
>> >> > django-users+unsubscr...@googlegroups.com.
>> >> > For more options, visit this group 
>> >> > athttp://groups.googl

Re: mach-o, but wrong architecture

2011-06-24 Thread Andy Dustman
I think this is the answer:
http://stackoverflow.com/questions/6152765/macports-didnt-place-python-select-in-opt-local-bin

On Fri, Jun 24, 2011 at 4:42 PM, John  wrote:
> I don't seem to be able to take a trick on this one.
> Tried using MacPorts to install python27 and py27-mysql (had to
> reinstall XCode for some reason) and it tells me that it cant find a
> dependency of python_select, but apparently python_select has been
> deprecated.
>
> Do you know a way around this?
>
> On Jun 23, 5:50 pm, Andy Dustman  wrote:
>> Did you make sure you completely cleaned out the build directory
>> between attempts? I.e. manually remove it. Also see (if you haven't
>> already)http://stackoverflow.com/questions/3061277/python-mysql-wrong-archite...
>>
>> I don't know exactly why it's so hard to build on Mac OS X, and I
>> wrote the package... I do know the MacPorts route works, because
>> that's why I'm using. The only thing MacPorts seems to do is change
>> the name of mysql_config to mysql_config5 (because of the way they do
>> MySQL package versioning). But with MacPorts, you end up building
>> MySQL itself for your architecture, rather than the fat binary
>> packages which mysql.com provides.
>>
>>
>>
>>
>>
>> On Thu, Jun 23, 2011 at 5:00 PM, John  wrote:
>> > O.K.  I know that there are a lot of suggestions out there for this
>> > problem, I think I have tried all of them but I am still getting the
>> > dreaded error in the subject line loading the MySQLdb module.
>>
>> > Everything was working fine, but I was having problems with a
>> > LocMemCache so I decided to upgrade from Django 1.2.3 to Django 1.3.
>> > At the same time I decided to move to Python 2.6 to Python 2.7.  This
>> > is on Mac SnowLeopard on a MacBook Pro.
>>
>> > I have tried build and install of the MySQL-python-1.2.3 connector
>> > using ARCHFLAGS="-arch i386", "-arch -686", "-arch x86-64" and "-arch
>> > x86-32".  I get the same error in all cases.  I can see that the
>> > module being loaded is the one that was built and installed in each
>> > case.
>>
>> > ALso, since it was mentioned as the reason for moving to Django 1.3,
>> > does anyone have any suggestions for solving my cache problem?  I am
>> > trying to save a rather large dictionary of financial calculation
>> > numbers to a LocMemCache.  In the debug environment it works just fine
>> > but when I deploy to an Apache http server the cache seems to get
>> > cleared between each HTTP request.  Via logging I can confirm that the
>> > object is serialized to the cache and can be immediately retrieved
>> > form the cache but the object no longer exists when the next HTTP
>> > request comes in on the same session.
>>
>> > Thank you for your asistance.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> Question the answers
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Question the answers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mach-o, but wrong architecture

2011-06-24 Thread Andy Dustman
"Safe" probably means "it won't crash".

On Fri, Jun 24, 2011 at 11:03 AM, John  wrote:
> So the documentation is incorrect?
>
> It claims that it is multi-process safe.
>
> On Jun 23, 6:53 pm, Malcolm Box  wrote:
>> Re your cacheing problem the behaviour you are seeing is exactly what would 
>> be expected using locmem cache.
>>
>> Apache is presumably running multiple processes each of which will have it's 
>> own locmem cache. Since the odds ate against two successive requests hitting 
>> the same apache process, you won't see the data in your cache.
>>
>> The simplest fix is to use memcached.
>>
>> HTH
>> Malcolm
>>
>> Sent from my iPhone, please excuse any typos
>>
>> On 23 Jun 2011, at 22:00, John  wrote:
>>
>>
>>
>> > O.K.  I know that there are a lot of suggestions out there for this
>> > problem, I think I have tried all of them but I am still getting the
>> > dreaded error in the subject line loading the MySQLdb module.
>>
>> > Everything was working fine, but I was having problems with a
>> > LocMemCache so I decided to upgrade from Django 1.2.3 to Django 1.3.
>> > At the same time I decided to move to Python 2.6 to Python 2.7.  This
>> > is on Mac SnowLeopard on a MacBook Pro.
>>
>> > I have tried build and install of the MySQL-python-1.2.3 connector
>> > using ARCHFLAGS="-arch i386", "-arch -686", "-arch x86-64" and "-arch
>> > x86-32".  I get the same error in all cases.  I can see that the
>> > module being loaded is the one that was built and installed in each
>> > case.
>>
>> > ALso, since it was mentioned as the reason for moving to Django 1.3,
>> > does anyone have any suggestions for solving my cache problem?  I am
>> > trying to save a rather large dictionary of financial calculation
>> > numbers to a LocMemCache.  In the debug environment it works just fine
>> > but when I deploy to an Apache http server the cache seems to get
>> > cleared between each HTTP request.  Via logging I can confirm that the
>> > object is serialized to the cache and can be immediately retrieved
>> > form the cache but the object no longer exists when the next HTTP
>> > request comes in on the same session.
>>
>> > Thank you for your asistance.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Question the answers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mach-o, but wrong architecture

2011-06-23 Thread Andy Dustman
Did you make sure you completely cleaned out the build directory
between attempts? I.e. manually remove it. Also see (if you haven't
already) 
http://stackoverflow.com/questions/3061277/python-mysql-wrong-architecture-error

I don't know exactly why it's so hard to build on Mac OS X, and I
wrote the package... I do know the MacPorts route works, because
that's why I'm using. The only thing MacPorts seems to do is change
the name of mysql_config to mysql_config5 (because of the way they do
MySQL package versioning). But with MacPorts, you end up building
MySQL itself for your architecture, rather than the fat binary
packages which mysql.com provides.

On Thu, Jun 23, 2011 at 5:00 PM, John  wrote:
> O.K.  I know that there are a lot of suggestions out there for this
> problem, I think I have tried all of them but I am still getting the
> dreaded error in the subject line loading the MySQLdb module.
>
> Everything was working fine, but I was having problems with a
> LocMemCache so I decided to upgrade from Django 1.2.3 to Django 1.3.
> At the same time I decided to move to Python 2.6 to Python 2.7.  This
> is on Mac SnowLeopard on a MacBook Pro.
>
> I have tried build and install of the MySQL-python-1.2.3 connector
> using ARCHFLAGS="-arch i386", "-arch -686", "-arch x86-64" and "-arch
> x86-32".  I get the same error in all cases.  I can see that the
> module being loaded is the one that was built and installed in each
> case.
>
> ALso, since it was mentioned as the reason for moving to Django 1.3,
> does anyone have any suggestions for solving my cache problem?  I am
> trying to save a rather large dictionary of financial calculation
> numbers to a LocMemCache.  In the debug environment it works just fine
> but when I deploy to an Apache http server the cache seems to get
> cleared between each HTTP request.  Via logging I can confirm that the
> object is serialized to the cache and can be immediately retrieved
> form the cache but the object no longer exists when the next HTTP
> request comes in on the same session.
>
> Thank you for your asistance.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Question the answers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Need some help with MySQL and on OSX

2011-06-06 Thread Andy Dustman
Everyone complains, but no one submits patches.

On Mon, Jun 6, 2011 at 12:54 PM, scot.hac...@gmail.com
 wrote:
>> On Monday, June 6, 2011 2:30:25 AM UTC+1, Kolbe wrote:
>>
>> > Anyone have any good documentation on getting django with MySQL on OSX
>> > out there?
>
> It really is amazing how difficult this still is. I've written two
> guides on this - one for pre-Leopard, one for post-Leopard:
>
> http://birdhouse.org/blog/2009/02/21/python-mysql-connections-on-mac-os/
> http://birdhouse.org/blog/2009/09/27/python-mysql-connections-and-snow-leopard/
>
> HTH,
> ./s
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Question the answers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Need some help with MySQL and on OSX

2011-06-06 Thread Andy Dustman
MacPorts will install it too, but you might find there are a lot of
dependencies.
On Jun 6, 2011 9:56 AM, "Ivo Brodien"  wrote:
>
>
>> MAMP. about as easy as it can get.
>> http://www.mamp.info/de/index.html
>
> But you will still need to install somehow MySQLdb and that is the main
problem.
>
> I don’t know about homebrew, but I remember that I had troubles getting
MySQLdb to work but I eventually did with the help of various blogs and
Stack Overflow posts, unfortunatelly I did not write down the steps, so good
luck. I hope homebrew is a one click solution.
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ANN: PyMySQL 0.3

2010-09-10 Thread Andy Dustman
On Sun, Sep 5, 2010 at 12:48 AM, Andy  wrote:
> Thanks Pete.
>
> I'm definitely interested in using PyMySQL for production.
>
> I'm interested in running Django in an async mode using gevent (http://
> www.gevent.org/). gevent provides a money patch that turns any Python
> code into non-blocking. The problem is that MySQLdb is written in C,
> so it'd still block, which would kinda defeat the whole purpose of
> having an async Django app if every database access is blocking.

Uh, no.

MySQLdb releases the GIL on any blocking call, so other threads can run.

Django is *not* asynchronous. It's threaded.
-- 
Question the answers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Help with installing MySQLdb package for Django on OS X Snow Leopard

2009-12-02 Thread Andy Dustman
To sum up (because I've been helping him off list too): It looks like
he had old versions of setuptools and XCode (from OS X 10.4, running
10.6). I think once XCode gets upgraded, he should be OK... assuming
MySQL is actually installed...

As for ZMySQLDA: SourceForge features the most release of any project
files, and that happens to be the latest one. I'm planning to spin off
ZMySQLDA into a separate project, because I don't work on it any more;
John EIkenberry is developing it now.

On Wed, Dec 2, 2009 at 8:13 AM, Frank DiRocco  wrote:
> James,
>
> With Snow Leo and preinstalled MySQL5 the package I'm using is here.
> http://sourceforge.net/projects/mysql-python/files/
> MySQL-python-1.2.3c1.tar.gz
>
> Direct Link: 
> http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download
>
> IMHO, source forge is a little wack these days. The UI is kinda
> convoluted, it took me a little digging before I found the file too :]
>
> -Frank
>
> On Dec 2, 2009, at 7:18 AM, James Dekker wrote:
>
>> Daniel,
>>
>> Under the Files tab, the only ones that are available are for Linux
>> not OS X Snow Leopard...
>>
>> -James
>>
>> On Wed, Dec 2, 2009 at 1:37 AM, Daniel Roseman
>>  wrote:
>>> On Dec 1, 11:23 pm, James Dekker  wrote:
>>>
 My problem, however, is that I can't seem to figure out how to
 install the MySQLdb package for Python / Django?

 Downloaded the tar.gz from:

 http://sourceforge.net/projects/mysql-python/
>>>
>>> The main 'Download Now' link from this page for some reason links to
>>> the Zope adaptor. However you can click on 'View all files' to see
>>> the
>>> actual packages for MySQLdb.
>>>
>>> Of course if you're still having problems there's no requirement to
>>> use MySQL in Django, you can just use sqlite3 which should work
>>> without any additional requirements.
>>> --
>>> DR.
>>>
>>> --
>>>
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en
>>> .
>>>
>>>
>>>
>>
>> --
>>
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en
>> .
>>
>>
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>



-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

MANDATED GOVERNMENT HEALTH WARNING:
Government mandates may be hazardous to your health.

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




BINARY columns

2009-02-16 Thread Andy Dustman

I'm working on a custom field type for Django which depends on being
able to save data in a BINARY column. (Not a big BLOB, just a couple
of bytes.) Unfortunately Django (trunk and probably 1.0) keeps trying
to turn it into unicode which fails. I'm now using patch.3.txt on
http://code.djangoproject.com/ticket/2417 and that seems to be doing
the job. What are the chances of something like this making it into
Django-1.1?
Looks like we might be past the feature freeze according to the 1.1 roadmap.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

MANDATED GOVERNMENT HEALTH WARNING:
Government mandates may be hazardous to your health.

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird get_or_create error

2007-05-09 Thread Andy Dustman

On 5/8/07, Brandon Low <[EMAIL PROTECTED]> wrote:
>
> Still not sure what's going on myself -- I've had one more occurence of
> the error, and have now confirmed that autocommit is on in the
> production application (by printing the result of select @@autocommit).
>
> It sounds quite possible that it's the immediate foreign key constraint
> check that's causing the problem, this would be fixed if I upgraded to
> 5.1?  Any other work arounds you can suggest?

5.1 looks to be the same in this respect, but if autocommit is on
somehow, then that's the most likely problem.

I vaguely remember that if you are using auto-reconnect (particularly
if you use connection.ping(True)) that autocommit is not automatically
turned off; the initial setting is controlled by option files, so
check your server default. However, I don't think that's the problem
here.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird get_or_create error

2007-05-08 Thread Andy Dustman

Not sure what is happening there. Django is not setting autocommit,
and MySQLdb disables autocommit by default. Have you actually verified
that autocommit is on when running your application?

It may also be due to the fact that MySQL (5.0 and earlier at least)
does not defer foreign key checks into the commit:

http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html

We ran into that problem when the serialization stuff was added around
PyCon. I think it would explain the behavior you are seeing when there
is a race to insert a new row.

-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why are my FloatFields strings ?

2007-05-08 Thread Andy Dustman

On 5/2/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:

> I'm going to work on that problem (putting in decimal support) this week
> sometime. Maybe today or tomorrow. It's starting to annoy me, seeing all
> the decimal-reated tickets in Trac, so after I knock off all the email
> ones (today), I want to fix up the decimal problem, in between other
> things.

Just to be clear MySQL has separate FLOAT and DECIMAL/NUMERIC column
types; the latter are fixed-point fields which correspond to Python's
Decimal type. So it is unfortunate that the Django mysql backend is
using a NUMERIC column for FloatField. Perhaps Django needs a
DecimalField (or NumericField) for fixed-point values? (You might be
working on this; haven't searched bugs.)

There's also a DOUBLE column type in MySQL for double-precision, which
may be a better fit for Python's float (which is a C double) and
Django's FloatField. MySQLdb returns FLOAT and DOUBLE columns as
Python floats so it's a matter of how much storage/precision you want.

http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird get_or_create error

2007-05-01 Thread Andy Dustman

On 5/1/07, Brandon Low <[EMAIL PROTECTED]> wrote:
>
> my model is very simple:
>
> class Referrer(models.Model):
> url = models.CharField(maxlength=255, unique=True)
>
> here is the relevent view code:
>
> referrer = request.META.get('HTTP_REFERER','-')
> r, r_new = Referrer.objects.get_or_create(url=referrer)

The only other option I can think of is that you are using a MySQL
storage engine that doesn't support transactions (or running in
autocommit mode)  and so you are getting a sort of race condition
where two requests come in about the same time, both do a SELECT and
see there is no matching row, and one gets it INSERTed first. Normally
I would expect to see the IntegrityError at the commit phase.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why are my FloatFields strings ?

2007-05-01 Thread Andy Dustman

On 5/1/07, Chris Brand <[EMAIL PROTECTED]> wrote:
>
> I've got a model that includes FloatFields as well as IntegerFields and
> CharFields.
> When I access the CharFields, I get strings. When I access the
> IntegerFields, I get integers, but when I want to use the Floatfields, I
> always have to add float() to convert the string to an actual float. Not
> that big a deal, but I always forget it first time around, and it just
> doesn't feel right.
>
> Here's a brief test :
> >>> c = Camp.objects.get(pk=1)
> >>> c.min_age
> '17.0'
> >>> a = c.min_age
> >>> type(a)
> 
>
> And here's the corresponding field definition :
> min_age = models.FloatField("Minimum age", max_digits=3,
> decimal_places=1, default=0, validator_list=[age_validator])
>
> Why is this ?
>
> I'm using 0.96 with a MySQL backend.

What version of Python are you using? I *think* FloatFields are
returned as Python Decimal objects, which don't exist before
Python-2.4, which means you would then get a string from MySQLdb. We
might need a fix for Django on Python-2.3 to work around this.

-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird get_or_create error

2007-05-01 Thread Andy Dustman

On 5/1/07, Brandon Low <[EMAIL PROTECTED]> wrote:
>
> How can a get_or_create cause an integrity constraint error?

Also... It's hard to see exactly what's going on because the code in
the traceback is using **kwargs. If you use get() or get_or_create(),
it's looking for a match on all the parameters. My guess is that there
is an additional parameter (other than that URL) which is not matched,
so it tries to create a new object, but then this violates the unique
index. The value of kwargs would go a long way towards figuring it
out.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird get_or_create error

2007-05-01 Thread Andy Dustman

On 5/1/07, Brandon Low <[EMAIL PROTECTED]> wrote:
>
> How can a get_or_create cause an integrity constraint error?

The error is on key 2, which is an additional unique index you
presumably have in your model. get_or_create should not cause
integrity errors on the primary key, but that's not what's happening
here.

>   File "/usr/lib/python2.4/site-packages/django/db/models/manager.py", line 
> 76, in get_or_create
> return self.get_query_set().get_or_create(**kwargs)
>
>   File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 
> 279, in get_or_create
> obj.save()
>
>   File "/usr/lib/python2.4/site-packages/django/db/models/base.py", line 238, 
> in save
> ','.join(placeholders)), db_values)
>
>   File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line 163, in 
> execute
> self.errorhandler(self, exc, value)
>
>   File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line 35, in 
> defaulterrorhandler
> raise errorclass, errorvalue
>
> IntegrityError: (1062, "Duplicate entry 
> 'http://images.google.de/imgres?imgurl=http://www.lostlogicx.com/' for key 2")

-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Mod_python + MySQLdb won't install ...

2007-03-21 Thread Andy Dustman

On 3/20/07, dbee <[EMAIL PROTECTED]> wrote:
>
> System: Linux 2.6.9-34.0.1.EL #1 Wed May 24 07:40:56 CDT 2006 i686
> athlon i386 GNU/Linux
> OS: CentOS
> Python: 2.3.4
> Mysql: 5.0
>
> I'm having lots of issues trying to get my django server up. It seems
> that mod_python won't work on my system.
>
> When I yum install mysql-python, the package installs fine, but I get
> this error whenever I need to import it into my python scope.
>
> >>> import MySQLdb
> ImportError: this is MySQLdb version (1, 2, 2, 'final', 0), but _mysql
> is version (1, 0, 0, 'final', 1)

You have conflicting pieces from different versions, or else this is
due in part to your build failure, when upgrading.

> When I try to build the source version of MySQLdb from sourceforge, it
> just errors with this non-descript error...
>
> error: command 'gcc' failed with exit status 1
>
> I really wasn't expecting it to take so long to get mod_python +
> MySQLdb working.
>
> Help

There is no way MySQLdb-1.0.0 is going to work with MySQL-5.0. The
oldest version that would possibly work is 1.2.0.

The gcc error you are getting indiciates... well not much, but my
guess is you are missing essential development files. Check the README
and make sure you have everything it says you need to have. You can
also build an RPM package.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MySQLdb version

2007-03-20 Thread Andy Dustman

On 3/20/07, chasfs <[EMAIL PROTECTED]> wrote:
>
> Thanks for the quick reply!  Do you know if Django has been tested
> with MySQLdb
> 1.2.2?

Yes. 1.2.2 is the best version you can get. Trust me.

> On Mar 20, 11:20 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> > On 3/20/07, chasfs <[EMAIL PROTECTED]> wrote:
> >
> > > The problem is that the MySQLdb page says that 1.2.1p2 has no changes
> > > that we should worry about.  Why is p2 required?

No changes relative to 1.2.1 that affect users using MySQL-4.1 or
newer. If you were using MySQL-4.0, 1.2.1 didn't work and you needed
1.2.1p2.

-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database introspection dies?

2007-02-28 Thread Andy Dustman

On 2/28/07, Adam Seering <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> I'm trying to introspect an old MySQL database (the old software
> that used the database was written in some nasty mix of Perl and C;
> it just bit the dust recently).  I try an inspectdb on it, and I get
> an ugly-looking stack trace.  Is 'inspectdb' expected to work?; has
> anyone recently used it on MySQL?

I just pointed it at a nagios database on a 5.0 server and it seems to
work OK.  I also tried the grant tables (mysql database) on a 4.1
server and it worked. However...

> The table that it appears to get stuck on, has fields of an
> autoincrement int pk, an enum, an int (used as a foreignkey to
> another table), a text field, and an auto timestamp field.  The final
> error is "1- isn't a valid int()" (see stack trace below); there are
> no "1-"'s in the table, unless the enum's feeding it one somehow
> (I've no idea how to check that?).  I'm assuming that means a code
> bug somewhere?; is this a known bug?; anyone know if it's in Django
> or MySQLdb (or should I go hunting)?

What version of MySQLdb is that?

In django.db.backends.mysql.introspection, try changing (in
get_table_description) "SELECT * FROM %s LIMIT 1" to "SELECT * FROM %s
LIMIT 0" and see if that helps. You might sitll have problems later on
anyway, but it will probably fix the introspection.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting HTTP header data in templates

2007-01-22 Thread Andy Dustman

On 1/22/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 1/22/07, James Bennett <[EMAIL PROTECTED]> wrote:
> > On 1/22/07, Andy Dustman <[EMAIL PROTECTED]> wrote:
> > > Here's how I made it work:
> > >
> > > Index: django/views/defaults.py
> >
> > That view uses RequestContext, so you could just add
> > 'django.core.context_processors.request' to your
> > TEMPLATE_CONTEXT_PROCESSORS setting and the full request will be made
> > available to the template.
>
> (though I think there's a good argument to be made for adding the
> referer to the context for that view, but I sent that reply too soon)

That does the trick. For future reference:

http://www.djangoproject.com/documentation/settings/#template-context-processors
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting HTTP header data in templates

2007-01-22 Thread Andy Dustman

On 1/22/07, Andy Dustman <[EMAIL PROTECTED]> wrote:
> On 1/22/07, Bo Shi <[EMAIL PROTECTED]> wrote:
> >
> > I think request.META is what you're looking for, i.e.:
> >
> >referrer = request.META.get('HTTP_REFERER', '/')
>
> I know that; I need to have access to it from a template, specifically
> my 404.html template, in a way that will work with generic views or
> get_object_or_404(). Unfortunately the 404 handler does not pass any
> of that stuff to the template as far as I can tell.

Here's how I made it work:

Index: django/views/defaults.py
===
--- django/views/defaults.py(revision 4391)
+++ django/views/defaults.py(working copy)
@@ -76,7 +76,7 @@
 The path of the requested URL (e.g., '/app/pages/bad_page/')
 """
 t = loader.get_template(template_name)
-return http.HttpResponseNotFound(t.render(RequestContext(request,
{'request_path': request.path})))
+return http.HttpResponseNotFound(t.render(RequestContext(request,
{'request_path': request.path, 'META': request.META})))

 def server_error(request, template_name='500.html'):
 """

I'd be happy to add a ticket for this; I think it's unlikely this
would cause any problem.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting HTTP header data in templates

2007-01-22 Thread Andy Dustman

On 1/22/07, Bo Shi <[EMAIL PROTECTED]> wrote:
>
> I think request.META is what you're looking for, i.e.:
>
>referrer = request.META.get('HTTP_REFERER', '/')

I know that; I need to have access to it from a template, specifically
my 404.html template, in a way that will work with generic views or
get_object_or_404(). Unfortunately the 404 handler does not pass any
of that stuff to the template as far as I can tell.

-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Getting HTTP header data in templates

2007-01-22 Thread Andy Dustman

I have a 404 page that I would like to display some of the HTTP
headers (particularly HTTP_REFERER) in so that user receiving the
error can make a usable report. Is there some way at getting at this
information in a template without having to have your view return a
HttpResponseNotFound object? I'm using get_object_or_404() but the
same problem applies with generic views.

-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What can be done about all the spam in django-users?

2007-01-19 Thread Andy Dustman


Don Arbow wrote:

On Jan 19, 2007, at 7:40 AM, LD 'Gus' Landis wrote:

> If the spam can't be stopped, the unsubscribe is the only option I
> guess, eh?



No, you go to the Google Groups web page and report the spam. In the
title of the message is a "Show Options" link, click that, then click
the "Report Abuse" link.

Google is very good at removing these messages and banning users who
send it.


Make sure you rate those messages one star, too. (No stars is unrated,
and unfortunately there is no way to rate less than one star.) Rating
up a few good messages wouldn't hurt.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: appname in admin

2007-01-05 Thread Andy Dustman


On Jan 5, 9:08 pm, "Aljosa Mohorovic" <[EMAIL PROTECTED]>
wrote:

i can't find info on how to change appname in admin interface.
example:
if i have "my_cool_app" app in project and it has admin interface
enabled it will display something like "My_cool_app" in
administration, can i make it display "My cool app description"?


You need to provide your own replacement for some admin templates,
specifically admin/base_site.html and maybe admin/base.html, depending
on what you want do do, and put them in one of your TEMPLATE_DIRS.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: >*< Free PC to PC access >*< Remote Access software >*

2006-12-21 Thread Andy Dustman


On 12/21/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:


Shabana wrote:

> [expunged]

there's no way to get google groups to simply just nuke anything that
mentions 50webs.com ?


I, for one, have been aggressively going after spammers in
django-users this morning, and I recommend everyone using the web view
spend a couple minutes doing to same. Be sure to rate messages, too.
--
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Somewhat awkward ImageField usage

2006-12-14 Thread Andy Dustman

I have this model:

class Photo(Model):

title = CharField(
maxlength = 80,
)
description = TextField()
photo = ImageField(
upload_to = "photos/%Y/%m/%d",
height_field = "H",
width_field = "W",
)
W = PositiveSmallIntegerField("Width", null=True, editable=False)
H = PositiveSmallIntegerField("Height", null=True, editable=False)

W and H are both set to null=True, because I found that if you used
the default of null=False, and created the columns as NOT NULL, you'd
get a database error upon the initial add because the columns were
being set to NULL. However, if you set them to null=True so that they
can contain NULL, they *do* get the dimensions saved to them. There
seems to be an intermediate step where the row is first inserted with
NULLs for those fields and then it is updated. The workaround is to
null=True and editable=False so that the user can't futz with these
values, but it would be better if null=False worked.

The docs (trunk) currently say about ImageField's height_field and
width_field that the referenced fields are auto-populated "each time a
model instance is saved" but that seems to not be literally true.

If this seems bug-worthy, let me know.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding a button to admin view?

2006-11-15 Thread Andy Dustman

On 10/31/06, iain duncan <[EMAIL PROTECTED]> wrote:
>
> Hi folks, I would like to add a custom form button to the admin
> interface somehow and am not sure how to go about it.
>
> I want to add a "download now" button the list view for some file
> entries, so it needs to be a link to file. Any idea how this should be
> done?

I'm looking to do something similar: I have an object that I'd like to
synchronize against an external database. Currently I do this with a
special view, but it would be nice to have a button in the admin view
to do this.

Currently the row of buttons is done with a {{ submit_row }} template
tag, and the admin/submit_line.html template. I suppose this template
could be overridden, but that would add the button for every object
type.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UTF8 character set problem

2006-11-01 Thread Andy Dustman

On 10/30/06, Pythoni <[EMAIL PROTECTED]> wrote:
>
> Here are MySQL settings, both on Linux and XP windows
>
>
> LINUX MySQL settings
> +--++
> | Variable_name| Value  |
> +--++
> | character_set_client | latin1 |
> | character_set_connection | latin1 |
> | character_set_database   | utf8   |
> | character_set_results| latin1 |
> | character_set_server | latin1 |
> | character_set_system | utf8   |
> | character_sets_dir   | /usr/share/mysql/charsets/ |
>
> | collation_connection | latin1_swedish_ci |
> | collation_database   | utf8_czech_ci |
> | collation_server | latin1_swedish_ci |
>
>
>
> XP Windows MySQL settings
> +--+--
> --
>
> | Variable_name| Value
>
> +--+--
> --
>
> | character_set_client | latin1
>
> | character_set_connection | latin1
>
> | character_set_database   | latin1
>
> | character_set_filesystem | binary
>
> | character_set_results| latin1
>
> | character_set_server | utf8
>
> | character_set_system | utf8
>
> | character_sets_dir   | C:\Program Files\MySQL\MySQL Server
> 5.0\share\charsets\
> +--+--
> --
> | collation_connection | latin1_swedish_ci |
> | collation_database   | latin1_swedish_ci |
> | collation_server | utf8_czech_ci |
> +--+---+

I think that collation_connection and collation_database take
precedence over collation_server, so you are really using
latin1_swedish_ci, although Django should be forcing utf8 (presumably
utf8_general_ci) when it opens the connection.

It also looks like your character set and collation settings are
different between Linux and XP.

> What command shall I use for data  exporting on Linux and what command
> on
> XP to import
> data?

Your command shown previously looked OK. Was the file transferred in
binary mode? (If that's even applicable.)
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Incompatible unicode django / mysql

2006-11-01 Thread Andy Dustman
On 11/1/06, mamcxyz <[EMAIL PROTECTED]> wrote:
>
> I having this error:
>
> OperationalError: (1267, "Illegal mix of collations
> (latin1_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for
> operation '='")
>
> When I try to run code like this:
>
> City.objects.filter(name='Medellín')
>
> I have a working site where I need to perform a data upgrade, and is
> common have this kind of city names (is a site for Colombia, in
> spanish)
>
> Never before get this problem...
>
> I use MySql 4.
>
>
> I try to do
> City.objects.filter(name='Medellín'.encode/decode('latin_1'))
>
> with not look.
>
> I search on Google and found this is a reported problem with Django but
> not understand what to do...

I assume your database is in latin1. Django tries to force utf8 if
your server version is at least 4.1. Are you using 4.0 or 4.1?

Try:

City.objects.filter(name=u'Medellín')

This ultimately passes a unicode object to  MySQLdb which should
encode it into the connection's character set encoding, which I guess
will be latin1.

BTW, what version of MySQLdb are you using?
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Still really struggling with JOINS

2006-10-27 Thread Andy Dustman

On 10/27/06, Tom Smith <[EMAIL PROTECTED]> wrote:

> Is there a way to do a complete dump, re-build the database and then
> import stuff (avoiding import errors... i.e doing some form of
> coercion)?

Use mysqldump with the --no-create-info option which avoids dumping
the table schemas. Drop the databse, use Django's syncdb to create the
tables, and then reload from your mysqldump output. If you hvae
deleted or renamed columns, this could be a problem. You should also
have a complete dump as a backup.

Another thing is to compare the output of Django's sqlall with the
output of mysqldump --no-data (dumps all table schema).

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: How to make tables generated by Django be utf8 encoded by default?

2006-10-27 Thread Andy Dustman

On 10/25/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I want to store Chinese characters in my MySQL 4.1.11 through Django
> but unluckily, like most novices, I get totally mess characters when
> displaying them on utf-8 encoded templates.
> After some investigation I found that the tables created by 'manage
> syncdb' are actually encoded by 'latin-1'. After changing the character
> set manually(using the 'alter table xxx convert to character set
> 'utf8''), the characters were finely displayed:-)
>
> So, do I have to change my table encoding manually every time after
> performing 'manage syncdb'? That must be very painful:(

A couple options:

In your MySQL server configuration, you can set default-character-set
= utf8 and then this will be used for your connection any any tables
you create.

Another option is to set the default character set on the database
with CREATE DATABASE xxx CHARACTER SET UTF8.

http://dev.mysql.com/doc/refman/5.0/en/alter-database.html

You want to do this prior to creating tables, of course. ALTER
DATABASE can be uased to set the default on an existing database, but
doesn't affect existing tables.
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django and Media Temple Grid Server

2006-10-18 Thread Andy Dustman

http://news.netcraft.com/archives/2006/10/17/price_competition_emerges_in_grid_hosting.html

This article from Netcraft focuses primarily on Media Temple (who I
never heard of before this discussion) and lists some competitors.

All-in-all, MT's software selections are somewhat conservative, at
best, and dated, at worst, but this is probably due to OS selection as
mentioned. Their FAQ specifically mentions Django and encourages
people to ask for it if they want it:

http://www.mediatemple.net/webhosting/gs/faq/lamp_stack-faq.htm

If I had to go out tomorrow and set up a hosted site, I'd go with
linode.com, which sells virtual servers via User-Mode Linux (UML), so
you get full control (i.e. root); and I'd go with Ubuntu 6.06 LAMP
server (several other distros to choose from), simply because it is
quick and pretty modern. I like Gentoo a lot, but I don't think a
source-based distro makes sense in a virtual server; their base
package only provides a 100 MHz slice of a dual-3.2 GHz Xeon (you can
burst to full CPU, however, with <40:1 contention). I haven't
personally used linode.com, but I know someone who has for a couple
years and loves it.

(Yeah, it's not grid computing, but it's another option.)

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: What IDE do you use? (semi-OT)

2006-10-10 Thread Andy Dustman

On 10/8/06, Serg Kovrov <[EMAIL PROTECTED]> wrote:

> I'd like to know what editor/IDE Django users (and developers) uses on
> daily basis, to boost development process. And why exactly - what
> features you find useful, how it helps you to save time (or just makes
> coding enjoyable, which probably increase productivity as well). Kind
> of best practices in terms of tools.

Generally, Emacs for projects. Python syntax and Subversion support
are what I primarily care about, and Emacs handles those well.
Sometimes for quick edits, if I'm not already in emacs, I'll use vim.
I've used WingIDE for working on MySQLdb, and some of the code
completion features are nice, but I've never actually used it with a
Django project. One of my gripes about WingIDE is, although it's good
for Python and C code, it doesn't really have a good mode for
ReStructured Text.

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ForeignKey field with null = True and blank = True

2006-10-05 Thread Andy Dustman

On 10/4/06, Seemant Kulleen <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> Now I'm at ForeignKey funkiness.  So I have the Services model which
> has a ForeignKey field to the Sermon model.  The funny thing is that
> if I choose a sermon object when I first create a new service object,
> all is well.  If, on the other hand, I don't choose one, then it turns
> out that I can never choose one.  That is to say, I can choose one,
> and hit save and when I come back in it's unchosen.  Happens every
> single time.  I've attached the services/models.py and
> sermons/models.py if that helps.

I've got a similar model arrangement:

instructor = ForeignKey(
Person,
limit_choices_to = dict(user__groups__name__in=['Instructors']),
null = True,
blank = True,
)

and I can change instructor from chosen to unchosen and vice versa
without any problem. I'm using a recent SVN trunk version of Django
with a MySQL backend. Have you altered your model since creating the
table? You may want to compare the output of manage.py sqlall with our
actual table schema.  Maybe your table schema has that column set NOT
NULL or something, but I would expect an error in that case.

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Relevance

2006-10-04 Thread Andy Dustman

On 10/4/06, Beau Hartshorne <[EMAIL PROTECTED]> wrote:
>
> On 4-Oct-06, at 6:12 PM, Andy Dustman wrote:
>
> > I'm not sure this will fix your problem, but it might from my reading
> > of the code. Try reversing the order of the filter() and extra()
> > methods, i.e.
> >
> > qs = Place.objects.all().extra(select={'relevance': match_expr},
> > params=[query]).filter(name__search=query)
>
> That doesn't seem to fix it for me. The problem seems to be that the
> code strips all of the column names when it does the SELECT COUNT(*),
> but doesn't strip the parameters from the list it passes to execute
> (). It breaks even without any other filters.
>
> A simpler example might be something like:
>
>  >>> qs = Place.objects.all().extra(select={'hello': '%s'}, params=
> ['world',])
>  >>> qs.count()
> Traceback (most recent call last):
>File "", line 1, in ?
>File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/
> query.py", line 202, in count
>  cursor.execute("SELECT COUNT(*)" + sql, params)
>File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/Django-0.95-py2.4.egg/django/db/backends/
> util.py", line 19, in execute
>  self.db.queries.append({
> TypeError: not all arguments converted during string formatting

Oh, *that's* interesting. It's not really execution of the query
that's causing the problem but the debug code that retains all
executed queries. Although the execution could be raising the same
exception: The part we are seeing above is in a finally clause. You
may have to examine your local variables in that last frame to see
what the values of sql and params are, and that may make the problem
more obvious. Use the little triangle on the left to open it up;
apparently it's not completely obvious to everyone that they do
something.

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Support for static content?

2006-10-04 Thread Andy Dustman

On 10/4/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> Django's database-centric approach seems to make certain kinds of
> mostly-static sites harder to build.  For example, most of what I want
> to put on my site is probably going to come from RestructuredText
> source, but that source isn't going to change in response to user
> interaction.  Yes, I could set up a ReST_page model and store the text
> in the database, but that has some real disadvantages as compared with
> keeping the content in my SVN repository along with the rest of the
> code, css, images, and other elements that are not going to be changed
> by user interaction: it gets harder to keep track of what I've done to
> the site, test changes on a beta site before they go live, etc.  I
> need a clean separation between the data that is changed by
> interacting with apps and data that isn't.
>
> Yes, Django is a framework, so I could build components that make this
> possible, but it seems to me that it should be a fundamental, built-in
> part of the system.  Has anyone already addressed these issues?

I've done a site using Apache 2.0 plus mod_python and mod_rewrite such
that most of the site (particularly the root) goes into Plone (via
mod_rewrite with proxying) but selected top-level directories are
either short-circuited out into local files or else directed into
other things like Trac or Django, i.e.


SetHandler python-program
PythonPath "['/usr/local/lib/django'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE MYAPP.settings


You may only need the above section, but I have some rewrite rules after this:

RewriteRule ^/(foo|bar|baz)/ - [L]
RewriteRule ^/(.*)
http://localhost:8001/VirtualHostBase/http/sitename:80/VirtualHostRoot/$1
[P,L]

The first rule prevents any further rewriting on directories that
should be handled by Django via mod_python. The second rule proxies
everything else to a local Zope server.

You can either take the approach that only a few directories get sent
to Django and the rest are local static files, or else say that just a
few are static files and everything else is handled by Django,
depending on your site layout.

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Relevance

2006-10-04 Thread Andy Dustman

On 9/15/06, mrstone <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I'm fiddling around with MySQL fulltext search and run into a problem.
>
> Using the below code works:
>
> match_expr = "MATCH(name) AGAINST (%s IN BOOLEAN MODE)"
> qs =
> Place.objects.all().filter(name__search=query).extra(select={'relevance':
> match_expr}, params=[query])
>
>
> But when calling qs.count() I get:
> TypeError at /
> not all arguments converted during string formatting
>
> Is this a bug or am I using the extra in a wrong way?

I'm not sure this will fix your problem, but it might from my reading
of the code. Try reversing the order of the filter() and extra()
methods, i.e.

qs = Place.objects.all().extra(select={'relevance': match_expr},
params=[query]).filter(name__search=query)

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Anal not Analog, Analysis: DB Question

2006-10-04 Thread Andy Dustman

On 10/4/06, Tom Smith <[EMAIL PROTECTED]> wrote:
>
> If I am looking for titles like "Anal Sex" or "Being Anal" then how
> do I construct this, ahem, query... to not return "Analysis" or
> "Analog"?

Two options: If your database supports it, try a full-text search:

object_list = Products.objects.filter(title__search=word)

Another option: MySQL at least has a REGEX search. To use it:

object_list = Products.objects.extra(where=["title REGEX %s"],
params=[r"\b%s\b" % word])

Above is untested in Django, but it should be what you want. \b
matches word boundaries.

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ManyToManyFields are not syncdb'able

2006-10-02 Thread Andy Dustman

On 10/2/06, seemant <[EMAIL PROTECTED]> wrote:
>
> Andy,
>
> This certainly gets me past the syncdb, so thanks!  However, when I try
> to add a service, I get this (note that I have not yet added people or
> roles, I wanted to try adding them using the + in the service tab):
>
> TypeError at /admin/services/service/add/
> Cannot resolve keyword ' name' into field
> Request Method: GET
> Request URL:http://localhost:8000/admin/services/service/add/
> Exception Type: TypeError
> Exception Value:Cannot resolve keyword ' name' into field
> Exception Location:
> /usr/lib/python2.4/site-packages/django/db/models/query.py in
> lookup_inner, line 835

Looks like there is a space in there that shouldn't be there, thus '
name'; can't be sure without code...
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ManyToManyFields are not syncdb'able

2006-10-02 Thread Andy Dustman

On 10/2/06, seemant <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm sorry about that.  All the ManyToManyFields have this sorta thing:
>
> LEM = models.ManyToManyField (
> Person,
> related_name = 'LEM',
> filter_interface = models.HORIZONTAL,
> limit_choices_to = { 'role__pk': Role.objects.get(name =
> 'LEM').id},
> )

Try this instead:

LEM = models.ManyToManyField (
Person,
related_name = 'LEM',
filter_interface = models.HORIZONTAL,
limit_choices_to = { 'role__name': 'LEM' },
)


-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ManyToManyFields are not syncdb'able

2006-10-02 Thread Andy Dustman

On 10/2/06, Seemant Kulleen <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> I've attached two files: people/models.py and services/models.py.  I
> have two many-to-many relationships defined: one is between people and
> roles (each person can fill many roles, and each role can be filled by
> many people); and one is between each activity in the service (banner
> bearer, crucifer, and so on) and people (each activity can be performed
> by many people in a specific role and each person can perform many
> activities).  Chris Long and tomaw helped me come up with appropriate
> "limit_choices_to" constructs in the services/models.py to restrict each
> activity to specific roles -- so that in the admin etc, only specific
> people are presented as choices for each activity.  Now, when I run
> python manage.py syncdb (with sqlite3 and postgresql both), I get the
> following error:

Your models did not include the limit_choices_to parameters, so it's
hard to say. However, you should probably have something like this:

limit_choices_to = dict(role__name="Priest"), # or whatever
limit_choices_to = {'role__name': "Priest"}, # if you prefer dict literals

Since your error was complaining about "people_role" not existing, I
suspect you had one underscore separating "role" and "name" and not
two, which indicates a join. I've done something very similar to the
about with Groups.
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Unknown column error when I add a field

2006-09-25 Thread Andy Dustman
On 9/20/06, Tool69 <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I'm totally new to django, I've made a little blog application and my
> original template is like this one:
>
> class News(models.Model):
> title = models.CharField(maxlength=255, verbose_name="Titre du
> billet")
> text = models.TextField(verbose_name="Contenu")
> keywords = models.CharField(maxlength=255, verbose_name="Mots
> clés")
> date = models.DateTimeField(verbose_name="Date de publication")
> etc.
>
> All is getting well but now (runnin it with MySQL on WebFaction), I
> wanted to stick an image with each post, so I added that field to my
> News class :
>
> post_image = models.ImageField(upload_to='entetes/', blank=True,
> help_text="Doit etre de 300px de large")
>
> But now, I received an error message saying :
> (1054, "Unknown column 'news_news.supplementary_image' in 'field
> list'")
>
> What's going wrong ?

You'll need to hand-update your table schema. If you run:

./manage.py sql appname

it willl print the new schema. Then you can run:

./manage.py dbshell

and then do:

alter table news.news add [new column definition goes here];

Alternatively, you can dump that table, DROP it, use manage.py syncdb
to re-create it, and then reload the dumped table (minus schema). I
usually use alter table.

I think there are plans to have Django modify existing schemas when
the models change, but it's not implemented yet.
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Request for 'transaction' disambiguation

2006-09-13 Thread Andy Dustman

On 9/13/06, Hawkeye <[EMAIL PROTECTED]> wrote:
>
> Nevermind...
>
> Looks like Django defaults to the default MySQL table type (MyISAM),
> which doesn't support transactions.
>
> My fault completely.

You can change the default table type in your MySQL server
configuration (/etc/mysql/my.cnf). You should probably also consider
changing your default character set (Django seems to prefer UTF-8).

[mysqld]
character-set-server= utf8
default-character-set   = utf8
default-table-type  = innodb

You can also set the default character set on your database after you
create it but before creating tables.
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Uploading Files

2006-09-08 Thread Andy Dustman

On 9/8/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> how can I upload file to /media/images/1.jpg with Django?

Start here:

http://www.djangoproject.com/documentation/model_api/#imagefield

If the admin interface is sufficient for you, you're done. Note that
this requires an object/row per image.
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Crappy filename validator

2006-09-07 Thread Andy Dustman

The model docs strongly suggest validating all filenames of uploaded
files for security reasons, so I wrote a validator that could be used
for this, but it's not pretty:

class filenameEndsWith(object):

def __init__(self, choices=[], error_message=None):
if not choices:
raise TypeError, "at least one ending must be specified"
self.choices = choices
self.error_message = error_message or "The file must be one of
these types: %s" % \
 (', '.join([ "%s (%s)" % (name, end)
  for end, name in choices ]))

def __call__(self, field_data, all_data):
if isinstance(field_data, str):
filename = field_data
else:
filename = field_data['filename']
for end, name in self.choices:
if filename.endswith(end):
return
raise ValidationError, self.error_message

Then you use it like this:

class Foo(Model):

FILETYPES = (
( '.doc', 'Microsoft Word' ),
( '.pdf', 'Adobe PDF' ),
( '.txt', 'Plain Text' ),
)
content = FileField(
upload_to = "foo/%Y/%m/",
validator_list = [
filenameEndsWith(choices=FILETYPES),
]
)

The ugly part of this is in the __call__() method: When uploading a
new file, field_data is a dictionary of values, and you have to check
field_data['filename']. When just editing an existing entry without
uploading a new file, field_data is a string.

It works, but is there a better way to do this?
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ReferenceError

2006-09-04 Thread Andy Dustman

On 9/3/06, Lorenzo <[EMAIL PROTECTED]> wrote:
>
>
> Andy Dustman wrote:
>
> > What versions of MySQL and MySQLdb/MySQL-python are you using?
>
>
> mysql  Ver 14.12 Distrib 5.0.22
> mysql-python 1.2.1_p2
>
> So it could be caused by mysql/mysql-py, not django?

Maybe. I'd need to see a traceback to figure that out.

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ReferenceError

2006-09-02 Thread Andy Dustman

On 9/2/06, Lorenzo <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I'm updating an application created with Django 0.91 a few months ago.
> I'm writing an external application that fills the db, using django as
> an ORM.
> Sometimes I get a strange ReferenceError, I think caused by a
> concurrency issue with the MySql layer (it is a multithreaded
> application).
>
> Is there any patch to solve this issue (what about this one
> http://code.djangoproject.com/changeset/3379) ? May be switching to
> django0.95?

What versions of MySQL and MySQLdb/MySQL-python are you using?
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Filtering by groups.

2006-09-01 Thread Andy Dustman

On 9/1/06, Gabriel Puliatti <[EMAIL PROTECTED]> wrote:
>
> Hello. I have an application in which a list should be filtered
> depending on what groups a user belongs, since the application is a
> homework list, and the list must only contain the classes the user
> (student) is enrolled.
>
> I know I should do this using filter, but I have no idea how to get
> the list of groups the current, logged in user is a member of, and
> then making that into a filter. Anyone have any tips?
>
> -
> def index(request):
> object_list = Homework.objects.order_by('-duedate')[:100]
> t = loader.get_template('homework/homework_list.html')
> c = Context
> 'object_list': object_list,
> })
> return HttpResponse(t.render(c))
> -
>
> This is the relevant function, in which the latest 100 homework
> entries are passed and then rendered by a template.
>
> If anyone has any tips on how to do this filtering by user group, then
> please do. Help is much appreciated at this point, considering I am a
> newbie. :P

You must have some sort of relation set up between Homework and User
and/or Group, don't you? So it will likely be something like
request.user.homework_set.all().order_by("-duedate"), unless you set a
related_name on your ForeignKeyField or ManyToManyField.

Or, if you are relating Homework to Group, then you might want
something like request.user.groups.homework_set.all().order_by("-duedate")

(It's late, I haven't sanity-checked the above.)
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: django cannot connect to mysql after upgrade

2006-08-31 Thread Andy Dustman

MySQL-5.0.24 accidentally introduced an ABI-incompatibilty, which
caused the "Commands out of sync" error; MySQL-5.0.24a fixes this.

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



MySQL backend patch

2006-08-31 Thread Andy Dustman

I've come up with a patch to the MySQL backend. If you use MySQL,
please check it out.

http://code.djangoproject.com/ticket/2635

One of the issues to resolve is: What is the minimum version of MySQL
which Django should support? I am doing all my development with 5.0,
and the early deployment I have so far is on 4.1, but I haven't tested
the patch against 4.1 yet.  Does anyone use anything older than 4.1?
Should this be a MySQL-5.0-specific backend and the existing one left
alone, i.e. make this one mysql5? Please discuss on this thread.

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: problems with unicode in website

2006-08-27 Thread Andy Dustman

On 8/26/06, Eugene Pyvovarov <[EMAIL PROTECTED]> wrote:
>
> thanks. when i change collation to utf8_unicode_ci; - all begin to work
> fine.

MySQLdb-1.2.2b1 is up on Sourceforge, and it should also fix this even
for the binary collation case, plus some other bugs. You should also
be able to install it with ez_setup.py, but it is not on many mirrors
yet, so the download may fail (failing for me at least).
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: problems with unicode in website

2006-08-26 Thread Andy Dustman

On 8/26/06, Eugene Pyvovarov <[EMAIL PROTECTED]> wrote:
>
> hello everybody. I'm new in django... just want to create base apps
> from tutorial on djangoproject website.
> I am using mysql 4.1 and python 2.4, django from svn
> When I create database in iso-8859-1 - all stuff working good, but when
> I befin to do the same website and making my database in utf-8 encoding
> - I have folowing errors, when I want to authorize in the system as
> admin:
>
> Inherite view http://paste.e-scribe.com/1334/
> Copy\paste view: http://paste.e-scribe.com/1335/
>
> please help me..

You apparently have a binary collation, which causes MySQLdb to return
text-like columns as arrays of characters. There are enough use cases
that this breaks that I'm going to fix it in MySQLdb-1.2.2 (beta
perhaps this weekend). In a nutshell, binary collations make character
columns (CHAR, VARCHAR, TEXT) come back as arrays. I'm going to change
this so they come back as normal strings. Non-binary collations will
cause  them to be returned as unicode strings if use_unicode=True;
otherwise they will also be strings.
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



question = Q() | -Q()

2006-08-24 Thread Andy Dustman

I had been hunting around for some way to do negation in queries, and
found QNot, though it is undocumented and not exported with Q. I
though this was a little bit clumsy, so here's a patch to add unary
negation to Q objects:

Index: django/db/models/query.py
===
--- django/db/models/query.py   (revision 3656)
+++ django/db/models/query.py   (working copy)
@@ -618,6 +618,9 @@
 def __or__(self, other):
 return QOr(self, other)

+def __neg__(self):
+return QNot(self)
+
 def get_sql(self, opts):
 return parse_lookup(self.kwargs.items(), opts)

Eventually I found .exclude() which should do what I want for some
cases, but I think for more complex queriers (i.e. where you don't
want to negate the entire expression), I think it is a little cleaner
to write -Q () instead of QNot(), especially if QNot is buried. Then
again, it may be buried deliberately.

`-`would not be my first choice for something that does logical
negation, but it seems like it's either that or `~` (__invert__,
bit-wise negation operator).

-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Pope Guido blesses Django

2006-08-18 Thread Andy Dustman

http://pyre.third-bit.com/blog/archives/613.html (found via
http://del.icio.us/holovarty)

"""Guido just pronounced: Django is *the* web framework

* Won't be part of the core, but will be as "standard" as PIL or NumPy
* This was not what I expected the outcome of my talk would be,
but hey, I'll take it ;-)
* He hopes that Django and TurboGears will converge
"""
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: search in django

2006-08-18 Thread Andy Dustman

On 8/18/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 8/18/06, Matthew Flanagan <[EMAIL PROTECTED]> wrote:
> > Why not use the same suffix syntax (or subset thereof) for other
> > django queries ie. __istartswith, __iexact, etc, instead of creating a
> > new one?
>
> This is a valid point. One small argument in favor of the current
> syntax is that search_fields accepts "auto joins," such as
> "person__first_name", and allowing the double-underscore lookup types
> *might* conflict with that (but possibly not). Something just "feels
> right" about the current implementation, anyway -- it's nice and
> short. But I really don't feel strongly either way.

I was going to say it's a valid point, too. Here's why it is the way
it is: When I originally thought about it, I was really only
interested in getting a startswith match, and the way to do that with
regular expressions is with a `^` at the beginning. Then I was going
through the list of searches, and thought exact would be a good one to
have, and `=` was fairly intuitive. Then I found search. [EMAIL PROTECTED] 
seemed
like a decent fit. The other reason I thought prefix operators were a
good idea was that they were already in use somewhat for the Admin
interface, i.e. `-` in ordering. I hadn't even thought about the auto
joins (wasn't really aware of the double-underscore part, I think I
tried single-underscore before).
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: search in django

2006-08-17 Thread Andy Dustman

On 8/16/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 8/15/06, Andy Dustman <[EMAIL PROTECTED]> wrote:
> > In fact, it does LIKE %string%, which is quite expensive. Usually want
> > I want out of an admin search is a startswith match, i.e. LIKE
> > string%, which can use an index. Unfortunately there doesn't seem to
> > be a way to do this yet. Maybe something like this:
> >
> > class Admin:
> >
> > search_fields = ["^last_name", "^first_name", "summary"]
> >
> > where a field name starting with ^ means to match the beginning. Looks
> > like this could be done with a couple lines in
> > django.contrib.admin.views.main.ChangeList.get_query_set()
>
> That's a really nice idea, Andy! We would most certainly add that in,
> if you wrote a patch.

http://code.djangoproject.com/ticket/2559

Implements ^ (istartswith), = (iexact), and @ (search). No prefix is
icontains (current behavior).
-- 
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: search in django

2006-08-15 Thread Andy Dustman

On 8/15/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Data in the database is searched by LIKE (or ILIKE) SQL command which
> is wrapped in Django ORM. If you need fulltext search engine you can
> use MySQL which has such feature (you need to user raw SQL for it),
> postgresql needs some addons for it.

In fact, it does LIKE %string%, which is quite expensive. Usually want
I want out of an admin search is a startswith match, i.e. LIKE
string%, which can use an index. Unfortunately there doesn't seem to
be a way to do this yet. Maybe something like this:

class Admin:

search_fields = ["^last_name", "^first_name", "summary"]

where a field name starting with ^ means to match the beginning. Looks
like this could be done with a couple lines in
django.contrib.admin.views.main.ChangeList.get_query_set()
-- 
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: MySQL UnicodeEncodeError

2006-08-08 Thread Andy Dustman

On 8/7/06, Niran Babalola <[EMAIL PROTECTED]> wrote:
>
> "UnicodeEncodeError: 'latin-1' codec can't encode characters in
> position 75-76: ordinal not in range(256)"

This indicates your default database connection character set is
latin1. You can change this in your server configuration, or you can
change it as a connect(charset="utf8") option in MySQLdb-1.2.1. Most
likely you'll have to hack on django.db.backends.mysql.base to set it
with the client.
-- 
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django vs. Rails vs. Symfony: Django is fastest

2006-07-14 Thread Andy Dustman

On 7/14/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
> On Jul 14, 2006, at 1:18 PM, Adrian Holovaty wrote:
> > Some folks benchmarked Symfony, Ruby on Rails and Django. Django was
> > the fastest.
>
> By over 30% -- hell yeah!
>
> Now, I've always known in my gut that Django's pretty damn fast, but
> seeing it verified by the RoR website...
>
> Priceless :)

And with MySQL, to boot.
-- 
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin connection mysql problem

2006-06-27 Thread Andy Dustman

On 6/26/06, Patrick <[EMAIL PROTECTED]> wrote:

>   File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 151, 
> in __init__
> self.converter[types.StringType] = string_literal
>
> TypeError: object does not support item assignment

I don't really know what the actual cause is, and I've seen this
reported several times, but if you are getting this, something is
probably botched with your MySQLdb installation. I recommend using
version 1.2.1, particularly if you are using MySQL-4.1 or newer (a
must-have for MySQL-5.0 or newer).

If you are manually installing MySQLdb (a.k.a.  MySQL-python), be sure
you remove all traces of the 1.2.0 installation before installing
1.2.1; otherwise you will have a mysterious import error involving the
sets module. If you are using some sort of package management system,
this is not likely to be an issue, as it should remove obsolete files
automatically.

This isn't actually a Django issue, so if you still have problems,
follow-up in the help forum over at
http://sourceforge.net/projects/mysql-python
(http://sourceforge.net/forum/forum.php?forum_id=70461). (Don't file a
bug; it's a problem with your installation.)
-- 
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: error in your SQL syntax near '(DATE_FORMAT... on adding date_hierarchy = 'pub_date'

2006-06-13 Thread Andy Dustman

On 6/12/06, Matt McClure <[EMAIL PROTECTED]> wrote:
>
> I received in a private email:
> > Hello Matthew,
> >
> > I'm seeing the exact same "date_hierarchy" problem and was wondering
> > if you received a solution offline and/or figured it out.
> >
> > Seems like the problem is somewhere among my Python 2.3.3, MySQLdb
> > 1.2.1 and the MySQL 3.23.53, 'cause I've got a Python 2.4.3, MySQLdb
> > 1.2.1 and MySQL 4.0.26-standard setup where the "date_hierarchy" in
> > models.py works just fine.
> >
> > Regards, John Eugene, Ore.
>
> I haven't found an answer to my question.
>
> FWIW, here are my versions:
>
> [EMAIL PROTECTED] ~]$ rpm -qf
> /usr/lib/python2.3/site-packages/MySQLdb/sets.py
> MySQL-python-0.9.2-4
> [EMAIL PROTECTED] ~]$ rpm -q python
> python-2.3.4-13.1
> [EMAIL PROTECTED] ~]$ rpm -q mysql
> mysql-3.23.58-16.FC3.1
>
> If I had to take a guess, I'd say that MySQL was probably changed
> between 3.23 and 4.0.26  to accept the syntax Django is using.  But
> that's only a naive guess.

Your original error was: "You have an error in your SQL syntax near
'(DATE_FORMAT(`polls_poll`.`pub_date`, '%Y-01-01 00:00:00') AS
DATETIME) FROM `p' at line 1"  I'm going to guess that the bit before
the leading parenthesis is "CAST", and CAST() does not exist prior to
MySQL-4.0.

http://dev.mysql.com/doc/refman/4.1/en/cast-functions.html

Solution: I recommend MySQL-4.1 or newer with MySQL-python-1.2.1.
-- 
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: How to debug MySQLdb issues

2006-06-09 Thread Andy Dustman

On 6/9/06, tomass <[EMAIL PROTECTED]> wrote:

> I have been testing on an Ubuntu desktop and my app works fine, but
> I've now migrated it to Fedora Core 3 where it will be in production
> and I'm having problems. I think the problem is related to the fact
> that I have custom RPMs for MySQL (using the 5.0 ones for RHEL3 from
> MySQL's website), but am using the generic MySQL-python RPM for FC3.

Ubuntu used MySQL-4.1 on breezy and now uses 5.0 on dapper. I'm pretty
sure dapper has MySQL-python-1.2.1, which is the only version which
really works with MySQL-5.0. MySQL-python on FC3 is probably 1.2.0 and
linked against MySQL-4.0 client libraries. I'd recommened getting the
MySQL-python-1.2.1 source tarball and buliding an RPM from that
against your MySQL-5.0 installation on FC3.
-- 
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: mysqldb error

2006-05-30 Thread Andy Dustman

On 5/28/06, Thn <[EMAIL PROTECTED]> wrote:
>
> Hi all - I'm using the latest code (rev 2997).
> Otherwise it's mod_python 1.10 / apache2 / python2.3 / mysql 5.0.21 /
> MySQLdb 2.0 -- all installed from Debian packages.

You must be a time-traveller if you have MySQLdb-2.0 installed; 1.2.1
is the latest version. 1.2.0 does not have complete MySQL-5.0 support,
or at least there are issues, so you should try to get 1.2.1.
-- 
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Time delta problem

2006-05-09 Thread Andy Dustman

On 5/8/06, George Sakkis <[EMAIL PROTECTED]> wrote:
>
> I posted this in MySQLdb's tracker but it seems it has to do with
> Django. I have a view with one field being a time difference, computed
> as sec_to_time(unix_timestamp(end)-unix_timestamp(start)). MySQL
> specifies that the return type is TIME, whose values may range from
> '-838:59:59' to '838:59:59'
> (http://dev.mysql.com/doc/refman/5.0/en/time.html) so that it can
> represent time intervals greater than 24 hours or even negative. When I
> run a query on the view through a Django app, I get a ValueError "hour
> must be in 0..23". Is there a way to go around this ?

In a nutshell, MySQL's TIME column corresponds to Python's
datetime.timedelta, i.e. it's a time interval, so that's what MySQLdb
uses. Django's TimeField, OTOH, is a time-of-day field, so it uses
Python's datetime.time. I'm not really sure what the correct fix is
here; suggestions are welcome.

--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: [MySQLdb] Could not load database backend: cannot import name ImmutableSet.

2006-05-09 Thread Andy Dustman

On 5/8/06, Paulo <[EMAIL PROTECTED]> wrote:
>
> Thanks for the tip! I will check it out when I get home this evening.
> I'll keep my fingers crossed that this will help me get django
> going... I've been wanting to start playing with Django for an
> upcoming project but am not a sys admin and can't get my box setup.
> *bangs head against the wall*
>
> I basically followed the instructions at <
> http://sourceforge.net/docman/display_doc.php?docid=32072&group_id=22307#building-and-installing
> > to build the latest version of MySQLdb.

That particular page is really just the README. The README in the
source distribution may be slightly more up-to-date.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: [MySQLdb] Could not load database backend: cannot import name ImmutableSet.

2006-05-08 Thread Andy Dustman

On 5/6/06, Paulo <[EMAIL PROTECTED]> wrote:

> 4. "python manage.py runserver" and "python manage.py init" start
> throwing errors
> -- my MYSQL DB is setup
> -- settings.py has the correct db info entered
>
> "python manage.py runserver" gives me quite a few errors:
> "bash-3.00$ python manage.py runserver
> Validating models...
> Unhandled exception in thread started by  0xb7c1b3ac>
> Traceback (most recent call last):
> ...
> django.core.exceptions.ImproperlyConfigured: Could not load database
> backend: cannot import name ImmutableSet. Is your DATABASE_ENGINE
> setting (currently, 'mysql') spelled correctly? Available options are:
> 'ado_mssql', 'mysql', 'postgresql', 'sqlite3'"

Have you upgraded from MySQLdb-1.2.0 to 1.2.1(_p2)? If so, 1.2.0 had
it's own sets module, which became redundant after Python-2.3, so it
is removed in 1.2.1. However if you have upgraded, it's likely still
lying around in /usr/lib/python2.3/site-packages/MySQLdb/sets.py*.
Remove the old sets module and you should be OK.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: auto_now_add bug with MySQL

2006-05-08 Thread Andy Dustman
On 5/5/06, Petar Mariæ <[EMAIL PROTECTED]> wrote:
> class Paper(models.Model):
> # ...
> submited_on = models.DateField(
> auto_now_add=True,
> )
> # ...
>
> The above will spit out:
> Exception Type: ValueError
> Exception Value:year is out of range
> Exception Location:
> C:\Dev\Python24\lib\site-packages\MySQLdb\connections.py in
> defaulterrorhandler, line 33
>
> The saved value of submited_on for the corresponding Paper is
> '-00-00' which is horribly wrong ;)
>
> I'm using MySQL 4.1.12a-nt and freshly baked django svn copy

Try the patch on this bug:

http://code.djangoproject.com/ticket/1584
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Install woes: error "python: can't open file 'django-admin.py' "

2006-05-05 Thread Andy Dustman

On 5/4/06, jbrewer <[EMAIL PROTECTED]> wrote:
>
> I have tried to install the MySQLdb and keep getting this error:
>
> error: command 'gcc' failed with exit status 1
>
> at the end of a bunch of stuff.

Yeah, that "bunch of stuff" just might be important. ya know. Keep in
mind you also would need MySQL installed, and that mysql_config must
be on your default PATH before building MySQLdb. Once you do that, it
seems to build correctly on Mac OS X.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: MySQL Query cache hits stay zero

2006-04-20 Thread Andy Dustman

On 4/20/06, Andy Dustman <[EMAIL PROTECTED]> wrote:
> I've reopened that bug, but I am very skeptical that anything in
> MySQLdb can be causing it.

And I'm probably right, since it seems he is using MySQL-4.0 which,
while it does have the query cache, it is disabled for transactions on
InnoDB. 4.1 and newer query cache supports transactions.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: MySQL Query cache hits stay zero

2006-04-20 Thread Andy Dustman

On 4/20/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 4/20/06, Beegee <[EMAIL PROTECTED]> wrote:
> > No, then it also doesn't work. When I repeat the following query:
> >
> > cursor.execute('select * from wifidog_businesses limit 10')
> >
> > using MySQLdb the number of Cache hits do not increase. However, the
> > number of Qcache_queries_in_cache also do not increase. Strange.
> >
> > I did find an issue on the MySQL for Python Sourceforge website that
> > seems to be describing the exact same issue:
>
> Ah, so it's a MySQLdb issue -- good to know. Andy Dustman, who's
> involved in maintaining MySQLdb, hangs out on the Django mailing list,
> so he might be able to shed more light on the issue.

I've reopened that bug, but I am very skeptical that anything in
MySQLdb can be causing it. All the caching logic happens on the server
side, and the only thing the client is required to do is to send the
exact (byte-for-byte) same query, and have query_cache_type (either
for SESSION or GLOBAL) set to 1, or else set query_cache_type to 2 and
use SELECT SQL_CACHE. For Django you'd want the former. Plus, updating
the tables used by the query invalidates the cache, but it doesn't
sound like you're doing that, or at least not in your example.

Do statements generated by Django have columns in a deterministic order?

--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Problem with threads accessing MySQL database

2006-04-10 Thread Andy Dustman

On 4/10/06, Eugene Lazutkin <[EMAIL PROTECTED]> wrote:
>
> kopikopiko wrote:
> > Hi,
> >
> > I have an application set up under:
> >  Django 0.91
> >  Windows 2000 Server
> >  MySQL 5.0
> > which reads scheduled events from a table then spawns threads (using
> > the Thread module) to process the events and update the table. As soon
> > as my threads started writing to the database I ran into MySQL error
> > 2013 - 'Lost connection to MySQL server during query'. Googling led me
> > to Eugene Lazutkin's blogging on the issue and patches 463 and 1442 to
> > deal with the problems of the conflict over the MySQL connection
> > between the threads and the original app. I applied patch 1442 as it
> > seemed more recommended and the problem seemed to go away.
>
> #1442 was applied to trunk some time ago. Most probably you are running
> an old version of Django.
>
> > I'm looking at how to address this by perhaps:
> > 1) applying patch 1539
>
> #1539 was applied to trunk as well.
>
> > 2) creating a new database connection in the thread (but don't know how
> > to do this)
> >
> > Any advice would be appreciated...
>
> svn up your Django installation and test again. Let us know the results.

The patch on #1590 was also recently applied, and it may also be a factor.

--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Database views

2006-04-10 Thread Andy Dustman

On 4/10/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 4/10/06, George Sakkis <[EMAIL PROTECTED]> wrote:
> > I understand Django doesn't support database views
> > (http://en.wikipedia.org/wiki/View_%28database%29) right out of the
> > box, but I was wondering if there's a reasonably easy way to implement
> > (or at least emulate) them. Here's an illustration of a possible API
> > (compatible to the magic-removal DB API):
>
> Hi George,
>
> I seem to recall using Django with database views in the past. Django
> models are simply wrappers around the database, so it should work just
> fine -- the only thing is, you can't make any changes to data
> (assuming you're dealing with read-only views).

I researched this a bit and found that for MySQL-5.0, MS-SQL, and
Oracle, you *can* update views that involve a join of multiple tables,
with one limitation: You can't update multiple tables at the same
time. Or to use the example, if you were updating PollChoice, you
could not update values from Poll and values from Choice in the same
UPDATE statement. However, since you are actually declaring what
columns come from what tables in your View, it should be possible for
the ORM to separate these into seperate statements.

To otherwise update multiple tables in a view requires triggers and
stored procedures. In PostgreSQL, it looks like you need a rule to
even update one table of a view (or might only been needed for
multiple table updates, I don't remember which). However, this should
not be a limitation for the View class described above.

--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Model inheritance

2006-03-30 Thread Andy Dustman

On 3/25/06, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 3/25/06, Andy Dustman <[EMAIL PROTECTED]> wrote:
> > Surprisingly (a bit, at least), I created an app with the example model:
>
> ..snip...
>
> > Which is not what you'd expect based on that page, so presumably the
> > changes haven't been implemented yet. Or is the page obsolete? I'd
> > assume not since there are some post-PyCon Sprint notes there.
>
> I'd bet on "not yet implemented". I don't know whether discussion's
> still going on about the best way to handle it or not, but generally
> once something's implemented a note about it is added on the
> "RemovingTheMagic" wiki page.

I think it's safe to say that model inhertiance doesn't work at all at
this point, or at least it doesn't in the admin interface. You can add
new items to a subclassed table, and they show up on the index, but
when you try to edit one, it tries to pull them out of the base class'
table, and you get a 404 page. It took a couple hours of testing and
cursing until I finally made the backup print all SQL statements,  and
figured out what was going on. Plus there is the previously-mentioned
problem that ManyToManyFields are not inherited.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Admin interface using CharField as a primary key

2006-03-30 Thread Andy Dustman

On 3/30/06, Daniel Bimschas <[EMAIL PROTECTED]> wrote:
>
> Hi there!
>
> I'm currently trying to convert an old webapp written in PHP into a
> django-based app. The PHP-System used VARCHAR-Fields as primary keys
> in the MySQL - DB.
>
> Now, if i convert the data for the new tables created by Django, I
> have the problem that the admin interface can't edit any entries where
> the title contains colons (":"), because the admin interface uses the
> primary keys in the url created.
>
> I'm currently using Django 0.92.

What sort of field (i.e. models.XXXField) are you using for your
primary key? Sounds like maybe a SlugField? Unless you are using the
default primary key (implicit id = models.AutoField(), which is
INTEGER AUTO_INCREMENT)? You might then need to set primary_key in
Meta to prevent the default PK from being created. See the model-api
docs.

(All this assumes you are using the magic-removal branch, because you
did say 0.92.)

--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Andy Dustman

On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
>
>
> Andy Dustman wrote:
> > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > Andy Dustman wrote:
> > > > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > OperationalError: (2002, "Can't connect to local MySQL server through
> > > > > socket '/var/lib/mysql/mysql.sock' (13)")
> > > >
> > > > This indicates your MySQL server isn't running,
> > > I think it is, since the admin site works fine if I use
> > > manage.py runserver , doesn't it also use the server?
> > >
> > > %myproject]# ps -eadf|grep sql
> > > root 18240 18044  0 12:32 pts/200:00:00 /bin/sh
> > > /usr/bin/mysqld_safe
> > > mysql18268 18240  0 12:32 pts/200:00:00 /usr/libexec/mysqld
> > > --basedir=/usr --datadir=/var/lib/mysql --user=mysql
> > > --pid-file=/var/run/mysqld/mysqld.pid --skip-locking
> > > --socket=/var/lib/mysql/mysql.sock
> > >
> > > unless 'MYSQL server' means somthing different from mysqld ??
> > >
> > >
> > > > and you are using DATABASE_HOST="localhost".
> > > well I use ='', but that should be the same
> > >
> > > but isn't that correct, since mysqld runs on the same host as django?
> >
> > Make sure apache can read /var/ilbmysql/mysql.sock. I'm a little
> how do I do that? I can't 'become' apache
> from the permissions it looks readable
>
> myproject$ ls -lst /var/lib/mysql/mysql.sock
> 4 srwxrwxrwx  1 mysql mysql 0 Mar 28 12:32 /var/lib/mysql/mysql.sock
> myproject$ ls -lst /tmp/mysql.sock

But is the parent directory world-readable? i.e. ls -ld /var/lib/mysql

> there a link to it in /tmp :
> 4 lrwxrwxrwx  1 mysql mysql 25 Mar 23 16:58 /tmp/mysql.sock ->
> /var/lib/mysql/mysql.sock
> [EMAIL PROTECTED] myproject]$
>
> > surprised to see it put the socket there, since (on Gentoo)
> > /var/lib/mysql is only accessible by the user the mysql server runs
> > as, so it puts the socket (which needs to be world-readable and
> > writable) in /var/run.
>
> >
> > When you run manage.py runserver, are you running as root?
> yes (should I?), but I can also run as myself, doesn't matter

You probably shoudn't run it as root on general principle. Make sure
you can access it as a non-root user. The error indicates it did not
get as far as the authentication phase so I am still leaning towards
filesystem permissions. You're not running a chroot apache by any
chance, are you? SELinux? Some sort of virtualization? I guess you
could try 127.0.0.1 for the database host which will make it use TCP
and see if that makes a difference.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Andy Dustman

On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
>
>
> Andy Dustman wrote:
> > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> >
> > > OperationalError: (2002, "Can't connect to local MySQL server through
> > > socket '/var/lib/mysql/mysql.sock' (13)")
> >
> > This indicates your MySQL server isn't running,
> I think it is, since the admin site works fine if I use
> manage.py runserver , doesn't it also use the server?
>
> %myproject]# ps -eadf|grep sql
> root 18240 18044  0 12:32 pts/200:00:00 /bin/sh
> /usr/bin/mysqld_safe
> mysql18268 18240  0 12:32 pts/200:00:00 /usr/libexec/mysqld
> --basedir=/usr --datadir=/var/lib/mysql --user=mysql
> --pid-file=/var/run/mysqld/mysqld.pid --skip-locking
> --socket=/var/lib/mysql/mysql.sock
>
> unless 'MYSQL server' means somthing different from mysqld ??
>
>
> > and you are using DATABASE_HOST="localhost".
> well I use ='', but that should be the same
>
> but isn't that correct, since mysqld runs on the same host as django?

Make sure apache can read /var/ilbmysql/mysql.sock. I'm a little
surprised to see it put the socket there, since (on Gentoo)
/var/lib/mysql is only accessible by the user the mysql server runs
as, so it puts the socket (which needs to be world-readable and
writable) in /var/run.

When you run manage.py runserver, are you running as root?
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Andy Dustman

On 3/28/06, abe <[EMAIL PROTECTED]> wrote:

> OperationalError: (2002, "Can't connect to local MySQL server through
> socket '/var/lib/mysql/mysql.sock' (13)")

This indicates your MySQL server isn't running, and you are using
DATABASE_HOST="localhost".
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Model inheritance

2006-03-25 Thread Andy Dustman

(Maybe this should go to django-developers, but I'm still a relative
noob on Django.)

I've been reading (and making some notes on) this page:

http://code.djangoproject.com/wiki/ModelInheritance

Surprisingly (a bit, at least), I created an app with the example model:

{{{
class Place(models.Model):
name = models.CharField(maxlength=50)

class Restaurant(Place):
description = models.TextField()

class ItalianRestaurant(Restaurant):
has_decent_gnocchi = models.BooleanField()
}}}

That page suggests the resulting schema would look like this:

{{{
CREATE TABLE "myapp_place" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(50) NOT NULL
);

CREATE TABLE "myapp_restaurant" (
"id" integer NOT NULL PRIMARY KEY REFERENCES "myapp_places" ("id"),
"description" text NOT NULL
);

CREATE TABLE "myapp_italianrestaurant" (
"id" integer NOT NULL PRIMARY KEY REFERENCES "myapp_restaurant" ("id"),
"has_decent_gnocchi" bool NOT NULL
);
}}}

However the resulting sql schema generated (using current
magic-removal and mysql for the DATABASE_ENGINE) is:

{{{
CREATE TABLE `places_italianrestaurant` (
`id` integer auto_increment NOT NULL PRIMARY KEY,
`name` varchar(50) NOT NULL,
`description` longtext NOT NULL,
`has_decent_gnocchi` bool NOT NULL
);
CREATE TABLE `places_place` (
`id` integer auto_increment NOT NULL PRIMARY KEY,
`name` varchar(50) NOT NULL
);
CREATE TABLE `places_restaurant` (
`id` integer auto_increment NOT NULL PRIMARY KEY,
`name` varchar(50) NOT NULL,
`description` longtext NOT NULL
);
}}}

Which is not what you'd expect based on that page, so presumably the
changes haven't been implemented yet. Or is the page obsolete? I'd
assume not since there are some post-PyCon Sprint notes there.

I had some ideas about implementing some of this as views, or at least
for reading (all implementations I could find could not deal with view
updates that affected more than one table without using triggers of
some sort), so you'd still have to update the base tables separately
as needed, but that is no worse (in fact the same) as if you doing an
explicit join.

Another weird thing I've found is model inheritance and
ManyToManyFields. I have a model that looks kind of like this:

{{{
class Tag(models.Model):
name = models.SlugField(unique = True, blank = False)

class Source(models.Model):
tags = models.ManyToManyField(Tag)

class Feed(Source):
url = models.URLField()
}}}

(There are other fields defined, but I'm omitting them for clarity, or
at least I hope so.)

As you'd expect, you get a tag table, a source table,  a source_tags
table (for the ManyToMany relation), and a feed table, but instead of
the feed table having all the columns from Feed and Source, it is
lacking a feed_tags table, i.e. Feed is not inheriting tags =
models.ManyToManyField(Tag) from Source. This seems wrong.

It looks like ManyToManyField is not accounted for in
Source._meta.fields, and so it's not inherited by Feed. Instead it's
kept in _meta.many_to_many. Maybe the class inheritance scheme should
account for those as well?

--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Need help for query, how could i do this with django ? or a raw SQL.

2006-03-25 Thread Andy Dustman

On 3/25/06, coulix <[EMAIL PROTECTED]> wrote:
>
> i got it working :
>
> def _module_get_top_users(limit):
> cursor = db.cursor()
> cursor.execute("""
> SELECT auth_users.username, COUNT(*) AS count
> FROM auth_users, recettes_recipes
> WHERE auth_users.id=recettes_recipes.owner_id
> GROUP BY username
> ORDER BY count DESC
> LIMIT %s
>  """% limit)
> res = cursor.fetchall()
> return res

Actually, you should let .execute() do parameter substitution:

def _module_get_top_users(limit):
cursor = db.cursor()
cursor.execute("""
SELECT auth_users.username, COUNT(*) AS count
FROM auth_users, recettes_recipes
WHERE auth_users.id=recettes_recipes.owner_id
GROUP BY username
ORDER BY count DESC
LIMIT %s
 """,  (limit,))
res = cursor.fetchall()
return res

Although in this situation, doing your own parameter substitution
(using %) is probably not harmful.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Need help for query, how could i do this with django ? or a raw SQL.

2006-03-24 Thread Andy Dustman

On 3/24/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> coulix wrote:
> > Hello,
> > I was trying to play with custom query but i didnt manage to get it
> > working,
>
> I too could not get the custom query from the API reference working:
>
> polls.get_list(
> select={
> 'choice_count': 'SELECT COUNT(*) FROM choices WHERE poll_id =
> polls.id'
> }
> )
>
> Trying the query in a 0.91/MySQL installation on both Mac OS X and an
> NT box generated the same error. (Since there's a single quote, a
> backtick and a double quote in the error message, it seems something is
> wonky in the behind-the-scenes query quoting.)

There's a closing parenthesis as well (after polls.id):

> ProgrammingError: (1064, "You have an error in your SQL syntax.  Check
> the manual that corresponds to your MySQL server version for the right
> syntax to use near 'SELECT COUNT(*) FROM choices WHERE poll_id =
> polls.id) AS `choi")

But then, you are putting polls.id in your query, and you are not
selecting from a polls table, so something is not right there. Maybe
you need a JOIN, or is polls.id supposed to be a Python attribute
reference? If so, it can't go directly in SQL.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Extreme file uploading

2006-03-24 Thread Andy Dustman

I'm working on a little app to manage a podcast RSS feed (believe it
or not, someboody actually edits it by hand now). So my first thought
was to use the FileField for uploading the enclosure. This worked fine
except for one issue: The podcast in question is for video, and the
files are typically 200 MB. I watched top while uploading one of these
and the mini-dev server went up to 1.5 GB resident (good thing I had 2
GB of RAM), but obviously this presents a problem. I don't know if
apache/mod_python would work any better or not. I'm guessing the
django server simply reads the entire request into memory and then
parses, while apache may start writing to a temp file somewhere.

Anyway. To work around this particular problem I changed it to a
FilePathField and stipulated that the files (which were already on the
server) would be uploaded by some other means. There are a couple
problems with this:

1) You lose all the nice get_*_url(), get_*_size() and friends that
FileField gives you.

2) To use an existing directory structure, I had to use the recursive
option, but it seems that the value that is stored loses any
subdirectory name between the path and the actual file. I filed a bug
with a patch for this (magic-removal):

http://code.djangoproject.com/ticket/1536

3) It stores the complete path in the database, and there's no obvious
way to trim the path down so you can paste the subdirectory/filename
onto the end of a URL short of repeating yourself and manually
clipping off the initial path, and there's no way I can see to get
that value out of the model. i.e. If I am using:

enclosure = models.FilePathField(path="/var/media/podcasts",
recursive=True, match="\.mp4$")

and I select the file /var/media/podcasts/banking/commercial.mp4,
there's not a way I can get it to just chop off the original path. I
suppose I could do this:

PODCAST_PATH = '/var/media/podcasts'

...

enclosure = models.FilePathField(path=PODCAST_PATH,
recursive=True, match="\.mp4$")

def get_enclosure_uri(self):
return enclosure[len(PODCAST_PATH):]

and then use {{ MEDIA_URL }}/{{ object.get_enclosure_uri }} in the
template. (or something like that)

Any other suggestions? Maybe a variant of FileField or an additional
option that disables upload in the admin interface but let's you pick
matching files out of MEDIA_ROOT?
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---