Bulk add foreign keys in admin interface

2013-10-25 Thread Kristofer Pettijohn
I am using the following type of model setup: 

class Product(models.Model): 
name = models.CharField(max_length=40) 
description = models.TextField(blank=True) 
active = models.BooleanField(default=True) 
priority = models.IntegerField(default=100) 
size_chart = models.ForeignKey(SizeChart) 
designer = models.ForeignKey(Designer) 
collections = models.ManyToManyField(Collection) 
categories = models.ManyToManyField(Category) 
price = models.DecimalField(max_digits=6, decimal_places=2) 
def __unicode__(self): 
return self.name 

class Variation(models.Model): 
color = models.ForeignKey(Color) 
size = models.ForeignKey(Size) 
product = models.ForeignKey(Product) 
price_override = models.DecimalField(max_digits=6, decimal_places=2, 
blank=True) 

I have Variations setup as TabularInline in Django admin. However, there are > 
200 different colors, and about 20 sizes. Adding 10 different colors with 15 
sizes is a lot of clicking for someone. What I would like to do is add some 
type of dropdown where multiple colors, along with multiple Sizes, can be 
selected, and then all of the Variations will be created for the cross product 
of those two selections. 

What I envision is having an area somewhere in the Django Admin for Product 
that is titled "Bulk Add" with drop down boxes for both Color and Size where 
multiple values for each can be selected. When the user is happy with their 
selection, they will click a button and all of the Variations will be created 
and the user will be back to the product page with all of the options now 
visible in the TabularInline section. 

Is this type of action possible? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1899431826.178951.1382753821780.JavaMail.zimbra%40cybernetik.net.
For more options, visit https://groups.google.com/groups/opt_out.


(3rd party app) How to safely reverse a custom user model admin url?

2013-10-25 Thread Ivan VenOsdel
My project uses a custom user model and I am trying to use a 3rd party app 
that uses the Reversing Admin 
URLstechnique
 to enhance my administration interface.

However problems arise when the app tries to make use of the url template 
tag to do a reverse lookup on the auth user ModelAdmin instance. When 
'auth_user_(something)' is referenced directly the template will produce a 
NoReverseMatch error. 

I would like to produce a patch for the package maintainer but I am unsure 
of how to reference the stand in user model without tying the app to my 
project or doing something kludgy that goes against the spirit of the 
django url tag.

The specific app I have been working with is the django-blog-zinnia 
application. Zinnia is using the following technique to provide changeset 
details in a generic way through the Django admin. 

The problem occurs when it tries to reverse auth_user_* when the site is 
using a custom user model. For Zinnia it occurs in the following places.

   - 
   
https://github.com/Fantomas42/django-blog-zinnia/blob/develop/zinnia/templates/admin/zinnia/widgets/_content_stats.html#L36
   - 
   
https://github.com/Fantomas42/django-blog-zinnia/blob/develop/zinnia/templates/zinnia/entry_list.html#L84

I have already 
reportedthis
 issue to the Zinnia maintainer however I would like to provide 
something more meaningful in the way of a patch. Replacing the auth_user 
part of the offending lines with 'myapp_customuser' will fix the issue for 
me but how do I do something that is viable for a 3rd party application?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11e950f6-a0da-4cc5-bb9c-ea88025915f8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Getting GIS Working - possible kernel32 problem

2013-10-25 Thread Sam Lai
Can you try running 'python.exe manage.py runserver' outside of
PyCharm, i.e. in the Command Prompt/PowerShell?

I've got a similar setup, although on Windows 7, and it works. Instead
of setting environment variables, I added the following parameters
into my settings.py to indicate the location of the GEOS DLLs -

GEOS_LIBRARY_PATH = os.sep.join((PROJECT_PATH, '..', 'Scripts', 'geos_c.dll'))
GDAL_LIBRARY_PATH = os.sep.join((PROJECT_PATH, '..', 'Scripts', 'gdal110.dll'))

