[JOBS - NYC] Python / Django developer for WNYC, New York Public Radio

2012-05-04 Thread Jeff Heard
This is not mine, so I can't give *all* the details, but I was asked to
forward this along.  It's a good gig - great people, offices in SoHo,
growing organization within a 100+ year old mainstay of New York City,

https://jobs-wnyc.icims.com/jobs/1116/job

-- 
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: Confused about GeoDjango and PostGIS

2012-04-25 Thread Jeff Heard
It can. I just usually consider it easier to create a new one
On Apr 25, 2012 1:38 PM, "vishy" <vishalsod...@gmail.com> wrote:

> So, the existing database cannot be used as a postgis db?
>
> On Apr 25, 9:21 pm, Jeff Heard <jefferson.r.he...@gmail.com> wrote:
> > Create a new spatial database and import the data.  That's by far your
> > easiest option.  You'll need to create a POINT column (look at the
> PostGIS
> > doc on how to add spatial columns) and then add rows either using the ORM
> > or with a spatial query including something like this as part of the
> insert:
> >
> > GeomFromText('POINT(' + x + ' ' + y + ')', 4326)
> >
> > where 4326 is the spatial reference system for longitude/latitude.
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Apr 25, 2012 at 11:17 AM, vishy <vishalsod...@gmail.com> wrote:
> > > Hi,
> >
> > > I need to do spatial queries like find places within 5 miles of a
> > > location given in latitude and longitude. So, I am thinking of
> > > exploring PostGIS and GeoDjango. I have installed both. Now, I already
> > > have a database which has a table for places with latitude and
> > > longitude. Can I enable this db to use postgis and add column to this
> > > table? Or, do I have to create a separate spatial db, create a table
> > > with a column of geometry type and import data into that table (from
> > > places table).? If I can use the existing database, how do I enable it
> > > to use PostGIS?
> >
> > > --
> > > 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.
>
>

-- 
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: Confused about GeoDjango and PostGIS

2012-04-25 Thread Jeff Heard
Create a new spatial database and import the data.  That's by far your
easiest option.  You'll need to create a POINT column (look at the PostGIS
doc on how to add spatial columns) and then add rows either using the ORM
or with a spatial query including something like this as part of the insert:

GeomFromText('POINT(' + x + ' ' + y + ')', 4326)

where 4326 is the spatial reference system for longitude/latitude.



On Wed, Apr 25, 2012 at 11:17 AM, vishy  wrote:

> Hi,
>
> I need to do spatial queries like find places within 5 miles of a
> location given in latitude and longitude. So, I am thinking of
> exploring PostGIS and GeoDjango. I have installed both. Now, I already
> have a database which has a table for places with latitude and
> longitude. Can I enable this db to use postgis and add column to this
> table? Or, do I have to create a separate spatial db, create a table
> with a column of geometry type and import data into that table (from
> places table).? If I can use the existing database, how do I enable it
> to use PostGIS?
>
> --
> 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: PostgreSQL Socket 5432 Error

2012-04-19 Thread Jeff Heard
The other possibility is that you need to build psycopg2 from scratch and set 
the pg_config option in setup.cfg. I have to do this with the brew build of pg 
because the socket is elsewhere



On Apr 19, 2012, at 7:32 PM, Russell Keith-Magee  
wrote:

> On Friday, 20 April 2012 at 6:04 AM, Zach wrote:
>> Hi I am trying to setup a PostgreSQL database for Heroku. I am running
>> into trouble.
>> 
>> I installed PostgreSQL(9.0) from EnterpriseDB on OS X 10.6. However,
>> when I do a simple
>> 
>> $ psql -U postgres
>> 
>> I get this error message.
>> 
>> psql: could not connect to server: No such file or directory
>> Is the server running locally and accepting
>> connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.
>> 5432"?
>> 
>> I am getting the same message when I do a syncdb.
>> 
>> Any ideas what could be causing this. Thank you so much!
>> 
> Well, the error message asks you:
>> Is the server running locally and accepting
>> connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.
>> 5432"?
> 
> 
> 
> Is it? I'm going to go out on a limb and say "No, it isn't". 
> 
> Just because you've installed Postgres doesn't *necessarily* mean you've 
> started the Postgres server. If the server isn't running, you won't be able 
> to connect to the server, which is what psql (and syncdb) is trying to do.
> 
> Yours,
> Russ Magee %-)
> 
> -- 
> 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: Dynamically generated models using exec. Is it too custly?

2012-04-16 Thread Jeff Heard
Check https://github.com/JeffHeard/ga_dynamic_models.  It may be similar to
what you're looking for.  Even if you don't want the code, you can see a
way of dynamically generating models.

On Mon, Apr 16, 2012 at 12:40 PM, Philip Mountifield <
pmountifi...@formac.net> wrote:

>  Did you know that you can use the type function to dynamiclly generate a
> class definition?
>
> See http://docs.python.org/library/functions.html?highlight=type#type
>
> From the example:
>
> >>> class X(object):... a = 1
> Is exactly the same as doing...>>> X = type('X', (object,), dict(a=1))
>
> No exec required...
>
> Regards
> Phil
>
>
>
> On 16/04/2012 17:19, Arruda wrote:
>
> I'm doing something like this to generate some models dynamically:
>
>  SIMILAR_MODELS_TEMPLATE=
>> """
>> @some_decorator
>> class %(PREFIX)sModel (Some_Abs_model):
>> \"""%(DESCRIPTION)s
>> \"""
>> pass
>> """
>
>
>  then I have a factory:
>
>> def similar_models_factory(prefix,description):
>>  format_dict = {
>>   'PREFIX' : prefix,
>>   'DESCRIPTION' : description,
>>  }
>>  cls_name = "%sModel" % prefix
>>  cls_source = SIMILAR_MODELS_TEMPLATE % format_dict
>>
>>  exec(cls_source)
>>  new_cls = locals().get(cls_name)
>>  return new_cls
>
>
>  And finally I have in the models.py:
>
>> from my_factories import similar_models_factory
>>
>
>
> SIMILAR_MODELS_LIST =(
>> {'prefix': 'Foo', 'desc' : 'Foo model and etc..',},
>> {'prefix': 'Bars', 'desc' : 'Bars model and etc..',},
>> .
>> )
>>
>
>
> for smodel in SIMILAR_MODELS_LIST:
>> cls = similar_models_factory(smodels['prefix'], smodels['desc'])
>> vars()[cls.__name__] = cls
>
>
>  And this gives my just what I want, but I read somewhere that if you do:
>
>> exec ""
>
>
> It would be too costly, and I would like to know if this would have some
> heavy load in my project(and if please, how can I calculate this, to
> compare?)
> Thanks!
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/64JCLnsIFu0J.
> 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.
>
>
>
> --
>
> Philip Mountifield
> Formac Electronics Ltd
> tel  +44 (0) 1225 837333
> fax  +44 (0) 1225 430995
> pmountifi...@formac.netwww.formac.netwww.telgas.net
>
>  --
> 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: svm python

2012-03-30 Thread Jeff Heard
Look in Orange. http://orange.biolab.si/



On Mar 30, 2012, at 2:23 AM, dummyman dummyman  wrote:

> Is any one aware of svm implementation using python ? 
> Apart from using weka tool ?
> 
> 
> On Thu, Mar 29, 2012 at 9:21 AM, dummyman dummyman  wrote:
> Hi,
> 
> I am looking for svm classifier implementation in python. My input is a set 
> of feature vectors of the form 
> [Feature1,Feature2,[Feature3],Feature4] =>This is for a user
> 
> so the input is basically a multidimensional list in python
> 
> I have a set of users . So we have of multidimensional lists. 
> Output should be confusion matrix or a statistical analysis 
> 
> Which is the best implementation of svm python module which suits these needs 
> ?
> 
> 
> 
> -- 
> 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: ANNOUNCE: Django 1.4 released

