Alessandro Candini | 10 Feb 12:00
Picon
Gravatar

Thread local storage issue under Apache

Hi everyone.

I have a django project in where I've added a custom .py file which 
launches a shell command (a GDAL utility to manipulate shapefiles):
subprocess.call(["ogr2ogr", "-t_srs", "EPSG:900913", shpGoogle, shpOrig])

If I run the function containing this command using django web server 
everything works fine and my new file have produced and stored on the 
filesystem.

But if I run the same application under the Apache web server, I get the 
following error:
Fatal Python error: Couldn't create autoTLSkey mapping

Do you have any idea on how to solve this?

Thanks in advance

Configuration details follows...

I'm using Apache/2.2.20 on Ubuntu-11.10 mod_wsgi-3.3 Python-2.7.2 
django-1.3.1

My django.wsgi file is the following
import os, sys
sys.path.append('/home/candini/Repos/CanetaRepo/tmp/STO')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

(Continue reading)

kalyani ram | 10 Feb 09:56
Picon
Gravatar

email feature

Hey all,

I am trying to include a new feature to my email tool, which is used
for forwarding the mail to the appropriate user and storing it in a
separate queue using django_cron. Can someone tell me how to do this.
It would be very help as i have limited idea on django.
thanks in advance

--

-- 
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Subhodip Biswas | 10 Feb 05:02
Picon
Gravatar

[Error] Mixing Two databases

Hi all,

I am trying to use two database for my django(Django nonrel 1.3.1)
project. One is Postgres and other is MongoDB.
After filling in details in settings.py :

DATABASES = {
    'default': {
        'ENGINE': 'django_mongodb_engine', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'Mongo_MSTR',                      # Or path to
database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for
localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for
default. Not used with sqlite3.
    },
    'geodata': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'mydatabase',                      # Or path to
database file if using sqlite3.
        'USER': 'Username',                      # Not used with sqlite3.
        'PASSWORD': 'Password',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for
localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for
default. Not used with sqlite3.
(Continue reading)

Python_Junkie | 10 Feb 04:29
Picon

Is it possible to implement an ODBC for Django

I wanted to know if the settings.py will support a generic ODBC
connection and if it could what the syntax would be in the database
section of the , settings.py file

--

-- 
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Picon

QuerySet and subselect

Hello.
I have a model named MyModel and it has its own table named my_model (as
an example).

Is it possible to write ORM-way request to be same as this SQL:
SELECT mo.* FROM (SELECT mi.* FROM my_model mi) AS mo WHERE mi.a=mo.a
AND mi.b=mo.b;

There is also an agregation+group by statements in subselect, but let's
assume that we don't have them.

Thanks

Gath | 9 Feb 20:16
Picon
Gravatar

Contribute to Django

Guys,

What do i need to learn/know before i start contributing to django
development?

Thanks

Gath

--

-- 
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

최국태 | 9 Feb 17:21
Picon
Gravatar

Re: Moving from python 3 to 2.x in windows 7 to use Django



Hi! 

I have 2 python version ( Python 2.7 and 3.2 ) in Windows 7. But I use Python 3.1 usually. ( I have 2 directories( Python27 and Python32 ))
I decided to use Django and tried to install it as guideline in https://docs.djangoproject.com/en/1.3/topics/install/#installing-official-release

But I got an error message while installing such as
File "C:\Django-131\setup.py", line 70
     if u'SVN' in version:

SyntaxError: Invalid syntax. 

By googling, I found that it came from python version I am using. 
So I thought my Windows takes Python 3.2 as default one. 
I tried to change it to Python 2.7 but failed. 
Would you please let me know how I can move from Python 3.2 to Python 2.7 in Winodws 7? 

Regards
KTChoi




--
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
trubliphone | 9 Feb 16:37
Picon
Gravatar

passing kwargs to forms of a formset - why is this working?

All,

I have managed to get some code working that passes extra kwargs to the __init__() function of the member forms of a formset.  This is good.  But I have no idea why it works.  Here is my basic code:

<snip>

class MyModel(models.Model):
  myField = models.CharField(max_length=10)

class MyForm(ModelForm):
  _request = None
  class Meta:
    model = MyModel
  def __init__(self,*args,**kwargs):
    self._request = kwargs.pop("request",None)
    super(MyForm,self).__init__(*args,**kwargs)
    # do something clever with request...

class MyFormsetBase(BaseModelFormSet):
  _request = None

  def __init__(self,*args,**kwargs):
    self.request = kwargs.pop("request",None)
    SubFormClass = self.form
    self.form = curry(SubFormClass,request=self._request)
    super(MyFormsetBase,self).__init(*args,**kwargs)

MyFormset = modelformset_factory(MyModel,formset=MyFormsetBase,can_delete=True)
MyFormset.form = staticmethod(curry(MyForm,request=MyFormsetBase._request))

</snip>

So if I initialize a formset like this:

<snip>
  # assume I got myRequest from my view function...
  myFormset = MyFormset(request.POST,request=myRequest)
</snip>

Then everything works; the forms of my formset are passed in "request" during initialization.  But I don't understand what's happening.  Why do I have to set the forms attribute twice - once inside the formset __init__() override, and once outside the class definition?  What's going on here?

Any advice would be appreciated.
            else:
                value[2] = subFormClass(queryset=qs,prefix=key,request=self._request)


--
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
kalyani ram | 9 Feb 15:10
Picon
Gravatar

regarding an error in settings.py

Hey all,
Tday is my first day with django and i tried configuring postgresql as
a backend and got an error like this:

 raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2
module: No module named psycopg2

Please help me. Thanks in advance.

--

-- 
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

anand jeyahar | 9 Feb 12:29
Picon
Gravatar

django error

Hi,
   Am rather new to django and this error makes no sense to me..

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/
base.py", line 460, in save
    self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/
base.py", line 522, in save_base
    manager.using(using).filter(pk=pk_val).exists())):
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/
query.py", line 550, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/
query.py", line 568, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
query.py", line 1194, in add_q
    can_reuse=used_aliases, force_having=force_having)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
