Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-09 Thread Jani Tiainen

9.1.2013 19:21, Ian Kelly kirjoitti:

On Wed, Jan 9, 2013 at 3:55 AM, Jani Tiainen <rede...@gmail.com> wrote:

Server is running Oracle Database 10g Release 10.2.0.5.0 - 64bit Production.
(EE edition)

and charset info:
NLS_CHARACTERSETWE8ISO8859P1
NLS_NCHAR_CHARACTERSET  AL16UTF16


Sorry, I meant your web server setup.



Windows 7, development server.

Staging server Ubuntu something (propably 10.04 LTS) 64bit

And symptoms were consistent. For some reason Django does something bad 
when it uses smart_str (and whatever that is in 1.5).


If we just force using force_unicode everything works except in older 
versions of cx_Oracle (our server had 5.0.4 or something) connection 
strings can't be unicode for some reason.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: ORM, Oracle and UTF-8 encoding problem.

2013-01-09 Thread Jani Tiainen

9.1.2013 12:28, Ian kirjoitti:

On Wednesday, January 9, 2013 12:38:28 AM UTC-7, Jani Tiainen wrote:

Tested against latest master. Same behaviour.

In Oracle backend base.py is following piece of code:

# Check whether cx_Oracle was compiled with the WITH_UNICODE option.
This will
# also be True in Python 3.0.
if int(Database.version.split('.', 1)[0]) >= 5 and not
hasattr(Database,
'UNICODE'):
  convert_unicode = force_text
else:
  convert_unicode = force_bytes

Which was added in
<https://github.com/django/django/commit/dcf3be7a62
<https://github.com/django/django/commit/dcf3be7a62>>

Thing is that my cx_Oracle is version 5.1.2, it has cx_Oracle.UNICODE
definition.


That sounds correct.  The cx_Oracle.UNICODE type constant is present
when cx_Oracle is compiled *without* the WITH_UNICODE option (which no
longer exists in 5.1 anyway).

And Django uses smart_str / force_bytes.

If I remove that and use convert_unicode as force_text / force_unicode
everything works as expected.


Strange, in 5.1 it shouldn't make any difference which is used, as long
as your NLS_LANG is getting set properly in the backend.  What is your
server setup?  It seems that sometimes that can get interfered with if
you have other services using Oracle in the same process.  It shouldn't
hurt anything though for us to do an additional check for cx_Oracle 5.1+
and always use force_text in that case.



Server is running Oracle Database 10g Release 10.2.0.5.0 - 64bit 
Production. (EE edition)


and charset info:
NLS_CHARACTERSETWE8ISO8859P1
NLS_NCHAR_CHARACTERSET  AL16UTF16

When cx_Oracle (Version 5.1.2) is compiled against 10.2.0.3 client:

I can insert unicode characters directly using cx_Oracle.
I can't insert unicode characters using ORM
I can't insert unicode characters using Django connection.cursor()

When cx_Oracle is compiled against instantclient 11.2 (multinational 
version) I can do all of the above without the problems.



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: ORM, Oracle and UTF-8 encoding problem.

2013-01-09 Thread Jani Tiainen

Ok, found source of the problem - but I don't know the solution.

I'm using Oracle client 10.2.0.3.0. It seems that unicode doesn't work 
there.


I compiled cx_Oracle against 11g instantclient 11.2 and it worked just fine.

So it must be something that Django assumes with Oracle and unicode 
capability.


I had cx_Oracle.UNICODE defined always which is checked in the code. I 
don't really know why.



9.1.2013 8:56, Jani Tiainen kirjoitti:

8.1.2013 21:00, akaariai kirjoitti:

I created the following test case into django's test suite modeltests/
basic/tests.py:
 def test_unicode(self):
 # Note: from __future__ import unicode_literals is in