Find those two files on your system (I didn't install GDAL or OSGeo4W
so I can't tell you where) and set the above parameters in settings.py
and see how you go.

On 26 October 2013 00:40, Robin St.Clair  wrote:
> Hi
>
> I am working with a project started by somebody else.It uses GIS. I have
> installed GDAL and OpenGeo4W, plus the C++ runtime.
>
> I have the following included in the path
>
> C:\Python27\;C:\Python27\Scripts;C:\Python27\Tools\Scripts\;C:\Python27\lib\site-packages;C:\gdalwin32-1.6\bin;C:\usr\bin;C:\Program
> Files\GDAL;C:\ms4w\Apache\cgi-bin;C:\OSGeo4W\bin;
>
>
> and the following environment variables are set
>
> GDAL_DATA = %OSGEO4W_ROOT%\share\gdal
> GDAL_DRIVER_PATH = C:\Program Files\GDAL\gdalplugins
> GEOS_LIBRARY_PATH=C:\OSGeo4W\lib
> OSGEO4W_ROOT=C:\OSGeo4w
> PROJ_LIB=%OSGEO4W_ROOT%\share\proj
> PYTHON_ROOT=C:\Python27
>
>
> Originally this development started on a linux box, I am using Vista SP2.
>
> My database is PostgreSQL 9.3, I have installed the PostGIS options and set
> up a normal and a GIS database.
>
> When I start runserver through Pycharm, I get the errors at the bottom of
> this post.
>
> It appears, and I might be wrong as I'm not mega experienced with this, that
> django/python can't find kernell32. This is used by the C library.
>
> Here is what I have found from thr debugger
> self = unable to get repr for class  handle=None
> mode=0
> name='kernel32'
> Funcptr = 
>
> Can somebody please point me in the correct direction, I'm banging my head
>
> Thanks
>
> Robin
>
>
> GEODJANGOGeos, TRACEBACK
>
> "C:\Program Files\JetBrains\PyCharm 3.0.1\bin\runnerw.exe"
> C:\Python27\python.exe "C:\Program Files\JetBrains\PyCharm
> 3.0.1\helpers\pycharm\django_manage.py" runserver  "C:/Users/Robin
> St.Clair/Desktop/CheckBuild"
>
> Validating models...
>
> Unhandled exception in thread started by   0x02E17EB0>>
>
> Traceback (most recent call last):
>
>   File
> "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py",
> line 92, in inner_run self.validate(display_num_errors=True)
>
>   File "C:\Python27\lib\site-packages\django\core\management\base.py", line
> 280, in validate num_errors = get_validation_errors(s, app)
>
>   File "C:\Python27\lib\site-packages\django\core\management\validation.py",
> line 35, in get_validation_errors for (app_name, error) in
> get_app_errors().items():
>
>   File "C:\Python27\lib\site-packages\django\db\models\loading.py", line
> 166, in get_app_errors self._populate()
>
>   File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 72,
> in _populate self.load_app(app_name, True)
>
>   File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 96,
> in load_app models = import_module('.models', app_name)
>
>   File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35,
> in import_module __import__(name)
>
>   File "C:\Python27\lib\site-packages\mptt\models.py", line 14, in 
> from mptt.fields import TreeForeignKey, TreeOneToOneField,
> TreeManyToManyField
>
>   File "C:\Python27\lib\site-packages\mptt\fields.py", line 42, in 
> from south.modelsinspector import add_introspection_rules
>
>   File
> "C:\Python27\lib\site-packages\south-0.8.2-py2.7.egg\south\modelsinspector.py",
> line 463, in  import south.introspection_plugins
>
>   File
> "C:\Python27\lib\site-packages\south-0.8.2-py2.7.egg\south\introspection_plugins\__init__.py",
> line 5, in  import south.introspection_plugins.geodjango
>
>   File
> "C:\Python27\lib\site-packages\south-0.8.2-py2.7.egg\south\introspection_plugins\geodjango.py",
> line 14, in  from django.contrib.gis.db.models.fields import
> GeometryField
>
>   File
> "C:\Python27\lib\site-packages\django\contrib\gis\db\models\__init__.py",
> line 5, in  from django.contrib.gis.db.models.aggregates import *
>
>   File
> "C:\Python27\lib\site-packages\django\contrib\gis\db\models\aggregates.py",
> line 2, in  from django.contrib.gis.db.models.sql import GeomField
>
>   File
> "C:\Python27\lib\site-packages\django\contrib\gis\db\models\sql\__init__.py",
> line 2, in  from django.contrib.gis.db.models.sql.query import
> GeoQuery
>
>   File
> "C:\Python27\lib\site-packages\django\contrib\gis\db\models\sql\query.py",
> line 4, in  from django.contrib.gis.db.models.fields import
> GeometryField
>
>   File
> "C:\Python27\lib\site-packages\django\contrib\gis\db\models\fields.py", line
> 4, in  from django.contrib.gis import forms
>
>   File 

Haystack - Stopwords

2013-10-25 Thread Ezequiel Bertti
I create a repository with a lot of stopwords of many languages.

https://github.com/ebertti/language-resource

Please, make your contribution!

-- 
Ezequiel Bertti
E-Mail: eber...@gmail.com
Cel: (21) 9188-4860

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACrQMYqVrFa9eUJBLBdtwxTSM-hRjGsb8n4hS5ddnJS2wRgwAw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Formatacao

2013-10-25 Thread fabricio mata de castro Mata

even through the code {{form.valor_ultimacompra | floatformat: 2}} does not 
return 
anything.

my model is

valor_ultimacompra = models.DecimalField (u'Vlr. Ult.Compra 'max_digits = 18
, decimal_places = 2, default = 0, blank = True, null = True)


when you step this way}} {{form.valor_ultimacompra works


can someone ajuadar me?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ea67281b-0e8e-48bf-9df3-3a19a0944e2e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Formatacao

2013-10-25 Thread Sandro Dutra
First it's recommeded to post in english. Recomendado postar em inglês.

Não sei que essa template tag "foundation" faz, você precisa explicar,
tendo em vista que ela não é built-in, já a referência de floatformat está
aqui:
https://docs.djangoproject.com/en/1.5/ref/templates/builtins/#floatformat

Sendo assim acho que não está retornando um float para ser tratado pelo
floatformat.

De resto, não tem como te ajudar com essa dúvida incompleta, não tem
informação suficiente. Da próxima, seja mais cuidadoso e escreva em inglês,
esta é uma lista internacional.


2013/10/25 fabricio mata de castro Mata 

>  estou usando no html
>
>{{ form.valor_ultimacompra|foundation }}
>
>
> quando tendo colocar  {{
> form.valor_ultimacompra|foundation|floatformat:2 }} o campo some alguem
> pode me ajudar?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/137f5a1e-8a60-415f-a7e8-df4a7cab6f6a%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAH%2Bpf9nnGyRObgvgHtFMGP%3DXTV1nuafMCs0R%3DBsimMKbm08M-g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


formatacao

2013-10-25 Thread fabricio mata de castro Mata


Quando uso no meu html   {{ form.valor_ultimacompra|foundation }} funciona 
mostra o valor  mas quando uso


  {{ form.valor_ultimacompra|foundation|floatformat:2 }} o valor some 


alguem pode me ajudar

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20de9fc9-9aae-4864-a311-d2e9286f6854%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Formatacao

2013-10-25 Thread fabricio mata de castro Mata
 estou usando no html  

   {{ form.valor_ultimacompra|foundation }}


quando tendo colocar  {{ 
form.valor_ultimacompra|foundation|floatformat:2 }} o campo some alguem 
pode me ajudar?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/137f5a1e-8a60-415f-a7e8-df4a7cab6f6a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Bug in admin models?

2013-10-25 Thread Sandro Dutra
Sorry, I didn't see the django.contrib.admin. You're overrriding the add
method for you model? Because it's appear the add method is returning None:

Exception Type: TypeError at /admin/myapp/mymodel/add/
Exception Value: 'NoneType' object has no attribute '__getitem__'


2013/10/25 Derek 

> Yes, I simplified the names in the installed list and traceback, and as
> result probably altered the correct grammer slighlty ... but I am hoping
> that someone who understand the "innards" of the Django admin can point
> what is _actually_ wrong; given that the error trace is not actually
> referencing any lines in my app/project.
>
>
>
> On Thursday, 24 October 2013 16:17:17 UTC+2, Nigel Legg wrote:
>
>> In installed apps you have s2.myapp, the traceback is just myapp.  Also
>> you have 's2.myapp, in the installed_apps, should it not be 's2.myapp', (ie
>> missing the end quote)?
>>
>>
>> Cheers, Nigel
>> 07914 740972
>>
>>
>>
>> On 24 October 2013 14:20, Derek  wrote:
>>
>>>  Yes, its there - the line after 'suit'.
>>>
>>>
>>> On Wednesday, 23 October 2013 19:22:54 UTC+2, Odin wrote:
>>>
 Can't see the django.contrib.admin in INSTALLED_APPS.


 2013/10/23 Derek 

> I am trying to add a model entry, via the admin; I get this error
> (which has not happened before), running Django on Ubuntu 12.04 with the
> test server.  Not sure if there is an error with the model (which has
> worked fine up to now) or ...?
>
>
> Request Method: POST
> Request URL: 
> http://127.0.0.1:8000/admin/**my**app/mymodel/add/
>
> Django Version: 1.5.4
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.staticfiles',
>  'django.contrib.messages',
>  'django.contrib.admindocs',
>  'django_nose',
>  'django_extensions',
>  'crispy_forms',
>  'autocomplete_light',
>  'admin_enhancer',
>  'smart_selects',
>  'selectable',
>  'massadmin',
>  's2.myapp,
>  'suit',
>  'django.contrib.admin')
> Installed Middleware:
> ('django.middleware.common.**Com**monMiddleware',
>  'django.contrib.sessions.**midd**leware.SessionMiddleware',
>  'django.middleware.csrf.**CsrfV**iewMiddleware',
>  'django.contrib.auth.**middlewa**re.**AuthenticationMiddleware',
>  'django.contrib.messages.**midd**leware.MessageMiddleware',
>  's2s.middle.middleware.**AdminS**essionMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/**dist**-packages/django/core/**
> handlers**/base.py" in get_response
>   115. response = callback(request,
> *callback_args, **callback_kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/options.py" in wrapper
>   372. return self.admin_site.admin_view(**vie**w)(*args,
> **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/utils/**
> decorat**ors.py" in _wrapped_view
>   91. response = view_func(request, *args,
> **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/views/**
> decorat**ors/cache.py" in _wrapped_view_func
>   89. response = view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/sites.py" in inner
>   202. return view(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/utils/**
> decorat**ors.py" in _wrapper
>   25. return bound_func(*args, **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/utils/**
> decorat**ors.py" in _wrapped_view
>   91. response = view_func(request, *args,
> **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/utils/**
> decorat**ors.py" in bound_func
>   21. return func(self, *args2, **kwargs2)
> File "/usr/local/lib/python2.7/**dist**-packages/django/db/**
> transactio**n.py" in inner
>   223. return func(*args, **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/options.py" in add_view
>   1009. self.log_addition(request, new_object)
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/options.py" in log_addition
>   530. action_flag = ADDITION
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/models.py" in log_action
>   18. e = self.model(None, None, user_id, content_type_id,
> smart_text(object_id), object_repr[:200], action_flag, change_message)
>
> Exception Type: TypeError at 

Re: Django traffic control

2013-10-25 Thread Thomas Orozco
You could use middleware, or a view decorator
On Oct 25, 2013 5:33 PM, "Nuno Lopes"  wrote:

> Hi guys/girls,
>
> I have a project in Django and I want to control the access to an API.
> Basically just know and register who is using it.
> I could go to each controller and do this by hand using the api key. But I
> am hoping that there is a better solution.
>
> Do you have some suggestion to give me? There's already some app doing
> this kind of site/url statistics?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/04451e5d-ad4e-411e-85b5-9986c77687d7%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMuNovRO%3DgrVv4RbfFBG6a4HJZFnE-MpAAdrHimDY5UXOVagQg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django traffic control

2013-10-25 Thread Nuno Lopes
Hi guys/girls, 

I have a project in Django and I want to control the access to an API. 
Basically just know and register who is using it.
I could go to each controller and do this by hand using the api key. But I 
am hoping that there is a better solution.

Do you have some suggestion to give me? There's already some app doing this 
kind of site/url statistics?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/04451e5d-ad4e-411e-85b5-9986c77687d7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Bug in admin models?

2013-10-25 Thread Derek
Yes, I simplified the names in the installed list and traceback, and as 
result probably altered the correct grammer slighlty ... but I am hoping 
that someone who understand the "innards" of the Django admin can point 
what is _actually_ wrong; given that the error trace is not actually 
referencing any lines in my app/project.


On Thursday, 24 October 2013 16:17:17 UTC+2, Nigel Legg wrote:
>
> In installed apps you have s2.myapp, the traceback is just myapp.  Also 
> you have 's2.myapp, in the installed_apps, should it not be 's2.myapp', (ie 
> missing the end quote)? 
>
>
> Cheers, Nigel 
> 07914 740972
>
>
>
> On 24 October 2013 14:20, Derek  wrote:
>
>> Yes, its there - the line after 'suit'.
>>
>>
>> On Wednesday, 23 October 2013 19:22:54 UTC+2, Odin wrote:
>>
>>> Can't see the django.contrib.admin in INSTALLED_APPS.
>>>
>>>
>>> 2013/10/23 Derek 
>>>
 I am trying to add a model entry, via the admin; I get this error 
 (which has not happened before), running Django on Ubuntu 12.04 with the 
 test server.  Not sure if there is an error with the model (which has 
 worked fine up to now) or ...?


 Request Method: POST
 Request URL: 
 http://127.0.0.1:8000/admin/**myapp/mymodel/add/

 Django Version: 1.5.4
 Python Version: 2.7.3
 Installed Applications:
 ('django.contrib.auth',
  'django.contrib.contenttypes'**,
  'django.contrib.sessions',
  'django.contrib.staticfiles',
  'django.contrib.messages',
  'django.contrib.admindocs',
  'django_nose',
  'django_extensions',
  'crispy_forms',
  'autocomplete_light',
  'admin_enhancer',
  'smart_selects',
  'selectable',
  'massadmin',
  's2.myapp,
  'suit',
  'django.contrib.admin')
 Installed Middleware:
 ('django.middleware.common.**CommonMiddleware',
  'django.contrib.sessions.**middleware.SessionMiddleware',
  'django.middleware.csrf.**CsrfViewMiddleware',
  'django.contrib.auth.**middleware.**AuthenticationMiddleware',
  'django.contrib.messages.**middleware.MessageMiddleware',
  's2s.middle.middleware.**AdminSessionMiddleware')


 Traceback:
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/core/**handlers/base.py" 
 in get_response
   115. response = callback(request, 
 *callback_args, **callback_kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/options.py"
  
 in wrapper
   372. return self.admin_site.admin_view(**view)(*args, 
 **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py" 
 in _wrapped_view
   91. response = view_func(request, *args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/views/**decorators/cache.py"
  
 in _wrapped_view_func
   89. response = view_func(request, *args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/sites.py" 
 in inner
   202. return view(request, *args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py" 
 in _wrapper
   25. return bound_func(*args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py" 
 in _wrapped_view
   91. response = view_func(request, *args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py" 
 in bound_func
   21. return func(self, *args2, **kwargs2)
 File "/usr/local/lib/python2.7/**dist-packages/django/db/**transaction.py" 
 in inner
   223. return func(*args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/options.py"
  
 in add_view
   1009. self.log_addition(request, new_object)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/options.py"
  
 in log_addition
   530. action_flag = ADDITION
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/models.py"
  
 in log_action
   18. e = self.model(None, None, user_id, content_type_id, 
 smart_text(object_id), object_repr[:200], action_flag, change_message)

 Exception Type: TypeError at /admin/myapp/mymodel/add/
 Exception Value: 'NoneType' object has no attribute '__getitem__'

  -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to django-users...@**googlegroups.com.
 To post to this group, send email to 

Getting GIS Working - possible kernel32 problem

2013-10-25 Thread Robin St.Clair
Hi

I am working with a project started by somebody else.It uses GIS. I have 
installed GDAL and OpenGeo4W, plus the C++ runtime.

I have the following included in the path

   - 
C:\Python27\;C:\Python27\Scripts;C:\Python27\Tools\Scripts\;C:\Python27\lib\site-packages;C:\gdalwin32-1.6\bin;C:\usr\bin;C:\Program
 
   Files\GDAL;C:\ms4w\Apache\cgi-bin;C:\OSGeo4W\bin;
   

and the following environment variables are set

   - GDAL_DATA = %OSGEO4W_ROOT%\share\gdal
   - GDAL_DRIVER_PATH = C:\Program Files\GDAL\gdalplugins
   - GEOS_LIBRARY_PATH=C:\OSGeo4W\lib
   - OSGEO4W_ROOT=C:\OSGeo4w
   - PROJ_LIB=%OSGEO4W_ROOT%\share\proj
   - PYTHON_ROOT=C:\Python27
   

Originally this development started on a linux box, I am using Vista SP2.

My database is PostgreSQL 9.3, I have installed the PostGIS options and set 
up a normal and a GIS database.

When I start runserver through Pycharm, I get the errors at the bottom of 
this post.

It appears, and I might be wrong as I'm not mega experienced with this, 
that django/python can't find kernell32. This is used by the C library.

Here is what I have found from thr debugger
self = unable to get repr for class 

Can somebody please point me in the correct direction, I'm banging my head

Thanks

Robin


*GEODJANGOGeos, TRACEBACK*

"C:\Program Files\JetBrains\PyCharm 3.0.1\bin\runnerw.exe" 
C:\Python27\python.exe "C:\Program Files\JetBrains\PyCharm 
3.0.1\helpers\pycharm\django_manage.py" runserver  "C:/Users/Robin 
St.Clair/Desktop/CheckBuild"

Validating models... 

Unhandled exception in thread started by >

Traceback (most recent call last):

  File 
"C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", 
line 92, in inner_run self.validate(display_num_errors=True)  

  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
280, in validate num_errors = get_validation_errors(s, app)

  File 
"C:\Python27\lib\site-packages\django\core\management\validation.py", line 
35, in get_validation_errors for (app_name, error) in 
get_app_errors().items():

  File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 
166, in get_app_errors self._populate()

  File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 
72, in _populate self.load_app(app_name, True)

  File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 
96, in load_app models = import_module('.models', app_name)

  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, 
in import_module __import__(name)

  File "C:\Python27\lib\site-packages\mptt\models.py", line 14, in  
from mptt.fields import TreeForeignKey, TreeOneToOneField, 
TreeManyToManyField

  File "C:\Python27\lib\site-packages\mptt\fields.py", line 42, in  
from south.modelsinspector import add_introspection_rules

  File 
"C:\Python27\lib\site-packages\south-0.8.2-py2.7.egg\south\modelsinspector.py", 
line 463, in  import south.introspection_plugins

  File 
"C:\Python27\lib\site-packages\south-0.8.2-py2.7.egg\south\introspection_plugins\__init__.py",
 
line 5, in  import south.introspection_plugins.geodjango

  File 
"C:\Python27\lib\site-packages\south-0.8.2-py2.7.egg\south\introspection_plugins\geodjango.py",
 
line 14, in  from django.contrib.gis.db.models.fields import 
GeometryField

  File 
"C:\Python27\lib\site-packages\django\contrib\gis\db\models\__init__.py", 
line 5, in  from django.contrib.gis.db.models.aggregates import *

  File 
"C:\Python27\lib\site-packages\django\contrib\gis\db\models\aggregates.py", 
line 2, in  from django.contrib.gis.db.models.sql import GeomField

  File 
"C:\Python27\lib\site-packages\django\contrib\gis\db\models\sql\__init__.py", 
line 2, in  from django.contrib.gis.db.models.sql.query import 
GeoQuery

  File 
"C:\Python27\lib\site-packages\django\contrib\gis\db\models\sql\query.py", 
line 4, in  from django.contrib.gis.db.models.fields import 
GeometryField

  File 
"C:\Python27\lib\site-packages\django\contrib\gis\db\models\fields.py", 
line 4, in  from django.contrib.gis import forms

  File 
"C:\Python27\lib\site-packages\django\contrib\gis\forms\__init__.py", line 
2, in  from django.contrib.gis.forms.fields import GeometryField

  File "C:\Python27\lib\site-packages\django\contrib\gis\forms\fields.py", 
line 8, in  from django.contrib.gis.geos import GEOSException, 
GEOSGeometry

  File "C:\Python27\lib\site-packages\django\contrib\gis\geos\__init__.py", 
line 6, in  from django.contrib.gis.geos.geometry import 
GEOSGeometry, wkt_regex, hex_regex

  File "C:\Python27\lib\site-packages\django\contrib\gis\geos\geometry.py", 
line 16, in  from django.contrib.gis.geos.coordseq import 
GEOSCoordSeq

  File "C:\Python27\lib\site-packages\django\contrib\gis\geos\coordseq.py", 
line 9, in  from django.contrib.gis.geos.libgeos import CS_PTR

  File "C:\Python27\lib\site-packages\django\contrib\gis\geos\libgeos.py", 
line 58, in  lgeos = CDLL(lib_path)

  File "C:\Python27\lib\ctypes\__init__.py", line 365, 

Re: Sessions memory issue

2013-10-25 Thread François Schiettecatte
John

You could certainly use that. I have not used it before.

François

On Oct 25, 2013, at 5:17 AM, John Carlo  wrote:

> Hello Francois, 
> 
> thank you very much for your reply. Not it's all clear.
> 
> What about using shelve?
> 
> import shelve
> 
> db = shelve.open("database", "c")
> db["one"] = 1
> db["two"] = 2
> db["three"] = 3
> db.close()
> 
> db = shelve.open("database", "r")
> for key in db.keys():
> print repr(key), repr(db[key])
> 
> 
> regards
> 
> Il giorno giovedì 24 ottobre 2013 23:10:43 UTC+2, François Schiettecatte ha 
> scritto:
> John 
> 
> There are a couple of ways you can handle this, either you store the files in 
> a database as a TEXT blob, or as a temporary file somewhere. 
> 
> And you can identify your users with request.user if they have to have an 
> account, or request.session.session_key if they don't, the session_key is the 
> cookie. For either to work the client has to accept cookies. 
> 
> The temporary file approach will required a database table to link the file 
> name to the user. 
> 
> I have used all of these and they all work well. 
> 
> If you need the text to be persistent across sessions I would store it in a 
> database, if it is around for an hour then just store it in a temporary file. 
> 
> And make sure you have a process to delete old data. 
> 
> Finally you could also compress the text when you save it. 
> 
> Hopes this helps. 
> 
> François 
> 
> 
> On Oct 24, 2013, at 3:51 PM, John Carlo  wrote: 
> 
> > Hello everybody, 
> > 
> > I'm a newbie with Django, I love it but something it's not clear to me. So 
> > I'm here to make a question. Thank you in advance. 
> > 
> > I have an application that has some istances of custom classes I wrote. At 
> > every client request, every istance creates a big list of strings. Then, a 
> > function combines the lists generated from the istances and send them to 
> > the client. 
> > I store the istances in the session, and the combining function get the 
> > istances through session. The problem is that the lists of strings comsume 
> > a  lot of memory... 
> > I know that sessions are stored in database, I can see them in the table 
> > django_session, but they are kept also in RAM, and this is my problem. 
> > How can I reduce the RAM memory consumption? 
> > 
> > I thought 2 ways: 
> > 1) Find a way to move the lists from the RAM and put them in the db, I hope 
> > there is something built-in in django session, but I did not find them 
> > 2) Instead building the lists of strings, I create a temp file in which I 
> > will append every string. In the end the combining function reads the temp 
> > files and combines them 
> > 
> > Could you please help me? I'm really I'm really stuck on this... 
> > 
> > thank you very much! 
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to django-users...@googlegroups.com. 
> > To post to this group, send email to django...@googlegroups.com. 
> > Visit this group at http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/django-users/c7118798-84fe-4a32-bba0-53452871b6ae%40googlegroups.com.
> >  
> > For more options, visit https://groups.google.com/groups/opt_out. 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/cbb30ae1-d903-4028-b8fa-7388c55d24d6%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Sessions memory issue

2013-10-25 Thread John Carlo
Hello Francois, 

thank you very much for your reply. Not it's all clear.

What about using shelve?

import shelve

db = shelve.open("database", "c")
db["one"] = 1
db["two"] = 2
db["three"] = 3
db.close()

db = shelve.open("database", "r")
for key in db.keys():
print repr(key), repr(db[key])


regards


Il giorno giovedì 24 ottobre 2013 23:10:43 UTC+2, François Schiettecatte ha 
scritto:
>
> John 
>
> There are a couple of ways you can handle this, either you store the files 
> in a database as a TEXT blob, or as a temporary file somewhere. 
>
> And you can identify your users with request.user if they have to have an 
> account, or request.session.session_key if they don't, the session_key is 
> the cookie. For either to work the client has to accept cookies. 
>
> The temporary file approach will required a database table to link the 
> file name to the user. 
>
> I have used all of these and they all work well. 
>
> If you need the text to be persistent across sessions I would store it in 
> a database, if it is around for an hour then just store it in a temporary 
> file. 
>
> And make sure you have a process to delete old data. 
>
> Finally you could also compress the text when you save it. 
>
> Hopes this helps. 
>
> François 
>
>
> On Oct 24, 2013, at 3:51 PM, John Carlo  
> wrote: 
>
> > Hello everybody, 
> > 
> > I'm a newbie with Django, I love it but something it's not clear to me. 
> So I'm here to make a question. Thank you in advance. 
> > 
> > I have an application that has some istances of custom classes I wrote. 
> At every client request, every istance creates a big list of strings. Then, 
> a function combines the lists generated from the istances and send them to 
> the client. 
> > I store the istances in the session, and the combining function get the 
> istances through session. The problem is that the lists of strings comsume 
> a  lot of memory... 
> > I know that sessions are stored in database, I can see them in the table 
> django_session, but they are kept also in RAM, and this is my problem. 
> > How can I reduce the RAM memory consumption? 
> > 
> > I thought 2 ways: 
> > 1) Find a way to move the lists from the RAM and put them in the db, I 
> hope there is something built-in in django session, but I did not find them 
> > 2) Instead building the lists of strings, I create a temp file in which 
> I will append every string. In the end the combining function reads the 
> temp files and combines them 
> > 
> > Could you please help me? I'm really I'm really stuck on this... 
> > 
> > thank you very much! 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/c7118798-84fe-4a32-bba0-53452871b6ae%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cbb30ae1-d903-4028-b8fa-7388c55d24d6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.