2012-03-23 Thread Jeff Heard

Do the PyCharm devs read this list? Will 1.4 work inside pycharm 2.5?


On Mar 23, 2012, at 3:58 PM, Mário Neto  wrote:

> Great! \,,/_
> 
> 2012/3/23 James Bennett 
> Django 1.4 is finally here!
> 
> For details, checkout the weblog:
> 
> https://www.djangoproject.com/weblog/2012/mar/23/14/
> 
> And the release notes:
> 
> https://docs.djangoproject.com/en/dev/releases/1.4/
> 
> --
> 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.
> 
> 
> 
> 
> -- 
> Att. Mário Araújo Chaves Neto
> Programmer, Designer and U.I. Engineer
> 
> MBA in Design Digital - 2008 - FIC
> Analysis and Systems Development - 2011 - Estácio
> Design and Implementation of Internet Environments - 2003 - FIC
> 
> -- 
> 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: Weird stacktrace coming from manage.py test

2012-03-23 Thread Jeff Heard
No, it turned out that my django-startproject.py was still the one for 1.3...

On Fri, Mar 23, 2012 at 10:47 AM, Reinout van Rees <rein...@vanrees.org> wrote:
> On 22-03-12 17:34, Jeff Heard wrote:
>>
>> Has anyone seen this before?  Am I missing something?  This hasn't even
>> gotten to my code yet.  I'm using this in my settings.py:
>>
>> TEST_RUNNER = 'django.contrib.gis.tests.GeoDjangoTestSuiteRunner'
>>
>> I have a template PostGIS database setup properly.  And I'm running the
>> stable release of Django 1.3.
>>
>> ---
>>
>> Traceback (most recent call last):
>
> ...
>
>>    self.connection.connection.autocommit = True
>> psycopg2.ProgrammingError: autocommit cannot be used inside a transaction
>
>
> For me, this normally means the database definition is not quite right.
>
> In your geodjango case, do you perhaps miss django.contrib.gis in your
> INSTALLED_APPS list?
>
>
> Reinout
>
> --
> Reinout van Rees                    http://reinout.vanrees.org/
> rein...@vanrees.org             http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul Graham"
>
> --
> 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.



Django-1.4c2 logging issue on Snow Leopard

2012-03-22 Thread Jeff Heard
Hi all.  I just created a new Django-1.4 project and got this error:

Traceback (most recent call last):
  File "manage.py", line 14, in 
execute_manager(settings)
  File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/core/management/__init__.py",
line 438, in execute_manager
utility.execute()
  File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/core/management/__init__.py",
line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/core/management/__init__.py",
line 252, in fetch_command
app_name = get_commands()[subcommand]
  File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/core/management/__init__.py",
line 101, in get_commands
apps = settings.INSTALLED_APPS
  File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/utils/functional.py",
line 276, in __getattr__
self._setup()
  File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/conf/__init__.py",
line 42, in _setup
self._wrapped = Settings(settings_module)
  File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/conf/__init__.py",
line 139, in __init__
logging_config_func(self.LOGGING)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py",
line 776, in dictConfig
dictConfigClass(config).configure()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py",
line 562, in configure
'filter %r: %s' % (name, e))
ValueError: Unable to configure filter 'require_debug_false': Cannot
resolve 'django.utils.log.RequireDebugFalse': No module named
RequireDebugFalse

I'm using virtualenv and the system python.

Regards,

-- Jeff

-- 
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.



Weird stacktrace coming from manage.py test

2012-03-22 Thread Jeff Heard
Has anyone seen this before?  Am I missing something?  This hasn't even
gotten to my code yet.  I'm using this in my settings.py:

TEST_RUNNER = 'django.contrib.gis.tests.GeoDjangoTestSuiteRunner'

I have a template PostGIS database setup properly.  And I'm running the
stable release of Django 1.3.

---

Traceback (most recent call last):
 File "manage.py", line 14, in 
   execute_manager(settings)
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/core/management/__init__.py",
line 438, in execute_manager
   utility.execute()
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/core/management/__init__.py",
line 379, in execute
   self.fetch_command(subcommand).run_from_argv(self.argv)
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/core/management/base.py",
line 191, in run_from_argv
   self.execute(*args, **options.__dict__)
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/core/management/base.py",
line 220, in execute
   output = self.handle(*args, **options)
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/core/management/commands/test.py",
line 37, in handle
   failures = test_runner.run_tests(test_labels)
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/test/simple.py",
line 359, in run_tests
   old_config = self.setup_databases()
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/test/simple.py",
line 296, in setup_databases
   test_db_name = connection.creation.create_test_db(self.verbosity,
autoclobber=not self.interactive)
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/db/backends/creation.py",
line 351, in create_test_db
   self._create_test_db(verbosity, autoclobber)
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/db/backends/creation.py",
line 425, in _create_test_db
   self.set_autocommit()
 File
"/Users/jeffersonheard/Source/geoanalytics/lib/python2.7/site-packages/django/db/backends/creation.py",
line 481, in set_autocommit
   self.connection.connection.autocommit = True
psycopg2.ProgrammingError: autocommit cannot be used inside a transaction

-- 
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: Caching and model import question

2012-03-21 Thread Jeff Heard
Well, I was wrong... how *should* this work?  I tried a signal handler
to reload modules whenever someone added or deleted a model, but that
only seems to matter if a particular module that loads "models" hasn't
been loaded yet.

On Wed, Mar 21, 2012 at 12:59 PM, Jeff Heard
<jefferson.r.he...@gmail.com> wrote:
> Thanks.  I don't think that *in principle* creating new models on the
> fly is a bad thing, although maybe some will argue with me.  There's
> another Django app that allows you to do this within the admin
> interface, and I've considered using it.  I dislike the idea of having
> to make assumptions about the backend that will be running, though,
> and assuming that my users will be using mod_wsgi, FastCGI, or
> gunicorn is anaethema to the idea of making a portable app.  I *think*
> I have it figured, out, although my implementation still feels
> "hackish" to me.  I suppose another couple of iterations on it may
> make sense.
>
> On Wed, Mar 21, 2012 at 12:52 PM, Tom Evans <tevans...@googlemail.com> wrote:
>> On Wed, Mar 21, 2012 at 4:19 PM, Jeff Heard <jefferson.r.he...@gmail.com> 
>> wrote:
>>> Question 1: Would this work with views, or for that matter, anything
>>> else in Django, assuming you're using a WSGI server like gunicorn?
>>> http://code.activestate.com/recipes/578078/  Specifically, will it
>>> cache across HTTP requests, or not?
>>>
>>
>> Probably, but that is the worst place to cache in a web framework, as
>> it is a cache per process. That is 'ok' if you use a single process,
>> multi thread serving model on a single server, but useless/wasteful if
>> you run a multi-process serving model or serve from multiple servers.
>>
>> It is much better to use caches at a higher level, eg memcached, which
>> is distributed and can be shared easily amongst any model.
>>
>>> I guess the one thing I don't understand well in Django is when
>>> modules are re-loaded.  I know it's different in a "full-fledged"
>>> setup vs. the test server, but is there a rule one can follow? Is it
>>> different on WSGI vs. FastCGI?
>>>
>>
>> Never automatically. mod_wsgi will reload your app if you touch
>> (change the mtime) the app.wsgi file. mod_fastcgi will reload your app
>> when you restart the process.
>>
>>> And finally, if I delete a module from sys.modules, does that
>>> effectively delete it from the cache or is there something else I need
>>> to do to make sure it's reloaded the next time someone makes a
>>> request?  I would assume that deleting the module from sys.modules
>>> would only delete it from one worker process.  Is there an accepted
>>> way to get a module to reload across all processes?
>>>
>>> What I'm trying to do is allow a user to create models on the fly by
>>> uploading data.  One answer is just to have a post_save signal call
>>> supervisorctl and restart the webservices, but that seems nonportable
>>> and rather broken.  There's got to be a better way.
>>>
>>
>> Eurgh. Now I don't want to help you! These links will help:
>>
>> http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Reloading_In_Daemon_Mode
>> http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_Daemon_Processes
>>
>> Cheers
>>
>> Tom
>>
>> --
>> 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: Caching and model import question