effect...
 a = Article.objects.create(headline='0
\u0442\u0435\u0441\u0442 test', pub_date=datetime.n  ow())
 self.assertEqual(Article.objects.get(pk=a.pk).headline, '0
\u0442\u0435\u0441\u0442 test'   )

This does pass on Oracle when using Django's master branch, both with
Python 2.7 and 3.3.

Django's backend is doing all sorts of trickery behind the scenes to
get correct unicode handling. I am not sure where the problem is. What
Django version are you using?


Sorry about forgotting version info. I tested with 1.3.1 and 1.4.1 and
both gave same behaviour.

And I know that there is quite a lot of trickery going on. I'll try to
figure out what causes that problem.


On 8 tammi, 17:34, Jani Tiainen <rede...@gmail.com> wrote:

Hi,

I've been trying to save UTF-8 characters to oracle database without
success.

I've verified that database is indeed UTF-8 capable.

I can insert UTF-8 characters directly using cx_Oracle.

But when I use ORM it will trash characters.

Model I use:

class MyTest(models.Model):
  txt = CharField(max_length=128)

s = u'0 \u0442\u0435\u0441\u0442 test'

i = MyTest()
i.txt = s
i.save()

i2 = MyTest.objects.get(id=i.id)
print i2.txt

u'0 \xbf\xbf\xbf\xbf test'

So what happens here? It looks like Django trashes my unicode string at
some (unknown point).

Additional note:

If I use cursor() from Django connection object strings get broken also.
So it must be django Oracle backend doing something evil for me.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient
before...








--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread Jani Tiainen

Tested against latest master. Same behaviour.

In Oracle backend base.py is following piece of code:

# Check whether cx_Oracle was compiled with the WITH_UNICODE option. 
This will

# also be True in Python 3.0.
if int(Database.version.split('.', 1)[0]) >= 5 and not hasattr(Database, 
'UNICODE'):

convert_unicode = force_text
else:
convert_unicode = force_bytes

Which was added in <https://github.com/django/django/commit/dcf3be7a62>

Thing is that my cx_Oracle is version 5.1.2, it has cx_Oracle.UNICODE 
definition.


And Django uses smart_str / force_bytes.

If I remove that and use convert_unicode as force_text / force_unicode 
everything works as expected.


9.1.2013 8:56, Jani Tiainen kirjoitti:

8.1.2013 21:00, akaariai kirjoitti:

I created the following test case into django's test suite modeltests/
basic/tests.py:
 def test_unicode(self):
 # Note: from __future__ import unicode_literals is in
effect...
 a = Article.objects.create(headline='0
\u0442\u0435\u0441\u0442 test', pub_date=datetime.n  ow())
 self.assertEqual(Article.objects.get(pk=a.pk).headline, '0
\u0442\u0435\u0441\u0442 test'   )

This does pass on Oracle when using Django's master branch, both with
Python 2.7 and 3.3.

Django's backend is doing all sorts of trickery behind the scenes to
get correct unicode handling. I am not sure where the problem is. What
Django version are you using?


Sorry about forgotting version info. I tested with 1.3.1 and 1.4.1 and
both gave same behaviour.

And I know that there is quite a lot of trickery going on. I'll try to
figure out what causes that problem.


On 8 tammi, 17:34, Jani Tiainen <rede...@gmail.com> wrote:

Hi,

I've been trying to save UTF-8 characters to oracle database without
success.

I've verified that database is indeed UTF-8 capable.

I can insert UTF-8 characters directly using cx_Oracle.

But when I use ORM it will trash characters.

Model I use:

class MyTest(models.Model):
  txt = CharField(max_length=128)

s = u'0 \u0442\u0435\u0441\u0442 test'

i = MyTest()
i.txt = s
i.save()

i2 = MyTest.objects.get(id=i.id)
print i2.txt

u'0 \xbf\xbf\xbf\xbf test'

So what happens here? It looks like Django trashes my unicode string at
some (unknown point).

Additional note:

If I use cursor() from Django connection object strings get broken also.
So it must be django Oracle backend doing something evil for me.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient
before...








--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread Jani Tiainen

8.1.2013 21:00, akaariai kirjoitti:

I created the following test case into django's test suite modeltests/
basic/tests.py:
 def test_unicode(self):
 # Note: from __future__ import unicode_literals is in
effect...
 a = Article.objects.create(headline='0
\u0442\u0435\u0441\u0442 test', pub_date=datetime.n  ow())
 self.assertEqual(Article.objects.get(pk=a.pk).headline, '0
\u0442\u0435\u0441\u0442 test'   )

This does pass on Oracle when using Django's master branch, both with
Python 2.7 and 3.3.

Django's backend is doing all sorts of trickery behind the scenes to
get correct unicode handling. I am not sure where the problem is. What
Django version are you using?


Sorry about forgotting version info. I tested with 1.3.1 and 1.4.1 and 
both gave same behaviour.


And I know that there is quite a lot of trickery going on. I'll try to 
figure out what causes that problem.



On 8 tammi, 17:34, Jani Tiainen <rede...@gmail.com> wrote:

Hi,

I've been trying to save UTF-8 characters to oracle database without
success.

I've verified that database is indeed UTF-8 capable.

I can insert UTF-8 characters directly using cx_Oracle.

But when I use ORM it will trash characters.

Model I use:

class MyTest(models.Model):
  txt = CharField(max_length=128)

s = u'0 \u0442\u0435\u0441\u0442 test'

i = MyTest()
i.txt = s
i.save()

i2 = MyTest.objects.get(id=i.id)
print i2.txt

u'0 \xbf\xbf\xbf\xbf test'

So what happens here? It looks like Django trashes my unicode string at
some (unknown point).

Additional note:

If I use cursor() from Django connection object strings get broken also.
So it must be django Oracle backend doing something evil for me.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...





--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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



ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread Jani Tiainen

Hi,

I've been trying to save UTF-8 characters to oracle database without 
success.


I've verified that database is indeed UTF-8 capable.

I can insert UTF-8 characters directly using cx_Oracle.

But when I use ORM it will trash characters.

Model I use:

class MyTest(models.Model):
txt = CharField(max_length=128)


s = u'0 \u0442\u0435\u0441\u0442 test'

i = MyTest()
i.txt = s
i.save()

i2 = MyTest.objects.get(id=i.id)
print i2.txt

u'0 \xbf\xbf\xbf\xbf test'


So what happens here? It looks like Django trashes my unicode string at 
some (unknown point).


Additional note:

If I use cursor() from Django connection object strings get broken also. 
So it must be django Oracle backend doing something evil for me.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Using django's oodb alone

2013-01-03 Thread Jani Tiainen

3.1.2013 14:30, Xavier Pegenaute kirjoitti:

Hi,

I would like to use the django's oodb in some (ncurses + python)
scripts. Any one have some experience on it?, do I need to use the
django scripting environment or may be I can avoid it?


Um... Django is just a Python library so you can use it like any other 
Python library, just provide configuration and you're good to go.




--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Serving static files: Tried 3 ways with no luck

2012-12-27 Thread Jani Tiainen

27.12.2012 5:03, warsam...@gmail.com kirjoitti:

I am having an unbelievable time getting my new django application to
servie static files, i have read the django documentation but it seems
as there isn't one consistent way to serve static files while in
development using the Django server.

In order are my settings.py file, my urls.py file and finally in my
base.html where i reference these files.


I have no idea why i still get 404 not found errors when the path is
full load as in when i reference in my base.html file {{ Media_Url}} it
actually resolves to /media/ yet the file is still not found.

If anyone can help, please let me know. i have spent way to long on this
small issue.


First STATIC_ROOT setting means location where collectstatic collects 
are your static files using finders. Usually you have two finders used, 
firstone is FileSystemFinder that uses STATICFILES_DIRS to find static 
files. Both settings must be absolute path(s).


Note that STATIC_ROOT is not needed for runserver

And second one is AppDirectoriesFinder that finds static files under 
static/ -folder of your apps (including admin app).


Both are analoguous to template-serving.

MEDIA_ROOT is meant for user uploaded content.

STATIC_URL then gives root URL where static files are served. In testing 
/static/ is good one, in production you might want to do some 
optimizations there.


Now you should be able to get it working.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Unique Id issue

2012-12-12 Thread Jani Tiainen

12.12.2012 8:55, ephan kirjoitti:

Hi all,

Am in a bit of a fix which I put myself in,I have the following models:

class  Town(...):
 name = models.CharField(unique=true)
 province = models.foreignKey(Province)


class Area():
 name = models.CharField(unique=true,max_length=120)
 town = models.CharField(Town)


The problem here is I made the assumption that an area name is
unique,unfortunatly after deploying ,I have just realized that some
towns have the same area names so I can't have example area x in town A
as  well as area x in town B.

We have already deployed and have 575 users so far,is there any safe way
of removing the unique key constraint on Area model without damaging the
records which are already there?



You can remove it safely. Though you have to run some SQL script 
manually (or to use some migration tool like South) to remove it from 
the database(s).


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Django Troubleshooting

2012-10-22 Thread Jani Tiainen

19.10.2012 7:07, Sun Simon kirjoitti:

https://www.djangoproject.com/download/

I am installing Django for Python on Win XP and came across this problem
during installation:

|tar xzvf Django-1.4.2.tar.gz
cd Django-1.4.2
sudo python setup.py install


What does "cd" mean? DOes it mean that I have to use command line to type it?
|


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


And if you want to go through slightly more complex setup than provided 
here and use virtualenv I wrote short tutorial as well:


http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: How to get oracle NUMBER with syncdb

2012-10-17 Thread Jani Tiainen

17.10.2012 14:28, Michał Nowotka kirjoitti:

Even if I don't mention inspectdb the problem still persists.
The basic question is how to map oracle NUMBER type from some model type.
If I understand this correctly, currently this is not supported.
In principle models.FloatField should handle it and give and option to
decide if the filed should me mapped into FLOAT or NUMBER.

But maybe (this requires some more oracle knowledge) that FLOAT is
just an alias of NUMBER(38,19).



Actually that is incorrect. Oracle equivalent for python float (and 
Django FloatField) is BINARY_FLOAT.


Oracle NUMBER must map to DecimalField with correct precisions and 
numbers. Since property of NUMBER field is to preserve accuracy (it's 
fixed point field).


Though there is not anyway to do it simply without knowledge of 
underlying database and context of your application. What you can do is 
create your own custom field and use just a NUMBER datatype.


See https://docs.djangoproject.com/en/1.4/howto/custom-model-fields/ for 
more information.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: How to get oracle NUMBER with syncdb

2012-10-17 Thread Jani Tiainen

17.10.2012 12:15, Michał Nowotka kirjoitti:

Hello,
I have some legacy oracle database against which I run inspectdb command.
One column in the DB has type NUMBER (without precision and scale) and
what I got from django is:

entity_id = models.DecimalField(unique=True, null=True, max_digits=0,
decimal_places=-127, blank=True)

If I now run syndb trying to generate schema from the model I will get
the error:

Error: One or more models did not validate:
DecimalFields require a "decimal_places" attribute that is a
non-negative integer.
DecimalFields require a "max_digits" attribute that is a positive integer.

My question is: how should I modify entity_id type oin the model to
get NUMBER generated in oracle?

BTW. Don't you think this is bug to generate model with inspectdb
which is invalid if you run it using syncdb?

Kind regards,
Michael Nowotka



https://docs.djangoproject.com/en/1.4/ref/django-admin/#django-admin-inspectdb

As you may have read that, it states few things:

"This feature is meant as a shortcut, not as definitive model 
generation.". No, there is no guarantee that syncdb will work. There 
might be fields that canno't be mapped correctly and particulary order 
might be totally off.


And on top of that, there is note that inspectdb works (only) with 
PostgreSQL, MySQL and SQLite. No Oracle mentioned.


When I mapped my models from Oracle I used 3rd party tool MyGeneration 
[1] to generate mappings. It was more easier and I had full control over 
how to map database to Django ORM. Though ordering problem still was 
persstent but at least I got models more or less right from the very 
beginning.



[1] http://sourceforge.net/projects/mygeneration/



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Trouble with VirtualEnv on Windows

2012-10-15 Thread Jani Tiainen

Hi,

Don't forget "yolk". Very powerful tool to display virtualenv contents 
in readable format. You can install it with pip install yolk.


15.10.2012 9:00, Frank Bieniek kirjoitti:

Hi,

do a "pip freeze" after you have activated your environment,
this way you see the packages that are visible to the python interpreter
inside your virtual env.

Possible Problem
You have installed all packaged before you created the virtual env.
-> virtual env shows no components.
pip install componentname should solve the problem.

or:
Windows reads the registry for some packages (mainly none native
packages) and
inside the virutual env this does not work.
Try to recreate the virtualenv with --system-site-packages option set.

another solution - use vagrant: - google for djangocon 2012 vagrant

Thanks
Frank







Am 15.10.2012 04:45, schrieb Joshua Russo:

I suppose I was a little light on the details of how I setup the
environment. I don't often setup a new environment from scratch so I
used this post as the basis:
http://slacy.com/blog/2011/06/django-postgresql-virtualenv-development-setup-for-windows-7/


The versions of each program I used / ended up with were:
   Python 2.7.3 (32 bit)
   Postgres 9.2 (32 bit)
   Setuptools 0.6c11 for Python 2.7
   Psycopg2 2.4.5 for Python 2.7 (32 bit)
   VirtualEnv 1.8.2
   Django 1.4.1



On Sunday, October 14, 2012 6:25:41 PM UTC-4, Joshua Russo wrote:

This is probably a VirturalEnv problem as opposed to a Django
problem but I was wondering if someone here could point me in the
right direction.

I'm trying to setup clean environment for a demonstration of
Django on Tuesday but I get the following when I try to setup the
project within the virtual environment. You can see that if I just
run python from within the virtual environment I do have access to
the libraries, but if I try to use the django-admin.py script, the
libraries aren't found. Any thoughts?

(django-tutorial)
C:\dev\venv\django-tutorial>Scripts\django-admin.py startproject
testsite
Traceback (most recent call last):
  File "C:\dev\venv\django-tutorial\Scripts\django-admin.py", line
2, in 
from django.core import management
ImportError: No module named django.core

(django-tutorial)
C:\dev\venv\django-tutorial>C:\dev\venv\django-tutorial\Script
s\python.exe
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core import management
>>> management

>>>

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



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Trouble with VirtualEnv on Windows

2012-10-14 Thread Jani Tiainen

Because the setup procedure used there is faulty.

This is what happens:

When installing Python install package will bind .PY(C) file execution 
to use _always_ main installation. It won't follow any path settings 
which virtualenv relies on.


I'm not sure can you even overcome that restriction easily on cmd. I 
know that powershell can do it (don't know how though) or personally I 
use TCC/LE.


Also psycopg2 is installed on main installation and virtualenv created 
with --no-site-packages should disable it from virtualenv.


This is the battle tested procedure how I do set up my environment:

http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/


15.10.2012 5:45, Joshua Russo kirjoitti:

I suppose I was a little light on the details of how I setup the
environment. I don't often setup a new environment from scratch so I
used this post as the basis:
http://slacy.com/blog/2011/06/django-postgresql-virtualenv-development-setup-for-windows-7/


The versions of each program I used / ended up with were:
Python 2.7.3 (32 bit)
Postgres 9.2 (32 bit)
Setuptools 0.6c11 for Python 2.7
Psycopg2 2.4.5 for Python 2.7 (32 bit)
VirtualEnv 1.8.2
Django 1.4.1



On Sunday, October 14, 2012 6:25:41 PM UTC-4, Joshua Russo wrote:

This is probably a VirturalEnv problem as opposed to a Django
problem but I was wondering if someone here could point me in the
right direction.

I'm trying to setup clean environment for a demonstration of Django
on Tuesday but I get the following when I try to setup the project
within the virtual environment. You can see that if I just run
python from within the virtual environment I do have access to the
libraries, but if I try to use the django-admin.py script, the
libraries aren't found. Any thoughts?

(django-tutorial)
C:\dev\venv\django-tutorial>Scripts\django-admin.py startproject
testsite
Traceback (most recent call last):
   File "C:\dev\venv\django-tutorial\Scripts\django-admin.py", line
2, in 
 from django.core import management
ImportError: No module named django.core

(django-tutorial)
C:\dev\venv\django-tutorial>C:\dev\venv\django-tutorial\Script
s\python.exe
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
 >>> from django.core import management
 >>> management

 >>>

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



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: reverse funtion returns fully qualified names

2012-10-03 Thread Jani Tiainen
Replying to myself.

It was oldish version of django-rest-framework that did mangled prefix.
With latest version (0.4.0 in my case) it's fixed.

On Wed, Oct 3, 2012 at 10:29 AM, Jani Tiainen <rede...@gmail.com> wrote:

> Hi,
>
> since we tried to upgrade our systems to work with 1.4 something very
> unexpected started to happen:
>
> reverse('my_view_name')
>
> Started to respond with fully qualified URL including domain name. And
> since our Django servers are behind proxies and load balancers it started
> to create very interesting effect since it now returns URL with domain name
> from local machine.
>
> Django 1.3 does return only absolute URL without domain name and
> everything works as expected.
>
> Though if you use same code (we had to upgrade few settings) with 1.3 it
> seems to still create fully qualified URLs with domain names.
>
> Is there some middleware or setting that affects in a behaviour we now
> experience?
>
> --
> Jani Tiainen
>
> - Well planned is half done and a half done has been sufficient before...
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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



reverse funtion returns fully qualified names

2012-10-03 Thread Jani Tiainen

Hi,

since we tried to upgrade our systems to work with 1.4 something very 
unexpected started to happen:


reverse('my_view_name')

Started to respond with fully qualified URL including domain name. And 
since our Django servers are behind proxies and load balancers it 
started to create very interesting effect since it now returns URL with 
domain name from local machine.


Django 1.3 does return only absolute URL without domain name and 
everything works as expected.


Though if you use same code (we had to upgrade few settings) with 1.3 it 
seems to still create fully qualified URLs with domain names.


Is there some middleware or setting that affects in a behaviour we now 
experience?


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Django 1.4.1, multiple geometry fields problem

2012-10-02 Thread Jani Tiainen
Well bug was closed because it fixed the issue back then. I suspect that 
internals of query has been changed between 1.3 and 1.4 that causes now 
a new problem.


Main issue is that when inserting or updating value cx_Oracle 
interpreted NULL value for OBJECT field when placeholder (%s)  as a 
CHAR. (since it's Oracle user type actually). And insertion or update 
failed.


As a solution it was implemented so that when ever encountering None 
value for geometry field placeholder and actual value was removed from 
the whole insert clause.


Now I think that internals how to figure out position of parameter and 
it's value was changed and there is not stuff that small if-part 
requires to work. It just requires someone with deeper knowledge of ORM 
than me to update that fix so it will work in newer versions of Django 
as well.


If someone else is encountering this issue I raised ticket 
https://code.djangoproject.com/ticket/19058



2.10.2012 15:55, George Silva kirjoitti:

Well, the bug was closed. You can try inserting empty geometries, but
then, you would need to recheck them if they are something before using.
A property might suit you well in this case.

if self.geometry.empty:
 return None


Hackish, but it's Oracle Spatial :o


And even that might work that is not an option for two reasons:
1) Models were working fine with previous version of Django (1.3)
2) I've more than 300 models which I really won't modify


On Tue, Oct 2, 2012 at 9:49 AM, Jani Tiainen <rede...@gmail.com
<mailto:rede...@gmail.com>> wrote:

I guess all this is related to special munging required by Oracle:

https://code.djangoproject.__com/ticket/10888
<https://code.djangoproject.com/ticket/10888>


2.10.2012 15:12, George Silva kirjoitti:

Then it's probably Oracle, which is riddled with bugs on the
spatial part.

I'm using PostGIS.

On Tue, Oct 2, 2012 at 8:38 AM, Jani Tiainen <rede...@gmail.com
<mailto:rede...@gmail.com>
<mailto:rede...@gmail.com <mailto:rede...@gmail.com>>> wrote:


 2.10.2012 14:34, Jani Tiainen kirjoitti:

 2.10.2012 14:06, George Silva kirjoitti:

 This is puzzling. I'm on 1.4.1 and I have models
with two
 geometric
 columns, without a hitch.

 The only interesting thing I can see is that you
are using
 SRID =
 settings.4326 on extent. Is that correct?


 Nope. Normally it's something totally different
depending on
 customer
 (and picked from settings file). I just tried qicly
replace it
 by more
 common WGS84...

 Maybe it's Oracle spesific or are you using Oracle as well?


 It might be Oracle spesific since I recall that there was
something
 done long time ago for Oracle and NULL values... And it
only happens
 if one or both fields are None (NULL) but if I provide data
for both
 fields it works.


     On Tue, Oct 2, 2012 at 7:52 AM, Jani Tiainen
 <rede...@gmail.com <mailto:rede...@gmail.com>
<mailto:rede...@gmail.com <mailto:rede...@gmail.com>>
 <mailto:rede...@gmail.com
<mailto:rede...@gmail.com> <mailto:rede...@gmail.com
<mailto:rede...@gmail.com>>>> wrote:

  Hi,

  I've several models that contains two geometry
fields
 (following is
  simplified example):

  class NetDiagram(models.Model):
   # Columns
   name = models.CharField(max_length=__60,
 blank=True, null=True)

   location =
models.GeometryField(_("__Center"),

  db_column='location', srid=4326, null=True,
blank=True)
   extent =
models.GeometryField(_("__Extent"),

  db_column='extent', srid=settings.4326, null=True,
 blank=True)

   objects = models.GeoManager()


  Now when trying to save model like that I get:

  Traceback (most recent call last):
 File



"c:\users\jtiai\work\keycom-__dev-std\prj\keycom\keycom___net_diagram\diagram\__entity_diagram_builder.py"__,


  line 134, in _save_to_database
   netdiagram.save()
 File



"C:\Users\jti

Re: Django 1.4.1, multiple geometry fields problem

2012-10-02 Thread Jani Tiainen

I guess all this is related to special munging required by Oracle:

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


2.10.2012 15:12, George Silva kirjoitti:

Then it's probably Oracle, which is riddled with bugs on the spatial part.

I'm using PostGIS.

On Tue, Oct 2, 2012 at 8:38 AM, Jani Tiainen <rede...@gmail.com
<mailto:rede...@gmail.com>> wrote:


2.10.2012 14:34, Jani Tiainen kirjoitti:

2.10.2012 14:06, George Silva kirjoitti:

This is puzzling. I'm on 1.4.1 and I have models with two
geometric
columns, without a hitch.

The only interesting thing I can see is that you are using
SRID =
settings.4326 on extent. Is that correct?


Nope. Normally it's something totally different depending on
customer
(and picked from settings file). I just tried qicly replace it
by more
common WGS84...

Maybe it's Oracle spesific or are you using Oracle as well?


It might be Oracle spesific since I recall that there was something
done long time ago for Oracle and NULL values... And it only happens
if one or both fields are None (NULL) but if I provide data for both
fields it works.


On Tue, Oct 2, 2012 at 7:52 AM, Jani Tiainen
<rede...@gmail.com <mailto:rede...@gmail.com>
<mailto:rede...@gmail.com <mailto:rede...@gmail.com>>> wrote:

 Hi,

 I've several models that contains two geometry fields
(following is
 simplified example):

 class NetDiagram(models.Model):
  # Columns
  name = models.CharField(max_length=60,
blank=True, null=True)

  location = models.GeometryField(_("Center"),
 db_column='location', srid=4326, null=True, blank=True)
  extent = models.GeometryField(_("Extent"),
 db_column='extent', srid=settings.4326, null=True,
blank=True)

  objects = models.GeoManager()


 Now when trying to save model like that I get:

 Traceback (most recent call last):
File


"c:\users\jtiai\work\keycom-dev-std\prj\keycom\keycom_net_diagram\diagram\entity_diagram_builder.py",

 line 134, in _save_to_database
  netdiagram.save()
File


"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\base.py",

 line 463, in save
  self.save_base(using=using, force_insert=force_insert,
 force_update=force_update)
File


"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\base.py",

 line 551, in save_base
  result = manager._insert([self], fields=fields,
 return_id=update_pk, using=using, raw=raw)
File


"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\manager.py",

 line 203, in _insert
  return insert_query(self.model, objs, fields,
**kwargs)
File


"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\query.py",

 line 1576, in insert_query
  return
query.get_compiler(using=using).execute_sql(return_id)
File


"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\sql\compiler.py",

 line 909, in execute_sql
  for sql, params in self.as_sql():
File


"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\sql\compiler.py",

 line 886, in as_sql
  for val in values
File


"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\contrib\gis\db\backends\oracle\compiler.py",

 line 25, in placeholder
  param_idx = self.query.columns.index(field.column)
 AttributeError: 'InsertQuery' object has no attribute
'columns'


 Error is consistent and happens when there is two or
more geometry
         fields on a single model.

 Same code worked on 1.3 flawlessly.

 --
 Jani Tiainen

 - Well planned is half done and a half done has been
sufficient
 before...

 --
 You received this message b

Re: Django 1.4.1, multiple geometry fields problem

2012-10-02 Thread Jani Tiainen


2.10.2012 14:34, Jani Tiainen kirjoitti:

2.10.2012 14:06, George Silva kirjoitti:

This is puzzling. I'm on 1.4.1 and I have models with two geometric
columns, without a hitch.

The only interesting thing I can see is that you are using SRID =
settings.4326 on extent. Is that correct?


Nope. Normally it's something totally different depending on customer
(and picked from settings file). I just tried qicly replace it by more
common WGS84...

Maybe it's Oracle spesific or are you using Oracle as well?


It might be Oracle spesific since I recall that there was something done 
long time ago for Oracle and NULL values... And it only happens if one 
or both fields are None (NULL) but if I provide data for both fields it 
works.



On Tue, Oct 2, 2012 at 7:52 AM, Jani Tiainen <rede...@gmail.com
<mailto:rede...@gmail.com>> wrote:

Hi,

I've several models that contains two geometry fields (following is
simplified example):

class NetDiagram(models.Model):
 # Columns
 name = models.CharField(max_length=__60, blank=True, null=True)

 location = models.GeometryField(_("__Center"),
db_column='location', srid=4326, null=True, blank=True)
 extent = models.GeometryField(_("__Extent"),
db_column='extent', srid=settings.4326, null=True, blank=True)

 objects = models.GeoManager()


Now when trying to save model like that I get:

Traceback (most recent call last):
   File

"c:\users\jtiai\work\keycom-__dev-std\prj\keycom\keycom_net___diagram\diagram\entity___diagram_builder.py",

line 134, in _save_to_database
 netdiagram.save()
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\base.py",

line 463, in save
 self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\base.py",

line 551, in save_base
 result = manager._insert([self], fields=fields,
return_id=update_pk, using=using, raw=raw)
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\manager.py",

line 203, in _insert
 return insert_query(self.model, objs, fields, **kwargs)
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\query.py",

line 1576, in insert_query
 return query.get_compiler(using=__using).execute_sql(return_id)
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\sql\compiler.__py",

line 909, in execute_sql
 for sql, params in self.as_sql():
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\sql\compiler.__py",

line 886, in as_sql
 for val in values
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\contrib\gis\db\__backends\oracle\compiler.py",

line 25, in placeholder
 param_idx = self.query.columns.index(__field.column)
AttributeError: 'InsertQuery' object has no attribute 'columns'


Error is consistent and happens when there is two or more geometry
fields on a single model.

Same code worked on 1.3 flawlessly.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient
before...

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






--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Django 1.4.1, multiple geometry fields problem

2012-10-02 Thread Jani Tiainen

2.10.2012 14:06, George Silva kirjoitti:

This is puzzling. I'm on 1.4.1 and I have models with two geometric
columns, without a hitch.

The only interesting thing I can see is that you are using SRID =
settings.4326 on extent. Is that correct?


Nope. Normally it's something totally different depending on customer 
(and picked from settings file). I just tried qicly replace it by more 
common WGS84...


Maybe it's Oracle spesific or are you using Oracle as well?


On Tue, Oct 2, 2012 at 7:52 AM, Jani Tiainen <rede...@gmail.com
<mailto:rede...@gmail.com>> wrote:

Hi,

I've several models that contains two geometry fields (following is
simplified example):

class NetDiagram(models.Model):
 # Columns
 name = models.CharField(max_length=__60, blank=True, null=True)

 location = models.GeometryField(_("__Center"),
db_column='location', srid=4326, null=True, blank=True)
 extent = models.GeometryField(_("__Extent"),
db_column='extent', srid=settings.4326, null=True, blank=True)

 objects = models.GeoManager()


Now when trying to save model like that I get:

Traceback (most recent call last):
   File

"c:\users\jtiai\work\keycom-__dev-std\prj\keycom\keycom_net___diagram\diagram\entity___diagram_builder.py",
line 134, in _save_to_database
 netdiagram.save()
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\base.py",
line 463, in save
 self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\base.py",
line 551, in save_base
 result = manager._insert([self], fields=fields,
return_id=update_pk, using=using, raw=raw)
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\manager.py",
line 203, in _insert
 return insert_query(self.model, objs, fields, **kwargs)
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\query.py",
line 1576, in insert_query
 return query.get_compiler(using=__using).execute_sql(return_id)
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\sql\compiler.__py",
line 909, in execute_sql
 for sql, params in self.as_sql():
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\db\models\sql\compiler.__py",
line 886, in as_sql
 for val in values
   File

"C:\Users\jtiai\Work\keycom-__dev-std\lib\site-packages\__django\contrib\gis\db\__backends\oracle\compiler.py",
line 25, in placeholder
 param_idx = self.query.columns.index(__field.column)
AttributeError: 'InsertQuery' object has no attribute 'columns'


Error is consistent and happens when there is two or more geometry
fields on a single model.

Same code worked on 1.3 flawlessly.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient
before...

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



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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.4.1, multiple geometry fields problem

2012-10-02 Thread Jani Tiainen

Hi,

I've several models that contains two geometry fields (following is 
simplified example):


class NetDiagram(models.Model):
# Columns
name = models.CharField(max_length=60, blank=True, null=True)

location = models.GeometryField(_("Center"), db_column='location', 
srid=4326, null=True, blank=True)
extent = models.GeometryField(_("Extent"), db_column='extent', 
srid=settings.4326, null=True, blank=True)


objects = models.GeoManager()


Now when trying to save model like that I get:

Traceback (most recent call last):
  File 
"c:\users\jtiai\work\keycom-dev-std\prj\keycom\keycom_net_diagram\diagram\entity_diagram_builder.py", 
line 134, in _save_to_database

netdiagram.save()
  File 
"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\base.py", 
line 463, in save
self.save_base(using=using, force_insert=force_insert, 
force_update=force_update)
  File 
"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\base.py", 
line 551, in save_base
result = manager._insert([self], fields=fields, 
return_id=update_pk, using=using, raw=raw)
  File 
"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\manager.py", 
line 203, in _insert

return insert_query(self.model, objs, fields, **kwargs)
  File 
"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\query.py", 
line 1576, in insert_query

return query.get_compiler(using=using).execute_sql(return_id)
  File 
"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\sql\compiler.py", 
line 909, in execute_sql

for sql, params in self.as_sql():
  File 
"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\sql\compiler.py", 
line 886, in as_sql

for val in values
  File 
"C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\contrib\gis\db\backends\oracle\compiler.py", 
line 25, in placeholder

param_idx = self.query.columns.index(field.column)
AttributeError: 'InsertQuery' object has no attribute 'columns'


Error is consistent and happens when there is two or more geometry 
fields on a single model.


Same code worked on 1.3 flawlessly.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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 lots of foreign keys - Django Admin

2012-09-26 Thread Jani Tiainen
Your query clearly indicates that you're still doing foreign keys 
against TITLE fields, which are strings. So something is definitely 
still incorrect in your models.


Make sure that your foreign keys really point to ID field (basically 
that is leaving out


26.9.2012 9:24, rentgeeen kirjoitti:

I postet the query above in the 1st post, it takes like 17secs, 1 of
them like 60 secs

|SELECT `auto_type`.`id`, `auto_type`.`client_id`,
`auto_type`.`category_id`, `auto_type`.`subcategory_id`,
`auto_type`.`project_id`, `auto_type`.`title`, `auto_client`.`id`,
`auto_client`.`title`, `auto_category`.`id`, `auto_category`.`client_id`,
`auto_category`.`title`, T4.`id`, T4.`title`, `auto_subcategory`.`id`,
`auto_subcategory`.`client_id`, `auto_subcategory`.`category_id`,
`auto_subcategory`.`title`, T6.`id`, T6.`title`, T7.`id`, T7.`client_id`,
T7.`title`, T8.`id`, T8.`title`, `auto_project`.`id`,
`auto_project`.`client_id`, `auto_project`.`category_id`,
`auto_project`.`subcategory_id`, `auto_project`.`title`, T10.`id`,
T10.`title`, T11.`id`, T11.`client_id`, T11.`title`, T12.`id`,
T12.`title`, T13.`id`, T13.`client_id`, T13.`category_id`, T13.`title`,
T14.`id`, T14.`title`, T15.`id`, T15.`client_id`, T15.`title`, T16.`id`,
T16.`title` FROM `auto_type` INNER JOIN `auto_client` ON
(`auto_type`.`client_id` = `auto_client`.`title`) INNER JOIN
`auto_category` ON (`auto_type`.`category_id` = `auto_category`.`title`)
INNER JOIN `auto_client` T4 ON (`auto_category`.`client_id` = T4.`title`)

Above is join from auto_category to auto_client "title".

If your model would be "right" it should be autocategory.client_id = T4.id.



INNER JOIN `auto_subcategory` ON (`auto_type`.`subcategory_id` =
`auto_subcategory`.`title`) INNER JOIN `auto_client` T6 ON
(`auto_subcategory`.`client_id` = T6.`title`) INNER JOIN `auto_category`
T7 ON (`auto_subcategory`.`category_id` = T7.`title`) INNER JOIN
`auto_client` T8 ON (T7.`client_id` = T8.`title`) INNER JOIN
`auto_project` ON (`auto_type`.`project_id` = `auto_project`.`title`)
INNER JOIN `auto_client` T10 ON (`auto_project`.`client_id` = T10.`title`)
INNER JOIN `auto_category` T11 ON (`auto_project`.`category_id` =
T11.`title`) INNER JOIN `auto_client` T12 ON (T11.`client_id` =
T12.`title`) INNER JOIN `auto_subcategory` T13 ON
(`auto_project`.`subcategory_id` = T13.`title`) INNER JOIN `auto_client`
T14 ON (T13.`client_id` = T14.`title`) INNER JOIN `auto_category` T15 ON
(T13.`category_id` = T15.`title`) INNER JOIN `auto_client` T16 ON
(T15.`client_id` = T16.`title`) ORDER BY `auto_type`.`id` DESC|

|what do you mean by back-end?|

python, django, centos6 64bit server, mysql

all works fine also on website + admin but only that part if I click each table 
in admin which are defined in admin.py

|   |class ProjectAdmin(admin.ModelAdmin):

|
 list_display = ('client', 'category', 'subcategory', 'title', )

admin.site.register(Project, ProjectAdmin)|

|the more I add FK's to list display and you click that PROJECT table or others 
the view of it in admin is making that query and takes so longif I make it 
just:|

|  class ProjectAdmin(admin.ModelAdmin):
 list_display = ( 'title', )

admin.site.register(Project, ProjectAdmin)|

NO FKs then it runs in 0.01ms

Screenshot:

http://cl.ly/image/3w3D3g0h3h1A



Also I wonder does admin run one query for each FK per row..




[snipsnip]


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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 lots of foreign keys - Django Admin

2012-09-25 Thread Jani Tiainen

26.9.2012 3:08, rentgeeen kirjoitti:

I did that already, removed the field_to and make them as normal primary
keys,

the problem is when I put FK fields into "list_display" admin it still
takes SQL 60 secs to process, if I remove them all is ok and App works
great.

so weird

On Tuesday, 25 September 2012 02:01:17 UTC-4, Jani Tiainen wrote:

Actually problem exists in your model. Unless this is legacy database
that you can't do anything about.

Major performance killer is done by defining all your foreign key
fields
to be _strings_. Yes. "field_to" in model.ForeignKey() means that this
field uses "field_to" in related model as a key. And that being a
string
is major performance killer.

Secondly your string fields are not indexed and using string as a
foreign key is not efficient in both terms space and performance.

If you don't specify one of your fields as primary key Django creates
one for you - called "id". If you don't specify "field_to" Django uses
primary key from your model in most of the cases that is "id", which is
integer. Indexed properly and so on.

Try changing all your models to "correct" and remove "field_to"
definitions from foreign keys. You should see quite a major speedup
after rebuilding the database.

25.9.2012 2:17, rentgeeen kirjoitti:
 > Have a SQL problem, adding this model all works correctly, the
problem
 > is in ADMIN.
 >
 > When I add the data just few to each table, by clicking on TYPE &
PAGE
 > in ADMIN the page is loading so slow, installed debug_toolbar and
SQL
 > took 17 seconds for the TYPE. When I tried the PAGE it gave me
timeout,
 > my question is what is wrong with my model? Is it constructed bad?
 >
 > My goal is this lets say example:
 >
 > www.example.com/audi/4doors/s4/sport/red/audi-url
<http://www.example.com/audi/4doors/s4/sport/red/audi-url>
 >
 > basically all 6 urls are dynamic that I would specify in the each
table
 > and would be in the PAGE as dropdowns also in others. What is the
 > optimal way to do that or optimize the model?
 >
 > Here is a screenshot of TYPE page loading:
 >
 > screenshot: http://cl.ly/image/2931040E0t35
<http://cl.ly/image/2931040E0t35>
 >
 > Records:
 >
 > auto_client = 3 rows
 >
 > auto_category = 2 rows
 >
 > auto_subcategory = 2 rows
 >
 > auto_project = 5 rows
 >
 > auto_type = 2 rows
 >
 > auto_page = 0 - because cliking on auto_page it times out because
of SQL
 > query. Basically togehter like 14 records thats nothing :)
 >
 > here is also mysql query in PHPmyadmin: cl.ly/image/2S320h3d0P0J
<http://cl.ly/image/2S320h3d0P0J>
 > <http://cl.ly/image/2S320h3d0P0J
<http://cl.ly/image/2S320h3d0P0J>> 17 seconds
 >
 > Please help thanks
 >
 >
 > |from  django.db import models
 >
 >
 > class Client(models.Model):
 >  title=  models.CharField(max_length=100,  unique=True)
 >  def __unicode__(self):
 >  return  self.title
 >
 > class Category(models.Model):
 >  client=  models.ForeignKey(Client,  to_field='title')
 >  title=  models.CharField(max_length=200,  unique=True)
 >  def __unicode__(self):
 >  return  self.title
 >
 > class Subcategory(models.Model):
 >  client=  models.ForeignKey(Client,  to_field='title')
 >  category=  models.ForeignKey(Category,  to_field='title')
 >  title=  models.CharField(max_length=200,  unique=True)
 >  def __unicode__(self):
 >  return  self.title
 >
 > class Project(models.Model):
 >  client=  models.ForeignKey(Client,  to_field='title')
 >  category=  models.ForeignKey(Category,  to_field='title')
 >  subcategory=  models.ForeignKey(Subcategory,  to_field='title')
 >  title=  models.CharField(max_length=200,  unique=True)
 >  def __unicode__(self):
 >  return  self.title
 >
 > class Type(models.Model):
 >  client=  models.ForeignKey(Client,  to_field='title')
 >  category=  models.ForeignKey(Category,  to_field='title')
 >  subcategory=  models.ForeignKey(Subcategory,  to_field='title')
 >  project=  models.ForeignKey(Project,  to_field='title')
 >  title=  models.CharField(max_length=200,  unique=True)
 >  def __unicode__(self):
 >  return  self.title
 >
 > class Page(models.Model):
 &g

Re: GeoDjango and shapefiles

2012-09-25 Thread Jani Tiainen

25.9.2012 11:53, Coulson Thabo Kgathi kirjoitti:

can geoDjango produce maps offline though, because i am trying to have
an app that shows locations of places using markers on the map. OFFLINE
WITHOUT INTERNET

--
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/-/OswCiPt2fyIJ.
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 don't need internet to show maps using different map servers and 
browser. You can still share everything from localhost (as you do while 
developing apps). It's still easiest way to do things.


I think gdal/ogr packages can create shapefiles from database if needed. 
Don't know how symbology works there.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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 lots of foreign keys - Django Admin

2012-09-25 Thread Jani Tiainen
itle`) INNER JOIN
`auto_category` ON (`auto_type`.`category_id` = `auto_category`.`title`)
INNER JOIN `auto_client` T4 ON (`auto_category`.`client_id` = T4.`title`)
INNER JOIN `auto_subcategory` ON (`auto_type`.`subcategory_id` =
`auto_subcategory`.`title`) INNER JOIN `auto_client` T6 ON
(`auto_subcategory`.`client_id` = T6.`title`) INNER JOIN `auto_category`
T7 ON (`auto_subcategory`.`category_id` = T7.`title`) INNER JOIN
`auto_client` T8 ON (T7.`client_id` = T8.`title`) INNER JOIN
`auto_project` ON (`auto_type`.`project_id` = `auto_project`.`title`)
INNER JOIN `auto_client` T10 ON (`auto_project`.`client_id` = T10.`title`)
INNER JOIN `auto_category` T11 ON (`auto_project`.`category_id` =
T11.`title`) INNER JOIN `auto_client` T12 ON (T11.`client_id` =
T12.`title`) INNER JOIN `auto_subcategory` T13 ON
(`auto_project`.`subcategory_id` = T13.`title`) INNER JOIN `auto_client`
T14 ON (T13.`client_id` = T14.`title`) INNER JOIN `auto_category` T15 ON
(T13.`category_id` = T15.`title`) INNER JOIN `auto_client` T16 ON
(T15.`client_id` = T16.`title`) ORDER BY `auto_type`.`id` DESC|

--
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/-/C_zR-hp12oUJ.
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.



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Getting Started

2012-09-24 Thread Jani Tiainen
It looks like you have older version of Django installed somewhere.

You definitely should go for virtualenv it saves lot of troubles in the
long run.

On Mon, Sep 24, 2012 at 7:07 PM, Greg Lindstrom <gslindst...@gmail.com>wrote:

> Hello,
>
> I am having trouble getting started using Django 1.4.1 on my Windows 7
> machine.  Everything appears to be installed (I'm running Python 2.7 and
> have been programming in Python for over 10 years; I figure it's time to
> see what all the fuss is over "the web" :-).
>
> Reading through the tutorial on the Django page (the "polls" project), I
> start a new project using "django-admin.py startproject mysite".  It
> creates a new directory -- as promised -- but I'm in trouble, already!  My
> directory structure does not match the tutorial.  I expect:
>
> mysite/manage.py
> mysite/mysite/__init__.py
> mysite/mysite/manage.py
> mysite/mysite/settings.py
> mysite/mysite/urls.py
> mysite/mysite/wgsi.py
>
> and I get all of those.  But, I also get
>
> mysite/__init__.py
> mysite/setings.py
> mysite/urls.py
>
> giving me __init__.py, settings.py, and urls.py in both the "outter" and
> "inner" directories.  I'm I in the wrong tutorial?  The initital web server
> runs and I can edi the models.py file, but when I attempt the "python
> manage.py sql polls" command the settings file die snot know about "polls"
> (I added it to the applications).
>
> I'm eager to learn Django; can someone please give me a kick in the proper
> direction?
>
> --greg
>
> --
> 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/-/fkNOGLcwvpQJ.
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: template rendering progress

2012-09-20 Thread Jani Tiainen

19.9.2012 16:13, Philippe Raoult kirjoitti:

Hello all,

I'm using django templates to generate pdf listings in my app. After
running render() on the template, reportlab is called to create the pdf.

My issue is that those listings can get quite big (hundreds of pages,
with images) and thus take very long to render. Reportlab has progress
callbacks that allow me to have a nice progress bar on screen, but the
template rendering doesn't seem to offer this functionality. Has anyone
managed to implement this or has any suggestion regarding this topic ?

Regards,
Philippe

--
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/-/kc5IlCznZ1wJ.
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 need to push your rendering task as "external" job. Celery is very 
good at it and it does integrate with Django very well.


Basic idea is that you have view that starts the task and returns you 
the progress view that is either refreshed by using meta-tag or quite 
common ajax-approach to poll a view that returns progress value. And of 
course some view to actually fetch the result.


But there is nothing in template engine that can offer this kind of 
features since it's property of HTTP protocol and how request/response 
cycle goes.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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 and shapefiles

2012-09-20 Thread Jani Tiainen

20.9.2012 17:36, Coulson Thabo Kgathi kirjoitti:

Hi guys i want to use geodjango for an application that gives map
locations but offline using shapefiles and geodjango, any information
that i can be refered to would be appreciated. I dont want to use google
maps because its wil be used offline

thank you

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


There is actually more than one way to do this. And without further 
knowledge what you're trying to show and where it's hard to give more 
details.


For example generating maps with shapefiles there is far better 
solutions than GeoDjango (GeoDjango is great for querying spatially and 
modifying data) like Mapnik or Mapserver on serverside. On client side 
there is practically only one really working solution - Openlayers.



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: how to use java script alert in view? i use form submit on post method. After sucessfull opreation in view i want alert

2012-09-16 Thread Jani Tiainen

17.9.2012 7:31, Navnath Gadakh kirjoitti:


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



First, a small nitpicking: you shouldn't post question to subject line 
only.


It all depends what you really mean by "alert"? Standard javascript 
alert popup? That can be quite easily done by redirecting a view that 
has template that contains javascript alert that is triggered for 
example onload event.


Though in general all kind of interruptive messaging is bad and will 
cause a pain after a while.


Also what would you show in case of unsuccessful operation? An alert as 
well?


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Conditions in template slows down the software

2012-09-14 Thread Jani Tiainen

kirjoitti:

I have used many condition in my templates, in order to filter my
results. My template file uses this code  :

{% for clients in client %}
 {% for amounts in amount %}
 {% for suspences in suspence %}
 {% for tadas in tada %}
  {% for transports in transport %}
  {% if clients.job_no == amounts.job_no%}
  {% if clients.job_no == suspences.job_no %}
{% if clients.job_no == tadas.job_no %}
 {% if clients.job_no == transports.job_no %}
   

{{ clients.job_no}}
 {{ clients.date }}
 {{ clients.receipt_no }}
 {{clients.name_and_address}}
{{amounts.field}}
...
...

This code slows down the system to a great extent. Please suggest me
an alternate and better solution.



You should process your data in a view to be suitable for rendering 
rather than using template to do data processing.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient 
before...


--
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: tastypie - some feedback / comments

2012-09-13 Thread Jani Tiainen

13.9.2012 11:23, sbrandt kirjoitti:

After evaluating some API creation frameworks, namely tastypie, pistion
and django rest framework, it came out that I would never use the first
two in my projects.

Sorry that I can't provide more detailed information, but it's about a
year ago. Both had issues with their architecture and philosophy not
being clear, straight or smart enough to me. The latter,
django-rest-framework (http://pypi.python.org/pypi/djangorestframework)
was very young at this time and followed the then-new paradigm of class
based views. Since it behaves like other django views (URL config,
mixins, etc.) it is very nice to use and extensible.

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


I'm also fan (and user) of django-rest-framework. Just because it's 
quite easily to be extended with all kind of stuff you need (specially 
since I work with ExtJS 4 which does have support that resembles REST 
from some parts), allows me to define URLs I want and does quite much 
stuff OOTB.


Also in few cases I really work things that do not bound to any models, 
querysets or whatsoever django-rest-framework just works with them as well.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to informati

2012-09-13 Thread Jani Tiainen

13.9.2012 11:04, Coulson Thabo Kgathi kirjoitti:

how i plot a point atleast manually is what i cant find how to do.

If atleast i could know how, which i think is done in the models.py then
i would be good to go afterwards

--
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/-/asb2PweS-HEJ.
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.


What you really mean by "plot"?

If you mean that show it somehow somewhere on a map then there is really 
nothing "built in" in Django for that. IIRC admin can show only

one (first?) geometry field defined.

So you need to have some kind of mapengine to actually produce map also 
known as WMS (or WFS).


Mapserver, Mapnik or Geoserver being propably one of the most used ones.

After you have done that you can build HTML page that uses some means to 
show map. OpenLayers is for that - it's javascript library to work with 
(interactive) maps on a webpage.


Now you should have all pieces that allows you to put together stuff 
that can show your points from a database.




--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to informati

2012-09-13 Thread Jani Tiainen

13.9.2012 10:51, Coulson Thabo Kgathi kirjoitti:

What i did so far is create a GeoDjango project, the define models as
shown below
#models.py looks like thi

from django.db import models

# Create your models here.
# This is an auto-generated Django model module created by ogrinspect.
from django.contrib.gis.db import models

class Locations(models.Model):
 zid = models.IntegerField()
 name = models.CharField(max_length=20)
 elev = models.FloatField()
 icon = models.IntegerField()
 point = models.PointField() #this i
tried to do it for the poin to be ploted
 geom = models.MultiLineStringField(srid=4326)
 objects = models.GeoManager()


# Auto-generated `LayerMapping` dictionary for Locations model
locations_mapping = {
 'zid' : 'ZID',
 'name' : 'NAME',
 'elev' : 'ELEV',
 'icon' : 'ICON',
 'point' : 'POINT'
 'geom' : 'MULTILINESTRING',
}


The rest of the files i followed the GeoDjango tutorial

but this does not seem to be working, First i tred bt using a .kml file
convert it to a shapefile then import it to generate models bt does not work

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


How are you trying to plot your points?

Have you tried to manually insert at least one known point to be sure 
that problem is not somewhere in your import process?


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to informati

2012-09-13 Thread Jani Tiainen

13.9.2012 10:29, Coulson Thabo Kgathi kirjoitti:

Can i be able to plot a points on maps with geodjango? i figured i can
plot polygons on a map but struggling to plot points is it possible? if
it is how do i do it or help with a link to information where i can find
how to do that. i have been searching and cant find much infor about it.


You can.


If i can atleast plot a point like points on the map below, that would
be great

HoustonCrimeMaps




How have you tried to do that exactly?

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Model Validation with Exception Handling

2012-09-13 Thread Jani Tiainen

Hi,

I'm using following piece of code with ExtJS:


def extjs_validate_instance(instance):
"""Validate given Django model instance.
Return ExtJS formatted error response.
"""
try:
instance.full_clean() # Validate
except ValidationError, e:
opts = instance._meta
nice_messages = []
for fname, msgs in e.message_dict.items():
nice_messages.append({
'name' : 
force_unicode(opts.get_field_by_name(fname)[0].verbose_name),

'error' : ', '.join(msgs),
})

response_obj = {
'success': False,
'items' : nice_messages}
raise ErrorResponse(status.HTTP_200_OK, response_obj)


Now it returns dict "nice_messages" which contains fieldname and 
message(s) associated with that field.



13.9.2012 2:36, Kurtis Mullins kirjoitti:

Just a quick example of a field that can have two completely different
error types but both throw a ValidationError while running full_clean().

Let's say my Model includes an email address. The email address must be
unique. It could either fail because 1. It's not Unique (or) 2. It's an
invalid email address.

What I really want to do is determine the exception/error-type so that I
can handle it appropriately.

On Wed, Sep 12, 2012 at 7:09 PM, Kurtis <kurtis.mull...@gmail.com
<mailto:kurtis.mull...@gmail.com>> wrote:

Hey Guys,

Do you have any suggestions on a good way to grab error types during
Model Validation? I'm not using Forms or HTML. First, here's a
simplified snippet showing my current format for Model Data Validation.

my_object = MyModel(**data_dict)
try:
 my_object.full_clean()
 my_object.save()
 return SuccessJSONResponse()
except ValidationError, e:
 print e.message_dict # Testing
 # ... build some custom JSON data from the error
 return ErrorJSONResponse(json_data)

This works fine for properly validating the data and being able to
print out errors. It also allows me to easily see which fields threw
errors. Unfortunately, it doesn't provide me with the types of
errors in a "programmatic" fashion as far as I can tell. For
example, a field can fail because it's a duplicate entry or it can
fail because it didn't meet the criteria of the field-type (e.g.
max_length).

What I'm hoping for is there's a way I can still easily validate my
data using my Model but get more specific information about the
types of errors. If it's an IntegrityError then I need to build a
custom response indicating which field had failed along with an
"internal" (to the project) error code and a description. If it's
some other specific error (for example, maybe an email address isn't
a "valid" email address) then I'd like to identify the error type,
field name, and display that error accordingly. Hopefully that makes
sense :)

I'm not sure if I'm just over-looking something or trying to do
things the hard way but I'm up for suggestions. Keep in mind that
Forms + HTML are out of the question since this is an API-only
application.

Thanks!
- Kurtis

--
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/-/7CS8sJxLHhwJ.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
<mailto:django-users%2bunsubscr...@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.



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Iphone applications via django

2012-09-12 Thread Jani Tiainen
I'm developing generic mobile app, mostly to be used with iPad/Android 
tablets. Currently we don't build native apps due our development being 
in such a early phase.


12.9.2012 15:49, Sait Maraşlıoğlu kirjoitti:

Sencha looks great, and saw some alternatives too, I will check them all.
One question about it. Do you develope applications for iphone, android
seperately or u create something then compile it for different enviroments?

havent got round for piston but have some outputs with tastypie already,
seems like it will be possible for me to get my output with some tweaks.
thx.


On Wednesday, 12 September 2012 13:25:07 UTC+3, Jani Tiainen wrote:

I'm using Sencha Touch to build mobile interface to Django application.
(basically Django serves just REST API, UI is pure JS/HTML5 stuff).

Nice thing is that there exists build process to use phonegap with
sencha touch to create real native app if needed.

12.9.2012 13:15, Stephen Anto kirjoitti:
 > Hi,
 >
 > Django piston is available to convert all django data into json
via handler.
 >
 > You can use this json data to both web and mobile interface.
 >
 > Currently I am working on the same cheers... Thanks for visiting
 > <http://www.f2finterview.com/>
 >
 > On Tue, Sep 11, 2012 at 2:29 PM, Sait Maraşlıoğlu
<sait...@gmail.com 
 > <mailto:sait...@gmail.com >> wrote:
 >
 > How do you create iphone applications via django.
 > Application logic will be django but what about user
interface, do
 > we do that with django too?
 >
 > --
 > 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/-/xL4mqQobAEUJ
<https://groups.google.com/d/msg/django-users/-/xL4mqQobAEUJ>.
 > To post to this group, send email to
django...@googlegroups.com 
 > <mailto:django...@googlegroups.com >.
 > To unsubscribe from this group, send email to
 > django-users...@googlegroups.com 
 > <mailto:django-users%2bunsubscr...@googlegroups.com
>.
 > For more options, visit this group at
 > http://groups.google.com/group/django-users?hl=en
<http://groups.google.com/group/django-users?hl=en>.
 >
 >
 >
 >
 > --
 > Thanks & Regards
 > Stephen S
 >
 >
 >
 > Website: www.f2finterview.com <http://www.f2finterview.com>
<http://www.f2finterview.com>
 > Blog: blog.f2finterview.com <http://blog.f2finterview.com>
<http://blog.f2finterview.com>
 > Tutorial: tutorial.f2finterview.com
<http://tutorial.f2finterview.com> <http://tutorial.f2finterview.com
<http://tutorial.f2finterview.com>>
 > Group: www.charvigroups.com <http://www.charvigroups.com>
<http://www.charvigroups.com>
 >
 > --
 > You received this message because you are subscribed to the Google
 > Groups "Django users" group.
 > To post to this group, send email to django...@googlegroups.com
.
 > To unsubscribe from this group, send email to
 > django-users...@googlegroups.com .
 > For more options, visit this group at
 > http://groups.google.com/group/django-users?hl=en
<http://groups.google.com/group/django-users?hl=en>.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient
before...

--
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/-/6J4paF2FOrgJ.
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.



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Iphone applications via django

2012-09-12 Thread Jani Tiainen
I'm using Sencha Touch to build mobile interface to Django application. 
(basically Django serves just REST API, UI is pure JS/HTML5 stuff).


Nice thing is that there exists build process to use phonegap with 
sencha touch to create real native app if needed.


12.9.2012 13:15, Stephen Anto kirjoitti:

Hi,

Django piston is available to convert all django data into json via handler.

You can use this json data to both web and mobile interface.

Currently I am working on the same cheers... Thanks for visiting
<http://www.f2finterview.com/>

On Tue, Sep 11, 2012 at 2:29 PM, Sait Maraşlıoğlu <saitma...@gmail.com
<mailto:saitma...@gmail.com>> wrote:

How do you create iphone applications via django.
Application logic will be django but what about user interface, do
we do that with django too?

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




--
Thanks & Regards
Stephen S



Website: www.f2finterview.com <http://www.f2finterview.com>
Blog: blog.f2finterview.com <http://blog.f2finterview.com>
Tutorial: tutorial.f2finterview.com <http://tutorial.f2finterview.com>
Group: www.charvigroups.com <http://www.charvigroups.com>

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



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Override save or other options?

2012-09-10 Thread Jani Tiainen

11.9.2012 7:23, Lachlan Musicman kirjoitti:

Hi All,

Simplistically, I have an event type model (for a "school class") with
a date field.

On saving of the first event, I want to add recurring objects.
Specifics for this project are "up to a latest date" (ie, end of term)
and "recur weekly only" (not daily, monthly, yearly, etc - for the
school's weekly timetable)

I have just tried overriding the save method on the object to auto
create these objects.

def save(self):
super(Event, self).save()

last_date = self.term.end_date
series_date = self.date + datetime.timedelta(7)
while series_date < last_date:
   super(Session, self).save(date = series_date)

I've realised that this will most probably not make new objects, but
will only update the date on the current object. Quite separately, I'm
also getting keyword argument error on "date".

How would you go about creating a series of events from a single save
press? Should I be using some sort of external system (celery or ???)
or should I write an additional method for the model that does the
auto-creation?

At some point after working this out, I will have a need to delete the
series as well...and I don't even want to think about editing the
series. Let's start with creating a recurring event and I'll work on
that later.


Rather than creating individual series of events from recurring I would 
do a concept called "recurring event". So it would be just a single 
event that is projected to spesific days as necessary. It requires a 
slightly more work but it's easier to maintain - for example entry would 
just state:


recurring = True
frequence = WEEKLY
start_date = 2012-09-11
end_date = 2012-12-01
start_time = 09:00
end_time = 10:00

Then I would roll out custom non-database concept of "calendar day" that 
would be projected from database using both individual entries and 
recurring entries.


Later on it would be very easy to modify existing recurring events and 
for example add cancellation of single event by creating overriding 
events concept.


This way amount of data will be kept relatively small, it's much easier 
to read and modify. Of course drawback is that you need top level 
mechanisms to work with single calendar entries that map to your 
database representation.



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Static files not loading when debug is false

2012-09-10 Thread Jani Tiainen
As I put in my second post. Static serving is not working (by default) when
you turn debugging off unless you provide --insecure option on manage.py
runserver command. That is by design. Though with you should see improperly
configured exception raised if you try to use forcefully static serving
view (url is not even added when debug is false thus you should just see
404 errors if you use recommended staticfiles configuration pattern).

Read carefully implications of using staticfiles app and how it replaces
runserver command:

https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/#runserver

HTH.

On Mon, Sep 10, 2012 at 3:57 PM, Karambir Singh Nain <akaram...@gmail.com>wrote:

> Yeah. during, debug=true, it is serving fine from static_root. But not
> when debug is false.
>
>
> On Monday, September 10, 2012 2:01:03 AM UTC+5:30, Jani Tiainen wrote:
>
>> I suppose that your frontend webserver is serving files from url /static/
>> from path that STATIC_ROOT points to?
>>
>> On Sun, Sep 9, 2012 at 10:23 PM, Karambir Singh Nain 
>> <akar...@gmail.com>wrote:
>>
>>> I have a fairly simple django project having some views, templates and
>>> static files like  css and images. My settings file include :
>>>
>>> STATIC_ROOT = '/home/karambir/Codes/**projects/cdi/cdi/static'
>>> STATIC_URL = '/static/'
>>> STATICFILES_DIRS = (
>>> '/home/karambir/Codes/**projects/cdi/cdi/data',
>>> )
>>> TEMPLATE_DIRS = (
>>> '/home/karambir/Codes/**projects/cdi/cdi/templates'
>>> )
>>>
>>> So I serve static files with  {{ STATIC_URL }} in the templates. And it
>>> is working fine when DEBUG is TRUE but every static file breaks when debug
>>> is set to false. Then I tried with django admin, it was also broken. So I
>>> run a ./manage.py collectstatic command. And then admin css works fine but
>>> my own files still not. I saw in the url of the loaded html page and it
>>> shows correct url and it is not loading.
>>> How can I know what is the main problem. What changes takes place when
>>> debug is set to false?
>>> (I'm running django1.4)
>>>
>>> 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/-/**fWCsL9PUI1EJ<https://groups.google.com/d/msg/django-users/-/fWCsL9PUI1EJ>
>>> .
>>> To post to this group, send email to django...@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users...@**
>>> googlegroups.com.
>>>
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>>
>>
>>
>>
>> --
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
>>  --
> 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/-/W-IOauTb9dQJ.
>
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Can't Find libclntsh.so.11.1 With Oracle Backend

2012-09-10 Thread Jani Tiainen
I've been using ldconfig to handle libs. It's easy as runnig following few
commands as a root. (Though I always use oracle instantclient, it's just
simpler in many cases):

$ echo  /oracle/product/11.1.0/db_1/**lib  > /etc/ld.so.conf.d/oracle.conf
$ ldconfig

On Mon, Sep 10, 2012 at 7:11 PM, Ian <ian.g.ke...@gmail.com> wrote:

> On Sunday, September 9, 2012 10:41:00 PM UTC-6, Jon Blake wrote:
>>
>> It looks like I have to tell my app what my path to libclntsh.so.11.1 is.
>> I have added:
>>
>> os.environ['LD_LIBRARY_PATH'] = '/oracle/product/11.1.0/db_1/**lib'
>>>
>>
>> to my app's wsgi.py file, but this does resolve my problem.
>>
>>
> LD_LIBRARY_PATH has to be set before the process starts to be honored.  So
> it's not sufficient to set it in the wsgi file with os.environ; you need to
> use an Apache SetEnv directive, or use a script to export it in the Apache
> process's environment variables when Apache is started.  Or as a third
> option, use ldconfig to make the Oracle library path globally visible.
>
> Cheers,
> Ian
>
> --
> 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/-/z8aKjhUtm3QJ.
>
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Static files not loading when debug is false

2012-09-09 Thread Jani Tiainen
Also just a note, if you're using manage.py runserver without debug = TRUE
setting, static file serving is not taking place. you can use --insecure
option to mark that you really want to do staticfile serving still from
django.

https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#django-admin-option---insecure


On Sun, Sep 9, 2012 at 11:30 PM, Jani Tiainen <rede...@gmail.com> wrote:

> I suppose that your frontend webserver is serving files from url /static/
> from path that STATIC_ROOT points to?
>
>
> On Sun, Sep 9, 2012 at 10:23 PM, Karambir Singh Nain 
> <akaram...@gmail.com>wrote:
>
>> I have a fairly simple django project having some views, templates and
>> static files like  css and images. My settings file include :
>>
>> STATIC_ROOT = '/home/karambir/Codes/projects/cdi/cdi/static'
>> STATIC_URL = '/static/'
>> STATICFILES_DIRS = (
>> '/home/karambir/Codes/projects/cdi/cdi/data',
>> )
>> TEMPLATE_DIRS = (
>> '/home/karambir/Codes/projects/cdi/cdi/templates'
>> )
>>
>> So I serve static files with  {{ STATIC_URL }} in the templates. And it
>> is working fine when DEBUG is TRUE but every static file breaks when debug
>> is set to false. Then I tried with django admin, it was also broken. So I
>> run a ./manage.py collectstatic command. And then admin css works fine but
>> my own files still not. I saw in the url of the loaded html page and it
>> shows correct url and it is not loading.
>> How can I know what is the main problem. What changes takes place when
>> debug is set to false?
>> (I'm running django1.4)
>>
>> 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/-/fWCsL9PUI1EJ.
>> 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.
>>
>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Static files not loading when debug is false

2012-09-09 Thread Jani Tiainen
I suppose that your frontend webserver is serving files from url /static/
from path that STATIC_ROOT points to?

On Sun, Sep 9, 2012 at 10:23 PM, Karambir Singh Nain <akaram...@gmail.com>wrote:

> I have a fairly simple django project having some views, templates and
> static files like  css and images. My settings file include :
>
> STATIC_ROOT = '/home/karambir/Codes/projects/cdi/cdi/static'
> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> '/home/karambir/Codes/projects/cdi/cdi/data',
> )
> TEMPLATE_DIRS = (
> '/home/karambir/Codes/projects/cdi/cdi/templates'
> )
>
> So I serve static files with  {{ STATIC_URL }} in the templates. And it is
> working fine when DEBUG is TRUE but every static file breaks when debug is
> set to false. Then I tried with django admin, it was also broken. So I run
> a ./manage.py collectstatic command. And then admin css works fine but my
> own files still not. I saw in the url of the loaded html page and it shows
> correct url and it is not loading.
> How can I know what is the main problem. What changes takes place when
> debug is set to false?
> (I'm running django1.4)
>
> 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/-/fWCsL9PUI1EJ.
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Django - change select items display

2012-08-27 Thread Jani Tiainen

27.8.2012 12:11, jm kirjoitti:

hi

do you solved it ? I'm looking for the same and do not find anything to
change which column is used in the SELECT instead of __unicode__

thanks

jm

Le mercredi 20 juillet 2011 00:16:06 UTC+2, galgal a écrit :

I use ModelForm. One of fields is:

|repertoire=  models.ForeignKey(Repertoire)
|

I need to change it's display type. Instead of using *unicode* in
display I want to show name and date of repertoire. How in ModelForm
I can do that?

--
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/-/gbAncWxkSL4J.
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 can change it by creating custom field and overriding 
label_from_instance method.


It's documented just below 
https://docs.djangoproject.com/en/1.3//ref/forms/fields/#django.forms.ModelChoiceField.empty_label


HTH,

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Dependent Ajax Form Fields

2012-08-26 Thread Jani Tiainen

26.8.2012 21:54, Joseph Mutumi kirjoitti:

Hello,

If A is a model with ForeignKey relationships to B. What would be the
best way of rendering two
selectboxes, A and B. The values of B are the values filtered through
using the relationship with
the selected value of A via an AJAX call.

I need to get these values from the DB as well as have Django validation
work out? All ideas are
welcome!


Well it works exactly as you described. You hookup with your JS 
framework to change event of selectbox A to run query and update

contents (by calling django view with correct params) of selectbox B.

I suggest that you keep validation to happen on form submit rather than 
when updating two field values.


Just find out what is the best way to do that with your JS framework.

Try googling "dependent selectboxes should get you going. By adding keyword Django might give even more help.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: What is the easy way to install DJango?

2012-08-23 Thread Jani Tiainen

23.8.2012 2:08, Demian Brecht kirjoitti:




 Or installing the M$ VC++ Express edition compatible with the
version used for the Python build 
--
 Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.com <mailto:wlfr...@ix.netcom.com>
HTTP://wlfraed.home.netcom.com/


Sure (or MinGW if I'm not mistaken) but the question was asking about an
"easy" way. I'm not sure that setting up a full build environment on a
Windows machine would qualify it to be such. Of course, that's entirely
subjective and not really related to the question at hand ;)

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


And even with those you will end up problems. One common 3rd party 
library that has extensions is PIL. And there is not really easy way to 
build PIL with all dependencies on windows machine - specially PNG 
support is a tricky one. Also for few build scripts there seem to be 
problem of passing different compiler than msvc for windows. So 
everything is not simple.


These parts are way simpler in *nix like environments - except in RHEL...

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: to_field can not use primary key of related object.

2012-08-23 Thread Jani Tiainen

23.8.2012 9:30, yillkid kirjoitti:


HI all.
I write a model:
class UserGroup(models.Model):
 groups = models.ForeignKey(Group, to_field='id')

and when I into admin backend:

<https://lh4.googleusercontent.com/-dxgts8I14Sw/UDXNrsM0CZI/AoA/6DQxSeD2mOw/s1600/123.jpeg>












According to the Django  document the combobox item should be a "id"
field in Group model,
but it is not, why ?


Where from the documenttion you got impression of that? As documentation 
states:


"Foreginkey.to_field
The field on the related object that the relation is to. By default, 
Django uses the primary key of the related object"


There is nothing about representation in a select field on a form. It 
still uses ID as a value to post. But what you see is just a 
representation of the __unicode__ method. There is way to change that 
behaviour for a particular form field if needed.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: What is the easy way to install DJango?

2012-08-22 Thread Jani Tiainen

22.8.2012 14:56, Tom Evans kirjoitti:

On Wed, Aug 15, 2012 at 3:53 PM, Vibhu Rishi <vibhu.ri...@gmail.com> wrote:

Hi,

If you are new to Django and are just getting around to learn it, I
recommend using BitNami Django stack for windows.
http://bitnami.org/stack/djangostack

So far, it has been the easiest to install on the windows machine.

Vibhu


I know a lot of people really like these bundled stacks, but there are
a few downsides to consider:

1) You get what the packagers have packaged. If that is not precisely
what you want, tough.
2) You gain no knowledge about how your stack is put together. If you
don't understand your stack, developing solutions using it becomes
trickier.
3) Django is not a language; its a python library. It's highly likely
you will also use other python libraries as part of your solution, so
working out how to deal with installing, upgrading and maintaining
python libraries is a useful skill. By just installing a stack, you
miss out on learning useful skills.

I don't want to put people off though; I'm sure the people at bitnami
have put together a good stack.

Cheers

Tom



I also agree that using any stack is simple way to get prepackaged 
"something" up and running.


But as Tom pointed out Django is just a python library. It's rather 
evitable to start need other libraries as well. Or if you happen to have 
some nice database backend like I do have Oracle and I use GeoDjango 
spatial parts that do require quite a bunch of external stuff to be 
installed. Never tried on bitnami stack but in general those will get 
tricky there.


I use windows environment for everyday development - as does about 20 my 
colleagues as well. I wrote small blog entry in April how I setup my 
environment. That includes python, virtualenv and TCC/LE that brings 
nice enhancement over standard CMD to make everything feel more 
"unix-like" environment without needs to do any virtual machine or dual 
boot tricks. But it's not hard to install everything it just requires 
some work. And after you get virtualenvs up and running setting up all 
kind of stuff is just a breeze.


http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/

I also know that there exists virtualenv-wrapper scripts for windows 
cmd/powershell but never got them working in my environment and I've 
been too lazy to try to fix them for my envs.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: problems in installing django on windows 7

2012-08-20 Thread Jani Tiainen
I've also written blog entry about slightly more complicated and more 
complete guide to get smooth ride with django and windows.


http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/


18.8.2012 6:54, Amyth Arora kirjoitti:

If you still face problem you can go through this tutorial right here
-> http://techstricks.com/install-django-on-windows-7/

On Sat, Aug 18, 2012 at 7:40 AM, Amyth Arora <aroras.offic...@gmail.com> wrote:

You can either create a symlink or add the django directory to your
path for it to work, on windows the django files are installed in
"C:\Python27\Lib\site-packages\django". You can replace the Python
directory according to the version of python you are using.

On Fri, Aug 17, 2012 at 11:10 PM, numsontech <virtuelawf...@gmail.com> wrote:

Hi!
I am new to the Django frameworks and and having difficulties getting it to
work on windows 7. I have successfully installed the latest release but when
I try to create a new project using the command "python django-admin.py
startproject mysite" it displays the following message: can't open file
'django-admin.py': [err 2] no such file or directory.

I wish to know how to resolve this.
  I am also trying to symlink the django-admin.py file but I don't know which
path to link it to.
Any information will be appreciated
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/-/EfBa2-sPjMwJ.
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.




--
Thanks & Regards


Amyth [Admin - Techstricks]
Email - aroras.offic...@gmail.com, ad...@techstricks.com
Twitter - @a_myth_____
http://techstricks.com/







--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Adding Button in admin form

2012-08-17 Thread Jani Tiainen

17.8.2012 13:42, Madhu kirjoitti:

No. URL linking is not the problem. I have the problem to add the input
button in admin form.

There will be so many buttons in admin form like save, add, delete. I
want to add my own button, but in the middle of admin form not at the
submit line or upper part of the admin form. That button should be
display near to my character field.

Using html we create  then button tag will be display
in the html page.
I want the same input button on the admin form.



If I understood correctly OP want's to display button after URL field 
that says something like "select existing". When user clicks it it 
fetches (ajax query maybe) list of URLs from database and user can 
select value that is then copied to text field instead of typing URL 
manually to text field.


How to achieve that kind of functionality in admin beats me. Probably it 
would be possible with custom field though I think it might work better 
out with totally custom form that looks like admin page where it's very 
easy to add more control than standard admin does.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: access the state of a Model object prior to it's modification ?

2012-07-16 Thread Jani Tiainen
Probably you want to do that logic a slightly differently on a model level
(so rule would apply always when you save your model).

So you would actually override model save method.

Probably rule is something like this:

class MyPublicationModel(Model):
def save(...):  # I don't remember the signature
if self.is_published and not self.publication_date:
# Published previously unpublished - set the date
self.publication_date = date.today()
   elif not self.is_published and self.publication_date:
# Mark already published as unpublished - clear the date
self.publication_date = None

   super(self, MyPublicationModel).save(...)

On Mon, Jul 16, 2012 at 3:39 AM, Nicolas Emiliani <or3s...@gmail.com> wrote:

>
>
> On Sun, Jul 15, 2012 at 8:10 PM, Jani Tiainen <rede...@gmail.com> wrote:
>
>> Hi,
>>
>> How about telling us what are you trying to achieve by comparing to
>> previous state of the object?
>>
>>
> Well, the model has a boolean field called published, and a publish_date
> that gets set "automatically"
> when the user through the admin panel sets the flag published to true. He
> could also unpublish it, but the
> date would still remain the same (on the date it was first published). And
> here comes the problem :
>
> If the user decides to republish I would have to set the date to current
> date, but how do I know if he
> is republishing or he modified some other field that has nothing to do
> with that attribute ? I would be
> republishing only if it's previous state was not published. But how can I
> acces that previous state ?
>
> Sounds waky :P
>
>
>
>> On Sun, Jul 15, 2012 at 1:49 AM, Nicolas Emiliani <or3s...@gmail.com>wrote:
>>
>>> Hi,
>>>
>>> Is there a way to access the state of a Model object prior to it's
>>> modification through a form ?
>>> Kind of a nasty question :S, let me explain.
>>>
>>> The thing is that if i use the save_model hook and the user modifies the
>>> model through the form,
>>> the obj parameter that I receive has already all the modifications
>>> loaded, so if  I have, let's say,
>>> a boolean attribute called "published"  and the user clicked published
>>> then :
>>>
>>> obj.published == True
>>>
>>> Is there a way to know which was the state of the model, in this case
>>> the state of obj.published,
>>> before the user clicked on the save button on the admin form ? or should
>>> I use a second model
>>> attribute and hide it on the form to keep the previous state ? is there
>>> a "Django" way to do this ?
>>>
>>> It's my first post, be gentle :P
>>>
>>> Thanks !
>>>
>>> --
>>> Nicolas Emiliani
>>>
>>> Lo unico instantaneo en la vida es el cafe, y es bien feo.
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
>>  --
>> 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.
>>
>
>
>
> --
> Nicolas Emiliani
>
> Lo unico instantaneo en la vida es el cafe, y es bien feo.
>
> --
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Query Distance from User

2012-07-15 Thread Jani Tiainen
groups.google.com/d/msg/django-users/-/_ERIIZrolmUJ>
>>>>> .
>>>>> 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<django-users%2bunsubscr...@googlegroups.com>
>>>>> .
>>>>> For more options, visit this group at http://groups.google.com/**
>>>>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>>>> .
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Nicolas Emiliani
>>>>
>>>> Lo unico instantaneo en la vida es el cafe, y es bien feo.
>>>>
>>>  --
> 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/-/xqKHuCVictIJ.
>
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: access the state of a Model object prior to it's modification ?

2012-07-15 Thread Jani Tiainen
Hi,

How about telling us what are you trying to achieve by comparing to
previous state of the object?

On Sun, Jul 15, 2012 at 1:49 AM, Nicolas Emiliani <or3s...@gmail.com> wrote:

> Hi,
>
> Is there a way to access the state of a Model object prior to it's
> modification through a form ?
> Kind of a nasty question :S, let me explain.
>
> The thing is that if i use the save_model hook and the user modifies the
> model through the form,
> the obj parameter that I receive has already all the modifications loaded,
> so if  I have, let's say,
> a boolean attribute called "published"  and the user clicked published
> then :
>
> obj.published == True
>
> Is there a way to know which was the state of the model, in this case the
> state of obj.published,
> before the user clicked on the save button on the admin form ? or should I
> use a second model
> attribute and hide it on the form to keep the previous state ? is there a
> "Django" way to do this ?
>
> It's my first post, be gentle :P
>
> Thanks !
>
> --
> Nicolas Emiliani
>
> Lo unico instantaneo en la vida es el cafe, y es bien feo.
>
> --
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Catch or raise exception designissue

2012-07-15 Thread Jani Tiainen
I think "letting to explode" is all about coloring the bike shed. It all
depends on a API contract - if parameter is required (thus meaning missing
it is a critical error) it should explode.

In case of incorrect request I prefer to raise 400 (Bad Request) with some
explanation what went wrong. Since 500 is usually meant for "catch all"
unexpected errors that happened in web server and server can't be more
precise what happened. I've done that according to RFC 2616 (HTTP 1.1
Specification) where is said that 4xx codes are meant for "client side
error" (Section 10.4), and 5xx which means "server error" (Section 10.5)

But I think all of that is matter of taste...

On Sun, Jul 15, 2012 at 12:23 AM, Melvyn Sopacua <m.r.sopa...@gmail.com>wrote:

> [reformatted]
>
> On 11-7-2012 20:41, Jani Tiainen wrote:
> > On Wed, Jul 11, 2012 at 4:47 PM, Andre Schemschat <dai...@web.de> wrote:
> >> In my view i have, naturally, some code to process the request and
> return
> >> a response. This code needs a get-parameter to operate within boundaries
> >> and this parameter is always provided within the application (Its an
> >> ajax-callback).
> > I only do 500-errors when something really critical happens (basically
> > programming error) in application and request can't proceed.
>
> Which is why letting this explode on itself is a good thing. Your ajax
> call should ensure the parameter is there. So when you get 500 errors
> one of three things is happening:
> - A browser does not handle the Ajax call correctly and you want the 500
> error context mailed to you to start debugging
> - A crawler that tries to interpret javascript is not doing a very good
> job and you want to update your robots.txt or block the crawler if it
> doesn't seem to be respecting it.
> - You refactored the javascript code or upgraded a js library and there
> now is a codepath that doesn't provide the parameter. Again, you want to
> see the information and probably catch it before it goes into production.
>
> Masking or reducing errors that should not normally happen is not a good
> thing. This is exactly what exceptions are for.
> --
> Melvyn Sopacua
>
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Form 'POST' to a database

2012-07-13 Thread Jani Tiainen
You still need to call result.is_valid() since it actually runs actual
validation rules.

Very basic form processing is usually done like this:

so in case of GET you return empty form. in case of invalid POST you return
form with values and error messages.

After successful POST you do redirect-after-post to avoid problems with
browser history back-button.

def form_view(request):
if request.method == 'POST':
form = MyForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect("/some/result/form")
else:
form = MyForm()
return HttpResponse("form/form.html", { 'form': form })

On Thu, Jul 12, 2012 at 4:44 AM, JJ Zolper <codinga...@gmail.com> wrote:

> I was able to make it work!
>
> from django.core.context_processors import csrf
> from django.template import RequestContext
> from django.http import HttpResponseRedirect
> from django.http import HttpResponse
> from django.shortcuts import render_to_response
> from MadTrak.manageabout.models import AboutMadtrak, AboutMadtrakForm
>
> def about(request):
> AboutMadtrakInstance = AboutMadtrak()
> result = AboutMadtrakForm(request.POST, instance=AboutMadtrakInstance)
> result.save()
> return HttpResponse('It worked?!? Of course it did. I knew that.')
>
> def about_form(request):
> return render_to_response('about_form.html', context_instance =
> RequestContext(request))
>
> I ended up looking at ModelForms and trying that since I was having issues.
>
> So does this method handle all validation and security issues for me?
>
> Or do I still need a "result.is_valid()" among other things?
>
>
> On Wednesday, July 11, 2012 11:51:19 AM UTC-4, Andre Schemschat wrote:
>>
>> Hey,
>>>>
>>>
>> yeah, it basicly is. Just a very, very basic example (And sorry if i
>> could highlight this as code, i didnt find something in the format-menu :/
>> ).
>> Of course you should validate your input first. And if you just want to
>> edit a Model within a form, you should check on the ModelForm-Class
>> https://docs.**djangoproject.com/en/dev/**topics/forms/modelforms/<https://docs.djangoproject.com/en/dev/topics/forms/modelforms/>
>>
>> def vote(request, poll_id):
>> try:
>> obj = YourModel.objects.get(pk=poll_**id)
>> obj.attributea = request.POST['attributea']
>> obj.attributeb = request.POST['attributeb']
>> obj.save()
>> return HttpResponse(validparamshere)
>> except ObjectDoesNotExist:
>> return HttpResponse(show_some_error)
>>
>>
>>>>  --
> 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/-/JTdViX4I6HEJ.
>
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Form 'POST' to a database

2012-07-11 Thread Jani Tiainen
Django makes always (at least currently) full record update (iow: there is
no dirty flag for fields).

Example given is "poor" in the sense that it uses directly POST data. I
strongly would suggest leveraging modelforms when ever possible - it saves
time and nerves. You get all the validation and other goodies for free.

On Wed, Jul 11, 2012 at 8:09 PM, Dennis Lee Bieber <wlfr...@ix.netcom.com>wrote:

> On Wed, 11 Jul 2012 08:36:39 -0700 (PDT), JJ Zolper
> <codinga...@gmail.com> declaimed the following in
> gmane.comp.python.django.user:
>
>
> > So originally:
> >
> > selected_choice = p.choice_set.get(pk=request.POST['choice'])
> >
> If I understand this (I've not run the tutorial, and only browsed
> the now-outdated print books), this statement is using the value from
> the "choice" field of the submitted form as the primary key to retrieve
> a record (model instance) from the database.
>
> pseudo-SQL
> select * from choice_set where pk = "request.POST['choice']"
>
> > this requests the submitted choice from the POST data and
> >
> > The part that says:
> >
> > selected_choice.votes += 1
> > selected_choice.save()
> >
> > Actually saves the choice to the database?
> >
> This then increments the votes field of the record (model instance)
> retrieved from the database, and then saves the record back.
>
> p-SQL
> update choice_set set
> votes = votes + 1
> where pk = selected_choice.pk
>
> {I don't know if Django is smart enough to only update the changed
> field, or if it updates the entire record}
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Catch or raise exception designissue

2012-07-11 Thread Jani Tiainen
It all depends what is "natural" for end user point of view.

If parameter is something like start or end value I think that the most
convenient thing is to provide some reasonable default if variable is
missing or is incorrect type. Then you may use logging facility to log to
some logger (debug, warn, errror) that value provided was incorrect and was
replaced by default value.

I only do 500-errors when something really critical happens (basically
programming error) in application and request can't proceed.

On Wed, Jul 11, 2012 at 4:47 PM, Andre Schemschat <dai...@web.de> wrote:

> Hi everybody,
> i'm currently working on my first django-application and stumbled upon a
> design issue, which i cant quite decide how to handle and i thought i may
> ask here, if there are any guidelines as to how to handle this :)
> In my view i have, naturally, some code to process the request and return
> a response. This code needs a get-parameter to operate within boundaries
> and this parameter is always provided within the application (Its an
> ajax-callback).
> The question now is, what to do if the parameter is not provided somehow.
> Should i catch the resulting KeyError (Or any unexpected exception in any
> view for that matter) and just redirect to a safe page, log the error away
> and display a warning to the user or should i just let the error pass (in
> debug show the error info page, in production the 500-page), since it
> shouldnt have happend within the application?
> I'm currently tending towards the second option, because in production
> there is the 500-page, so the user doesnt get to see ugly errors and with
> an error-handling middleware i can log the exceptions and in debug its
> easier to take care of the bug, but i like to hear some opinions from the
> more experienced django-devs in here, cause i'm sure im missing some vital
> point :D
>
> Thanks,
> Andre
>
> --
> 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/-/bQyS-29Lb4QJ.
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: model sends two requests

2012-07-11 Thread Jani Tiainen
In one public site we ended up doing both, server side re-submission checks
and client side javascript with timeout re-enable "hack".

We just store magic key to cache which is checked on every submission. If
magic key is missing submission is valid (first one) and key is set if
form was valid:

if request.method == 'POST':
if cache.get('%s.%s' % (request.session.session_key,
data['unique_id'])):
if form.is_valid():
cache.set(('%s.%s' % (request.session.session_key,
data['unique_id']), true) # Block subsequent requests
else:
pass # Output error messages about form
else:
# Key is in the cache, fail
return HttpResponseBadRequest()

On Tue, Jul 10, 2012 at 2:22 PM, jonas peters <jonas.peters...@gmail.com>wrote:

> Thanks, helped me a lot.
>
>
>
> Em segunda-feira, 9 de julho de 2012 17h53min23s UTC-3, Dennis Lee Bieber
> escreveu:
>
>> On Mon, 9 Jul 2012 09:26:15 -0700 (PDT), jonas peters
>> <jonas.peters...@gmail.com> declaimed the following in
>> gmane.comp.python.django.user:
>>
>> > I have a model and use standard django administration, when a user
>> clicks
>> > the save button it sends the request, it takes time to respond and the
>> user
>> > clicks the save button again and then sends another request, and
>> creating
>> > two records. have some setting in django to avoid this problem? I
>> thought
>> > about locking the save button when it is clicked so the user does not
>> click
>> > more than once to complete the request.
>> >
>> In general (that is, not Django specific), my experience is that
>> potentially slow sites in which an extra submittal would cause problems
>> tend to include a warning message to only click once (the sites I've
>> seen this on tend to be online markets -- where the warning is that
>> double clicking could result in a second order charged to the credit
>> card.
>>
>> The other general solution would be to collect the data, send it
>> to
>> a separate worker thread/process and immediately return a "please wait"
>> type response -- this response should have an automatic redirect (using
>> a cookie to identify the worker) to a page that will either find the
>> worker thread has finished and can return the real next page -- or if
>> the worker is still busy resend the "please wait" page.
>>
>> More specific modes:
>> http://www.turnkeylinux.org/**blog/prevent-double-click-**form-submission<http://www.turnkeylinux.org/blog/prevent-double-click-form-submission>
>> (general search: prevent double click form submit
>> http://www.google.com/#hl=en&**sclient=psy-ab=prevent+**
>> double+click+form+submit=**prevent+double+click+form+**
>> submit_l=serp.3..**0i30j0i5i30.8464.23704.0.**
>> 23926.28.25.2.1.1.6.503.4601.**0j21j3j5-1.25.0...0.0.c3W_**
>> 7yOZRzI=1=on.2,or.r_**gc.r_pw.r_qf<http://www.google.com/#hl=en=psy-ab=prevent+double+click+form+submit=prevent+double+click+form+submit_l=serp.3..0i30j0i5i30.8464.23704.0.23926.28.25.2.1.1.6.503.4601.0j21j3j5-1.25.0...0.0.c3W_7yOZRzI=1=on.2,or.r_gc.r_pw.r_qf>
>> .,cf.osb=**9da4b66dc5fd8e9a=1044=**748
>> )
>>
>>
>>
>> > Sorry my english Thanks!
>> --
>> Wulfraed Dennis Lee Bieber AF6VN
>> wlfr...@ix.netcom.com
>> HTTP://wlfraed.home.netcom.**com/
>>
>>  --
> 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/-/ZU-HtLFqcp4J.
>
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Different authentication package

2012-07-10 Thread Jani Tiainen
Maybe you should more clearly specify your needs.

On Tue, Jul 10, 2012 at 1:33 AM, Melvyn Sopacua <m.r.sopa...@gmail.com>wrote:

> On 9-7-2012 20:41, Jani Tiainen wrote:
> > Are you asking how to write custom authentication backend that can suit
> > your needs?
>
> No, that would be my backup plan. I'm looking for something I can
> install and replace the backend with that suits my needs. I've been
> looking around the web and other then some snippets not finding much.
> --
> Melvyn Sopacua
>
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Different authentication package

2012-07-09 Thread Jani Tiainen
Are you asking how to write custom authentication backend that can suit
your needs? If so, it's all documented in Django documentation:
https://docs.djangoproject.com/en/1.4/topics/auth/#other-authentication-sources
is
good place to start reading.

On Mon, Jul 9, 2012 at 5:26 PM, Melvyn Sopacua <m.r.sopa...@gmail.com>wrote:

> Hi,
>
> does anyone have some recommendations about different authentication
> backends for Django?
> My issues with contrib.auth are:
>
> - User model has an emailaddress which makes dealing with alias emails
> for a user more complex (current app I'm writing has an email gateway)
>
> - Can't plug a different user object to the authentication middleware,
> because user retrieval methods are hardcoded to the module
> - No easy way to offload password hashing to the database server
>
> If at all possible, I'd rather not loose the admin, since it's a great
> help adding seed data during development.
> --
> Melvyn Sopacua
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: view didn't return an HttpResponse object....plz help

2012-07-06 Thread Jani Tiainen

6.7.2012 13:18, manish girdhar kirjoitti:

so sorry friend..am new to the django and am unable to catch your
point...can you please describe this with example or with my code..thank
you..


[Snip snip with binary scissors]

Problem is that there is two problem points:

Your view doesn't have "default path" so
IF request.method is POST and IF form.is_valid is FALSE your code 
doesn't return anything.


This means that your view will return something only if request.method 
is not POST (return render_to_response(...) is called) or if 
request.method is POST and form.is_valid() is true (return 
HttpResponseRedirect(..) is called)


Simplest way to fix it is to indent last "return render_to_response..." 
one level outer (same level as if request.method == 'POST' and last 
else) making it to be executed if request.method is not POST or if 
form.is_valid() is false.


In short form:

def studentid(request):
if request.method == 'POST'
form = Student_loginForm(request.POST)
if form.is_valid():
return HttpResponseRedirect(...)
else:
form = Student_loginForm()
return render_to_response('add_record/studentid.html', ...)


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...


--
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: view didn't return an HttpResponse object....plz help

2012-07-06 Thread Jani Tiainen
It doesn't ever work since you should rerender form with current data 
and errors if form.valid() returns false.


Currently your logic doesn't return _nothing_ if form.valid() is false

def studentid(request):
if request.method == 'POST':
form = Student_loginForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
rollno = cd['rollno']
return 
HttpResponseRedirect(reverse('record_system.views.search' , args=(rollno)))

# No else here, nothing is rendered!

else:
# This else is for if request.method == POST
form = Student_loginForm()
return render_to_response('add_record/studentid.html', 
context_instance=RequestContext(request))



I suggest that you put last return one indent level to left so it will 
always render either errored form or in case method was not POST empty form.


6.7.2012 12:31, manish girdhar kirjoitti:

thanks for the concern firend but i already have an form.error in my
template...


*this is my template..
*


 student id



 {% if form.errors %}
 
 Please correct the error{{ form.errors|pluralize }} below.
 
 {% endif %}
  STUDENT RECORD SYSTEM
 
 
 {% csrf_token %}

 Student Roll no:
  
  
 







On Fri, Jul 6, 2012 at 2:49 PM, Jani Tiainen <rede...@gmail.com
<mailto:rede...@gmail.com>> wrote:

Print out form.errors it will contain dictionary about fields and
errors in particular field.

You get the error because your form didn't validate in the first
place so either you have bad data, are missing required data or
something else in validation fails. form.errors will reveal that.

6.7.2012 12:16, manish girdhar kirjoitti:

thank you for your concern friend,but i have an another view .in
that it
perfectly worksbut here am getting problem and i know

*"if form.is_valid():"*   is getting falsewhat am looking for is

this, that why here am getting problem.
this thing perfectlly works in my adding two number view's
appication.


On Fri, Jul 6, 2012 at 2:35 PM, Karl Sutt <k...@sutt.ee
<mailto:k...@sutt.ee>
<mailto:k...@sutt.ee <mailto:k...@sutt.ee>>> wrote:

 There is no HttpResponse object returned if the form is
*not* valid.

 You might want to return a template saying that the form
input was
 incorrect.

 Tervitades/Regards
 Karl Sutt



 On Fri, Jul 6, 2012 at 11:49 AM, manish girdhar
 <manishgirdha...@gmail.com
<mailto:manishgirdha...@gmail.com>
<mailto:manishgirdhar88@gmail.__com
<mailto:manishgirdha...@gmail.com>>> wrote:

 hii tom,
 yeah i have rectidy rollno = cd["rollno"] ,but again am
getting
 error didn't get an httpresponse object...

 this is my view.


 def studentid(request):
  if request.method == 'POST':
  form = Student_loginForm(request.__POST)
  if form.is_valid():
  cd = form.cleaned_data
  rollno = cd['rollno']
  return

HttpResponseRedirect(reverse('__record_system.views.search' ,
 args=(rollno)))
  else:
  form = Student_loginForm()

  return
render_to_response('add___record/studentid.html',
 context_instance=__RequestContext(request))


 the error is in*"if form.is_valid: "*..its getting
false and

 ultimately the further process is not going on..

 thanks in advance.


 On Thu, Jul 5, 2012 at 7:34 PM, Tom Evans
 <tevans...@googlemail.com
<mailto:tevans...@googlemail.com>
<mailto:tevans.uk@googlemail.__com
<mailto:tevans...@googlemail.com>>> wrote:

 On Thu, Jul 5, 2012 at 8:38 AM, manish girdhar
 <manishgirdha...@gmail.com
<mailto:manishgirdha...@gmail.com>
 <mailto:manishgirdhar88@gmail.__com
<mailto:manishgirdha...@gmail.com>>> wrote:
  > yes it was indentation error and i rectified
that.thanks
 for the concern
  > friend..
  >

 I would have thought that it was you refering to
the undefined
 variable rollno here:

  cd = form.cleaned_data
  rollno = cd[rollno]

Re: view didn't return an HttpResponse object....plz help

2012-07-06 Thread Jani Tiainen
Print out form.errors it will contain dictionary about fields and errors 
in particular field.


You get the error because your form didn't validate in the first place 
so either you have bad data, are missing required data or something else 
in validation fails. form.errors will reveal that.


6.7.2012 12:16, manish girdhar kirjoitti:

thank you for your concern friend,but i have an another view .in that it
perfectly worksbut here am getting problem and i know

*"if form.is_valid():"*   is getting falsewhat am looking for is
this, that why here am getting problem.
this thing perfectlly works in my adding two number view's appication.


On Fri, Jul 6, 2012 at 2:35 PM, Karl Sutt <k...@sutt.ee
<mailto:k...@sutt.ee>> wrote:

There is no HttpResponse object returned if the form is *not* valid.
You might want to return a template saying that the form input was
incorrect.

Tervitades/Regards
Karl Sutt



On Fri, Jul 6, 2012 at 11:49 AM, manish girdhar
<manishgirdha...@gmail.com <mailto:manishgirdha...@gmail.com>> wrote:

hii tom,
yeah i have rectidy rollno = cd["rollno"] ,but again am getting
error didn't get an httpresponse object...

this is my view.


def studentid(request):
 if request.method == 'POST':
 form = Student_loginForm(request.POST)
 if form.is_valid():
 cd = form.cleaned_data
 rollno = cd['rollno']
 return
HttpResponseRedirect(reverse('record_system.views.search' ,
args=(rollno)))
 else:
 form = Student_loginForm()

 return render_to_response('add_record/studentid.html',
context_instance=RequestContext(request))


the error is in*"if form.is_valid: "*..its getting false and
ultimately the further process is not going on..

thanks in advance.


On Thu, Jul 5, 2012 at 7:34 PM, Tom Evans
<tevans...@googlemail.com <mailto:tevans...@googlemail.com>> wrote:

On Thu, Jul 5, 2012 at 8:38 AM, manish girdhar
<manishgirdha...@gmail.com
<mailto:manishgirdha...@gmail.com>> wrote:
 > yes it was indentation error and i rectified that.thanks
for the concern
 > friend..
 >

I would have thought that it was you refering to the undefined
variable rollno here:

 cd = form.cleaned_data
 rollno = cd[rollno]
 rollno = request.POST.get(rollno)

Should it not read:

 cd = form.cleaned_data
 rollno = cd["rollno"]
 rollno = request.POST.get(rollno)

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
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
<mailto:django-users%2bunsubscr...@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
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
<mailto:django-users%2bunsubscr...@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
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
<mailto:django-users%2bunsubscr...@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.


--
Jani Tiainen

- Well pla

Re: Query with GeoDjango

2012-07-01 Thread Jani Tiainen
I thought that it was fixed along with
https://code.djangoproject.com/ticket/12344 ... Bascially it aoubt that
Django picks "origin manager" to be used in related models (and thus
related model manager) as well and that seem to cause queries to fail.



On Sun, Jul 1, 2012 at 3:42 AM, Ethan Jucovy <ethan.juc...@gmail.com> wrote:

> On Sat, Jun 30, 2012 at 8:31 PM, Odagi <fcmira...@gmail.com> wrote:
>
>> It's working! Thanks a lot.
>> Is There a problem with mixing regular models fields with geomodels ones?
>>
>
> No, there's no problem, as long as you remember to use a GeoManager on
> every model that ever does geospatial queries (whether or not it has any
> geospatial fields itself)
>
> -Ethan
>
> --
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Jani Tiainen
I meant that if for some reason Django sends incorrect content type from a
view or something like that your javascript framework might guess
incorrectly your ajax request content type and not parse script tags.

On Sat, Jun 30, 2012 at 1:51 AM, Jani Tiainen <rede...@gmail.com> wrote:

> It's known limitation of your ajax request and has nothing to do with
> Django nor templates. Or well it might do.
>
> Most of the javascript frameworks can extract script and inject it
> correctly to current DOM. Since you mention jquery I guess that you're
> using that for ajax queries so make sure that your $.ajax() has dataType
> attribute to set as 'html'. It should (according to docs) parse script
> parts correctly.
>
>
> On Fri, Jun 29, 2012 at 11:45 PM, Larry Martell 
> <larry.mart...@gmail.com>wrote:
>
>> I have a django template that has some javascript/jQuery code in it
>> that defines some keyup event handers. If a user goes to the URL
>> directly the javascript is executed, and the event handers all work
>> fine. There is also a field that they can type in that triggers the
>> same URL request to be sent via ajax. When they do this, it seems that
>> the html is rendered, but the javascript is not executed. I discovered
>> this by noticing that the page was rendered, but none of the
>> javascript event handers were being called. I proved this by adding:
>>
>>
>>
>>alert('here we are');
>>
>>
>> to the template, and the alert doesn't show when the request comes
>> from ajax. But if I go to the URL directly it does.
>>
>> Is this a known issue? Is there some way I can get my javascript code
>> to run to install my event handlers when the request comes from ajax?
>>
>> TIA!
>> -larry
>>
>> --
>> 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.
>>
>>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Jani Tiainen
It's known limitation of your ajax request and has nothing to do with
Django nor templates. Or well it might do.

Most of the javascript frameworks can extract script and inject it
correctly to current DOM. Since you mention jquery I guess that you're
using that for ajax queries so make sure that your $.ajax() has dataType
attribute to set as 'html'. It should (according to docs) parse script
parts correctly.

On Fri, Jun 29, 2012 at 11:45 PM, Larry Martell <larry.mart...@gmail.com>wrote:

> I have a django template that has some javascript/jQuery code in it
> that defines some keyup event handers. If a user goes to the URL
> directly the javascript is executed, and the event handers all work
> fine. There is also a field that they can type in that triggers the
> same URL request to be sent via ajax. When they do this, it seems that
> the html is rendered, but the javascript is not executed. I discovered
> this by noticing that the page was rendered, but none of the
> javascript event handers were being called. I proved this by adding:
>
>
>
>alert('here we are');
>
>
> to the template, and the alert doesn't show when the request comes
> from ajax. But if I go to the URL directly it does.
>
> Is this a known issue? Is there some way I can get my javascript code
> to run to install my event handlers when the request comes from ajax?
>
> TIA!
> -larry
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: interpretting urls

2012-06-28 Thread Jani Tiainen

Hi,

Quote from URL dispatcher documentation:
"To design URLs for an app, you create a Python module informally called 
a URLconf (URL configuration). This module is pure Python code and is a 
simple mapping between URL patterns (as simple regular expressions) to 
Python callback functions (your views).

"

So you need to do your homework and learn how to read and write (Python) 
regular expressions since pretty much everything in url

config is a regular expression.

28.6.2012 1:29, Smaran Harihar kirjoitti:

The doc did not give details for *r'^(?:index/?)?$'*, in

(r'^(?:index/?)?$', 'geonode.views.index')

Thanks,
Smaran

On Wed, Jun 27, 2012 at 4:16 AM, bruno desthuilliers
>
wrote:



On Tuesday, June 26, 2012 6:52:06 PM UTC+2, Sam007 wrote:

Hi,

I am bit confused about what exactly do these urls imply in the
url.py


This is all documented here :
https://docs.djangoproject.com/en/dev/topics/http/urls/


--
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: Render time

2012-06-26 Thread Jani Tiainen
I stumbled upon this while looking about this timing stuff:
http://www.html5rocks.com/en/tutorials/webperformance/basics/

Seemed slightly more verbose than W3C formal documentation.

On Tue, Jun 26, 2012 at 10:38 PM, Melvyn Sopacua <m.r.sopa...@gmail.com>wrote:

> On 26-6-2012 5:04, Andy McKay wrote:
> >> Now they want me to add to that how long
> >> the browser takes to render the page after it gets the data.
> >
> > You can use the navigation timing API:
> >
> >
> https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
>
> Wow, really nice. Can't believe I missed that.
>
> --
> Melvyn Sopacua
>
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: setting up django with virtualenv on windows7

2012-06-25 Thread Jani Tiainen

26.6.2012 0:39, Dan Johnson kirjoitti:

On 06/25/2012 03:12 PM, mymlyn wrote:

i started a topic on stackoverflow, analysing responses on SO, on
similar topics, im not really sure wether ill get any feedback there
so im gonna try here :) described my problem here:
http://stackoverflow.com/questions/11193905/setting-up-django-with-virtualenv-on-windows7/


could any1 explain to me why isnt this working? //or how is this
supposed to work if everything was ok


import django
django.__path__
should return to you where it is installed. Check to make sure that it
is installed inside the virtualenv. I've noticed that sometimes under
windows I need to activate and deactivate the instance for pip to work
correctly, not sure why.



I've never needed to do anything extra. One thing that happens is that 
standard windows command prompt happens to bound .py(w) extensions to 
use python from c:\python27\ directory and not ones within virtualenv.


See more in my blog entry how I and my team has done it:
http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: base_url() in django

2012-06-25 Thread Jani Tiainen
One actual use-case I have is when sending links in emails, for example
confirmations, password resets links etc. And IIRC there is a way to do it
in Django it's just not documented.

Personally I resolved it by using configuration variable in settings.py
since in my case actual Django installation is behind proxies and absolute
url user sees is not the same what Django app server sees.

On Mon, Jun 25, 2012 at 10:20 PM, Kurtis Mullins
<kurtis.mull...@gmail.com>wrote:

> Is this an actual issue? You realize that there's no difference between
>> /doc/ and http://example.com/doc/ if the current server is
>> http://example.com/?
>>
>
> +1
>
> I'd like to see the use-case where having absolute URLs everywhere is
> actually necessary. It's not hard to do in certain places where you might
> actually need it. The only place I see needing absolute URLs is when going
> from HTTP to HTTPs and for printing out links that people may copy and
> paste. Even in the former case, a permanent-redirect is better.
>
> --
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: cad application

2012-06-21 Thread Jani Tiainen

21.6.2012 14:40, Satvir Toor kirjoitti:

can we make cad applications through the django??? If any one know
about a link  where i can find such information just tell me.  I could
not find any information regarding it.



Of course it is possible, though it all depends what you mean by "cad 
application" and what's your goal.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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 creating project from the Command Prompt

2012-06-07 Thread Jani Tiainen

7.6.2012 10:29, andres orozco kirjoitti:

I've installed django 1.4 and i want to test the installation, i don't
know too much about this cuz' i'm just learning, but i tried it using
the windows 7 command prompt but i've got this error 
http://i.imgur.com/znZGW.png
could someone help me please?



Your path indicates that you have installed Python 3.2. Django is only 
Python 2.x compatible currently.


So install Python 2.7.x

Since you're beginner I also promote my blogpost how to make life easier 
in Windows 7:

http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Oracle schema not working

2012-06-04 Thread Jani Tiainen

4.6.2012 14:36, rahajiyev kirjoitti:

Why is Django strangely quoting column and table names? It gives
Oracle syntax errors.

DatabaseError at /

relation "foo" does not exist
LINE 1: ...ty", "foo"."address_country" FROM "foo"."...

Of course it exists as foo, not as "foo".

I already did the CREATE SYNONYM trick to avoid messing with schemas.



By default Oracle makes following assumption: if given name (column, 
table, schema etc.) is not quoted it's converted implicitly to uppercase 
and used as that.


Thus clause: select * from SoMeTaBle becomes to select * from "SOMETABLE".

If you provide quotes Oracle uses table name as is and thus making it 
case-sensitive.


In theory Django should make all names uppercase regradless how you 
write it. I recall someone to complain strange behavior in cases with 
Oracle backend.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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



The Prettiest Pink Pony in Town

2012-06-01 Thread Jani Tiainen

Hi,

Since summer seems to arrived (I just saw young elk running at the back 
yard of our office). I decided to type in magical words "pink pony" in 
youtube search.



Here is what I found. Enjoy!

http://www.youtube.com/watch?v=vY14EGd71FY

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Oracle schema not working

2012-06-01 Thread Jani Tiainen

1.6.2012 10:43, rahajiyev kirjoitti:

Hello. The user connecting to Oracle is an ordinary user and needs to
prefix all tables with the schema name.
I've tried crafting Meta.db_table like so:
http://cd-docdb.fnal.gov/cgi-bin/RetrieveFile?docid=3156=1=DjangoOracle.html

But I get error

DatabaseError at /

schema "foo" does not exist
LINE 1: ...ty", "foo"."table_name"."address_country" FROM "foo"."...


I also tried wrapping request in a TransactionMiddleware and execute
this SQL before the fetching (modifying Meta accordingly):
MyModel.objects.raw('ALTER SESSION SET CURRENT_SCHEMA=foo')

Neither way helped. The user has the needed permissions.



Since Oracle doesn't make a difference between user and schema (they're 
equivalents)


Simplest thing is to create (private/public) synonyms for tables for 
user in question. Otherwise you need to prefix with schema name.


See also ticket https://code.djangoproject.com/ticket/6148

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: App inside another app or nesting in django apps

2012-06-01 Thread Jani Tiainen

1.6.2012 9:16, Derek kirjoitti:

And the Zen of Python?

"Flat is better than nested"


But don't forget, again Zen of Python:

"Namespaces are one honking great idea -- let's do more of those!"




On Jun 1, 8:10 am, Jani Tiainen<rede...@gmail.com>  wrote:

31.5.2012 19:22, Kurtis Mullins kirjoitti:


Sure. They're just Python modules. All you need to do is:



1. Include the files: __init__.py and models.py
2. Add the application to your settings.py, for example:  myproject.myapp.subapp



It *should* work, although I haven't personally tested it yet.



On Thu, May 31, 2012 at 7:46 AM, vijay shanker<vshanker...@gmail.com>wrote:

can we write one app inside some another django-app .
please suggest any reference or articles


It works perfectly. We've been using it in our environment for a good while.

There lies only one caveat - all appnames still must be unique and as
known app name is last part of module hierarchy.

So you can't have two conflicting apps:

myapp.subapp<-- appname is subapp
myotherapp.subapp<-- appname is subapp

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...





--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: App inside another app or nesting in django apps

2012-06-01 Thread Jani Tiainen

31.5.2012 19:22, Kurtis Mullins kirjoitti:

Sure. They're just Python modules. All you need to do is:

1. Include the files: __init__.py and models.py
2. Add the application to your settings.py, for example:  myproject.myapp.subapp

It *should* work, although I haven't personally tested it yet.

On Thu, May 31, 2012 at 7:46 AM, vijay shanker<vshanker...@gmail.com>  wrote:

can we write one app inside some another django-app .
please suggest any reference or articles


It works perfectly. We've been using it in our environment for a good while.

There lies only one caveat - all appnames still must be unique and as 
known app name is last part of module hierarchy.


So you can't have two conflicting apps:

myapp.subapp  <-- appname is subapp
myotherapp.subapp <-- appname is subapp

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: How to generate secure passwords

2012-05-30 Thread Jani Tiainen

30.5.2012 9:03, Emily Namugaanyi kirjoitti:

Hi Django users,

I am working on a project that as to generate secure passwords
(passwords that cannot be hacked) every time a user register and the
password lasts for a period of time. S,here I am wondering whether
django has a provision for this or I need to find another way...
Thank you for your time

Emily.



Sounds like your problem is not about generatic "secure passwords". But 
instead you need to build secure authorization behind that.


So you have to build a system that checks is given username + password 
to protected content combination already expired. If that's the case, no 
access is granted to protected content.


Then password wouldn't contain any information about it's validity. Only 
validity checks happens on your side of system - in your code, on your 
server.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Use Django to implement my GUI!

2012-05-19 Thread Jani Tiainen
's better between running a unicorn server
>> >>> or apache with mod_wsgi
>> >>>
>> >>> I don't know if i'm clear, but i hope. In
>> >>> brief I'd like to use the
>> >>> django framework features to design my Gui
>> >>> like i want, customize
>> >>> interactions between the gui and the backend,
>> >>> and choose a good web
>> >>> server for the production.
>> >>>
>> >>> Thank you for advance
>> >>>
>> >>> --
>> >>> 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/-/uZMPKqBO1JcJ.
>> >>> 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.
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> ngont...@epitech.net
>> >>> sympav...@gmail.com
>> >>> 
>> >>> Aux hommes il faut un chef, et au chef il faut des hommes!
>> >>>
>> >>>
>> >>>
>> >>>
>> >> --
>> >> Armaturen und Fittings Stüss e.K.
>> >> Frank Stüss + Inhaber
>> >> Tel. +49+6187-5019 + FAX. +49+6187-91725
>> >> Kilianstädter Straße 25 + D-61137 Schöneck
>> >> email frank.stu...@stuess.de <http://www.stuess.de>
>> >> Sitz Schöneck, HRA5340, Amtsgericht Hanau
>> >> USt.-ID: DE252310440
>> >>
>> >> 
>> >> Fördermitglied der Wirtschaftsjunioren
>> >> Hanau-Gelnhausen-Schlüchtern
>> >> Umfassende Infos: http://www.wj-hanau.de
>> >> Senator #68128
>> >>
>> >>
>> >> --
>> >> 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.
>>
>>
>
>
> --
> ngont...@epitech.net
> sympav...@gmail.com
> 
> *Aux hommes il faut un chef, et au** chef il faut des hommes!*
>
>  --
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Use Django to implement my GUI!

2012-05-16 Thread Jani Tiainen

Hi,

Like I said, it all depends what you have and what is the goal.

You keep constantly talking about magical "server" that talks with the 
database. Is this server already existing piece of infrastructure that 
some programs already use and you like to hook up with that?


Or is this server something that you just invented in lack of better 
knowledge?


You talk about state changes (in example you give a task). Must those 
changes be reflected in "real time" between arbitrary clients? Or is it 
sufficient that client sees changes at some later point?




16.5.2012 3:30, Eugène Ngontang kirjoitti:

Hi Jani!

Now you can understand what i meant, but I'm not just try to mec things
complicated.

I'm not talking here about my technical implementation, but i'm
describing the needs/contraints, and my app architecture to you.

-  The remote clients are at the heart of the software system, since
data stored in the database are destined to them (the server push each
information to the corresponding host)
- When a client starts, it trys to establish a connection with the
server, and if succeed, it retrieves its informations from the server.
The server then send back informations conerning the host executing the
client (the way server retrieves informations from the data base manager
doesn't matter here, it's a technical purpose)
- When a task state changes, it has to notify the server by sending a
packet through the network. The GUI (web browser) has then to display
the new state.
- When a user of the software wants to create a new task on a host, it
uses the GUI for the purpose, and the information has to be sent to the
remote corresponding client/host for processing.

Tell in my place, what logic would you adopt. I would like idea from you
guys in this case, before go on a first definitive choice.

I can see web sockets solves so much problems for developpers, and i'm
still looking if it could help achieve correctly what I want to. The
problem of IE < 10 for the instance is not so important.

Now also, can you try to advise me the best way for serving file using
python-Django (apache, unicorn, ..)?

Thanks again.

2012/5/15 Jani Tiainen <rede...@gmail.com <mailto:rede...@gmail.com>>

Hi,

Now it starts to make "sense".

I just wonder why are you trying to build something so extremely
complicated?

What is the rationale behind to have additional middleware layer
between web ui and the server backend?

Wouldn't it be sufficient to have architecture like:

Browser <-> django middleware <-> remote backend

Communication between django middle ware and remote backend should
be built on top of some messaging system, like celery + rabbitmq
which gives you quite standard asyncronous communication between
django middleware and remote backend. Of course you might need to
write some adapters on remote side but that's part of the job.

Only real problem is that if you need to push changes to browser
side. There doesn't exists any really good ways to do that. HTML5
was supposed to bring websockets to overcome the problem. One big
problem is that only from IE series only IE 10 supports it. All
others, FF, Chrome, Safari has had it for a good while.

There exists also alternative workarounds like Comet, BOSH, push and
few others.

So let
15.5.2012 2:18, Eugčne Ngontang kirjoitti:

Hi Jani!

I haven't seen the last statements of your post, whre you say
I'm not
really clear and that i'm building a non-http GUI using Django.


OK let's stay on the rendering issue only, and specify things
simply.
This is a simple description of the architecture I want to set up :

- A Client (not a user interface). Client here means a module
which is
installed in a remote computer and communicate with the server
via socket.

- A server listening from several remote client (Here i'm not
talking
yet about http request), and receive informatons from them. In fact
client must be doing actions and send informations about their
actions
to the server. In the oder hand data to be processed by each
client is
pushed/dispatched by the server.

- And admin (not Django Admin, but admin in the sens of my app),
destined to be the module allowing use of the application. Then the
Admin module is part of the server and will proviede a GUI for
manipulating data in the data base. It's in this GUI that users
of the
application will enter their request, by filling a form or
clicking a
link for exemple. And data from the GUI could be stored in the data
base, while being send to the remote clients (not to be
displayed by the
client, but to be processed). In the same way, informations

Re: Use Django to implement my GUI!

2012-05-15 Thread Jani Tiainen

Hi,

Now it starts to make "sense".

I just wonder why are you trying to build something so extremely 
complicated?


What is the rationale behind to have additional middleware layer between 
web ui and the server backend?


Wouldn't it be sufficient to have architecture like:

Browser <-> django middleware <-> remote backend

Communication between django middle ware and remote backend should be 
built on top of some messaging system, like celery + rabbitmq which 
gives you quite standard asyncronous communication between django 
middleware and remote backend. Of course you might need to write some 
adapters on remote side but that's part of the job.


Only real problem is that if you need to push changes to browser side. 
There doesn't exists any really good ways to do that. HTML5 was supposed 
to bring websockets to overcome the problem. One big problem is that 
only from IE series only IE 10 supports it. All others, FF, Chrome, 
Safari has had it for a good while.


There exists also alternative workarounds like Comet, BOSH, push and few 
others.


So let
15.5.2012 2:18, Eugčne Ngontang kirjoitti:

Hi Jani!

I haven't seen the last statements of your post, whre you say I'm not
really clear and that i'm building a non-http GUI using Django.


OK let's stay on the rendering issue only, and specify things simply.
This is a simple description of the architecture I want to set up :

- A Client (not a user interface). Client here means a module which is
installed in a remote computer and communicate with the server via socket.

- A server listening from several remote client (Here i'm not talking
yet about http request), and receive informatons from them. In fact
client must be doing actions and send informations about their actions
to the server. In the oder hand data to be processed by each client is
pushed/dispatched by the server.

- And admin (not Django Admin, but admin in the sens of my app),
destined to be the module allowing use of the application. Then the
Admin module is part of the server and will proviede a GUI for
manipulating data in the data base. It's in this GUI that users of the
application will enter their request, by filling a form or clicking a
link for exemple. And data from the GUI could be stored in the data
base, while being send to the remote clients (not to be displayed by the
client, but to be processed). In the same way, informations comming from
those clients to the server have to be diplayed in the GUI.

With a graphical GUI, The server could have a reference to an object
representing my GUI, and it will be done.
But I choose a web GUI for view and administration. It's where Django comes.

And my problem is to make my server being running a network thread,
receiving data from the GUI(web browser) and sending informations update
to the GUI (for web page content).

This is really my issue. If all the actions of my server depended on my
GUI request (http request), I could do what I like behind when handling
a http request, but while managing http:8080 connexions, the application
is running another process/thread on another TCP/UDP port.

And yes I want a web GUI.

Is why I'm looking the best way to achieve that. We can exclude Django
web server, as it will not be used in production for the application
deployment.

Hope now it's clear for you, and more for the other users.

Thanks!

2012/5/13 Jani Tiainen <rede...@gmail.com <mailto:rede...@gmail.com>>

Hi,

There is several ways to achieve what you maybe want to do. One of
the simplest way is separate frontend (your userinterface) and
server backend. You can build your Django application as a service
(xml-rpc, json-rpc, restful). That would give you advantage to
choose whatever frontend you like. Of course it would add some overhead.

On Sun, May 13, 2012 at 1:14 PM, Eugene NGONTANG
<sympav...@gmail.com <mailto:sympav...@gmail.com>> wrote:

Hi!

I'm a python developper, but new in django.

I'm devolopping a multi clients-server application.

The server and the clients are communicating via sockets, The server
receive somme states from clients, and display them in the User
interface.
In the other hand, the server has to send a message(packet) to the
client when an event  occurs in the GUI, and data are stored in a
database.


Note that Django is mainly built for web (HTTP protocol based)
applications. In such an environment you run two different things:
your GUI (usually browser) that is totally ignorant of server side
(Django). Then you send request to some URL, Django routes it to
some view and view produces again next output to be displayed in GUI
(browser again). One of the common functions in the view is database
manipulation.

Then I choose to make a web interface where data could be viewed and
manipulated. And I discovered Dj

Re: Deferred fields problem.

2012-05-14 Thread Jani Tiainen
I'm still on 1.3.1 but planning to upgrade to 1.4 quite soon.

On Mon, May 14, 2012 at 3:50 PM, akaariai <akaar...@gmail.com> wrote:

> On May 14, 3:29 pm, Jani Tiainen <rede...@gmail.com> wrote:
> > 14.5.2012 14:50, akaariai kirjoitti:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > On May 14, 2:37 pm, Jani Tiainen<rede...@gmail.com>  wrote:
> > >> Hi,
> >
> > >> I have in my database quite a bunch of a models where I do have quite
> > >> large fields and I'm using .only('pk', 'identifier') to fetch only
> those
> > >> two fields - mainly to make serverside natural sort for a data.
> Database
> > >> is legacy one and it's being used with other external programs as well
> > >> so changing it is not possible.
> >
> > >> After sorting I just need to get slice of data and fetch rest of
> fields
> > >> in one query. I haven't found simple way to fetch rest of the fields
> in
> > >> one request.
> >
> > >> So what I would like to do:
> >
> > >> qs = MyModel.objects.all().only('pk', 'identifier')
> >
> > >> list_of_models = sort_naturally(qs, 'identifier')
> >
> > >> sublist_of_models = list_of_models[10:20]
> >
> > >> for model in sublist_of_models:
> > >>   model.fetch_all_deferred_fields()
> > > While not totally same, how about:
> > > for model in MyModel.objects.all(pk__in=[obj.pk for obj in
> > > sublist_of_models]):
> > > or maybe this will work, too:
> > > for model in MyModel.objects.all(pk__in=sublist_of_models):
> >
> > > You will lose the sorting, so you will need to resort the models
> > > again. If your model instances are changed, you will lose those
> > > changes.
> >
> > > If the above isn't enough the best you can do currently is to create a
> > > helper method which will do the merge manually.
> >
> > That would probably do, and now you mentioned it I already have merge
> > function that can merge arbitrary dicts to models... ;)
> >
> > "Dare to be stupid" like Weird Al Yankovic sings...
> >
> > Of course my DB backend Oracle has limit of (I think it was 1000)
> > elements in parameter list so it would require additional work if
> > someone wants to work with more than 1k elements in a sublist.
>
> I don't know the version of Django you are using, but at least 1.4
> should automatically know how to split the list into multiple parts to
> work around the 1000 parameters limit in Oracle. See:
>
> https://github.com/django/django/blob/stable/1.4.x/django/db/models/sql/where.py#L181
>
>  - Anssi
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Deferred fields problem.

2012-05-14 Thread Jani Tiainen

14.5.2012 14:50, akaariai kirjoitti:



On May 14, 2:37 pm, Jani Tiainen<rede...@gmail.com>  wrote:

Hi,

I have in my database quite a bunch of a models where I do have quite
large fields and I'm using .only('pk', 'identifier') to fetch only those
two fields - mainly to make serverside natural sort for a data. Database
is legacy one and it's being used with other external programs as well
so changing it is not possible.

After sorting I just need to get slice of data and fetch rest of fields
in one query. I haven't found simple way to fetch rest of the fields in
one request.

So what I would like to do:

qs = MyModel.objects.all().only('pk', 'identifier')

list_of_models = sort_naturally(qs, 'identifier')

sublist_of_models = list_of_models[10:20]

for model in sublist_of_models:
  model.fetch_all_deferred_fields()

While not totally same, how about:
for model in MyModel.objects.all(pk__in=[obj.pk for obj in
sublist_of_models]):
or maybe this will work, too:
for model in MyModel.objects.all(pk__in=sublist_of_models):

You will lose the sorting, so you will need to resort the models
again. If your model instances are changed, you will lose those
changes.

If the above isn't enough the best you can do currently is to create a
helper method which will do the merge manually.


That would probably do, and now you mentioned it I already have merge 
function that can merge arbitrary dicts to models... ;)


"Dare to be stupid" like Weird Al Yankovic sings...

Of course my DB backend Oracle has limit of (I think it was 1000) 
elements in parameter list so it would require additional work if 
someone wants to work with more than 1k elements in a sublist.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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



Deferred fields problem.

2012-05-14 Thread Jani Tiainen

Hi,

I have in my database quite a bunch of a models where I do have quite 
large fields and I'm using .only('pk', 'identifier') to fetch only those 
two fields - mainly to make serverside natural sort for a data. Database 
is legacy one and it's being used with other external programs as well 
so changing it is not possible.


After sorting I just need to get slice of data and fetch rest of fields 
in one query. I haven't found simple way to fetch rest of the fields in 
one request.


So what I would like to do:

qs = MyModel.objects.all().only('pk', 'identifier')

list_of_models = sort_naturally(qs, 'identifier')

sublist_of_models = list_of_models[10:20]

for model in sublist_of_models:
model.fetch_all_deferred_fields()



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: files are downloadable in browser because of apache conf file! help!!!

2012-05-13 Thread Jani Tiainen
You should deploy django files outside www directories. That way even
incorrect config shouldn't reveal any actual files.

On Sat, May 12, 2012 at 8:20 AM, doniyor <doniyor@googlemail.com> wrote:

> hey guys, i was configuring my django project on server, in httpd.conf
> file. suddenly i have 500 Internal Server Error. before that i had the page
> where files can be just downloaded. how can i fix this? apache2.2 is
> running and mod_wsgi is installed. i think, i dont know how to tell apache
> about my mod_wsgi and djangoproject. What i now have is:
>
> a folder 'apache' next to my django project folder. Apache folder has:
> apache_django_wsgi.conf, myproject.wsgi, __init__.py, urls_production.py,
> settings_production.py
>
> and in httpd.conf i have this (stahlhandel is my djangoproject):
>
> http://85.114.145.142/>>
> RewriteEngine On
> RewriteLog  /usr/local/httpd/logs/**rewrite.log
> RewriteLogLevel 2
> RewriteMap  low int:tolower
> RewriteMap  subdom  txt:/usr/local/httpd/conf/**subdomains.lst
> RewriteCond ${subdom:%{HTTP_HOST}}  ^(/.*)$
> RewriteRule ^/(.*)$   %1/$1 [E=SUBDOM:${low:%{HTTP_HOST}}]
> DocumentRoot /usr/local/httpd/htdocs/admin
> Servername admin.afect.stahlbaron.de
> 
>
> http://85.114.145.142/>>
> ServerAdmin webmaster
> Servername afect.stahlbaron.de
> Serveralias www.afect.stahlbaron.de
> DocumentRoot /usr/local/httpd/vhtdocs/**stahlbaron/stahlhandel
> SuexecUserGroup stahlbaron stahlbaron
> ScriptAlias /cgi-bin/ /usr/local/httpd/vhtdocs/**stahlbaron/cgi-bin/
> WSGIScriptAlias / /www/vhtdocs/stahlbaron/**
> stahlhandel/apache/lastsite.**wsgi
> 
> Options SymLinksIfOwnerMatch Indexes
> AllowOverride AuthConfig
> Allow from all
> 
>
> 
> Order deny,allow
> Allow from all
> 
>
>   ScriptAlias /php/ 
> /usr/local/httpd/conf/php/stah**lbaron.de/<http://stahlbaron.de/>
>   AddHandler php-cgi .php
>   Action php-cgi /php/php.cgi
> # DocumentRoot /usr/local/httpd/htdocs/
># Servername afect.stahlbaron.de
> 
>
> can it be that i am missing  tag or is it here not relevant?
>
> 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/-/xXizu5s--zcJ.
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Use Django to implement my GUI!

2012-05-13 Thread Jani Tiainen
Hi,

There is several ways to achieve what you maybe want to do. One of the
simplest way is separate frontend (your userinterface) and server backend.
You can build your Django application as a service (xml-rpc, json-rpc,
restful). That would give you advantage to choose whatever frontend you
like. Of course it would add some overhead.

On Sun, May 13, 2012 at 1:14 PM, Eugene NGONTANG <sympav...@gmail.com>wrote:

> Hi!
>
> I'm a python developper, but new in django.
>
> I'm devolopping a multi clients-server application.
>
> The server and the clients are communicating via sockets, The server
> receive somme states from clients, and display them in the User
> interface.
> In the other hand, the server has to send a message(packet) to the
> client when an event  occurs in the GUI, and data are stored in a
> database.
>
>
Note that Django is mainly built for web (HTTP protocol based)
applications. In such an environment you run two different things: your GUI
(usually browser) that is totally ignorant of server side (Django). Then
you send request to some URL, Django routes it to some view and view
produces again next output to be displayed in GUI (browser again). One of
the common functions in the view is database manipulation.


> Then I choose to make a web interface where data could be viewed and
> manipulated. And I discovered Django, which fit all my needs. I tested
> and liked the framework.
>
> My questions are:
> - Can I override the djando admin methods so that i can not only
> customized my views and html page, but also manipulate objects in
> database, so that i can do another action when catching an  event in
> the GUi.
> For example, taking the django admin tutorial, I would like to do and
> action like sending a message the user choose "add a poll". How can I
> do those things? Cause I noticed that method that alter data in data
> base are part of django admin module and cannot be overriden
>
>
You shouldn't "fight against admin". If something cannot be done in the
admin you usually get a way with writing your own stuff.


> - To achieve what I want, i would like to run my server engine and my
> django admin in two separated threads. How do i run my admin module in
> a thread? Cause till now i'm using the command line "python manage.py
> runserver
>

Again your GUI would run "somewhere" (it's not relevant) and it's not
concern of Django. It's architecture is designed to be share nothing -
which means that you can run several threads/processes of your applications
- And those threads/processes are not aware of other existence. And it
doesn't matter.


> - I also tried to overide tables name, and foreign keys names. Could
> you guys provide me a true life example?
>
>
Err.. Override what and where? And how you tried to do that?


> - And now in the production step, I would like you guys to tell me
> what to choose for serving files. I would like to with your experience
> what's better between running a unicorn server or apache with mod_wsgi
>
> I don't know if i'm clear, but i hope. In brief I'd like to use the
> django framework features to design my Gui like i want, customize
> interactions between the gui and the backend, and choose a good web
> server for the production.
>
>
No you're definitely not clear. My interpretation is that you want to build
(non-http based) GUI using Django as backend server. Even Django isn't
exactly designed for such a work it still can do it.

If it was something else try to split your questions in smaller fragments,
perferably with more clearly specified use cases, workflows and samples of
the code.


> Thank you for 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@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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: examples of integrating Sencha 2.0 Javascript front end.

2012-05-13 Thread Jani Tiainen
Hi,

We're using ExtJS 4.1 (not Sencha Touch 2.0) but we decided not to
"integrate"  ExtJS anyway in the Django itself. We have built some helpers
to produce output responses ExtJS expects but nothing major. Front end is
usually designed with Sencha Architect 2 so it's plain JS.

Also in newer codes we have experimented with django-rest-framework to make
serverside work more like an API for different frontends.

On Sat, May 12, 2012 at 6:14 PM, django-user59 <venkat.ran...@gmail.com>wrote:

> Hi,
>
> I'm looking to integrate a JavaScript framework like Sencha 2.0 into
> django backend. How do I do this? Are there examples of this that anyone
> can point to? There will be quite a bit of interactive AJAX 2.0 calls from
> the Javascripts.
>
> 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/-/3Tf8V5ErEG4J.
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: New Install - django-admin.py ... just gives contest/options but doesn't run?

2012-05-10 Thread Jani Tiainen

10.5.2012 0:46, Robert G kirjoitti:

Awesome, thought I tried this but apparently not.

I had to use d:\myproj>python d:/Python27/Scripts/django-admin.py
startproject mysite to make it work, but it worked so yay!

On with the tutoral I go!

On May 9, 3:59 pm, Daniel Roseman<dan...@roseman.org.uk>  wrote:

On Wednesday, 9 May 2012 18:34:41 UTC+1, Robert G wrote:


I can't seem to find much about this error online - any suggestions?


On the contrary, this is very much a FAQ. Your Windows installation is set
to run scripts against Python, but without passing any arguments.

Easiest way to fix it is to explicitly use `python django-admin.py
startproject mysite` instead.
--
DR.




I also could recommend really to use virtualenv - saves nerves and time. 
I wrote short blog entry a while ago about setting "sane" python/django 
environment specially in win7: 
http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: __contains, ok but contains how many ;-) ?

2012-05-09 Thread Jani Tiainen
Hi,

There is no way to do that in a pure Django ORM, so only option is to fall
back to raw SQL. The exact SQL syntax is dependent on your database backend
but Django can still get you real model instances. See more about raw SQL
at https://docs.djangoproject.com/en/dev/topics/db/sql/

Though if you're pulling all results in your code you can easily add pure
Python property/method to your model to get count of the keyword and then
it would be database agnostic.

On Wed, May 9, 2012 at 6:30 PM, Guillaume Florent
<florentsail...@gmail.com>wrote:

> Hi everybody,
> I would like to know if there if a simple way to know how many times a
> given field contains a string.
> e.g. Note.objects.filter(notedescription__contains='keyword')
> What would be the recommended way to know how many times 'keyword' is
> hit in the 'notedescriptiont' field? Do I have have to iterate over
> the resulting queryset or can someone think of a more elegant way?
> (i.e. is adding on the fly a 'count' field to each object in the
> queryset feasible?)
> Best regards,
> G Florent
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: inspectdb+oracle

2012-05-08 Thread Jani Tiainen
You're using old CX_Oracle (5.0.4) which is known to have issues with 
unicode. Try updating to 5.1.1 and see if problem persists.


8.5.2012 10:50, mapapage kirjoitti:

I'm working on a django project on Ubuntu 10.04 with Oracle Database
Server
I use Oracle Database 10g xe universal Rel.10.2.0.1.0 against
cx_Oracle-5.0.4-10g-unicode-py26-1.x86_64

My db is generated by oracle 10gr2 enterprise edition (on Windows XP,
import done in US7ASCII character set and AL16UTF16 NCHAR character
set, import server uses AL32UTF8 character set, export client uses
EL8MSWIN1253 character set and AL16UTF16 NCHAR )

When I try django-admin.py inspectdb I get the following error:
  ..."indexes = connection.introspection.get_indexes(cursor,
table_name)
   File "/usr/lib/pymodules/python2.6/django/db/backends/oracle/
introspection.py", line 116, in get_indexes
 for row in cursor.fetchall():
   File "/usr/lib/pymodules/python2.6/django/db/backends/oracle/
base.py", line 483, in fetchall
 for r in self.cursor.fetchall()])
cx_Oracle.DatabaseError: OCI-22061: invalid format text [T".

I am aware of "inspectdb works with PostgreSQL, MySQL and SQLite." but
from posts I saw that it also works with oracle somehow. Does anyone
know how I could fix this prob?

Thx




--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Presentation Viewer on django

2012-05-08 Thread Jani Tiainen
To be able to do that you have to convert your presentation to something
more generic that can be shown. Plain HTML
and Flash are two popular formats to do that. For a free solution you can
use (headless) openoffice/liberoffice to automatically convert your ppt to
html/flash and then
show it on your page (inside frame).

Another option is to make sure that you return correct mime-types for a
(i)frame and then your users are required to have powerpoint installed on
their machines to be able to show it in browser. And I think it only works
for IE, not  for FF/Chrome/Safari...

On Tue, May 8, 2012 at 1:34 AM, Amr Abdel-wahab <
amr.mohamed.abdelwa...@gmail.com> wrote:

> I don't want to generate a pdf/ppt or edit it I just need to upload it
> in one page and show it in a frame in another page in the browser
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Presentation Viewer on django

2012-05-07 Thread Jani Tiainen
There exists few tools that uses openoffice/libreoffice to convert those
proprietary formats (doc, ppt, xls) so that you can show them on a web.

See:  http://www.boutell.com/newfaq/creating/powerpointtoweb.htmlfor
starting point.



On Mon, May 7, 2012 at 7:34 PM, Sandro Dutra <hexo...@gmail.com> wrote:

> About PDF's you can use any PDF API for Python like reportlab and see
> examples like this:
> https://docs.djangoproject.com/en/dev/howto/outputting-pdf/?from=olddocs
>
> PPT is a proprietary and closed spec format from MS Powerpoint, probably
> you've to reverse engineering (or search for format spec) to write a view
> that can handle the information you want to extract.
>
>
> 2012/5/7 Amr Abdel-wahab <amr.mohamed.abdelwa...@gmail.com>
>
>> Hi All,
>> I am new to Django I need a complete way where I can allow the user to
>> upload a ppt or pdf file and then in the template I show this file
>> embedded
>>
>> Many Thanks,
>> Amr
>>
>> --
>> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: help with "Key 'timeout' not found in "

2012-05-04 Thread Jani Tiainen


4.5.2012 1:22, psychok7 kirjoitti:

hi i have done a succefull query and i converted the results into links
so i can make a post by clicking on the links to make a reservation.


No, you haven't. When you click you'll still send very much standard GET 
request to server. You can and should verify that by using some 
debugging console.



my problem is, theres a variable timeout that i want to specify
manually, but i get a "Key 'timeout' not found in "

i know i am supposed to pass that variable but i just dont know how.



my code is :

def reserve (request,user_id,park_id):
#only works if the user exists in database
u = get_object_or_404(User, pk=user_id)
n = get_object_or_404(Notification, pk=park_id)
p = get_object_or_404(Park, pk=1)
r = Reservation(user=u ,notification=n, park=p,
timeout=int(request.POST['timeout']),active=True,parked=False,reservation_date=datetime.now())
r.save()
return HttpResponse('Spot reserved')

html:

{% if parks %} You searched for: {{ query }}
Found {{ parks|length }} park{{ parks|pluralize }}.  {% for
park in parks %}  {{ park.park_address }} {% endfor %}  {% endif %}

can someone help me?


If above is your true HTML and nothing removed you're just creating list 
of standard links.


If you want to pass additional parameters there is few ways to achieve it:

a) You can modify your sent url by javascript and add timeout manually 
to get query parameters.


b) You transform your links to selectable list/dropdown and create real 
HTML form to send post with real submit button.


c) Hybrid of a and b. I won't go into details since it would be just a mess.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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 Jani Tiainen

25.4.2012 19:17, vishy kirjoitti:

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?



It depends on your environment but basic workflow is same is in *nix 
instructions. And it's not even hard. :


createdb yourdatabase
createlang plpgsql yourdatabase
psql -d yourdatabase -f postgis.sql
psql -d yourdatabase -f postgis_comments.sql
psql -d yourdatabase -f spatial_ref_sys.sql


Of course in your case you can skip creation of database. Just create 
language and install postgis stuff.


After that you need to make sure that your database user has access to
geometry_columns and spatial_ref_sys tables.

Add new column (For PostGIS 1.5.x, newer postgis has simpler alternative 
syntax):


SELECT AddGeometryColumn('my_table', 'my_geom', 4326, 'POINT', 2)

And after that just update new geometry column:
update my_table set my_geom = GeomFromText('POINT(' + x + ' ' + y +')', 
4326)


And don't forget to commit. If you have lot's of geometries (1M+) you 
probably want to drop out spatial index and recreate it afterwards. 
Otherwise building index takes just long time.



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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 with syncdb in geodjango tutorial

2012-04-24 Thread Jani Tiainen

25.4.2012 7:59, kenneth gonsalves kirjoitti:

hi,

I am following the geodjango tutorial, and when doing syncdb, I get the
following error:

[lawgon@xlquest geodjango]$ python manage.py syncdb
Creating tables ...
Creating table world_worldborder
Installing custom SQL ...
Installing indexes ...
Failed to install index for world.WorldBorder model:
AddGeometryColumns() - invalid SRID
CONTEXT:  SQL statement "SELECT AddGeometryColumn('','',$1,$2,$3,$4,$5)"
PL/pgSQL function "addgeometrycolumn" line 5 at SQL statement

am using postgis on Fedora 16 and django trunk



I've seen that error when you try to create new column in postgis 
database with SRID that doesn't exists in postgis srid definitions.


You can check does SRID exist in database:

select * from spatial_ref_sys where srid=;

I suppose you did provided some SRID when defining column in model...

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Can't start new project

2012-04-15 Thread Jani Tiainen

One more advice so you don't get caught with the problems:

(Well I suggest that you start using virtualenvs as well, they really rock)

After installing TCC/LE create one batch file (I use tcstart.btm) with 
the following contents:


@echo off
rem Set python binding to handle virtualenvironments
set .py;.pyc=python.exe


Note, if you're not using virtual environments or not have your python 
in the path use full absolute path instead of just "python.exe".


Create a shortcut on your desktop (or anywhere you like).

Open properties of the shortcut and set "target" to something like
"C:\Program Files (x86)\JPSoft\TCCLE12\tcc.exe" "c:\mysettings\tcstart.btm"

And of course, "start in" is good to place where ever you have your 
projects, removes need for extra cd.


This should get you up and running smoothly and should get around the 
problem of windows peculiarities in python invocation.


16.4.2012 1:23, Brandy kirjoitti:

I certainly will. Thanks for the advice:)

On Sunday, April 15, 2012 2:42:00 PM UTC-5, Jani Tiainen wrote:

It's apparently TCC/LE which saves me about all that command
execution and arg passing hazzle.. :)

Never used plain command prompt so I've been immune to peculiarities
of Windows command line utilities.

I suggest you give it a try - it's really nice.

On Sun, Apr 15, 2012 at 10:04 PM, Brandy <brandy.norri...@yahoo.com
<mailto:brandy.norri...@yahoo.com>> wrote:

If you would like to read more about the issue, I found the
error already reported on the Python website:
http://bugs.python.org/issue7936 <http://bugs.python.org/issue7936>

On Saturday, April 14, 2012 1:52:00 PM UTC-5, Jani Tiainen wrote:

Sounds very goofy. django-admin.py just creates files,
doesn't open any editors so there is somthing really fishy
going on in your machine...

On Sat, Apr 14, 2012 at 8:27 PM, Brandy
<brandy.norri...@yahoo.com
<mailto:brandy.norri...@yahoo.com>> wrote:

What I mean is, I can create 2 or 3 new projects without
problems. I play with them and create files, etc. Then,
for whatever reason, when I run django-admin.py
startproject  again, an editor widow opens
(emacs in my case, since that is what I was using), and
django doesn't create any files. All I can do is edit
the projects I already have created.

    On Saturday, April 14, 2012 12:45:32 AM UTC-5, Jani
Tiainen wrote:

I really suggest you to use virtualenv, it makes
your life easier in the long run. Also I use a
TCC/LE instead of powershell / cmd prompt to mimic
more unix like environment.

Though you mentioned " After a while, if I try to
start a new project, my editor opens and no files or
directories are created. " what you exactly mean by
that?

I feel that I should write short article how to make
development in win7 slightly less painful...

On Sat, Apr 14, 2012 at 8:19 AM, Brandy
<brandy.norri...@yahoo.com
<mailto:brandy.norri...@yahoo.com>> wrote:

No, I'm not using virtual environments.

    On Friday, April 13, 2012 11:51:33 PM UTC-5,
Jani Tiainen wrote:

Are you using virtual environments?

Since I've been doing all my django
development on windows last 3 years without
any major problems...

On Sat, Apr 14, 2012 at 6:04 AM, Brandy
<brandy.norri...@yahoo.com
<mailto:brandy.norri...@yahoo.com>> wrote:

After first installing Django, I am able
to use "django-admin.py startproject
" with no problem. After a
while, if I try to start a new project,
my editor opens and no files or
directories are created. After doing
LOTS of research, it turns out this is a
rather common problem/bug. I have tried
what feels like everything. I have
edited the PATH, checked that all
appropriate registry entries are
"python.exe" "%1" %* (I even tr

Re: Can't start new project

2012-04-15 Thread Jani Tiainen
It's apparently TCC/LE which saves me about all that command execution and
arg passing hazzle.. :)

Never used plain command prompt so I've been immune to peculiarities of
Windows command line utilities.

I suggest you give it a try - it's really nice.

On Sun, Apr 15, 2012 at 10:04 PM, Brandy <brandy.norri...@yahoo.com> wrote:

> If you would like to read more about the issue, I found the error already
> reported on the Python website: http://bugs.python.org/issue7936
>
>
> On Saturday, April 14, 2012 1:52:00 PM UTC-5, Jani Tiainen wrote:
>
>> Sounds very goofy. django-admin.py just creates files, doesn't open any
>> editors so there is somthing really fishy going on in your machine...
>>
>> On Sat, Apr 14, 2012 at 8:27 PM, Brandy <brandy.norri...@yahoo.com>wrote:
>>
>>> What I mean is, I can create 2 or 3 new projects without problems. I
>>> play with them and create files, etc. Then, for whatever reason, when I run
>>> django-admin.py startproject  again, an editor widow opens
>>> (emacs in my case, since that is what I was using), and django doesn't
>>> create any files. All I can do is edit the projects I already have created.
>>>
>>>
>>> On Saturday, April 14, 2012 12:45:32 AM UTC-5, Jani Tiainen wrote:
>>>
>>>> I really suggest you to use virtualenv, it makes your life easier in
>>>> the long run. Also I use a TCC/LE instead of powershell / cmd prompt to
>>>> mimic more unix like environment.
>>>>
>>>> Though you mentioned " After a while, if I try to start a new project,
>>>> my editor opens and no files or directories are created. "  what you
>>>> exactly mean by that?
>>>>
>>>> I feel that I should write short article how to make development in
>>>> win7 slightly less painful...
>>>>
>>>> On Sat, Apr 14, 2012 at 8:19 AM, Brandy <brandy.norri...@yahoo.com>wrote:
>>>>
>>>>> No, I'm not using virtual environments.
>>>>>
>>>>>
>>>>> On Friday, April 13, 2012 11:51:33 PM UTC-5, Jani Tiainen wrote:
>>>>>
>>>>>> Are you using virtual environments?
>>>>>>
>>>>>> Since I've been doing all my django development on windows last 3
>>>>>> years without any major problems...
>>>>>>
>>>>>> On Sat, Apr 14, 2012 at 6:04 AM, Brandy <brandy.norri...@yahoo.com>wrote:
>>>>>>
>>>>>>> After first installing Django, I am able to use "django-admin.py
>>>>>>> startproject " with no problem. After a while, if I try to
>>>>>>> start a new project, my editor opens and no files or directories are
>>>>>>> created. After doing LOTS of research, it turns out this is a rather 
>>>>>>> common
>>>>>>> problem/bug. I have tried what feels like everything. I have edited the
>>>>>>> PATH, checked that all appropriate registry entries are "python.exe" 
>>>>>>> "%1"
>>>>>>> %* (I even tried %%), I've tried variations of "django-admin 
>>>>>>> startproject"
>>>>>>> and "python django-admin startproject". The only thing that has worked 
>>>>>>> so
>>>>>>> far is reinstalling Django. However, I wind up encountering the same
>>>>>>> problem eventually. Does anyone have a permanent fix not listed here? I 
>>>>>>> am
>>>>>>> running Python27, Django 1.4, and Windows 7. Thanks in advance.
>>>>>>>
>>>>>>> --
>>>>>>> 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/-/**G4kncIixzIAJ<https://groups.google.com/d/msg/django-users/-/G4kncIixzIAJ>
>>>>>>> .
>>>>>>> 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<django-users%2bunsubscr...@googlegroups.com>
>>>>>>> .
>>>>>>> For more options, visit this group at http://groups.google.com/**
>>>>>>> group/django-users?hl=en

Re: Can't start new project

2012-04-14 Thread Jani Tiainen
Sounds very goofy. django-admin.py just creates files, doesn't open any
editors so there is somthing really fishy going on in your machine...

On Sat, Apr 14, 2012 at 8:27 PM, Brandy <brandy.norri...@yahoo.com> wrote:

> What I mean is, I can create 2 or 3 new projects without problems. I play
> with them and create files, etc. Then, for whatever reason, when I run
> django-admin.py startproject  again, an editor widow opens
> (emacs in my case, since that is what I was using), and django doesn't
> create any files. All I can do is edit the projects I already have created.
>
>
> On Saturday, April 14, 2012 12:45:32 AM UTC-5, Jani Tiainen wrote:
>
>> I really suggest you to use virtualenv, it makes your life easier in the
>> long run. Also I use a TCC/LE instead of powershell / cmd prompt to mimic
>> more unix like environment.
>>
>> Though you mentioned " After a while, if I try to start a new project, my
>> editor opens and no files or directories are created. "  what you exactly
>> mean by that?
>>
>> I feel that I should write short article how to make development in win7
>> slightly less painful...
>>
>> On Sat, Apr 14, 2012 at 8:19 AM, Brandy <brandy.norri...@yahoo.com>wrote:
>>
>>> No, I'm not using virtual environments.
>>>
>>>
>>> On Friday, April 13, 2012 11:51:33 PM UTC-5, Jani Tiainen wrote:
>>>
>>>> Are you using virtual environments?
>>>>
>>>> Since I've been doing all my django development on windows last 3 years
>>>> without any major problems...
>>>>
>>>> On Sat, Apr 14, 2012 at 6:04 AM, Brandy <brandy.norri...@yahoo.com>wrote:
>>>>
>>>>> After first installing Django, I am able to use "django-admin.py
>>>>> startproject " with no problem. After a while, if I try to
>>>>> start a new project, my editor opens and no files or directories are
>>>>> created. After doing LOTS of research, it turns out this is a rather 
>>>>> common
>>>>> problem/bug. I have tried what feels like everything. I have edited the
>>>>> PATH, checked that all appropriate registry entries are "python.exe" "%1"
>>>>> %* (I even tried %%), I've tried variations of "django-admin startproject"
>>>>> and "python django-admin startproject". The only thing that has worked so
>>>>> far is reinstalling Django. However, I wind up encountering the same
>>>>> problem eventually. Does anyone have a permanent fix not listed here? I am
>>>>> running Python27, Django 1.4, and Windows 7. Thanks in advance.
>>>>>
>>>>> --
>>>>> 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/*
>>>>> *ms**g/django-users/-/**G4kncIixzIAJ<https://groups.google.com/d/msg/django-users/-/G4kncIixzIAJ>
>>>>> .
>>>>> To post to this group, send email to django-users@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> django-users+unsubscribe@**googl**egroups.com<django-users%2bunsubscr...@googlegroups.com>
>>>>> .
>>>>> For more options, visit this group at http://groups.google.com/**group
>>>>> **/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>>>> .
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Jani Tiainen
>>>>
>>>> - Well planned is half done, and a half done has been sufficient
>>>> before...
>>>>
>>>>   --
>>> 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/-/**MFfD9AEjNQUJ<https://groups.google.com/d/msg/django-users/-/MFfD9AEjNQUJ>
>>> .
>>>
>>> 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 <django-users%2bunsubscr...@googlegroups.com>.
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>>
>>
>>
>>
>> --
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
>>   --
> 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/-/wTBEfVJGr6AJ.
>
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Can't start new project

2012-04-13 Thread Jani Tiainen
I really suggest you to use virtualenv, it makes your life easier in the
long run. Also I use a TCC/LE instead of powershell / cmd prompt to mimic
more unix like environment.

Though you mentioned " After a while, if I try to start a new project, my
editor opens and no files or directories are created. "  what you exactly
mean by that?

I feel that I should write short article how to make development in win7
slightly less painful...

On Sat, Apr 14, 2012 at 8:19 AM, Brandy <brandy.norri...@yahoo.com> wrote:

> No, I'm not using virtual environments.
>
>
> On Friday, April 13, 2012 11:51:33 PM UTC-5, Jani Tiainen wrote:
>
>> Are you using virtual environments?
>>
>> Since I've been doing all my django development on windows last 3 years
>> without any major problems...
>>
>> On Sat, Apr 14, 2012 at 6:04 AM, Brandy <brandy.norri...@yahoo.com>wrote:
>>
>>> After first installing Django, I am able to use "django-admin.py
>>> startproject " with no problem. After a while, if I try to
>>> start a new project, my editor opens and no files or directories are
>>> created. After doing LOTS of research, it turns out this is a rather common
>>> problem/bug. I have tried what feels like everything. I have edited the
>>> PATH, checked that all appropriate registry entries are "python.exe" "%1"
>>> %* (I even tried %%), I've tried variations of "django-admin startproject"
>>> and "python django-admin startproject". The only thing that has worked so
>>> far is reinstalling Django. However, I wind up encountering the same
>>> problem eventually. Does anyone have a permanent fix not listed here? I am
>>> running Python27, Django 1.4, and Windows 7. Thanks in advance.
>>>
>>> --
>>> 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/-/**G4kncIixzIAJ<https://groups.google.com/d/msg/django-users/-/G4kncIixzIAJ>
>>> .
>>> 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 <django-users%2bunsubscr...@googlegroups.com>.
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>>
>>
>>
>>
>> --
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
>>   --
> 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/-/MFfD9AEjNQUJ.
>
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Can't start new project

2012-04-13 Thread Jani Tiainen
Are you using virtual environments?

Since I've been doing all my django development on windows last 3 years
without any major problems...

On Sat, Apr 14, 2012 at 6:04 AM, Brandy <brandy.norri...@yahoo.com> wrote:

> After first installing Django, I am able to use "django-admin.py
> startproject " with no problem. After a while, if I try to
> start a new project, my editor opens and no files or directories are
> created. After doing LOTS of research, it turns out this is a rather common
> problem/bug. I have tried what feels like everything. I have edited the
> PATH, checked that all appropriate registry entries are "python.exe" "%1"
> %* (I even tried %%), I've tried variations of "django-admin startproject"
> and "python django-admin startproject". The only thing that has worked so
> far is reinstalling Django. However, I wind up encountering the same
> problem eventually. Does anyone have a permanent fix not listed here? I am
> running Python27, Django 1.4, and Windows 7. Thanks in advance.
>
> --
> 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/-/G4kncIixzIAJ.
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: ORA-00918: column ambiguously defined.

2012-04-13 Thread Jani Tiainen
Hi,

Could you provide a bit more information since I tried to reproduce your
problem but I didn't manage to do it.

On Thu, Apr 12, 2012 at 7:48 PM, Rui Silva <ourc...@gmail.com> wrote:

> Hi,
>
> I was working with django 1.3.1 and oracle and i got this error:
> ORA-00918: column ambiguously defined.
> After some digging in django/db/models/sql/compiler.py i discovered
> the bug/error:
>
> My models had a definition according to django sujested naming:
>
> class SampleModel(models.Model):
>   my_custom_id = models.AutoField('ID', db_column='MY_CUSTOM_ID'
> primary_key=True)
>   field2 = models...
>
> class RelatedSampleModel(models.Model):
>   id = models.AutoField('ID', primary_key=True)
>   sample_model = models.ForeignKey(SampleModel)
>
> As it happens, when we make a query that involves select_related, the
> generated query WILL NOT create a column alias for the my_custom_id
> column and we will have something like:
>
> SELECT * FROM (
>   SELECT ROWNUM AS "_RN", "_SUB".* FROM (
>   SELECT
>   "SAMPLE_MODEL"."MY_CUSTOM_ID",
>   "SAMPLE_MODEL"."FIELD2...",
>   "RELATED_SAMPLE_MODEL"."ID",
>
> "RELATED_SAMPLE_MODEL"."MY_CUSTOM_ID"
>   FROM  "REL"
>   INNER JOIN ".)) "_SUB" WHERE ROWNUM <= 21) WHERE
> "_RN" > 0'
>
>
> The problem was the definition of the db_column in uppercase and the
> foreignkey as a regular model field, witch resulted in a lowercase
> column name in the sql generator.
> I solved this error by changing all the names to lowercase. After
> that, django correctly defined the column alias:
> "RELATED_SAMPLE_MODEL"."MY_CUSTOM_ID" as Col20
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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



<    1   2   3   4   5   6   7   8   >