query.py", line 1129, in add_filter
    connector)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
where.py", line 67, in add
    value = obj.prepare(lookup_type, value)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
where.py", line 316, in prepare
    return self.field.get_prep_lookup(lookup_type, value)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/
__init__.py", line 292, in get_prep_lookup
    return self.get_prep_value(value)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/
__init__.py", line 479, in get_prep_value
    return int(value)
ValueError: invalid literal for int() with base 10: '192.168.8.123'

Rather what i don't understand is why django is trying to int casting
the string... find attached the models.py file and the script am
running in python manage.py shell.

models.py:

#!/usr/bin/env python
import datetime
from django.db import models

class Lock(models.Model):

#    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=100,unique=True)
    #value = models.IntegerField(null=True)
    # No point.. if the record exists, there's  a lock, else there
isn't.
    info = models.CharField(max_length=1000)
    timestamp = models.DateTimeField(auto_now=True)

    @classmethod
    def clean(self, name, age=0):
        # Get a datetime that is offset by 'age' seconds
        dt = datetime.datetime.now() - datetime.timedelta(seconds=age)

        # Query and delete
        old = Lock.objects.filter(name=name , timestamp__lte=dt)
        old.delete()

Here's the code that triggers the error.

from locker.models import *

name = "192.168.8.123"
info = "Migrating VIP %s at %s "%("234.34.32.342","12.34.43.22")
lock = Lock(name,info)
lock.save()

now from what i understand django tries to search the table with the
primary key as the name field. But django documentation says it by
default creates an automatic  primary key field 'id'. My question is
why does it expect it to be explicitly passed??

--

-- 
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Demetrio Girardi | 9 Feb 13:46
Picon

WSGIHandler freezes, how do I find out why?

I have a single django project, deployed on two separate installations
of Apache + python + mod_wsgi.

The first installation has python 2.6 and everything works fine.

The second installation has python 2.7. With this one, a few things
work correctly - namely django's debug 404 pages, the login page.
However, when I try to access some views, WSGIHandler simply freezes
forever and I have no idea how to debug this. Once the thing freezes,
it stays frozen until I restart apache (not even 404 pages work
anymore).

I tried wrapping WSGIHandler in some dummy code in the wsgi script and
that gets executed no problem.

The development server runs fine on the same python 2.7 installation.

--

-- 
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Gmane