2012-03-21 Thread Jeff Heard
Thanks.  I don't think that *in principle* creating new models on the
fly is a bad thing, although maybe some will argue with me.  There's
another Django app that allows you to do this within the admin
interface, and I've considered using it.  I dislike the idea of having
to make assumptions about the backend that will be running, though,
and assuming that my users will be using mod_wsgi, FastCGI, or
gunicorn is anaethema to the idea of making a portable app.  I *think*
I have it figured, out, although my implementation still feels
"hackish" to me.  I suppose another couple of iterations on it may
make sense.

On Wed, Mar 21, 2012 at 12:52 PM, Tom Evans <tevans...@googlemail.com> wrote:
> On Wed, Mar 21, 2012 at 4:19 PM, Jeff Heard <jefferson.r.he...@gmail.com> 
> wrote:
>> Question 1: Would this work with views, or for that matter, anything
>> else in Django, assuming you're using a WSGI server like gunicorn?
>> http://code.activestate.com/recipes/578078/  Specifically, will it
>> cache across HTTP requests, or not?
>>
>
> Probably, but that is the worst place to cache in a web framework, as
> it is a cache per process. That is 'ok' if you use a single process,
> multi thread serving model on a single server, but useless/wasteful if
> you run a multi-process serving model or serve from multiple servers.
>
> It is much better to use caches at a higher level, eg memcached, which
> is distributed and can be shared easily amongst any model.
>
>> I guess the one thing I don't understand well in Django is when
>> modules are re-loaded.  I know it's different in a "full-fledged"
>> setup vs. the test server, but is there a rule one can follow? Is it
>> different on WSGI vs. FastCGI?
>>
>
> Never automatically. mod_wsgi will reload your app if you touch
> (change the mtime) the app.wsgi file. mod_fastcgi will reload your app
> when you restart the process.
>
>> And finally, if I delete a module from sys.modules, does that
>> effectively delete it from the cache or is there something else I need
>> to do to make sure it's reloaded the next time someone makes a
>> request?  I would assume that deleting the module from sys.modules
>> would only delete it from one worker process.  Is there an accepted
>> way to get a module to reload across all processes?
>>
>> What I'm trying to do is allow a user to create models on the fly by
>> uploading data.  One answer is just to have a post_save signal call
>> supervisorctl and restart the webservices, but that seems nonportable
>> and rather broken.  There's got to be a better way.
>>
>
> Eurgh. Now I don't want to help you! These links will help:
>
> http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Reloading_In_Daemon_Mode
> http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_Daemon_Processes
>
> Cheers
>
> Tom
>
> --
> 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.



Caching and model import question

2012-03-21 Thread Jeff Heard
Question 1: Would this work with views, or for that matter, anything
else in Django, assuming you're using a WSGI server like gunicorn?
http://code.activestate.com/recipes/578078/  Specifically, will it
cache across HTTP requests, or not?

I guess the one thing I don't understand well in Django is when
modules are re-loaded.  I know it's different in a "full-fledged"
setup vs. the test server, but is there a rule one can follow? Is it
different on WSGI vs. FastCGI?

And finally, if I delete a module from sys.modules, does that
effectively delete it from the cache or is there something else I need
to do to make sure it's reloaded the next time someone makes a
request?  I would assume that deleting the module from sys.modules
would only delete it from one worker process.  Is there an accepted
way to get a module to reload across all processes?

What I'm trying to do is allow a user to create models on the fly by
uploading data.  One answer is just to have a post_save signal call
supervisorctl and restart the webservices, but that seems nonportable
and rather broken.  There's got to be a better way.

-- 
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.



Caching and module import question

2012-03-19 Thread Jeff Heard
Question 1: Would this work with views, or for that matter, anything else
in Django, assuming you're using a WSGI server like gunicorn?
http://code.activestate.com/recipes/578078/  Specifically, will it cache
across HTTP requests, or not?

I guess the one thing I don't understand well in Django is when modules are
re-loaded.  I know it's different in a "full-fledged" setup vs. the test
server, but is there a rule one can follow? Is it different on WSGI vs.
FastCGI? And finally, if I delete a module from sys.modules, does that
effectively delete it from the cache or is there something else I need to
do to make sure it's reloaded the next time someone makes a request?  I
would assume that deleting the module from sys.modules would only delete it
from one worker process.

-- 
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: psycopg2, postgres9.1, Mac OS - problem with psycopg2

2012-02-22 Thread Jeff Heard
Just as a followup to this, there are a few problems that have been patched
on Django with regards to Postgres 9.1.  They're not in the stable release,
but if you're using custom binary fields, such as PostGIS geometry, you
will need to search for the patch and apply it.  You may see '\x00' is not
a UTF-8 code or something like that.

On Wed, Feb 22, 2012 at 1:28 PM, Shawn Milochik  wrote:

> You can either add the proper path of pg_config to your PATH, or just
> extract the psycopg2 and add the full path to pg_config into the config
> file it contains then run 'python setup.py install' on the setup.py in the
> package.
>
>
> --
> 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+unsubscribe@**
> 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: Newbie django/python with C++ background wants enums

2012-02-01 Thread Jeff Heard
*slightly* better would be:

class X(models.Model):
YES='Y'
NO='N'
DEFAULT='D'
TO_USE = ((X.YES, "Yes"), (X.NO, "No"), (X.DEFAULT, "Default"))

txt= models.CharField(db_index=True,null=True, blank=True,max_length=30)
use_txt= models.CharField(blank=False,max_length=1,default='D',
choices=X.TO_USE)

and in admin.py

class XForm(forms.ModelForm):
def clean(self):
cleaned_data=super(XForm, self).clean()
txt=cleaned_data['txt'].strip()
use_txt=cleaned_data['use_txt'].strip()

if *not txt* and use_txt==X.YES:
raise forms.ValidationError('This is needed!')

return cleaned_data

On Wed, Feb 1, 2012 at 8:13 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

>  You could use a class, such as:
>
> class TO_USE:
> Y = 'Yes'
> N = 'No'
>
> if char == TO_USE.Y:
> pass
>
> _Nik
>
>
> On 2/1/2012 1:45 PM, NENAD CIKIC wrote:
>
> Hello, the subject expresses my discomfort with certain python
> characteristics, given my background, and my lack of python knowledge.
> Specifically lets say that I have a model with a Text field and char
> field. The char field is length 1 and says "use or do not use the text
> field". The char field can have Y or N values.
> So using the admin interface I wanted to override the clean method but I
> did not want to write
> if text.__len__==0 and char=='Y':
>   raise exception
>
> In C/C++ you would use enum for these sort of things. So I ended with
> defining in models.py something as:
> TO_USE= (
> ('Y', 'Yes'),
> ('N', 'No'),
> )
>
> class X(models.Model):
> txt= models.CharField(db_index=True,null=True,
> blank=True,max_length=30)
> use_txt=
> models.CharField(blank=False,max_length=1,default='D',choices=TO_USE)
>
> and in admin.py something as
> class XForm(forms.ModelForm):
> def clean(self):
> cleaned_data=super(XForm, self).clean()
> txt= cleaned_data['txt'].strip()
> use_txt=cleaned_data['use_txt'].strip()
>
> if txt.__len__()==0 and use_txt==TO_USE.__getitem__(0)[0]:
> raise forms.ValidationError('This is needed!')
>
> return cleaned_data
>
> The part .__getitem__(0)[0] is not very readable. I have looked for enums
> in python, and if I have understood well, it seems they are not implemented.
> What is the best way to do it in python for my problem, given that I do
> not want to write =='Y'.
> Thanks
> Nenad
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/oqGo6Td_lYoJ.
> 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.
>

-- 
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: OGC Web Feature Service for GeoDjango

2012-02-01 Thread Jeff Heard
Great.  There's more coming down the pipe.  WFS was the first thing I had
reasonably finished...

On Tue, Jan 31, 2012 at 10:16 AM, George Silva <georger.si...@gmail.com>wrote:

> Wow! Congratulations on this release.
>
> I'm looking at it right now.
>
> :D
>
> On Tue, Jan 31, 2012 at 1:11 PM, Jeff Heard 
> <jefferson.r.he...@gmail.com>wrote:
>
>> https://github.com/JeffHeard/ga_ows
>>
>> http://geoanalytics.renci.org/uncategorized/ogc-wfs-for-django-released-on-github/
>>
>> It's not feature complete yet by any means, but it is quite usable.
>>  There is also an implementation of WMS included, but it is currently
>> undocumented as I clean up that code and make it similar to my more
>> recently implemented WFS.  This package is a reusable app that will allow
>> you to expose any GeoDjango model as a Web Feature Service.
>>
>> Supported formats for output are currently anything that is supported by
>> a single-file format in OGR.  Shapefiles are not yet supported for output
>> but will be soon.
>>
>> Also, you can adapt WFS to any python object (including other ORMs) by
>> deriving from WFSAdapter.
>>
>> -- Jeff
>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> George R. C. Silva
>
> Desenvolvimento em GIS
> http://geoprocessamento.net
> http://blog.geoprocessamento.net
>
>  --
> 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: GIS Distance from Point to Geometry Collection

2012-01-31 Thread Jeff Heard
It should return whatever the units are in the coordinate system you have
set.  You will probably want to transform the geometry to UTM first.
 Something that treats the geometry as flat and sets distance to be in
meters or similar.  srid=3857 or 900913 will do this nicely (caveat
emptor).

-- Jeff

On Tue, Jan 31, 2012 at 9:07 PM, Alex Kopp <loafer...@gmail.com> wrote:

> Yes Jeff, this is what I want to do. I wasn't sure if there was an easier
> way. What units does the distance function return? I tried this and it
> seems to return the distance in units of 10km, is this correct?
>
>  Thanks again!
>
>
> On Tue, Jan 31, 2012 at 9:04 PM, Jeff Heard 
> <jefferson.r.he...@gmail.com>wrote:
>
>> Got it.  So what you want to do is a list comprehension over the geometry
>> object, which *should* give you individual geometries is what it sounds
>> like.  Then you can calculate distance() from each of these.  Something
>> like this?
>>
>> interesting_point = Point(x, y)
>> collection = result.geom
>> min_dist = min([g.distance(interesting_point) for g in collection])
>>
>> or for every geometrycollection in a queryset:
>>
>> result = MyModel.objects.all()
>> min_dist = min([min([g.distance(interesting_point) for g in coll]) for
>> coll in result])
>>
>> Brute force and thus a bit slow, but it should work if I understand you
>> correctly...
>>
>> -- Jeff
>>
>>
>> On Tue, Jan 31, 2012 at 8:45 PM, Alex Kopp <loafer...@gmail.com> wrote:
>>
>>> Here's a more concrete example, say I am storing shapes of all
>>> countries. Now, the US can't be stored in one polygon (we have hawaii and
>>> alaska), therefore I have to store the many polygons in one
>>> geometrycollection.
>>>
>>> Now, say I have another point on the map, I would like to know how ar it
>>> is from ANY of the polygons...
>>>
>>>
>>> On Tue, Jan 31, 2012 at 8:41 PM, Alex Kopp <loafer...@gmail.com> wrote:
>>>
>>>> Perhaps I didn't explain it well, Jeff. I am just trying to get the
>>>> smallest distance from one point to any of the points, lines, or polygons
>>>> inside of a queryset. The data I am receiving from the queryset is a
>>>> geometrycollection already... That is how it is being stored in the
>>>> database.
>>>>
>>>> On Tue, Jan 31, 2012 at 8:36 PM, Jeff Heard <
>>>> jefferson.r.he...@gmail.com> wrote:
>>>>
>>>>> You should be able to create a geometrycollection object from a
>>>>> queryset (you may have to use a list comprehension for this), then
>>>>> calculate the centroid and take the distance from that. Taking the 
>>>>> distance
>>>>> from the edge should only be a little more
>>>>> Complicated.  Check the django GEOS API docs For complete details
>>>>>
>>>>>
>>>>>
>>>>> On Jan 31, 2012, at 6:36 PM, Loafer <loafer...@gmail.com> wrote:
>>>>>
>>>>> > I have a model that currently stores a Geographic Point (Using Django
>>>>> > GIS (GeoDjango)) and another model that has a field to store a
>>>>> > geometry collection (A collection of polygons, lines, and or points).
>>>>> >
>>>>> > I am trying to find the distance from the point to any one of the
>>>>> > shapes in the geometry collection. Apparently the distance function
>>>>> > only works on single shapes, not a collection. Are there any
>>>>> > workarounds to this?
>>>>> >
>>>>> > Any help is appreciated.
>>>>> >
>>>>> > Thanks.
>>>>> >
>>>>> > --
>>>>> > 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.
>>>>&g

Re: GIS Distance from Point to Geometry Collection

2012-01-31 Thread Jeff Heard
Got it.  So what you want to do is a list comprehension over the geometry
object, which *should* give you individual geometries is what it sounds
like.  Then you can calculate distance() from each of these.  Something
like this?

interesting_point = Point(x, y)
collection = result.geom
min_dist = min([g.distance(interesting_point) for g in collection])

or for every geometrycollection in a queryset:

result = MyModel.objects.all()
min_dist = min([min([g.distance(interesting_point) for g in coll]) for coll
in result])

Brute force and thus a bit slow, but it should work if I understand you
correctly...

-- Jeff


On Tue, Jan 31, 2012 at 8:45 PM, Alex Kopp <loafer...@gmail.com> wrote:

> Here's a more concrete example, say I am storing shapes of all
> countries. Now, the US can't be stored in one polygon (we have hawaii and
> alaska), therefore I have to store the many polygons in one
> geometrycollection.
>
> Now, say I have another point on the map, I would like to know how ar it
> is from ANY of the polygons...
>
>
> On Tue, Jan 31, 2012 at 8:41 PM, Alex Kopp <loafer...@gmail.com> wrote:
>
>> Perhaps I didn't explain it well, Jeff. I am just trying to get the
>> smallest distance from one point to any of the points, lines, or polygons
>> inside of a queryset. The data I am receiving from the queryset is a
>> geometrycollection already... That is how it is being stored in the
>> database.
>>
>> On Tue, Jan 31, 2012 at 8:36 PM, Jeff Heard 
>> <jefferson.r.he...@gmail.com>wrote:
>>
>>> You should be able to create a geometrycollection object from a queryset
>>> (you may have to use a list comprehension for this), then calculate the
>>> centroid and take the distance from that. Taking the distance from the edge
>>> should only be a little more
>>> Complicated.  Check the django GEOS API docs For complete details
>>>
>>>
>>>
>>> On Jan 31, 2012, at 6:36 PM, Loafer <loafer...@gmail.com> wrote:
>>>
>>> > I have a model that currently stores a Geographic Point (Using Django
>>> > GIS (GeoDjango)) and another model that has a field to store a
>>> > geometry collection (A collection of polygons, lines, and or points).
>>> >
>>> > I am trying to find the distance from the point to any one of the
>>> > shapes in the geometry collection. Apparently the distance function
>>> > only works on single shapes, not a collection. Are there any
>>> > workarounds to this?
>>> >
>>> > Any help is appreciated.
>>> >
>>> > Thanks.
>>> >
>>> > --
>>> > 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.
>>>
>>>
>>
>  --
> 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: GIS Distance from Point to Geometry Collection

2012-01-31 Thread Jeff Heard
You should be able to create a geometrycollection object from a queryset (you 
may have to use a list comprehension for this), then calculate the centroid and 
take the distance from that. Taking the distance from the edge should only be a 
little more
Complicated.  Check the django GEOS API docs For complete details



On Jan 31, 2012, at 6:36 PM, Loafer  wrote:

> I have a model that currently stores a Geographic Point (Using Django
> GIS (GeoDjango)) and another model that has a field to store a
> geometry collection (A collection of polygons, lines, and or points).
> 
> I am trying to find the distance from the point to any one of the
> shapes in the geometry collection. Apparently the distance function
> only works on single shapes, not a collection. Are there any
> workarounds to this?
> 
> Any help is appreciated.
> 
> Thanks.
> 
> -- 
> 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.



ANN: OGC Web Feature Service for GeoDjango

2012-01-31 Thread Jeff Heard
https://github.com/JeffHeard/ga_ows
http://geoanalytics.renci.org/uncategorized/ogc-wfs-for-django-released-on-github/

It's not feature complete yet by any means, but it is quite usable.  There
is also an implementation of WMS included, but it is currently undocumented
as I clean up that code and make it similar to my more recently implemented
WFS.  This package is a reusable app that will allow you to expose any
GeoDjango model as a Web Feature Service.

Supported formats for output are currently anything that is supported by a
single-file format in OGR.  Shapefiles are not yet supported for output but
will be soon.

Also, you can adapt WFS to any python object (including other ORMs) by
deriving from WFSAdapter.

-- Jeff

-- 
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: Tutorial for dev version not working (Polls app): admin

2012-01-29 Thread Jeff Heard
syncdb will not remake tables that are already made.  For that you will
have to pipe the output of:

$ python manage.py resetsql

through your database backend.  Then try restarting the server and looking
at your admin.


On Sat, Jan 28, 2012 at 10:15 PM, Alec Taylor wrote:

> Going through the tutorial using the latest trunk in a virtualenv.
>
> I am getting stuck in this section:
>
> https://docs.djangoproject.com/en/dev/intro/tutorial02/#s-customize-the-admin-form
>
> No matter how I rearrange the fields (even when I remove the
> "question" field), I cannot notice any difference in the poll admin
> screens. I have tried syncdb, and restarting the server.
>
> I've looked at the index screen
> (http://localhost:9400/admin/polls/poll/), the view screen
> (http://localhost:9400/admin/polls/poll/1/) and the add screen
> (http://localhost:9400/admin/polls/poll/add/). There are no
> differences in field order/display on any of these pages.
>
> I have followed the tutorial exactly, but the fields aren't being
> rearranged.
>
> Is there a different way of rearranging admin fields in Django 1.4?
>
> Thanks for helping me get this working,
>
> Alec Taylor
>
> --
> 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: Problem in Geodjango

2012-01-27 Thread Jeff Heard
Check that you are actually using the
django.contrib.gis.db.backends.postgis (or other) database backend in your
settings.py. It sounds like the SQL to create geometry columns is never
getting called.

On Thu, Jan 12, 2012 at 4:38 AM, Vicky .. wrote:

> Hi Everyone ..
>
> I am following the steps given in
> https://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/#
>
> and the steps i followed before
> https://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/#spatial-queries
>  were
> working fine but after that I got error in the ** qs =
> WorldBorder.objects.filter(mpoly__contains=pnt_wkt)* in this Statement .
>
>  Error it is showing is
>
>  *FieldError: Cannot resolve keyword 'mpoly' into field. Choices are:
> area, fips, geom, id, iso2, iso3, lat, lon, name, pop2005, region,
> subregion, un*
>
> and if I am executing this line
>
> * sm = WorldBorder.objects.get(name='San Marino')** *
>
> *Error is  *
>
> ***DatabaseError: column world_worldborder.geom does not exist LINE 1:
> ...ld_worldborder"."lon", "world_worldborder"."lat", "world_wor...**
>
>  --
> 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: GeoDjango - Error while importing data

2012-01-27 Thread Jeff Heard
you are using Postgres 9.1  There is a bug in the adapter for 9.1.  It is
addressed and fixed with this patch:

https://code.djangoproject.com/ticket/16778

On Mon, Jan 16, 2012 at 2:52 AM, Serge RABEVOHITRA <
serge.rabevohi...@gmail.com> wrote:

> Hi,
>
> I've just begun to learn GeoDjango. So I followed step by step the
> "geodjango tutorial".
> When I was at the step "Import data" (TM_WORLD_BORDERS-0.3.shp) , i've
> got this error message :
> "Failed to save the feature (id:0) into the model with the keyword
> arguments : {'iso2' : u'AG'
> DatabaseError: ERREUR: sequence d'octets invalide pour l'encodate
> UTF-8 : 0x00"
>
> I'm very pleased if anyone could help me.
> Thanks.
>
> Regards!
> Serge
>
> --
> 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: A problem with a solution, but is it the right one?

2012-01-20 Thread Jeff Heard
Yeah, I started doing that after I posted...  Thanks for the advice.  I'll
be posting this code up on GitHub in a few days, as it's part of a
reasonably complete implementation for Django of ISO 19142, Open Geospatial
Consortium's Web Feature Service.

-- Jeff

On Fri, Jan 20, 2012 at 7:30 AM, francescortiz <francescor...@gmail.com>wrote:

> I would pass bound data instead of calling from_request:
>
> https://docs.djangoproject.com/en/dev/ref/forms/api/#ref-forms-api-bound-unbound
>
> This way you don't have to worry about forms logic, but just about
> filling the default data.
>
> Francesc
>
> On Jan 18, 8:42 pm, Jeff Heard <jefferson.r.he...@gmail.com> wrote:
> > My basic problem is this: I have multiple kinds of requests that come in,
> > and some of them share parameters and valid values and default values. I
> > cannot expect my users to pass all form values on the URL line, but
> > unpassed parameters must be set to appropriate defaults, not merely None.
> >
> > These shared parameter sets are broken out into separate RequestForm
> > classes, but I also wanted to put the parsing and default values into
> those
> > classes. So I came up with the "from_request" method, which I put into
> each
> > RequestForm subclass and created a class method called "create" in
> > RequestForm that class every class in cls.mro()'s from_request method
> > independently, then calls .clean() on the form to validate it.
> >
> > Another caveat is that I must shadow the request.GET dictionary with a
> > case-insensitive dictionary, which I take care of in the
> > django.views.generic.View.dispatch() method.
> >
> > The code for my proposed solution is here:
> >
> > http://dpaste.com/hold/689872/
> >
> > Does this make sense to people?  Sorry to kind of flood the list with
> this
> > problem all day in different forms, but i think I'm close to having
> > something I like.
> >
> > -- Jeff
>
> --
> 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.



A problem with a solution, but is it the right one?

2012-01-18 Thread Jeff Heard
My basic problem is this: I have multiple kinds of requests that come in,
and some of them share parameters and valid values and default values. I
cannot expect my users to pass all form values on the URL line, but
unpassed parameters must be set to appropriate defaults, not merely None.

These shared parameter sets are broken out into separate RequestForm
classes, but I also wanted to put the parsing and default values into those
classes. So I came up with the "from_request" method, which I put into each
RequestForm subclass and created a class method called "create" in
RequestForm that class every class in cls.mro()'s from_request method
independently, then calls .clean() on the form to validate it.

Another caveat is that I must shadow the request.GET dictionary with a
case-insensitive dictionary, which I take care of in the
django.views.generic.View.dispatch() method.

The code for my proposed solution is here:

http://dpaste.com/hold/689872/

Does this make sense to people?  Sorry to kind of flood the list with this
problem all day in different forms, but i think I'm close to having
something I like.

-- Jeff

-- 
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: Missing something obvious? Question about forms

2012-01-18 Thread Jeff Heard
There is no presentation layer, actually.  I mean, theoretically the forms
could be rendered, but I really just want them to validate input data AND..
and this is the kicker, AND I need them to provide default values, which
Forms as I understand, don't do, except for presentation.  As in, when I
pull form_instance.count, it should be 1, even if nothing was specified in
the GET dictionary.  It's not my standard...

-- Jeff

On Wed, Jan 18, 2012 at 11:06 AM, Tom Evans <tevans...@googlemail.com>wrote:

> That would probably do it. You may also need to give it a different
> widget, I'd guess that a  is not how you would present this to
> the user - although maybe you are just using the form for processing
> and not to generate a presentation layer.
>
> Cheers
>
> Tom
>
> On Wed, Jan 18, 2012 at 4:01 PM, Jeff Heard <jefferson.r.he...@gmail.com>
> wrote:
> > Sadly these strings are arbitrary, yes...  I suppose I could subclass
> > MultipleChoiceField and kill the validator.
> >
> > On Wed, Jan 18, 2012 at 10:54 AM, Tom Evans <tevans...@googlemail.com>
> > wrote:
> >>
> >> On Wed, Jan 18, 2012 at 3:51 PM, Andre Terra <andrete...@gmail.com>
> wrote:
> >> > https://docs.djangoproject.com/en/dev/ref/forms/fields/#choicefield
> >> >
> >> >
> https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.MultipleChoiceField
> >> >
> >> >
> >>
> >> That is how I almost replied, but a MultipleChoiceField constrains the
> >> submitted values to be within a predefined list of acceptable values.
> >> You couldn't use a MultipleChoiceField to collect an arbitrary number
> >> of arbitrary strings, it would fail validation.
> >>
> >> Cheers
> >>
> >> Tom
> >>
> >> --
> >> 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.
>
> --
> 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: Missing something obvious? Question about forms

2012-01-18 Thread Jeff Heard
Sadly these strings are arbitrary, yes...  I suppose I could subclass
MultipleChoiceField and kill the validator.

On Wed, Jan 18, 2012 at 10:54 AM, Tom Evans wrote:

> On Wed, Jan 18, 2012 at 3:51 PM, Andre Terra  wrote:
> > https://docs.djangoproject.com/en/dev/ref/forms/fields/#choicefield
> >
> https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.MultipleChoiceField
> >
> >
>
> That is how I almost replied, but a MultipleChoiceField constrains the
> submitted values to be within a predefined list of acceptable values.
> You couldn't use a MultipleChoiceField to collect an arbitrary number
> of arbitrary strings, it would fail validation.
>
> Cheers
>
> Tom
>
> --
> 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.



Case insensitive query dictionaries

2012-01-18 Thread Jeff Heard
I have a standard that requires that HTTP parameter names be
case-insensitive, and while I thought for awhile I could ignore that
requirement, I've found that clients use all kinds of case structures on
their parameters, so I need case insensitivity.

Is there a standard way to ignore the case of parameters in a request.GET /
request.POST / request.REQUEST dictionary?  I haven't found one.  If not,
would the "best" (most Django-esque) implementation of this be in
middleware, or to construct a "wrapper" that digs all the parameters out of
the class and returns a case normalized version?

-- Jeff

-- 
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.



Missing something obvious? Question about forms

2012-01-18 Thread Jeff Heard
I have a largish API I have to implement from a standard, and it requires
very complex HTTP processing.  I'd like to use django.forms.Form for that,
but I can't figure out how to use a form to store a list of parameters.

So while my homemade code might be:

foo = int(request.get('foo', '1'))
bar = request.getlist(bar)

I can't figure out the corresponding Form class.  What I would *want* is
something like this:

class MyForm(Form):
   foo = IntegerField()
   bar = ListField(CharField)

but there is no "ListField"  How is this normally handled?

-- Jeff

-- 
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: pseudo one-to-one

2012-01-16 Thread Jeff Heard
You might modify the manager to store historical entries in a different table 
with the same structure. 



On Jan 16, 2012, at 2:18 AM, Mike Dewhirst  wrote:

> On 16/01/2012 5:19pm, Bill Beal wrote:
>> Why not have a child model that differs from the one-to-one child model
>> in that the parent key is now a foreign key to the parent?  When another
>> child needs to replace the current one in the one-to-one relationship,
>> move the child to the second table where there is a many-to-one
>> relationship to the parent, then modify the one-to-one child record.  If
>> necessary, duplicate the current one-to-one record in the many-to-one
>> table.  Does this make sense?
> 
> I understand what you mean but it feels a bit yukky. Thinking about it some 
> more maybe I need a 'hidden' field which gets updated on saving based on the 
> existence of a more modern child.
> 
> Dunno.
> 
> Thanks
> 
> Mike
> 
> 
>> 
>> Bill Beal
>> 
>> On Mon, Jan 16, 2012 at 12:55 AM, Mike Dewhirst > > wrote:
>> 
>>I need a one-to-many to behave like a one-to-one.
>> 
>>The parent instance of my model can only ever have one current child
>>instance of another model. Multiple child instances have to exist
>>and be kept for the historical record.
>> 
>>The main benefit of one-to-one relationships is that they can be
>>mapped together (in the Admin) as an extension of the parent.
>> 
>>In a view I suppose I can use a manager to filter the children into
>>a pseudo-one-to-one thingy but how do I do this in the Admin?
>> 
>>Maybe sort them into date order and only show one? Is there a better
>>way?
>> 
>>Thanks for any help
>> 
>>Mike
>> 
>>--
>>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+unsubscribe@__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.
> 
> -- 
> 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: Does anyone know any blogs that write about how to quickly install and deploy a django application on Amazon EC2?

2012-01-12 Thread Jeff Heard
http://kencochrane.net/blog/2011/06/django-gunicorn-nginx-supervisord-fabric-centos55/

I would go there.  It's not Amazon EC2 specific, but Amazon's distribution
by default is a Centos-based one, so everything should be in the same
place.  Plus, he very helpfully gives you code you can use to get
everything running quickly.  The hardest thing is getting nginx running
within the main initlevel, but even that is not hard, just tedious.

This does not, however, tell you how to setup S3 storage to be Django's
file backend.  You'll have to look somewhere else for that

On Thu, Jan 12, 2012 at 6:32 PM, Stuart Laughlin wrote:

>
> On Thursday, January 12, 2012 10:09:13 AM UTC-6, Javier Guerra wrote:
>
>> On Thu, Jan 12, 2012 at 9:54 AM, Stuart Laughlin 
>> wrote:
>> >  # author admits he is a non-sysadmin noob
>>
>> ad-hominem
>>
> False. I pointed out what the author clearly stipulates.
>
> "I’m a sys admin NOOB. I am also teaching myself to code. This is my first
> time setting up this stack so there are probably going to be some
> bugs/security issues I conveniently side stepped just to get it to work."
>
> "This is obviously not secure enough for a ‘production’ environment."
>
> If that's what you want to model your deployment after, be my guest. I
> hardly think it's fallacious of me to suggest someone do otherwise.
>
>
> >  # he uses apache instead of... well... anything else
>
>> well-tuned apache and mod_wsgi is on the same league as the cool boys.
>>  (i still prefer nginx, and i don't think this is a good example of
>> apache tuning, but nothing bad about it)
>>
> I don't care a whit about what "the cool boys" are doing. What I care
> about is a production deployment that works efficiently and reliably and
> that is diagnosable when something doesn't work. Apache fails those
> criteria; nginx and lighttpd pass (in my opinion and the opinion of many
> other developers who have used these technologies for non-trivial web
> applications in production environments).
>
>
>> > Bonus reason:
>>
>> >  # he uses mysql instead of postgres
>>
>> again, might not be the bestest choice but nowhere near a bad one.
>>
> That's why I listed it as a bonus reason. Better than mssql and sqlite for
> a production deployment anyway, eh?
>
>
> --Stuart
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/ByBrEdUj8HUJ.
>
> 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: collectstatic missing on Linux

2012-01-09 Thread Jeff Heard
Make sure the staticfiles app is in your INSTALLED_APPS setting.  That'd be
my first guess.  If it is, do a manage.py console and try importing it to
make sure that the django environment can see it.

-- Jeff

On Tue, Jan 10, 2012 at 1:22 AM, Mike Dewhirst wrote:

> The manage.py collectstatic subcommand doesn't exist on my Linux staging
> server but it does exist (and works) on my Win XP development machine. I'm
> using exactly the same settings.py on both machines.
>
> On Linux, in a Python interpreter I can do ...
>
> >>>from django.contrib import staticfiles
> >>>
>
> ... but when I type
>
> $/usr/bin/python /srv/www/proj/manage.py help
>
> ... it returns a list of available subcommands[1] without collectstatic in
> the list.
>
> Win XP 32-bit
> Python 2.7
> Django 1.4a
>
> Linux 64-bit
> Python 2.6
> Django 1.4a
>
> The application itself runs under Apache on the Linux staging server if I
> manually copy all the static files to the STATIC_ROOT directory.
>
> Any hints appreciated
>
> Thanks
>
> Mike
>
> [1]
> Available subcommands:
>  cleanup
>  compilemessages
>  createcachetable
>  dbshell
>  diffsettings
>  dumpdata
>  flush
>  inspectdb
>  loaddata
>  makemessages
>  reset
>  runfcgi
>  runserver
>  shell
>  sql
>  sqlall
>  sqlclear
>  sqlcustom
>  sqlflush
>  sqlindexes
>  sqlinitialdata
>  sqlreset
>  sqlsequencereset
>  startapp
>  startproject
>  syncdb
>  test
>  testserver
>  validate
>
> --
> 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+unsubscribe@**
> 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.



ModelForms and ProcessFormViews w models containing BooleanFields

2011-12-20 Thread Jeff Heard
I feel like this should be obvious but I can't figure it out.  When
creating a ProcessFormView or a ModelForm on a model with a BooleanField
somewhere in, I get the classic problem of "This field is required" in the
actual rendered page.  Is there some way to turn off this behaviour and
make the fields editable?  I know in a regular form, you specify a
BooleanField(required=False) for all your boolean fields, but since the
ModelForms and in particular the ProcessFormViews are automatically
generated from the model, I can't seem to do that.

-- Jeff

-- 
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: Error in syncdb

2011-12-03 Thread Jeff Heard
Never mind.  My error was elsewhere.  A little putzing around led me to
realize that you can't put db_index=True into a geometry field of any sort
in PostGIS backend.

On Sat, Dec 3, 2011 at 11:25 AM, Jeff Heard <jefferson.r.he...@gmail.com>wrote:

> I have a custom field type that I defined, and now I can't do a syncdb.
>  The relevant bits of the type are
>
> class PyMongoField(models.CharField):
>__metaclass__ = models.SubFieldBase
>
>...
>def db_type(self, connection):
>   return 'varchar(64)'
>...
>
> But I just get this when I do reset or syncdb on an app with a model that
> uses that field type.  Any clue?
>
> Traceback (most recent call last):
>   File "manage.py", line 14, in 
> execute_manager(settings)
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 438, in execute_manager
> utility.execute()
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 379, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/base.py",
> line 191, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/base.py",
> line 220, in execute
> output = self.handle(*args, **options)
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/base.py",
> line 286, in handle
> app_output = self.handle_app(app, **options)
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/commands/reset.py",
> line 35, in handle_app
> sql_list = sql_reset(app, self.style, connection)
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/sql.py",
> line 107, in sql_reset
> return sql_delete(app, style, connection) + sql_all(app, style,
> connection)
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/sql.py",
> line 146, in sql_all
> return sql_create(app, style, connection) + sql_custom(app, style,
> connection) + sql_indexes(app, style, connection)
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/sql.py",
> line 141, in sql_indexes
> output.extend(connection.creation.sql_indexes_for_model(model, style))
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/db/backends/creation.py",
> line 250, in sql_indexes_for_model
> output.extend(self.sql_indexes_for_field(model, f, style))
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/creation.py",
> line 12, in sql_indexes_for_field
> output = super(PostGISCreation, self).sql_indexes_for_field(model, f,
> style)
>   File
> "/opt/data/ga/jeff/lib/python2.7/site-packages/django/db/backends/postgresql/creation.py",
> line 68, in sql_indexes_for_field
> if db_type.startswith('varchar'):
> AttributeError: 'NoneType' object has no attribute 'startswith'
>
>

-- 
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.



Error in syncdb

2011-12-03 Thread Jeff Heard
I have a custom field type that I defined, and now I can't do a syncdb.
 The relevant bits of the type are

class PyMongoField(models.CharField):
   __metaclass__ = models.SubFieldBase

   ...
   def db_type(self, connection):
  return 'varchar(64)'
   ...

But I just get this when I do reset or syncdb on an app with a model that
uses that field type.  Any clue?

Traceback (most recent call last):
  File "manage.py", line 14, in 
execute_manager(settings)
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/__init__.py",
line 438, in execute_manager
utility.execute()
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/__init__.py",
line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/base.py",
line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/base.py",
line 220, in execute
output = self.handle(*args, **options)
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/base.py",
line 286, in handle
app_output = self.handle_app(app, **options)
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/commands/reset.py",
line 35, in handle_app
sql_list = sql_reset(app, self.style, connection)
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/sql.py",
line 107, in sql_reset
return sql_delete(app, style, connection) + sql_all(app, style,
connection)
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/sql.py",
line 146, in sql_all
return sql_create(app, style, connection) + sql_custom(app, style,
connection) + sql_indexes(app, style, connection)
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/core/management/sql.py",
line 141, in sql_indexes
output.extend(connection.creation.sql_indexes_for_model(model, style))
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/db/backends/creation.py",
line 250, in sql_indexes_for_model
output.extend(self.sql_indexes_for_field(model, f, style))
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/creation.py",
line 12, in sql_indexes_for_field
output = super(PostGISCreation, self).sql_indexes_for_field(model, f,
style)
  File
"/opt/data/ga/jeff/lib/python2.7/site-packages/django/db/backends/postgresql/creation.py",
line 68, in sql_indexes_for_field
if db_type.startswith('varchar'):
AttributeError: 'NoneType' object has no attribute 'startswith'

-- 
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: Perhaps more of a general Python question, but..

2011-11-23 Thread Jeff Heard
Okay, I did this, but I also have stuff that I'm adding to the
django.contrib namespace, or at least I did.  I created the following:

django/
  __init__.py # empty
  contrib/
 __init__.py # empty

and in my packages line in setup.py I had just ['django'].

Now I seem to have overwritten all of django, because when I type python
manage.py shell I get

"no module named core.management"

-- Jeff

On Wed, Nov 23, 2011 at 2:15 PM, DrBloodmoney <drbloodmo...@gmail.com>wrote:

> On Wed, Nov 23, 2011 at 2:01 PM, Jeff Heard <jefferson.r.he...@gmail.com>
> wrote:
> > I have several django apps. all of which are in separate packages and
> can be
> > installed seperately.  I would like them all to be sub-packages of a
> master
> > package named "ga" So:
> > ga.datacube
> > ga.pyramid
> > ga.sensorcollection
> >  and so on.  The problem is that when I install them the packages never
> seem
> > to show up.  My project structure looks like this:
> > GA pyramid project:
> > /home/jeff/ga/ga_pyramid/
> > ga/
> >   __init__.py# contains "import pyramid"
> >   pyramid/
>  __init__.py #<<<< needs init
> >   models.py
> >   views.py
> >   tasks.py
> >   tests.py
> >   urls.py
> >   static/
> >   templates/
> >
> > GA datacube project:
> > /home/jeff/ga/ga_datacube/
> > ga/
> >   __init__.py# contains "import datacube"
> >   datacube/
>  __init__.py #<<<< needs init and here
> >   models.py
> >   views.py
> >   tasks.py
> >   tests.py
> >   urls.py
> >   static/
> >   templates/
>
> Make sure you add the __init__.py s to magically transform it into a module
>
> --
> 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.



Perhaps more of a general Python question, but..

2011-11-23 Thread Jeff Heard
I have several django apps. all of which are in separate packages and can
be installed seperately.  I would like them all to be sub-packages of a
master package named "ga" So:

ga.datacube
ga.pyramid
ga.sensorcollection

 and so on.  The problem is that when I install them the packages never
seem to show up.  My project structure looks like this:

GA pyramid project:
/home/jeff/ga/ga_pyramid/
ga/
  __init__.py# contains "import pyramid"
  pyramid/
  models.py
  views.py
  tasks.py
  tests.py
  urls.py
  static/
  templates/


GA datacube project:
/home/jeff/ga/ga_datacube/
ga/
  __init__.py# contains "import datacube"
  datacube/
  models.py
  views.py
  tasks.py
  tests.py
  urls.py
  static/
  templates/


My setup py's packages line for datacube is just ['ga.datacube']

but when install the app in settings.py and then do python manage.py shell,
I get this:

"no module named datacube"

I must be doing something wrong in my setup.py or else my package
structure, but I'm really not sure what. Can I install multiple packages
with the same prefix?

-- 
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: Editable datagrid

2011-11-21 Thread Jeff Heard
You have multiple licensing options.  One of those licenses is the GPL. How
that translates to "open source" is the source of an eternal flamewar that
we'll quietly skip.  If your organization permits GPL then you're fine.

-- Jeff

On Mon, Nov 21, 2011 at 11:43 PM, Vikas Rawal <
vikasli...@agrarianresearch.org> wrote:

>
> > I would look at Sencha.
>
> Does not seem open-source. Is it?
>
> Vikas
>
> --
> 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: Editable datagrid

2011-11-21 Thread Jeff Heard
I would look at Sencha.  They seem to have a nice clean grid control.  It
uses a RESTful interface for importing / exporting data from local data
models via an AJAX proxy.  You use JSON to ship  data back and forth.  I'd
think you could use something like django-piston to expose your models to
the grid, but I'm not 100% certain about that.

-- jeff

On Mon, Nov 21, 2011 at 11:46 AM, Vikas Rawal <
vikasli...@agrarianresearch.org> wrote:

> I am new to django and to web programming. I am trying to build a
> database application for entering/querying/viewing data from a mysql
> database. The data entry module needs to have datagrids where users
> can enter multiple rows of data belonging to a particular set.
>
> Would be grateful for pointers to resources on the best way to
> implement datagrids in django.
>
> Vikas
>
> --
> 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: Question on cleaning ModelForms

2011-10-18 Thread Jeff Heard
But I want to be able to invalidate my form if geocoding fails...  Can I still 
do that in the save method?



On Oct 18, 2011, at 4:52 AM, Daniel Roseman  wrote:

> On Monday, 17 October 2011 20:30:35 UTC+1, Jefferson Heard wrote:
> class FarmersMarket(ModelForm):
>class Meta:
>   model = models.FarmersMarket
>   exclude = ('location',)
>def clean(self):
>   place, (lat, lng) = _g.geocode(self.cleaned_data['address'])
>   self.cleaned_data['location'] = Point(lng,lat)
>   return self.cleaned_data
> 
> 
> 
> Here's my code minus the exception handling.  Now what I *want* to
> have happen is that the models.FarmersMarket.location field on the
> model is set sometime shortly after the form is submitted by the user,
> by way of geocoding the data, rather than having them tediously enter
> a POINT wkt string in the textarea field.  So my idea was to put a
> call to geopy.Google.geocode in FarmersMarket.self.clean.  I can
> confirm clean() is getting called, but for some reason, the 'location'
> field isn't being set in the model.  I get a whine from Django that
> the location field cannot be NULL (which is true, it can't).
> 
> Can anyone tell me how I'm supposed to be doing this? I want them to
> enter an address on the form, not a latitude/longitude pair.
> 
> -- Jeff
> 
> 
> The point is, you've told Django that `location` isn't a field on this form, 
> by specifying it in `exclude`. So Django doesn't take any notice of the extra 
> element you've added in cleaned_data.
> 
> The way to do this is to override the form's save method and do it there:
> 
> def save(self, commit=False):
> market = super(FarmersMarket, self).save(commit=False)
> place, (lat, lng) = _g.geocode(market.address)
> market.location = Point(lng,lat)
> if commit:
> market.save()
> return market
> 
> --
> DR.
>  
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/3LiBsqFIJYoJ.
> 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.



Question on cleaning ModelForms

2011-10-17 Thread Jeff Heard
class FarmersMarket(ModelForm):
   class Meta:
  model = models.FarmersMarket
  exclude = ('location',)

   def clean(self):
  place, (lat, lng) = _g.geocode(self.cleaned_data['address'])
  self.cleaned_data['location'] = Point(lng,lat)
  return self.cleaned_data



Here's my code minus the exception handling.  Now what I *want* to
have happen is that the models.FarmersMarket.location field on the
model is set sometime shortly after the form is submitted by the user,
by way of geocoding the data, rather than having them tediously enter
a POINT wkt string in the textarea field.  So my idea was to put a
call to geopy.Google.geocode in FarmersMarket.self.clean.  I can
confirm clean() is getting called, but for some reason, the 'location'
field isn't being set in the model.  I get a whine from Django that
the location field cannot be NULL (which is true, it can't).

Can anyone tell me how I'm supposed to be doing this? I want them to
enter an address on the form, not a latitude/longitude pair.

-- Jeff

-- 
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: Is there a way to provide a delete-hook on a custom field?

2011-09-13 Thread Jeff Heard
Thanks.  That works!

-- Jeff

On Tue, Sep 13, 2011 at 11:13 AM, Shawn Milochik  wrote:
> You can use the post_delete signal in Django's signals. Then, assuming your
> MongoDB collection name is derived from your model in a consistent manner
> then you're all set.
>
> --
> 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.



Is there a way to provide a delete-hook on a custom field?

2011-09-13 Thread Jeff Heard
I have a custom field class that very nicely references a document in
MongoDB, but I would like to have the document deleted if the record
is deleted.  That is, I have a MongoDBField that stores an object ID
in a structured database using the regular Django ORM.  The field
back-references to the record's primary key, so I can use NoSQL
lookups and SQL lookups interchangeably to find the same record, even,
which is quite nice.  However right now, Ihave to write a custom
delete() function for every model that uses it.  I'd like to have
something in the field that whenever the model instance's delete()
function is called. Perhaps the best thing is just to have a class
HybridModel(Model) and have all models that use both databases inherit
from that?

-- Jeff

-- 
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.