Re: Errors Using Pip In Powershell to Download Django

2014-07-17 Thread Sam Lai
Can you provide some console output so we can see what commands you're
entering and what the actual output is?

On 17 July 2014 04:06, Malik Rumi  wrote:
> Yesterday I tried to get the 1.7rc1 and got the error 'file contains no
> section headers'. I assumed this was because it was a tarball, and after
> looking around gave up for the night.
> Tonight I decided to just get 1.6.5. But to my surprise, I got the same
> error. I have no control over putting section headers in these files. What
> do I do now? Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/357d221c-7ac0-40cf-854a-9890ecded8ab%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: Geodjango and Python 3.3

2014-03-27 Thread Sam Lai
Hmm, you might be right Alex. I set up the virtualenv with all that a
while ago and I've just been copying the geo-related DLLs for new
environments.

On 27 March 2014 11:27, Alex Mandel <tech_...@wildintellect.com> wrote:
> You might get more responses on the GeoDjango mailing list:
> geodja...@googlegroups.com
>
> I agree the basic libraries probably all work. Are you sure you used
> OSGeo4w with Python3? OSGeo4w ships 2.7.x, so unless the GDAL and GEOS
> wrappers also work with Python3 that sounds odd.
>
> pypi page makes it look like those libs work in Python3
> https://pypi.python.org/pypi/GDAL/
> https://pypi.python.org/pypi/Shapely (Infers Geos)
>
> Thanks,
> Alex
>
> On 03/25/2014 05:34 PM, Sam Lai wrote:
>> I'm developing a site using Python 3.3, Django, Geodjango and
>> PostgreSQL. It is a bit tricky getting all the libraries to work, but
>> the stack does work. I installed GEOS using OSGeo4W, but I had to
>> explicitly specify the GEOS_LIBRARY_PATH and GDAL_LIBRARY_PATH in
>> settings.py.
>>
>> On 25 March 2014 23:28, rgreene <rgre...@feaverslane.com> wrote:
>>> Good day,
>>>
>>> I'm developing under Windows against a PostGIS database. On
>>> https://docs.djangoproject.com/en/1.7/ref/contrib/gis/install/#windows,
>>> Python 2.7 is shown in the installation steps. I've been reading up on
>>> Python 3.3 (for instance, https://wiki.python.org/moin/Python2orPython3),
>>> and as the development is just getting started I would like to go this route
>>> if possible. Are their any packages/libraries in the typical
>>> Geodjango/PostGIS statck that are not compatible with Python 3.3?
>>>
>>> Thanks in advance,
>>> Randal
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/5831a490-c1b6-4804-a09e-d99d79648a19%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/53337086.6080804%40wildintellect.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: Geodjango and Python 3.3

2014-03-25 Thread Sam Lai
I'm developing a site using Python 3.3, Django, Geodjango and
PostgreSQL. It is a bit tricky getting all the libraries to work, but
the stack does work. I installed GEOS using OSGeo4W, but I had to
explicitly specify the GEOS_LIBRARY_PATH and GDAL_LIBRARY_PATH in
settings.py.

On 25 March 2014 23:28, rgreene  wrote:
> Good day,
>
> I'm developing under Windows against a PostGIS database. On
> https://docs.djangoproject.com/en/1.7/ref/contrib/gis/install/#windows,
> Python 2.7 is shown in the installation steps. I've been reading up on
> Python 3.3 (for instance, https://wiki.python.org/moin/Python2orPython3),
> and as the development is just getting started I would like to go this route
> if possible. Are their any packages/libraries in the typical
> Geodjango/PostGIS statck that are not compatible with Python 3.3?
>
> Thanks in advance,
> Randal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5831a490-c1b6-4804-a09e-d99d79648a19%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: [ELI5] how to deploy django

2014-03-03 Thread Sam Lai
On 4 March 2014 14:36, Walter Wang  wrote:
>  I tried my best to follow the various guides out there, but the official
> documentation here
> https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/ has
> different instructions than the instructions here,
> https://www.digitalocean.com/community/articles/using-mod_wsgi-to-serve-applications-on-ubuntu-12-04

Follow the digitalocean instructions. The official Django
documentation assumes you are across Apache and how mod_wsgi works in
general, and therefore doesn't give step-by-step instructions.

> I have been at this for over a week now, and I can't figure out how to
> deploy django with mod_wsgi and apache on a linux web server.
>
> Can someone give or point to me a step to step instruction on how to deploy
> django?
>
> Specifically,
> 1. what do I do with the httpd.conf file?

Follow the digitalocean instructions and don't touch this file (for
reference, it is referring to /etc/apache2/httpd.conf).

> 2. wsgi file? what's the difference between "making a wsgi file" and a
> wsgi.py file?

They're the same thing. mod_wsgi doesn't care what the extension is.
The content in your two examples is slightly different as one was
written for an older version of Django.

If you're still stuck, you'll need to provide more details like -
Linux distribution and version, Django version, Apache version, path
to project, virtual host file contents, the output when you use the
'wget' command to visit the website, and also anything in the Apache
log files.

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


Re: help with GEOS and PROJ.4 in windows 7

2014-02-16 Thread Sam Lai
Did you try the steps listed in the geodjango documentation,
specifically 
https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#osgeo4w
and the following step to configure the environment? If you did and it
didn't work, what was the error?

On 16 February 2014 05:55, Nicholas Perez  wrote:
> Hello i am trying to install these libraries GEOS and PROJ.4 to use with
> geodjango(according to tutorial on the website). I am new to this so any
> help would be greatly appreciated. i have sqlite3 installed in windows 7 and
> want to use Spatialite but i need these (GEOS and PROJ.4) before proceeding.
> Thank you for your time.
>
> Nicholas Perez
>
> ps: please include proper instructions to install this in windows 7 since
> that is the platform i am currently using. Thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8b8366ed-80c4-4b43-86a4-4a3b155c161b%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

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


Re: virtualenv on Windows

2014-01-29 Thread Sam Lai
Oops, my memory failed me. They don't work with pip, but they do work
with easy_install, which virtualenvs have as well (at least mine do).

http://stackoverflow.com/a/5442340/150999

For example,

easy_install C:\Users\sam\Downloads\Pygments-1.6.win-amd64-py2.7.exe



On 29 January 2014 16:27, Mike Dewhirst <mi...@dewhirst.com.au> wrote:
> On 29/01/2014 2:23pm, Sam Lai wrote:
>>>
>>> However, even after downloading from that site they cannot be installed
>>> manually into a virtualenv! Only pip can do that.
>>
>>
>> You can install the packages from
>> http://www.lfd.uci.edu/~gohlke/pythonlibs/ by simply running -
>>
>> pip install 
>
>
> I did try that earlier but had no luck. Maybe I got the incantation wrong?
>
> (proj-x) C:\users\miked\env\proj-x>pip install
> C:\install_kits\python\postgresql\psycopg2-2.4.5.win32-py2.7.exe
>
> Exception:
> Traceback
> ...
> ValueError: ('Missing distribution spec',
> '\\install_kits\\python\\postgresql\\psycopg2-2.4.5.win32-py2.7.exe')
>
> Mike
>
>
>>
>> ... from inside your virtualenv. Those .exe files are pip-compatible
>> ZIP archives
>>
>> On 29 January 2014 13:56, Mike Dewhirst <mi...@dewhirst.com.au> wrote:
>>>
>>> A little while ago I suggested to someone using Windows to implement
>>> virtualenv "later". So I thought I'd document my experience here.
>>>
>>> In summary, it probably works well if you have Visual Studio. The process
>>> outlined below shows a clumsy workaround if you don't.
>>>
>>> Hope it helps someone
>>>
>>> Mike
>>>
>>> - - - - - -
>>>
>>> $pip install virtualenv # first step (requires pip obviously)
>>>
>>> $mkdir c:\users\miked\env
>>>
>>> $virtualenv --no-site-packages c:\users\miked\env\proj-x
>>> New python executable in c:\users\miked\env\proj-x\Scripts\python.exe
>>> Installing setuptools, pip...done.
>>>
>>> Now copy your "myproject-x" into c:\users\miked\env\proj-x\myproject-x
>>>
>>> At this point on Linux one would install virtualenv-wrapper but that is
>>> unfortunately not available for Windows so a simple workaround is ...
>>>
>>> 1. mkdir \users\miked\bin # could be anything eg \users\miked\bat
>>>
>>> 2. Add C:\users\miked\bin to the path environment variable
>>>
>>> 3. Create a batch file called C:\users\miked\bin\proj-x.bat containing:
>>>
>>> cd \users\miked\env\proj-x\myproject-x
>>> ..\Scripts\activate
>>>
>>> 4. Create another batch file
>>> C:\users\miked\env\proj-x\myproject-x\exit.bat
>>> containing:
>>>
>>> cd \users\miked\
>>> \users\miked\env\proj-x\Scripts\deactivate
>>>
>>> 5. Test the workaround by opening a command prompt somewhere and entering
>>> proj-x. You should see:
>>>
>>> C:\Documents and Settings\Mike Dewhirst\Desktop>cd
>>> \users\miked\env\proj-x\myproject-x
>>>
>>> C:\users\miked\env\proj-x\myproject-x>..\Scripts\activate
>>> (proj-x) C:\users\miked\env\proj-x\myproject-x>
>>>
>>> 6. Test the exit batch file by entering exit at that command prompt:
>>>
>>> C:\users\miked\env\proj-x\myproject-x>..\Scripts\activate
>>> (proj-x) C:\users\miked\env\proj-x\myproject-x>exit
>>>
>>> (proj-x) C:\users\miked\env\proj-x\myproject-x>cd \users\miked\
>>>
>>> (proj-x) C:\users\miked>\users\miked\env\proj-x\Scripts\deactivate
>>> C:\users\miked>
>>>
>>> This should let you get into and out of the virtualenv quite easily.
>>>
>>> Now comes the difficult bit for Windows - installing stuff in the new
>>> Python's site-packages. First, though, discover what you already have
>>> installed in your main site-packages:
>>>
>>> pip freeze > requirements.txt  # lists existing site-packages
>>>
>>> Here is mine, most of which I don't want in proj-x
>>>
>>> Django==1.5.4
>>> Jinja2==2.7.1
>>> MarkupSafe==0.18
>>> Pygments==1.6
>>> South==0.7.6
>>> Sphinx==1.1.3
>>> coverage==3.7
>>> django-discover-runner==1.0
>>> docutils==0.9.1
>>> filemov==1.1.1-2728-py2.7
>>> pillow==2.3.0
>>> pss==1.38
>>> psycopg2==2.4.5
>>> py2exe==0.6.9
>>> pytz==2012h
>>> pywin32==218
>>> virtualenv==1.11.2
>>>
>>> So I edit it down to the f

Re: virtualenv on Windows

2014-01-28 Thread Sam Lai
> However, even after downloading from that site they cannot be installed 
> manually into a virtualenv! Only pip can do that.

You can install the packages from
http://www.lfd.uci.edu/~gohlke/pythonlibs/ by simply running -

pip install 

... from inside your virtualenv. Those .exe files are pip-compatible
ZIP archives

On 29 January 2014 13:56, Mike Dewhirst  wrote:
> A little while ago I suggested to someone using Windows to implement
> virtualenv "later". So I thought I'd document my experience here.
>
> In summary, it probably works well if you have Visual Studio. The process
> outlined below shows a clumsy workaround if you don't.
>
> Hope it helps someone
>
> Mike
>
> - - - - - -
>
> $pip install virtualenv # first step (requires pip obviously)
>
> $mkdir c:\users\miked\env
>
> $virtualenv --no-site-packages c:\users\miked\env\proj-x
> New python executable in c:\users\miked\env\proj-x\Scripts\python.exe
> Installing setuptools, pip...done.
>
> Now copy your "myproject-x" into c:\users\miked\env\proj-x\myproject-x
>
> At this point on Linux one would install virtualenv-wrapper but that is
> unfortunately not available for Windows so a simple workaround is ...
>
> 1. mkdir \users\miked\bin # could be anything eg \users\miked\bat
>
> 2. Add C:\users\miked\bin to the path environment variable
>
> 3. Create a batch file called C:\users\miked\bin\proj-x.bat containing:
>
> cd \users\miked\env\proj-x\myproject-x
> ..\Scripts\activate
>
> 4. Create another batch file C:\users\miked\env\proj-x\myproject-x\exit.bat
> containing:
>
> cd \users\miked\
> \users\miked\env\proj-x\Scripts\deactivate
>
> 5. Test the workaround by opening a command prompt somewhere and entering
> proj-x. You should see:
>
> C:\Documents and Settings\Mike Dewhirst\Desktop>cd
> \users\miked\env\proj-x\myproject-x
>
> C:\users\miked\env\proj-x\myproject-x>..\Scripts\activate
> (proj-x) C:\users\miked\env\proj-x\myproject-x>
>
> 6. Test the exit batch file by entering exit at that command prompt:
>
> C:\users\miked\env\proj-x\myproject-x>..\Scripts\activate
> (proj-x) C:\users\miked\env\proj-x\myproject-x>exit
>
> (proj-x) C:\users\miked\env\proj-x\myproject-x>cd \users\miked\
>
> (proj-x) C:\users\miked>\users\miked\env\proj-x\Scripts\deactivate
> C:\users\miked>
>
> This should let you get into and out of the virtualenv quite easily.
>
> Now comes the difficult bit for Windows - installing stuff in the new
> Python's site-packages. First, though, discover what you already have
> installed in your main site-packages:
>
> pip freeze > requirements.txt  # lists existing site-packages
>
> Here is mine, most of which I don't want in proj-x
>
> Django==1.5.4
> Jinja2==2.7.1
> MarkupSafe==0.18
> Pygments==1.6
> South==0.7.6
> Sphinx==1.1.3
> coverage==3.7
> django-discover-runner==1.0
> docutils==0.9.1
> filemov==1.1.1-2728-py2.7
> pillow==2.3.0
> pss==1.38
> psycopg2==2.4.5
> py2exe==0.6.9
> pytz==2012h
> pywin32==218
> virtualenv==1.11.2
>
> So I edit it down to the following, create a directory and save it as
> C:\users\miked\env\proj-x\requirements\requirements.txt
>
> Django==1.5.4
> South==0.7.6
> coverage==3.7
> django-discover-runner==1.0
> pillow==2.3.0
> psycopg2==2.4.5
> pytz==2013.9
>
> pip install -r C:\users\miked\env\proj-x\requirements\requirements.txt
>
> And this where (my) problems start. First pip will download the packages
> successfully but I don't have Visual Studio installed so those packages
> requiring compilation don't get installed. Here is a snippet of pip output
> after the downloads:
>
> Installing collected packages: Django, South, coverage,
> django-discover-runner, pillow, psycopg2, pytz
>   Running setup.py install for Django
>
> ... and so on until errors start to appear. In my case the signal is:
>
> error: Unable to find vcvarsall.bat
>
> Afterwards, pip freeze shows:
>
> (proj-x) C:\users\miked\env\proj-x>pip freeze
> Django==1.5.4
> South==0.7.6
> coverage==3.7
> django-discover-runner==1.0
>
> ... which indicates pillow, psycopg2 and pytz did not install.
>
> But how come they were installed in the main site-packages? That's because
> they were originally downloaded from
> http://www.lfd.uci.edu/~gohlke/pythonlibs/ and installed manually.
>
> However, even after downloading from that site they cannot be installed
> manually into a virtualenv! Only pip can do that. The only workaround I have
> found is to manually copy them from the main site-packages to the new
> virtualenv site-packages. Clumsy.
>
> My proj-x requirements.txt file now looks like this ...
>
> Django==1.5.4
> South==0.7.6
> coverage==3.7
> django-discover-runner==1.0
> # pillow==2.3.0 http://www.lfd.uci.edu/~gohlke/pythonlibs/
> # psycopg2==2.4.5 http://www.lfd.uci.edu/~gohlke/pythonlibs/
> # pytz==2013.9 http://www.lfd.uci.edu/~gohlke/pythonlibs/
>
> After the above clumsy workaround everything works well and pip freeze
> displays ...
>
> Django==1.5.4
> South==0.7.6
> coverage==3.7
> 

Re: UnicodeDecodeError in python manage.py flush

2014-01-20 Thread Sam Lai
It looks like you have named one of your model classes with a name
that contains a non-ASCII character. Stick with class names with only
a-z, A-Z, 0-9 characters and see if that helps.

On 21 January 2014 10:29, Edgar Reyes  wrote:
> Hi, I'm looking in google search about this error but I didn't find anything
> similar.
>
> Any suggestions ?
>
> python manage.py flush
> You have requested a flush of the database.
> This will IRREVERSIBLY DESTROY all data currently in the 'cbbc' database,
> and return each table to the state it was in after syncdb.
> Are you sure you want to do this?
>
> Type 'yes' to continue, or 'no' to cancel: yes
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File
> "/usr/local/pythonenv/DJANGO_1.6_py_2.7.3/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 399, in execute_from_command_line
> utility.execute()
>   File
> "/usr/local/pythonenv/DJANGO_1.6_py_2.7.3/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/usr/local/pythonenv/DJANGO_1.6_py_2.7.3/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 249, in run_from_argv
> stderr.write('%s: %s' % (e.__class__.__name__, e))
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 343:
> ordinal not in range(128)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4c119cf8-594f-4ba1-8005-3d520ff4d9d7%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

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


Re: Exception on start django server in windows 7

2014-01-20 Thread Sam Lai
It's due to the accent on the e in your username. This is a 'bug' in the
way Python works with the Windows command prompt.

Long story short, just move the 'Python' directory out from your Desktop to
somewhere just on your C:\ drive (so your username isn't in the path) and
everything will work, e.g. C:\Python. Maybe C:\work\Python would be a more
descriptive path.


On 21 January 2014 11:08, Moisés Batista dos Santos Filho <
msneofi...@gmail.com> wrote:

> Hi, everyone. I need help!
> I was reading django's tutorial when the next step was start server. But
> when I put this instruction in command line, python manage.py runserver:
>
>
> 
>
> I'm trying solve this error but no successful.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cfea2648-ecfe-4533-b6be-912d1fd5c4f0%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: Getting GIS Working - possible kernel32 problem

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

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

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

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

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

Re: Tests not loading initial_data fixtures

2013-10-03 Thread Sam Lai
Ah, turns out all you have to do is specify -

fixtures = [ 'initial_data' ]

... in the TestCase and it'll load all the initial_data fixtures from
all apps. Still a bit odd that loading initial_data fixtures isn't the
default in tests though.

On 3 October 2013 16:49, Sam Lai <samuel@gmail.com> wrote:
> I'm trying to test a Django management command in app X that parses
> data files and inserts data into models that are located in apps Y and
> Z. Apps Y and Z have initial_data.json files in them. On running my
> test however, it seems that my initial_data fixtures are not being
> loaded.
>
> I could specify the initial_data fixtures manually (presumably I can
> do ../) using the 'fixtures' variable in my TestCase, but that isn't
> very DRY and becomes tedious when more apps are introduced with their
> own initial_data.
>
> I tracked this down to a change that Russell made 3 years ago
> (https://github.com/django/django/commit/b31a1b99261d05bf8a34495ee9faf4d6592b8b36).
> The commit message and content explains why *custom SQL* fixtures
> aren't loaded automatically during testing, but says nothing about why
> xml/yaml/json fixtures are no longer loaded either.
>
> All django-users threads that I can find on this refer to the
> situation prior to this change, and state that initial_data fixtures
> *were* loaded.
>
> What's the reason for the change? I thought initial_data is designed
> for data that should always be in the database, so this is a bit odd.
> Can't really find anything in the docs that mentions this either.
>
> Thanks,
>
> Sam

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


Tests not loading initial_data fixtures

2013-10-03 Thread Sam Lai
I'm trying to test a Django management command in app X that parses
data files and inserts data into models that are located in apps Y and
Z. Apps Y and Z have initial_data.json files in them. On running my
test however, it seems that my initial_data fixtures are not being
loaded.

I could specify the initial_data fixtures manually (presumably I can
do ../) using the 'fixtures' variable in my TestCase, but that isn't
very DRY and becomes tedious when more apps are introduced with their
own initial_data.

I tracked this down to a change that Russell made 3 years ago
(https://github.com/django/django/commit/b31a1b99261d05bf8a34495ee9faf4d6592b8b36).
The commit message and content explains why *custom SQL* fixtures
aren't loaded automatically during testing, but says nothing about why
xml/yaml/json fixtures are no longer loaded either.

All django-users threads that I can find on this refer to the
situation prior to this change, and state that initial_data fixtures
*were* loaded.

What's the reason for the change? I thought initial_data is designed
for data that should always be in the database, so this is a bit odd.
Can't really find anything in the docs that mentions this either.

Thanks,

Sam

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


Re: Bootstrap - django-bootstrap3 or django-crispy-forms

2013-09-26 Thread Sam Lai
Yep.  django-bootstrap-* and django-crispy-forms only provide helpers
for outputting HTML with bootstrap CSS classes. Neither are really
necessary to use Bootstrap (just makes it slightly easier), which is
applied through HTML and CSS and Django doesn't place any restrictions
on how your HTML/CSS is structured.

On 26 September 2013 22:53, Nigel Legg  wrote:
> Hi, I've been looking into using Bootstap3 on the django app I'm working on.
> It seems you can do this with both django-bootstrap and crispy-forms.
> Am I right in thinking that django-bootstap allows you to use bootstrap
> across the whole site, while crispy forms is just for forms?  So you can use
> both together? Or am I missing something?
>
> Cheers, Nigel
> 07914 740972
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

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


Re: virtualenv setup

2012-12-29 Thread Sam Lai
It looks like you haven't installed Django in your virtualenv. In your
virtualenv directory, look in lib/python2.x/site-packages and see if there
is a Django directory in there.

You can also try sourcing your venv, then running Python, and entering in
the following statement to see if Python can find Django -

import django

If it can't, try the following statements in the Python shell and see if
your venv's site-packages directory is in the system path -

import sys
sys.path

Finally, try the following command in your usual shell and make sure it is
referring to the right Python executable (it should be referring to the one
in your venv/bin directory) -

which python


On 30 December 2012 09:23, Phil  wrote:

> Hi,
>
> Thanks for reply. Yeah I activated the source(terminal has "venv" beside
> my username). I followed instructions here(so I pip installed django etc
> after getting virtualenv up and running)...
>
> https://devcenter.heroku.com/articles/django#prerequisites
>
> If I runserver thats when I get the error. If I runserver without
> activating source it works fine but that would be using my system wide
> python. Just need to figure out how to get it to recognise the virtualenv
> python.
>
>
> On Saturday, December 29, 2012 10:16:45 PM UTC, quinonesvictor wrote:
>
>> Hi Phil
>>
>> sorry for the question, but, did you activate your virtualenv source?
>> $ source bin/activate (?)
>>
>> Anyway, I'd try to install django via pip once you I have my virtualenv
>> created and activated.
>>
>> Cheers
>>
>> On Sat, Dec 29, 2012 at 7:01 PM, Phil  wrote:
>>
>>> Hi,
>>>
>>> I have python/django working system wide. But am currently looking into
>>> using Heroku for a new project so am trying to get virtualenv setup for the
>>> first time. When I run "django-admin.py startproject whatever" it creates
>>> the project ok, but then when I run "python manage.py runserver 8080" from
>>> the project folder I get the following error...
>>>
>>> ImportError: No module named django.core.management
>>>
>>> Is it because at the top of my "manage.py" it is pointing to my system
>>> wide python(#!/usr/bin/env python) instead of my virtualenv one? If so how
>>> do I fix this? I tried changing the path at the top of the manage.py file
>>> but didn't seem to do anything.
>>>
>>> --
>>> 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/-/n4-**fu8ioveIJ
>>> .
>>> 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
>>> .
>>>
>>
>>
>>
>> --
>> Quiñones Victor Manuel
>> Tel: +54 0362 15 4 880839
>> Resistencia - 3500
>> Argentina
>>
>  --
> 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/-/Gb4JYmpcK-0J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Postgresql Index & expensive queries [n00bie alert]

2012-10-19 Thread Sam Lai
On 20 October 2012 14:16, Barry Morrison  wrote:
> I've got a pretty expensive query...Wondering if I can't speed things up in
> regards to Postgresql.
>
> Here is the model: [1] http://dpaste.org/JmEeQ/
>
> Here is the sql statement: [2] http://dpaste.org/GbfAJ/
>
> Here is the template: [3] http://dpaste.org/vxRs4/
>
> Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/
>
> Total Postgresql/SQL n00b, so this may be a stupid statement. I'm wondering
> if an index on '"press_page"."article_id"' wouldn't speed things up a bit?

Are you using the django-debug-toolbar? If not, consider using it -
once installed, visit that page in your browser, open up the toolbar,
select SQL queries, find the offending query (processing times are
shown), and click the Explain link. That will tell you what PostgreSQL
is doing, and how performance can be improved.

Alternately, fire up a terminal and launch the psql database shell.
Type in the query ([2]) but prefix it with the word EXPLAIN. This will
tell you what PostgreSQL is doing to process that query. If you see
Seq Scan in there, consider adding the index. Remember to run the SQL
statement - ANALYZE press_page - after you create the index so it can
update the internal statistics that it uses to decide how to process a
query.

You can also do this within the PGadmin application if that makes things easier.

> In dev, I don't have the amount of data that exists in production, so I
> can't easily/realistically recreate this scenario.

You really need to have a good subset (considering both the number of
records, and the distribution of values within each record) if it is
not possible to have a copy of the production database. PostgreSQL
performs analysis on the data itself and uses those statistics to
decide how to process the query (whether to use an index, scan
sequentially etc.). If you dev database is not a good representation,
then the results you'll see with your dev database, and hence your
improvements, may have no effect or a negative effect in production.

I do believe having an index on press_page.article_id is a good idea
though. Also, are you really showing every article in that view?
Consider using a limit so you're not retrieving all the records, only
to use the first 10. The pagination features in Django may be useful
here. Finally, an index on press_page.pgnumber may also be worth
considering so PostgreSQL may be able to avoid the sorting step (an
index of the default type is sorted by the field in ascending order).

> FWIW, I'm running:
>
> Django 12.04
> Postgresql 9.1.5
> Django 1.4.1
>
> I'm using memcache on the view to cache it, it helped take page load down
> significantly, but I was wondering if there wasn't something I could do from
> the DB side of things since I know it's this query that is taking the page
> so long to load.
>
> 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/-/U92OjnMgEggJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Beginner problem linking pages from homepage?

2012-09-22 Thread Sam Lai
On 23 September 2012 06:40, Vincent Fulco  wrote:
> Missing something basic here even after scouring web and running thru online
> tut a few times.
>
> Started a project 'mysite' and added twitter bootstrap then created a static
> homepage "index.html' to act as a simple launchpad to other more information
> & feature laden pages.  Used direct_to_template to access the first page and
> it renders fine under the development server and a virtualenv (the latter is
> in the path).  The homepage has a number of hrefs to the other pages which I
> filled in with './foo1', './foo2', etc.
>
> Using the hello function placed in ~/.../mysite/mysite/views.py, I've tried
> to branch off the main page as such in urls.py (goal is /homepage/foo1).
> *Note the extra code required in the file isn't represented here.
>
> from mysite.views import hello
> ...
> urlpatterns = patterns('',
>url(r'^foo1$', hello),
>url(r'^foo2$', hello),
>url(r'^foo3$', hello),
>url(r'^foo4$', hello),
> )
>
> have also tried:
>
> urlpatterns = patterns('homepage',
>url(r'^foo1$', hello),
>url(r'^foo2$', hello),
>url(r'^foo3$', hello),
>url(r'^foo4$', hello),
> )
>
> This causes the site to break with a 404 error even though I think I am
> supplying a correct regex and a toy function.  I suspect there is something
> with the mysite views.py not being found but not sure.  I have tried to more
> explicitly reference the views.py file with mysite.views.py trials.

If you haven't already, enable DEBUG in mysite/settings.py. Your 404
page should then indicate which URL regular expressions it has
checked. Are the above URL regular expressions in that list? Is
ROOT_URLCONF in mysite/settings.py set to 'mysite.urls'?

I just created a toy project with that urls.py and it worked fine.

> I am not even sure if philosophically this is considered a good practice of
> django.  Thanks in advance for your assistance.  V.

Generally you would not create a views.py in your project directory
(mysite/mysite is your project directory). You would usually create an
app (mysite/manage.py startapp appname), create your views, app-level
URLs, models etc. in there, and then reference them in your project
urls.py by including your app's urls.py.

Also, generally you would reference the view using a string, instead
of the actual view function itself. This saves you from having to
import every view, and avoid clashes in larger projects where you may
have view functions with the same name in different apps. In the
second urls.py you posted, the first parameter to patterns, where you
have 'homepage' specified, is used to shorten these view function
strings - that parameter is appended to your url definitions, i.e. you
could use the following urls.py instead -

urlpatterns = patterns('mysite',
   url(r'^foo1$', 'hello'),
   url(r'^foo2$', 'hello'),
   url(r'^foo3$', 'hello'),
   url(r'^foo4$', 'hello'),
)

... and Django will append 'mysite' to all the view function strings,
turning them into 'mysite.hello'. See
https://docs.djangoproject.com/en/dev/topics/http/urls/#the-view-prefix

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

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



Re: Template Error: Invalid block tag: 'endblock', expected 'empty' or 'endfor'

2012-03-26 Thread Sam Lai
On 25 March 2012 11:56, Homer  wrote:
> I tried to create an index webpage but Django told me I had a template
> error:
>
> Invalid block tag: 'endblock', expected 'empty' or 'endfor'
>
> Here is the code of index.html:
>
> {% extends "base.html" %}
>
> {% block title %}Home{% endblock %}
> {% block content %}
>
> Welcome to So Easy! 学中文
>
> Showcase
> 
> 
> {% for item in item_list|slice:":3" %}
> 
> {{ item.name }}
> {% if item.photo_set.count %}
> 
> {% else %}
> No Photos (yet)
> {% endif %}
> 
> 
> <% endfor %>

This line should be {% endfor %}.

> 
> 
> View the full list;
>
> {% endblock %}    #Error Here
> {% block footer %}
>
> I hope someone can help me. 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/-/Dn_zBeC7tnYJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Template Error: Invalid block tag: 'endblock', expected 'empty' or 'endfor'

2012-03-26 Thread Sam Lai
On 25 March 2012 11:56, Homer  wrote:
> I tried to create an index webpage but Django told me I had a template
> error:
>
> Invalid block tag: 'endblock', expected 'empty' or 'endfor'
>
> Here is the code of index.html:
>
> {% extends "base.html" %}
>
> {% block title %}Home{% endblock %}
> {% block content %}
>
> Welcome to So Easy! 学中文
>
> Showcase
> 
> 
> {% for item in item_list|slice:":3" %}
> 
> {{ item.name }}
> {% if item.photo_set.count %}
> 
> {% else %}
> No Photos (yet)
> {% endif %}
> 
> 
> <% endfor %>

This line should be {% endfor %}.

> 
> 
> View the full list;
>
> {% endblock %}    #Error Here
> {% block footer %}
>
> I hope someone can help me. 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/-/Dn_zBeC7tnYJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Accessing objects from a dictionary in templates

2012-03-24 Thread Sam Lai
On 24 March 2012 09:29, gowtham  wrote:
> Template tag filters like this (made one for each field in the library
> object) helps me to get what i wanted But, that seems too silly to do...
>
> in template
> {{ reslibdic|hash2libcode:res.result_id }}
>

I had the same thought as Reinout did, but after your clarification I
realised you want to get something out of reslibdic by using another
variable as the key. AFAIK, there is no in-built way of doing this.

However, it is worth taking a step back and having a look at what
you're trying to do.

"I have two models (Library and Result) linked by a third linking
model (libraryresult (has id, library_id and result_id fields FKeyed
to respective tables). A many to many relationship."

By the sounds of things, you have actually defined a third model,
libraryresult, that links the Library and Result models together. That
third model is unnecessary (unless you have other attributes to store
with the link, which you don't seem to have - if you do, see
https://docs.djangoproject.com/en/1.4/topics/db/models/#intermediary-manytomany).

If you simply define a ManyToManyField on the Result model pointing to
the Library model, e.g.

class Result(models.Model):
# ...
libraries = models.ManyToManyField(Library)

... then you can get all the related libraries for a particular result
by simply doing -

r = Result.objects.get(pk=1)
print r.libraries.all()

You can do the same in the template. There is no need to build the
reslibdic object.

See 
https://docs.djangoproject.com/en/1.4/topics/db/models/#many-to-many-relationships
for help defining the model, and
https://docs.djangoproject.com/en/1.4/topics/db/queries/#many-to-many-relationships
for help querying the related objects.

> in template tag file:
>
> def hash2libcode(h,key):
>     if key in h:
>         return h[key].librarycode
>     else:
>         return None
>
> register.filter(hash2libcode)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Running manage.py commands in Windows Power Shell

2012-03-15 Thread Sam Lai
On 15 March 2012 04:35, orschiro  wrote:
> Hello,
>
> I have a question which is based on the discussion here:
>
> http://groups.google.com/group/django-users/browse_thread/thread/2333f5dc8d0674f0
>
> I'm working on Windows 7 with the PowerShell. Python 2.7 and the path
> to django-admin.py is stored in my PATH variable.
>
> After creating a project I can make use of the various manage.py
> commands in my PowerShell. However, only in the following way:
>
> 'python manage.py runserver'
>
> If I only type '.\manage.py runserver' then a new CMD window is opened
> running again 'python manage.py runserver'. That is, the command is
> forwarded to the CMD shell which opens it with the Python
> interpreter.
>
> Is there any way to tell the PowerShell to interpret the command given
> within the shell instead of launching a CMD window?

For me, both ways execute within PowerShell's shell. I do have
ActiveState ActivePython installed instead of the Python distribution
from python.org though; I find the ActiveState distribution integrates
much better with Windows than python.org's.

That said, I can't really explain why you're seeing what you're seeing
though. Does it happen if you just do '.\test.py' where test.py just
contains simple Python commands like a couple of print statements?

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

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



Re: Haystack Solr Error

2012-03-06 Thread Sam Lai
On 5 March 2012 07:49, coded kid  wrote:
> I'm trying to rebuild_index, so after inputting manage.py rebuild-
> index , I'm getting:
>
> Removing all documents in your index because you said so.
> fail to clear Solr index: [Errno 10061] No connection could be made
> because the target
> machine actively refused it.
>
> What I'm I doing wrong?

That error message means your Django app cannot connect to your Solr
instance. Is it running? Is it listening on the right host/port? Might
be worth restarting Solr in case it got into a bad state and is
refusing connections. Also check your Solr logs to ensure it can
listen on the port it is configured on.

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

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



Re: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-30 Thread Sam Lai
On 29 January 2012 16:49, JJ Zolper  wrote:
> Sam,
>
> I have set up VirtualBox with Python and Django. Things have gone
> flawlessly.
>
> Only thing I've noticed is it seems to be running a tad bit slow. I feel
> this way because I had a native installation before and it ran quite well.

Have you installed the VirtualBox Guest Additions? That will, among
other things, optimise your  video which should make it feel a lot
faster.

This looks like a good guide for installing it on Ubuntu 11.10 -
http://www.varunvats.com/2011/06/install-virtualbox-guest-additions-for-ubuntu-11-04-guest/

> Before I go too far into writing code I was hoping to "perfect" my
> environment. I want to be able to donate enough resources such as RAM to the
> VM so that it runs well but at the same time maintain a steady local Windows
> boot.
>
> Would you mind helping get me situated?
>
> My Laptop is a Fujitsu Lifebook T5010. A 231 GB HDD with 4 GB RAM. I have
> Windows 7 Enterprise 64 bit operating system installed.
>
> The original or current setup for my Ubuntu 11.10 on my VirtualBox system
> is:
>
> Base Memory: 700 MB (RAM? max is 4096)
> Storage: 40 GB (Fixed)
> Video Memory: 12 MB (max is 128)
> Monitor count is 1
>
> Those are all the details I thought might be useful. I would really
> appreciate some guidance as to what you set yours up as or what you think
> might be the best to optimize performance?
>
> As a side note I'm really asking anyone in this thread what their opinion
> is? I plan is to look through this thread and see who else mentioned Linux
> and see if I can get input so I'm ready to go before I dive too deep into my
> development.
>
> Thanks to you and to everyone who has been very patient with me, given me so
> many tips, and stepped me through my setup!
>
> Much appreciation,
>
> JJ Zolper
>
>
>
>
> --
> 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/-/y689VFsrhDUJ.
>
> 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.



djangosnippets.org domain has expired

2012-01-28 Thread Sam Lai
Heads-up to whoever is in charge of this domain - it has expired and
is now redirecting to a GoDaddy domain parking page.

-- 
You received this message because you are subscribed to the Google 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: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-25 Thread Sam Lai
On 26 January 2012 13:14, JJ Zolper  wrote:
>> The keywords were 'in production'. The development server (i.e. python
>> manage.py runserver) works fine under Windows. But when you want to
>> make the website accessible to your audience (the internet, company
>> etc.), you should host that on Linux.
>
> I still don't quite understand. Can you explain more? I would think this
> means that my Django files should be on a Linux portion of my web server? I
> am with Bluehost.com

When you are developing your Django app, the development server that
comes with Django (python manage.py runserver) works fine on Windows.
When you are ready to move things into production for everyone else
access, you should not use the development server; instead you should
use a proper web server, e.g. nginx, cherokee or Apache. Those web
servers tend to be better documented on Linux.

If it makes things easier, just do everything on Linux.

> I have installed ActiveState and will give it a try. I have my VS up and
> running with Python Tools for VS so that should be okay.
>
> Hey Sam you've been a great help. Would you by chance mind giving me your
> e-mail address? That way in the future I could work with you? I won't bother
> you too much don't worry! lol. Just since I am trying your advice it could
> be a great help to me.
>
> What Virtual Machine did you pick? What Linux version are you running?

I'm just using VirtualBox, running a whatever Linux distro I happen to
like at the time, e.g. CentOS, Ubuntu etc.

> If you prefer e-mailing/want to give me your address my next inquery would
> just go to your e-mail.
>
> Thanks so much!
>
> JJ Zolper
>
> --
> 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/-/nMqg8xOLXRcJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-25 Thread Sam Lai
On 26 January 2012 12:05, JJ Zolper  wrote:
>>  Unless you have a
>>  preference for Windows though, I wouldn't use it as a Django app web
>>  server in production; there's far less support on the net to help you
>>  out when things go wrong.
>
> Let me see if this what you mean... so when I want to run "python manage.py
> runserver," a Django command I should steer clear of Windows?

The keywords were 'in production'. The development server (i.e. python
manage.py runserver) works fine under Windows. But when you want to
make the website accessible to your audience (the internet, company
etc.), you should host that on Linux.

>> I use ActiveState Komodo Edit on Windows to modify files on my Linux
>> VM which runs the web server for my Django apps. It means I don't get
>> a debug environment though; working on finding something to make that
>> work.
>
> So I should install ActiveState Komodo Edit to Windows. Which in turn well
> help me to work with my Django server through a Virtual Machine?

That's one way. It's a bit more complex than simply doing everything
inside a Linux VM. Komodo Edit also works in Linux as well.

> If I have this right I should install my CPython distro to VS and build my
> Python on Windows in VS. Then on the side I should have a VM running with my
> Django server (aka my Django project)?

See above; the runserver command works fine under Windows.

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

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



Re: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-25 Thread Sam Lai
On 26 January 2012 04:50, JJ Zolper <cod...@madtrak.com> wrote:
> In many of the (I)DEs (PythonWin, IDLE, probably the various EMACS
> and VI configurations, SciTE), one can edit a file, save it (some will
> save for you if needed), then hit some key combo which will spawn a
> Python interpreter passing it the file for execution. You may even be
> prompted to supply command line arguments (PythonWin, I know does this).
>
> This is very interesting thanks for sharing! As for the information above
> that has cleared it up quite a bit for me.
>
> Sam Lai has helped a lot I think I am going to try to see if CPython works
> in VS because he thinks I will have less compatibility with IronPython and
> Django which would not be good. For the time being however I think I might
> just use VS since I am still new to really what I could be lacking with that
> as far as compatibility.

Python Tools for Visual Studio should automatically detect CPython if
you have that installed. If you haven't, I suggest you download an
install a CPython distribution called ActivePython Community Edition
(http://www.activestate.com/activepython/downloads). It will set up
Python in your Windows environment properly, which the official one
doesn't seem to do right (judging by the posts here about Windows).

The bonus with VS is the great debugger, which works with CPython as
well. Many of the IDEs mentioned are just great text editors, and
don't include a debug environment (i.e. the ability to set
breakpoints, explore stack, step through code visually etc.). Some do
include such an environment, including PyCharm and PyDev.

PostgreSQL also works fine on Windows. No idea about all the GIS stuff
though. If you're comfortable with using Linux, then go for it, but
most of the basic stuff you can do on Windows (until you need other
bits of software to make things work, like Redis). Unless you have a
preference for Windows though, I wouldn't use it as a Django app web
server in production; there's far less support on the net to help you
out when things go wrong.

I use ActiveState Komodo Edit on Windows to modify files on my Linux
VM which runs the web server for my Django apps. It means I don't get
a debug environment though; working on finding something to make that
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/-/2LQU1l81OyoJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-24 Thread Sam Lai
On 24 January 2012 07:58, JJ Zolper  wrote:
> Yes I knew I was in the Python shell I just never saw anything that
> described you couldn't make Django commands within the Python interpreter. I
> mean it is based on Python isn't it? That's where I thought logically you
> could make Django calls from in Python?

These 'Django commands' you're referring to, i.e. those involving
manage.py, are commands that are meant to be run from the command
prompt. You are executing a python script file, but they are not
Python commands.

> SO
>
> Is your best advice to have a OS prompt open in tandem with my Visual Studio
> Python Interpreter open? That being said that would be the best solution
> given my situation I suppose. However within the interpreter Python Tools
> for VS there may be limitations. That is what I've heard at least. I'm just
> referring to the interactive intellisense I think?..

VS doesn't work well outside of a VS project. Without one, it won't
know what your Python search path is, where all your code is located,
so you'll have minimal Intellisense (it'll know about the built-in
Python libraries, but not much else). You'll may also have issues
executing code because it doesn't know how to find all your code and
dependencies without the Python search path, and without that you'll
probably also lose the great debugging abilities of VS. All you're
really left with is a glorified syntax-checking text editor.

If you really want to do that, then the best solution is to open a
separate Command Prompt to run 'manage.py runserver' from. I mentioned
CPython before; that's just a name for the Python you download from
python.org. I used it to differentiate that from IronPython, which is
a .NET implementation of Python. I believe there are outstanding
issues with Django and IronPython, so it probably isn't worth trying
that.

You also seem to be confused with a Django project vs. a VS project. A
Django project simply defines the directory structure, and gives you a
few files to start with, including manage.py. This structure is how
Django is able to find the various files it needs.

A VS project is necessary to let VS know where all your files are,
where it should look for your Python packages etc. It is for VS to
know how to execute, debug and manage your code. Django does not know
anything about the VS project, and it shouldn't because it has nothing
to do with Django once Django is running.

Once you've created a VS Python Application project (ideally in the
same directory as your Django project), here's how to make it run the
built-in Django test server -

1. Right-click on your VS project in the Solution Explorer, and click
Properties.
2. Click on the Debug tab.
3. In 'Script Arguments', type 'runserver'.
4. Save the Project properties.
5. Add the files in your Django project to your project by
right-clicking on your VS project, Add, Existing item.
6. Right-click on manage.py and select 'Set as Startup File'.

To test, just go Debug -> Start Debugging or press F5.

I've had a quick play around; looks like the 'Execute project in
Python Interactive' option doesn't pass script arguments along, so
that won't work for running the test server, but then again, there's
nothing to interact with in the test server anyway. You can use that
option to test out models and the Django API though.

> Thank you for the tip on starting my server Andrew I will surely exit the
> Python interpreter and use a prompt!
>
> JJ Zolper
>
> --
> 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/-/y2Pz2JDeEo0J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-23 Thread Sam Lai
On 23 January 2012 15:22, JJ Zolper  wrote:
> Hello everyone,
>
> I was able to install Django to my machine and before I was using the
> command prompt. Django's path is in my Windows 7 64 bit Enterprise
> Environment variable. Python worked fine as well too. I also installed
> IPython because I heard it was useful but I haven't tried that yet.
> Everything has been good so far. I would like some input on what I am
> currently trying now.
>
> I have gone ahead and installed IronPython. I already had Visual Studio 2010
> on my computer so I was using that. I also installed Python Tools for Visual
> Studio. As I mentioned before I already have Python 2.7.2 installed.
>
> I was able to see the image/window in step 3
> here: http://pytools.codeplex.com/wikipage?title=Installation%20-%20details=Home
>
> It shows the options pane for Python Tools for Visual Studio. I was able to
> see that PT4VS (Python Tools for Visual Studio) was correctly including the
> location of the Python install at C:/Python27/python.py. Everything looked
> good there as it seems that Python was incorporated into PT4VS. I was trying
> to continue through the tutorial but I was having problems. I tried this
> command: python manage.py runserver but I only recieved a traceback error.

You've left out the most important bit - the actual traceback error. What is it?

If it can't find something, then it could be a PYTHONPATH issue.
Google tells me PT4VS may not support the usual way modules are
discovered (http://pytools.codeplex.com/discussions/254602), although
that should affect IronPython only, and not CPython (possibly
intellisense as well).

Inside PT4VS, in the interactive window, type in the following and
paste the result -

import sys
print sys.path

> Additionally in PT4VS there is a field for a startup script. I wrote one and
> here it is:
>
> import os
> import IPython
> import django
> os.chdir('c:\\MTDevelopment\\Django\\newartists')
>
> This so that I could change my directory to where my startproject was set
> with all the django web framework files. Also to import IPython and django
> as you see here. That seemed to work as I anticipated.

This smells like a hack. Your default working directory should already
be the directory your app is in. If it isn't, you need to check your
project settings (you are using a Python VS project right?).

> What I am asking you is why am I not able to get the full power of Django?
> In my command prompt I wasn't inside the python interpreter and ran the
> Django commands and everything worked fine. However, I was under the
> impression that with a Python interpreter in VS that I could have everything
> come in in a start up script and just go on my way coding with Django having
> set the directory to the location of my startproject?
>
> When I type: django and IPython into my PT4VS now I see:
>
 IPython
>  'C:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\__init__.pyc'>
 django
>  'C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\__init__.pyc'>
>
> so it is imported it correctly I think but I'm not able to use it. I've been
> working hard on teaching myself how to get all this set up and any help from
> you all would make my time working on this a lot easier!
>
> Thanks so much,
>
> JJ Zolper
>
> --
> 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/-/P5AJ334Yr8YJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: does php code works in Django

2011-10-20 Thread Sam Lai
On 20 October 2011 20:15, Chen Xu  wrote:
> Hi, everyone:
> I am new to Django, does anyone know whether php code works in Django?

This list's archives will have the answer to your question, and many
variations of it.

http://groups.google.com/group/django-users

The short answer is no; PHP and Python are two different languages,
and Django has a different way of structuring web apps, compared to
plain-old PHP.

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

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



Re: template newlines

2011-08-14 Thread Sam Lai
On 14 August 2011 14:00, Python_Junkie  wrote:
> I think that if you performed the logic to determine if there actually
> is something in the interest for that row in the view and
> then only pass those components from the view, and not in the template
> then your problem goes away.
>

I don't think so, but I haven't tested it. Django's template parser
does not remove newlines anywhere, even if only a template directive
exists on that line. For HTML, this isn't an issue. You can try
sacrificing template readability by putting everything on to one line.

There has been a fair bit of discussion about this, but no consensus
was arrived at. For now, the better solution is to use jinja2
(http://jinja.pocoo.org/). Its language is based on Django's, and is
largely compatible, but it has the added bonus of being able to remove
newlines like so,

{%- if interests|length > 0 %}
...
{%- endif %}

Notice the - after the % sign. This tells jinja2 to remove the
previous newline character. You can also add them at the closing % to
remove the following newline character.

It is pretty easy to use with Django (and many people do), and you can
just use it for this particular template, leaving all others to use
Django's in-built templating system.

>
> On Aug 13, 8:53 pm, CrabbyPete  wrote:
>> I'm using the django template system for format a text email. I send
>> it a dictionary and it formats the output. The problem is that it
>> inserts lots of newlines
>>
>> Here is the template, and reports is a dictionary that contains an
>> event and a dictionary of interests
>>
>> Weekly Contact List For {{date}}
>> {% for event, interests in report.items %}
>>     {% if interests|length > 0 %}
>>         {{event}}
>>         {% for interest, value in interests.items %}
>>             {{ value }} {% if value == 1 %} lead {% else %} leads {%
>> endif %} for {{ interest }}
>>         {% endfor %}
>>     {% endif %}
>> {% endfor %}
>>
>> Is there a way for it just to print the lines without adding all the
>> extra blank lines when interests = 0?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: uber weird access problem from windows

2011-05-23 Thread Sam Lai
On 23 May 2011 11:15, Kenneth Gonsalves  wrote:
> On Sat, 2011-05-21 at 08:04 -0400, AJ wrote:
>> Just out of curiosity, is it firefox 4? Is it seen with some of the
>> other
>> web forms too?
>
> just one form - I do not have access to that machine right now, but I do
> not think it is ff4. Will confirm.

Is installing Firebug an option? That might be able to give you some
visibility as to what it is doing - script issue, failed form submit
etc.

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

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



Re: haystack

2011-05-12 Thread Sam Lai
On 12 May 2011 17:31, pankaj sharma  wrote:
>
> can u tell me which one is better in sphinx and haystack

Haystack provides only the glue between Django and a search
engine/indexer. With Haystack, you still need to pick a search engine
to use, e.g. Solr, Whoosh, Xapian. It doesn't support Sphinx yet
though.

As for comparisons between Solr (Lucene), Xapian or Sphinx - it'll
depend on your situation, but they're fairly similar. Whoosh is
intended for smaller deployments. Best thing is to try them out. If
you decide on Sphinx, there's a django-sphinx to help you.

> On May 11, 10:01 pm, Tarkeshwar Thakur  wrote:
>> In your settings filehttp://docs.djangoproject.com/en/dev/topics/settings/
>>
>> On Thu, May 12, 2011 at 10:20 AM, pankaj sharma
>> wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> > hello friends, i want to use haystack for my website,
>> > but i am having too many problems to install it.
>> > in the dowumentation it is telling to add haystack to ur installed
>> > apps. now it it telling to do "HAYSTACK_SITECONF =
>> > 'myproject.search_sites'"
>> > now where should i type this i dont have any idea about so please help
>> > me
>>
>> >http://docs.haystacksearch.org/dev/tutorial.html
>>
>> > --
>> > You received this message because you are subscribed to the Google 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.
>>
>> --
>> - Tarkeshwar
>> Blog: tarkeshwar.com 
>> Pet project: operty.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.
>
>

-- 
You received this message because you are subscribed to the Google 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 & Two Factor Authentication (2FA)

2011-03-24 Thread Sam Lai
On 24 March 2011 07:52, pokecho  wrote:
> I am writing to ask whether it is possible to configure
> "django.contrib.auth"  so that it can implement Two Factor
> Authentication to step up login security.
>
> The idea is that instead authenticating against just "username" and
> "password" one could add another field say "passcode" which would
> receive a dynamic token or PIN for additional security.

Is a separate passcode field really necessary? Of all the 2FA auth
systems I've used, most ask the user to concatenate their
user-selected PIN and the generated code together to form the
password.

The only exception that I've encountered is 2FA Windows
authentication, and that was because the login screen still needed to
pass the user's Windows credentials on to the Windows logon process so
it could authenticate the user itself using the username and password
before logging them in. The extra password doesn't add much security;
it is only there to placate Windows requirements.

If you can repurpose the password field to be a PIN + token value
field, then a custom auth backend would be simple and all that's
required.

> I have tried to extend "User" by subclassing, while noting that there
> a couple of objections to this approach. I'm not a fan of monkey-
> patching and I am not quite sure adding fields using the documented
> 'ForeignKey' extension strategy will do the trick. In any case, when I
> try to login as admin after all the grunt work of subclassing, Python
> spits out all sorts of exceptions including the nefarious *None Type*
> --  'None Type' object has no attribute 'DoesNotExist'.
>
> Finally, assuming we can effectively implement 2 Factor
> Authentication, how would we ensure that the admin adapts to 2FA i.e.
> that its login form contains an additional "passcode" field for user
> token/PIN input and verification.
>
> I am new to Django, but not to Python so any assistance in this matter
> will be highly appreciated. Hacking this is like trying to resolve a
> rubix cube with one hand. So help me out here if you can.
>
> Patrick
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Syncing with an MS Exchange server...

2011-03-04 Thread Sam Lai
On 4 March 2011 23:23, illuminated  wrote:
> Hello everyone,
>
> Part of an application I'm developing at the moment is messaging and
> one of the features should be ability to access an MS Exchange user
> account (not through IMAP) and get his emails, contacts and calendars
> (the code is not hosted on same server as Exchange; not even on a
> Windows node).
>
> For some time I'm trying to find a way to achieve this but without
> success.
>
> Does anyone have at least an idea what should I be looking for? Has
> anyone written anything similar in Python? Any tip/suggestion
> appreciated.

If you can enforce a requirement for Exchange 2007 or later, the
easiest way would be to use Exchange Web Services, which are based on
SOAP messages. This I believe is how Apple implemented Exchange
support in OSX.

Reference - http://msdn.microsoft.com/en-us/library/bb204119.aspx

Example from Unix shell -
http://blogs.msdn.com/b/exchangedev/archive/2009/02/05/quick-and-dirty-unix-shell-scripting-with-ews.aspx

If you're familiar with Java, Microsoft has released the source code
to the Java version of their EWS client API here
(http://archive.msdn.microsoft.com/ewsjavaapi/Release/ProjectReleases.aspx?ReleaseId=5501).
You could consider using that as inspiration for whatever
functionality you need in Python.

If you have to support Exchange 2003, then you'll have to use WebDAV
to interact with Exchange. There are plenty of references for this one
the web. It is considered a legacy API though, and at some point in
the future, will probably be removed.

> My final move would be to look for opensource plugins for Evolution,
> Thunderbird, etc for Exchange synchronization and see how they did
> it...
>
> Thanks all,
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: curious about model classes

2011-03-03 Thread Sam Lai
On 3 March 2011 08:02, Alex Hall  wrote:
> Hi all,
> Still working through that tutorial. I am just curious: why are none
> of the class variables called self.var, but rather just var? For
> example:
> import models
> class Poll(models.Model):
>  question=models.CharField(max_length=200)
>
> Should that not be
> self.question=...
> instead? Otherwise, saying something like:
> poll=Poll()
> poll.question="question?"
> should not work; question is not told to be part of the class by way
> of self. This may stray from django and into pure python territory, so
> sorry if it gets off-topic. I have never seen a class that does not
> tie its variables to itself with self or some other keyword. Come to
> think of it, there is no __init__ method. I know that it is not
> necessary to have one, but I figured I would have seen one to get
> things set up.

Django uses the magic of metaclasses to build model instances - see
http://code.djangoproject.com/browser/django/trunk/django/db/models/base.py#L26

> --
> Have a great day,
> Alex (msg sent from GMail website)
> mehg...@gmail.com; http://www.facebook.com/mehgcap
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Authorization of static content

2011-02-23 Thread Sam Lai
On 23 February 2011 19:03, Joakim Hove  wrote:
> Hello,
>
> I am using Django to create an album application. I was planning to
> use djangos user system for authorization, however the final image
> viewing will be like:
>
>     
>
> Where image.url should resolve to something like 
> http://static-images.com/path/to/image.jpg
>
> Here http://static-images.com is another apache virtual host which
> only serves static content. However this scheme fails miserably when
> it comes to authorization - anyone can completely bypass my django app
> (with authorization) and point their browser to:
>
>    http://static-images.com/path/to/image.jpg
>
> Any suggestions of how to combine django based authorization with
> serving of static content? I am the owner of the box in question and
> can modify the apache setup way beyond my competence.

An alternate solution is to use Django to perform the authorization,
but pass the serving of the image file to the web server. This
question has come up before, so here's a link to the previous thread -

http://groups.google.com/group/django-users/browse_thread/thread/3216b31b8a03f1ca?pli=1

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

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



Re: population of *.html fields from Django

2011-02-07 Thread Sam Lai
On 7 February 2011 03:34, gintare  wrote:
> I would like to use only plain html field names
> Reading them is not a problem with request in views.
> How to populate html document back ?
>
>
> I have *.html with lines:
>
>
>   textarea>
>  
>  
>
> #in views.py
> item = request.POST.get('cbnWw','')
> #do smth with item
> #now i would like to return item back to html.
> #Normally i should use {{ }} for variable output.
> #IS IT POSSIBLE TO USE HTML SYNTAX  and populate textarea and
> checkboxes
>
>  return render_to_response('x.html',{ 'LangFROMt', 'EN'}, 
>
>
> ?

Nope, because Django's templating system doesn't know anything about
the template's structure/syntax. The templating system can be used for
more than just HTML (e.g. JSON, XML, CSV etc.).

What's wrong with using the {{ }} templating syntax? The alternative
you're suggesting makes things very confusing - the template will be
getting values from two different places, and what happens if there is
more than one form in the template with the same field name?

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

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



Re: Some beginners question

2011-01-31 Thread Sam Lai
On 31 January 2011 15:55, vishy  wrote:
> 1) I want to read files. Where should I put these files? I am not using a
> model to link to the files. And how to discover the path to files? I am
> working on windows, and in development environment I am using the full path
> to the file.

Wherever you want to. A little more to the point - what kind of files
are they? Will they be read-only? Where would be the most appropriate
location?

> 2) I created my own custom classes, but when I import into views.py, I get
> module not found. Why so? My custom classes are inside
> application\myclassfolder.

How are you importing them?

I suspect you're missing the blank __init__.py file required before
Python recognizes a directory as a module.

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

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



Re: How to write joins ?

2011-01-27 Thread Sam Lai
On 28 January 2011 16:07, sushanth Reddy  wrote:
> hi Sam,
>
> Here is example model:
>
> class Profile(models.Model):
>  name = models.CharField(max_length=50, primary_key=True)
>  assign = models.CharField(max_length=50)
>  doj = models.DateField()
>  dob = models.DateField()
>
>  class Meta:
>     db_table = u'profile'
>
>  def __str__(self):
>  return  '%s %s %s %s' % ( self.name,self.assign,self.doj,self.dob)
>
>  def __unicode__(self):
>  return  u'%s %s %s %s' % ( self.name,self.assign,self.doj,self.dob)
>
>
> class working(models.Model):
>    w_name =models.ForeignKey(Profile, db_column='w_name')
>    monday =  models.IntegerField(null=True, db_column='monday', blank=True)
>    tuesday =  models.IntegerField(null=True, db_column='tuesday',
> blank=True)
>    wednesday =  models.IntegerField(null=True, db_column='wednesday',
> blank=True)
>
>    class Meta:
>     db_table = u'working'
>
>    def __str__(self):
>  return  '%s %s %s %s' % (
> self.w_name,self.monday,self.tuesday,self.wednesday)
>
>    def __unicode__(self):
>  return  u'%s %s %s %s' % (
> self.w_name,self.monday,self.tuesday,self.wednesday)
>
 m=working.objects.filter(w_name__name='sushanth')
 m.query.as_sql()
> (u'SELECT `working`.`id`, `working`.`w_name`, `working`.`monday`,
> `working`.`tuesday`, `working`.`wednesday` FROM `working` WHERE
> `working`.`w_name` = %s ', ('sushanth',))

>
> But i am not getting any joins in above ...

Because you're not asking for any information that requires a join to
retrieve. You asked for all 'working' objects where the foreign key
name is 'sushanth'. As the primary key of Profile is the name field,
that value is also stored in the 'working' model. Therefore you
haven't asked for any information that requires the join.

The join will be requested when you traverse the join in your model, e.g.

 m=working.objects.filter(w_name__name='sushanth')
 print m[0].w_name.assign

If you want to avoid the second database hit, use select_related(), e.g.

 m=working.objects.filter(w_name__name='sushanth').select_related()

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

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



Re: newbie help with console, can't run Django function

2011-01-27 Thread Sam Lai
On 27 January 2011 14:26, Casual Coder  wrote:


> Is there a way to see what all got imported from django?

In Python, you can see what is available in each imported module by
using the dir function, e.g.

>>> import django
>>> dir(django)
['VERSION', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_
_path__', 'get_version']

If you want to see what has been imported into the root namespace
(can't think of the pythonic term at the moment), call dir without any
parameters, e.g.

>>> import django
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'django']

-- 
You received this message because you are subscribed to the Google 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 write joins ?

2011-01-27 Thread Sam Lai
On 28 January 2011 12:16, sushanth Reddy  wrote:
> HI,
>
> How to write joins in django,i have gone through below django documentation
> ,but joins are not working for my model
>



> Class working(models.model)
>   w_name =models.ForeignKey(Profile, db_column='name')
>   monday =  models.IntegerField(null=True, db_column='monday', blank=True)
>   tuesday =  models.IntegerField(null=True, db_column='tuesday', blank=True)
>   wednesday =  models.IntegerField(null=True, db_column='wednesday',
> blank=True)
>
>   class Meta:
>     db_table = u'working'
>
>   lass __str__(self):
>  return  '%s %s %s %s' % (
> self.w_name,self.monday,self.tuesday,self.wednesday)
>
>   class __unicode__(self):
>  return  u'%s %s %s %s' % (
> self.w_name,self.monday,self.tuesday,self.wednesday)
>
>
> I am trying to do join between two tables profile and workingday
>
>  like m=working.objects.filter(name='sushanth').select_related()
>
>
> if i run above query i'll get
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/pymodules/python2.6/django/db/models/manager.py", line 129,
> in filter
>     return self.get_query_set().filter(*args, **kwargs)
>   File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 498,
> in filter
>     return self._filter_or_exclude(False, *args, **kwargs)
>   File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 516,
> in _filter_or_exclude
>     clone.query.add_q(Q(*args, **kwargs))
>   File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line
> 1675, in add_q
>     can_reuse=used_aliases)
>   File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line
> 1569, in add_filter
>     negate=negate, process_extras=process_extras)
>   File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line
> 1737, in setup_joins
>     "Choices are: %s" % (name, ", ".join(names)))
> FieldError: Cannot resolve keyword 'name' into field. Choices are:  monday,
> tuesday, wednesday,  w_name

The error message is quite descriptive already. To perform the filter
on the foreign key field, you use the name of the foreign key, *not*
the name of the field the foreign key refers to. So this will work -

m=working.objects.filter(w_name='sushanth').select_related()

BTW, setting the name field in your Profile model as the primary key
is probably going to be a bad idea - what happens when two people have
the same name? An ID is probably better, and if you leave the
primary_key argument out, Django will automatically create one for
you.

Also, in Python, classes should be named in TitleCase by convention.

-- 
You received this message because you are subscribed to the Google 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's documention is horrible

2011-01-10 Thread Sam Lai
On 11 January 2011 13:39, Christophe Pettus  wrote:
>
> On Jan 10, 2011, at 1:25 PM, Simon W wrote:
>
>> For such a good web framework it's a shame that the documention is not 
>> structured well .. at all.
>
> I have no doubt that the project would be more than receptive to doc patches 
> to fix the problem.

This isn't about patches to the existing docs (which are great for
their purpose). It is about Django missing an API reference manual,
something like .NET Class Library Reference
(http://msdn.microsoft.com/en-us/library/gg145045.aspx), PHP's
Function Reference (http://www.php.net/manual/en/funcref.php) or
Java's (rather hideous looking) API reference
(http://download.oracle.com/javase/6/docs/api/).

I'm glad someone brought this up (although 'horrible' seems like too
strong a word). I miss not having these docs in some online form
because once you know enough about Django, you often know that Django
has capability x but you don't remember what class/namespace it is in.
You end up having to google and spend a while locating the info in the
existing docs. Browsing or grepping the code isn't much better (maybe
I'm missing an app or two here).

API docs also tend to be more structured and concise so you can
instantly see what parameters take what, what exceptions might be
thrown, what the return value is/represents etc.

Right now, I almost always have a browser tab open to
code.djangoproject.com for this purpose.

Talk/ideas are cheap, so here's my take on possible API docs for Django -

An API reference site structured in a similar manner to the above
examples, with the ability to easily search; integrated pydocs; links
to relevant sections of the Django docs; a link to see the code of the
function/class/method etc. A wiki-style section for each page would be
nice too to document caveats, tips, tricks, relevant snippets etc.

Of course the dynamic nature of the code makes this harder to do and
will probably require some human intervention to ensure an entry
exists for every parameter, mapped method etc.



P.S. what's the short answer to why the current Django docs aren't on
a wiki site instead of being versioned inside SVN?

There are some minor clarifications here and there that I'd like to
add, but the overhead of producing a patch, creating a ticket,
flagging down a committer, getting a consensus, and finally having the
patch committed is a bit off-putting. I can understand the process for
code, but it just seems a bit over-the-top for docs. Maybe a
compromise would be adding something like the per-paragraph comments
that The Django Book site has; that way the docs stay official, yet
there's still a way for users to add to them.

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

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



Re: merge 2 views?

2011-01-01 Thread Sam Lai
On 2 January 2011 00:56, bruno desthuilliers
 wrote:
> "simple_tag" is nothing new - it has been here since the 0.96 days
> IIRC.

But only the version in v1.3 has the ability to manipulate the context
object (which is what's needed in the suggested alternative solution),
thanks to the new takes_context parameter.

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



Re: merge 2 views?

2010-12-31 Thread Sam Lai
The one downside to this solution is that these variables will fetched
for every request, even if navigation.html was not included in the
output template.

An alternative solution would be to create a template tag that fetches
these variables, and only load and use this template tag in
navigation.html. That way those variables are only fetched if
navigation.html is included.

It's a little bit more complicated in code though (made a lot easier
in Django 1.3 with simple_tag), and might not be worthwhile if you
aren't doing complicated computations.

http://docs.djangoproject.com/en/dev/howto/custom-template-tags/

On 30 December 2010 05:32, Thom van Ledden  wrote:
> Thanks a lot for pointin me in the right direction!
>
> made a context_processor.py for my navigation, and added it to my
> settings.py
>
> from basic.blog.models import Category
> from common.models import fillNavigationFinishedProjects
> from common.models import fillNavigationUnfinishedProjects
>
> def navigation(request):
>    """
>    Adds navigation  variables to the context.
>
>    """
>    return {
>    'finishedProjects':fillNavigationFinishedProjects(),
>    'unfinishedProjects':fillNavigationUnfinishedProjects(),
>    'blogCategories':Category.objects.all(),
>    }
>
> Seems to work perfectly!
> thanks much!
>
> On 29 dec, 18:51, Michael  wrote:
>> Look into context processors, that sounds like what you need.
>>
>> http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-c...
>> --
>> Michael 
>>
>> On Wed, 2010-12-29 at 08:51 -0800, Thom van Ledden wrote:
>> > Hi django developers,
>>
>> > Ive got a seperate navigation.html file which need to be rendered on
>> > each page, but the page need some vars for that. how can i get those
>> > vars to be defined just only once?
>>
>> > my idea: the main_page should add the vars for the navigation, and the
>> > views of the content pages will have their own vars, and those need to
>> > be merged some how
>> > some files i uploaded:http://thomvl.pastebin.com/gGjGj4NP
>> >http://thomvl.pastebin.com/uYUp5iCjhttp://thomvl.pastebin.com/Yv6fPTP7
>>
>> > could anyone point me where i go wrong? (the main_page 's vars are the
>> > ones i need, aside of title ofcourse)
>>
>> > Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: De-coupling settings.py from project

2010-12-31 Thread Sam Lai
On 31 December 2010 03:50, eblume  wrote:
> In particular, I'm having trouble specifying the static content URL
> and the fixtures directories at a per-application level rather than in
> the project settings.py file.

Can't you implement a static files finder, in the similar way to
template loaders to achieve the same effect?

http://docs.djangoproject.com/en/dev/howto/static-files/

New in Django 1.3.

> Is there a way to specify settings like STATIC_URL or FIXTURES_DIRS
> per-application rather than per-site? Even better - is there a
> mechanism to use a settings.py file in the application rather than in
> the site?

As Christophe explained, it is possible, but I also agree with
Christophe - you're going to the extreme for very unlikely use cases.
Also keep in mind that every time Django handles a request, it will
import the settings for *every* app, instead of just the app you think
will be used to handle the request. Settings could then clash, making
debugging a pain.

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

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



Re: Replace URLResolver?

2010-12-28 Thread Sam Lai
On 28 December 2010 22:43, Martin  wrote:
> Hi.
>
> I would like to use subdomains in my URL-dispatch. Thats not supported
> by Django.
>
> Is it possible to replace Django URLResolver with my own? Must this be
> done as a Middleware class?

No, you can't really replace the default URLResolver without changing
any code in Django - lines 100-101 in django/core/handlers/base.py
(http://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py).
And even if you did, you would only be given the path_info of the
request, not the entire request object itself.

Your only option is middleware.

> (Why is Django URL resolver not implemented as a Middleware class?)

Besides what Brian said, it is probably for the same reason why regex
is the only way to specify URLs - there wasn't a need for anything
else when it was first designed, and given the current solution works
for nearly all cases, there have been minimal attempts to change it.

At some point, I'm considering rewriting the entire URL
resolution/reversal system to make it more modular, and submitting it
as a patch. (I bumped up against another limitation of it and had to
hack around it by changing Django code.) Don't hold your breath for
inclusion in a Django release any time soon though; as such a critical
part of Django, it'll probably be a while before it makes it into
trunk.

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

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



Re: unsupported operand type(s) for -: 'unicode' and 'int'

2010-12-23 Thread Sam Lai
I'd say you should check if the pagesize variable is a string or not
on this line -

upperbound=self.pagesize * int(arg0)

Remember in Python, 'hello' * 2 == 'hellohello'.

On 24 December 2010 05:04, prasad iyer  wrote:
> Hi Everyone,
> I am getting type error on integer. I have tried converting all the
> possible variables to int but still the problem persist. Can anyone
> help me out with this type error
> following is the stack trace
> http://dpaste.com/289886/
>
> following are the 2 functions which are giving me the problem
>
> def list_movies(request,page_no=1, orderby=None):
>        try:
>
>                page=int(page_no)
>        except ValueError:
>                page=1
>        if orderby is None:
>                orderby='-date_pub'
>        latest_movies=Movies.objects.all().order_by(orderby)
>        pagination=TubePagination(latest_movies, 20)
>        try:
>                page=int(page)
>                assert (type(page) is IntType)
>                movies=pagination.get_page(page)
>        except InvalidPage:
>                errorcontent='[{"error":"10001"}]'
>                return HttpResponse(content=errorcontent,mimetype='application/
> json')
>        json_serializer=serializers.get_serializer('json')()
>        jsonobj=json_serializer.serialize(movies, ensure_ascii=False)
>        return HttpResponse(content=jsonobj, mimetype="application/json")
>
>
>
>
> class TubePagination:
>        def __init__(self, arg0, arg1=1):
>                self.objs=arg0
>                self.pagesize=arg1
>        def get_page(self, arg0):
>                upperbound=self.pagesize * int(arg0)
>                if upperbound > len(self.objs):
>                        k=upperbound - len(self.objs)
>
>                        if  k > self.pagesize :
>                                raise InvalidPage(arg0)
>                        else:
>                                lowerbound=len(self.objs) - (len(self.objs) % 
> self.pagesize)
>                else:
>                        lowerbound=upperbound-self.pagesize
>                if lowerbound < 0:
>                        lowerbound = 0
>                return self.objs[lowerbound:upperbound]
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Haystack error rebuinding index

2010-12-20 Thread Sam Lai
2010/12/21 Daniel França :
> anyone?
>
> 2010/12/19 Daniel França 
>>
>> Hi all
>> I was using haystack(xapian) at a Mac, so I moved it to a Linux (Ubuntu
>> 10.10) using python 2.6.6, but now when I try to rebuild the index I get the
>> following error:
>> AttributeError: 'ProfileIndex' object has no attribute 'full_prepare'
>> ProfileIndex is my index, I didn't created a full_prepare atribute, but I
>> wonder that haystack created that for me, right?

full_prepare is a method in the SearchIndex class in Haystack. Does
ProfileIndex inherit from SearchIndex?

Maybe haystack isn't installed properly and Python can't find the
SearchIndex class? Although that should be a different error I
believe.

>> Anyone has any idea where can be the error? and how can I fix it?
>>
>> my Django version: 1.2.3
>> Best Regardds,
>> Daniel França
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Developing a search engine

2010-12-15 Thread Sam Lai
On 16 December 2010 08:56, marcoarreguin  wrote:
> I'm trying to make a search engine with my database, parsing de text
> that the user write in the textbox to make a list with the cleaned
> words, in just one table of the DB in the fields: title, descripcion
> and tags, I have something like this but I don't know how to finish
> it:

You're trying to do what's called full text search (FTS), and
databases out of the box are horrible at doing that (i.e. without the
FTS components). You'll run into all kinds of issues trying to
construct the query, and the performance will be bad.

If you're using MySQL, Django can interface with its FTS component -
http://docs.djangoproject.com/en/dev/ref/models/querysets/#search

Otherwise, I suggest using one of the open source search engines
(Solr, Whoosh, Xapian etc.) and using Haystack to connect it to
Django. Whoosh is a nice, easy choice and works for sites with small
amounts of traffic.

http://haystacksearch.org/

>
> from django.http import HttpResponse
> from django.shortcuts import render_to_response
> from myproject.parsing.models import Stores
> from pyparsing import *
> from django.db.models import Q
>
> def search_form(request):
>    return render_to_response('search_form.html')
>
> def search(request):
>        errors= []
>        if 'q' in request.GET:
>                q = request.GET['q']
>        if not q:
>                errors.append('Write something')
>        else:
>                qclean= parseText(q)
>                for Word in qclean:
>                        Foundstores = 
> Stores.objects.filter(Q(name__icontains=Word) |
> Q(description__icontains=Word) | Q(tags__icontains=Word))
>
>                        #But remeber that I have more than one word,
> so I need to concatenate all the querysets of each one of the words in
> qclean
>
>                return render_to_response('search_results.html', {'Found':
> Foundstores, 'query': qclean})
>
>        return render_to_response('search_form.html', {'errors': errors})
>
>
>
> def parseText(texto):
>        parser=OneOrMore(Word(alphas))
>        #articles in spanish
>        arreglo=("de","en","la")
>        for articulo in arreglo:
>                parser.ignore(CaselessLiteral(articulo))
>        salida=parser.parseString(texto)
>        return salida
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: DateTimeField doesnt get future date.

2010-12-12 Thread Sam Lai
On 13 December 2010 13:45, Recep KIRMIZI <rkirm...@gmail.com> wrote:
> On Mon, 13 Dec 2010 13:33:37 +1100
> Sam Lai <samuel@gmail.com> wrote:
>
>> Sounds odd. What is the future date you're entering? Are you sure your
>> system has the right date format set, e.g. you're not entering a
>> MM/dd/ date when the system is expecting a dd/MM/ date or vice
>> versa?
>>
> This is what i tried just now:
> Date: 23/12/2010
> Time: 12:00:00
> i've set these values from the datepicker applet in admin panel.
>
> now i recognized sth. I guess it's expecting as u said. MM/dd/
> bec. i've chosen a past date and it works. Coinsidencely today is 13rd. of 
> December. so the days before this date in this month are like 11/12/2010 so 
> it 's ok both day or month less then 12 :)
> i tried past month. 25th it failed again. how can i change the default 
> datetime format?

Windows or Linux?

>> On 13 December 2010 08:29, Recep KIRMIZI <rkirm...@gmail.com> wrote:
>> > Hi i have a model which has a datetime field like
>> >
>> >    pub_date = models.DateTimeField("Etkinlik Tarihi")
>> >
>> > this model is written to organize some events in a cafe. when i m trying 
>> > to create some events from the admin panel. if i choose today and now from 
>> > the date widget in admin; it works. if i choose a past date it works too. 
>> > But if i choose a future date, it says. Enter a valid date. i dont know is 
>> > it a bug about django or did i do sth. wrong in my model. here is my whole 
>> > model.
>> >
>> > p.s.: i'm using django trunk on my server
>> >
>> > (InteractiveConsole)
>> >>>> import django
>> >>>> django.VERSION
>> > (1, 3, 0, 'alpha', 1)
>> >>>>
>> > --
>> > #!/usr/bin/python
>> > #-*- coding: utf-8 -*-
>> > from django.db import models
>> > from photologue.models import Photo
>> >
>> > class Etkinlik(models.Model):
>> >    name = models.CharField("Etkinlik Adı", max_length=100)
>> >    text = models.TextField("Etkinlik Metni", max_length=2000)
>> >    foto = models.ForeignKey(Photo)
>> >    pub_date = models.DateTimeField("Etkinlik Tarihi")
>> >    is_active = models.BooleanField("Aktif", default=True)
>> >
>> >    class Meta:
>> >        get_latest_by = "pub_date"
>> >        verbose_name = "Etkinlik"
>> >        verbose_name_plural = "Etkinlikler"
>> >
>> >    def __unicode__(self):
>> >        return u"%s - %s" %(self.name, self.text)
>> >
>> >    def get_absolute_url(self):
>> >        return "/etkinlik/%i/" % self.id
>> > --
>> >
>> >
>> > --
>> > Yours,
>> > Recep KIRMIZI <rkirm...@gmail.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-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at 
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
> --
> Recep KIRMIZI <rkirm...@gmail.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: DateTimeField doesnt get future date.

2010-12-12 Thread Sam Lai
Sounds odd. What is the future date you're entering? Are you sure your
system has the right date format set, e.g. you're not entering a
MM/dd/ date when the system is expecting a dd/MM/ date or vice
versa?

On 13 December 2010 08:29, Recep KIRMIZI  wrote:
> Hi i have a model which has a datetime field like
>
>    pub_date = models.DateTimeField("Etkinlik Tarihi")
>
> this model is written to organize some events in a cafe. when i m trying to 
> create some events from the admin panel. if i choose today and now from the 
> date widget in admin; it works. if i choose a past date it works too. But if 
> i choose a future date, it says. Enter a valid date. i dont know is it a bug 
> about django or did i do sth. wrong in my model. here is my whole model.
>
> p.s.: i'm using django trunk on my server
>
> (InteractiveConsole)
 import django
 django.VERSION
> (1, 3, 0, 'alpha', 1)

> --
> #!/usr/bin/python
> #-*- coding: utf-8 -*-
> from django.db import models
> from photologue.models import Photo
>
> class Etkinlik(models.Model):
>    name = models.CharField("Etkinlik Adı", max_length=100)
>    text = models.TextField("Etkinlik Metni", max_length=2000)
>    foto = models.ForeignKey(Photo)
>    pub_date = models.DateTimeField("Etkinlik Tarihi")
>    is_active = models.BooleanField("Aktif", default=True)
>
>    class Meta:
>        get_latest_by = "pub_date"
>        verbose_name = "Etkinlik"
>        verbose_name_plural = "Etkinlikler"
>
>    def __unicode__(self):
>        return u"%s - %s" %(self.name, self.text)
>
>    def get_absolute_url(self):
>        return "/etkinlik/%i/" % self.id
> --
>
>
> --
> Yours,
> Recep KIRMIZI 
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: FileField and location and storage

2010-12-08 Thread Sam Lai
Some more background -

If you look at lines 228 to 230 of django/db/models/fields/files.py,
you'll see that the generate_filename method is overwritten by your
upload_to method if you specify one.

228 self.upload_to = upload_to
229 if callable(upload_to):
230 self.generate_filename = upload_to

On 9 December 2010 15:43, Sam Lai <samuel@gmail.com> wrote:
> I have a custom file storage working with a specific subdir structure.
>
> Did you pass in a method specifying the path in the upload_to kwarg
> for FileField?
>
> Here's my model code, where EnhancedFileSystemStorage is my custom
> file storage class, and get_random_dir_name is just a helper method
> that does exactly as named.
>
>    file_storage = EnhancedFileSystemStorage(location=settings.DYNMEDIA_ROOT,
>                                             base_url=settings.DYNMEDIA_URL)
>
>    def file_upload_to(instance, filename):
>        return os.path.join(get_random_dir_name(instance.file_storage.location,
> filename), filename)
>
>    file = models.FileField(upload_to=file_upload_to, storage=file_storage)
>
> On 9 December 2010 05:24, dmitry b <dmitry.ma...@gmail.com> wrote:
>> Hi,
>>
>> I've written a custom Storage that uses WebDAV as its underlying
>> engine.  When I save a file '/foo/bar/file.ext', I want it to be saved
>> under /foo/bar in the webdav filesystem.  However, it seems that
>> FileField overrides the directory structure:
>>
>>    def generate_filename(self, instance, filename):
>>        return os.path.join(self.get_directory_name(),
>> self.get_filename(filename))
>>
>> where get_directory_name() is defined as
>>
>>    def get_directory_name(self):
>>        return
>> os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(self.upload_to
>>
>> I'm not really sure why FileField finds it appropriate to impose its
>> own directory structure on the underlying storage engine.  But short
>> of creating a custom subclass of FileField and overriding
>> generate_filename and/or get_directory_name(), is there a different
>> way of preserving the original file location path?
>>
>>
>> Thanks
>> Dmitry
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: FileField and location and storage

2010-12-08 Thread Sam Lai
I have a custom file storage working with a specific subdir structure.

Did you pass in a method specifying the path in the upload_to kwarg
for FileField?

Here's my model code, where EnhancedFileSystemStorage is my custom
file storage class, and get_random_dir_name is just a helper method
that does exactly as named.

file_storage = EnhancedFileSystemStorage(location=settings.DYNMEDIA_ROOT,
 base_url=settings.DYNMEDIA_URL)

def file_upload_to(instance, filename):
return os.path.join(get_random_dir_name(instance.file_storage.location,
filename), filename)

file = models.FileField(upload_to=file_upload_to, storage=file_storage)

On 9 December 2010 05:24, dmitry b  wrote:
> Hi,
>
> I've written a custom Storage that uses WebDAV as its underlying
> engine.  When I save a file '/foo/bar/file.ext', I want it to be saved
> under /foo/bar in the webdav filesystem.  However, it seems that
> FileField overrides the directory structure:
>
>    def generate_filename(self, instance, filename):
>        return os.path.join(self.get_directory_name(),
> self.get_filename(filename))
>
> where get_directory_name() is defined as
>
>    def get_directory_name(self):
>        return
> os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(self.upload_to
>
> I'm not really sure why FileField finds it appropriate to impose its
> own directory structure on the underlying storage engine.  But short
> of creating a custom subclass of FileField and overriding
> generate_filename and/or get_directory_name(), is there a different
> way of preserving the original file location path?
>
>
> Thanks
> Dmitry
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Django in production on Windows

2010-12-07 Thread Sam Lai
Eeek. Just had a poke around with getting Django running on IIS.

Making it work with FastCGI will need a bit of work; doesn't work out
of the box and isn't well documented as most of the focus has been on
PHP.

It does seem to work ok with PyISAPIe. I'd probably install Apache and
use that instead though, either replacing IIS, or using IIS as a
reverse proxy to Apache.

On 8 December 2010 11:07, Sam Lai <samuel@gmail.com> wrote:
> On 8 December 2010 02:50, shmengie <1st...@gmail.com> wrote:
>> www.cygwin.com is one possible windows avenue that might work.  When I
>> was hanging on to windows because I had to support it, I used cygwin
>> religiously.  I found a lot about cygwin to be frustrating, but it was
>> better than being w/out unix/linux all-together.
>
> That isn't really going to help. The issue isn't *nix compatibility,
> but connecting Django with IIS. FastCGI is the official way to go; the
> other ISAPI modules are the next best thing.
>
> I work with both platforms, and I've lost count the number of times
> I've typed 'ls' into a Windows command prompt and have it error out :)
> Luckily it works in PowerShell, which is one of the things that
> Windows does that's better than *nix.
>
>> Unless you absolutely positively must remain a Windows/Microsoft
>> supporter, I recommend grabbing an old decommissioned box and slap
>> Linux on it.  It's gotten a lot easier with the latest distributions.
>> I use Ubuntu for most, but Cent-os might be just what you need, and
>> I've heard good things about Mint, but haven't gone there.  If you can
>> live without the Xwindows/GUI almost *any* machine will work and
>> perform just fine.  W/Google and apt-get command line, you should be
>> able to get a box up and running inside of a couple of hours.
>
> It doesn't work like that in corporate environments. You can't just
> set up a box and connect it to the network - the IT admins will scream
> at you (at the very least). They need to be properly assessed,
> configured, and most importantly maintained - an improperly
> maintained/configured *nix box isn't secure either. And as OP doesn't
> have any *nix admins, it isn't going to happen unless they hire or
> outsource.
>
>> I can imagine Linux is frightening, but it doesn't need to be.  For me
>> it's like a big box of toys, you might have to do a fair amount of
>> reading, but there's a lot of good documentation and Google can be
>> your friend.  I prefer googling linux issues over Microsoft Technet
>> issues.  Tech-net can be such a royal PITA.
>
> It isn't utopia on the Linux side either - with the slight variations
> between every Linux distro, often solutions you find don't exactly
> work because of some annoying difference (versions, config paths,
> location of files, default packages etc.).
>
>> Argh, soo far off topic, my apologies.
>
> So back to on to the topic -
>
> Is the issue that FastCGI isn't up to scratch in terms of performance,
> or is it not working at all?
>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: Django in production on Windows

2010-12-07 Thread Sam Lai
On 8 December 2010 02:50, shmengie <1st...@gmail.com> wrote:
> www.cygwin.com is one possible windows avenue that might work.  When I
> was hanging on to windows because I had to support it, I used cygwin
> religiously.  I found a lot about cygwin to be frustrating, but it was
> better than being w/out unix/linux all-together.

That isn't really going to help. The issue isn't *nix compatibility,
but connecting Django with IIS. FastCGI is the official way to go; the
other ISAPI modules are the next best thing.

I work with both platforms, and I've lost count the number of times
I've typed 'ls' into a Windows command prompt and have it error out :)
Luckily it works in PowerShell, which is one of the things that
Windows does that's better than *nix.

> Unless you absolutely positively must remain a Windows/Microsoft
> supporter, I recommend grabbing an old decommissioned box and slap
> Linux on it.  It's gotten a lot easier with the latest distributions.
> I use Ubuntu for most, but Cent-os might be just what you need, and
> I've heard good things about Mint, but haven't gone there.  If you can
> live without the Xwindows/GUI almost *any* machine will work and
> perform just fine.  W/Google and apt-get command line, you should be
> able to get a box up and running inside of a couple of hours.

It doesn't work like that in corporate environments. You can't just
set up a box and connect it to the network - the IT admins will scream
at you (at the very least). They need to be properly assessed,
configured, and most importantly maintained - an improperly
maintained/configured *nix box isn't secure either. And as OP doesn't
have any *nix admins, it isn't going to happen unless they hire or
outsource.

> I can imagine Linux is frightening, but it doesn't need to be.  For me
> it's like a big box of toys, you might have to do a fair amount of
> reading, but there's a lot of good documentation and Google can be
> your friend.  I prefer googling linux issues over Microsoft Technet
> issues.  Tech-net can be such a royal PITA.

It isn't utopia on the Linux side either - with the slight variations
between every Linux distro, often solutions you find don't exactly
work because of some annoying difference (versions, config paths,
location of files, default packages etc.).

> Argh, soo far off topic, my apologies.

So back to on to the topic -

Is the issue that FastCGI isn't up to scratch in terms of performance,
or is it not working at all?

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

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



Re: Javascript and template rendering problem

2010-11-29 Thread Sam Lai
On 30 November 2010 07:03, Anderson Goulart  wrote:
> Hi,
>
> How can I render to a javascript code a variable set in a view? I tried {{ 
> variable }} but it returns nothing in the html source code. When I put this 
> {{ variable }} outside 

Re: WEB SERVICE IN DJANGO USING SOAP

2010-11-27 Thread Sam Lai
I don't know much about converting WSDL to SOAP/REST in Django.
Probably easier with SOAP as WSDL and SOAP are often used together.

You need to check if the first character is actually the BOM. Open the
file in a hex editor and see what the first byte is. It might not be.
A quick Google tells me expat should be able to deal with the BOM, so
it might be some other character. In any case, the first character
needs to be the < character. There can't be any visible/invisible
characters preceding it, e.g. a newline.

If the first two bytes are FE FF then it is the BOM.

On 27 November 2010 19:09, sami nathan  wrote:
> After opening and closing also showing me the same result i cant say
> not to output the BOM to generator b coz its an another person who
> generated and gave to me and asking me to create web service using
> just wsdl file and given me open choice of use rather SOAP or REST i
> also decided to use REST now will u refer me the tutorial to rest and
> also to solve above problem
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: WEB SERVICE IN DJANGO USING SOAP

2010-11-26 Thread Sam Lai
No, you need that line. It is the first *character* of the file that
you need to remove. It is an *invisible* character. Try opening and
closing it in notepad; it might remove it. Otherwise, can you get your
WSDL generator to not output the BOM?

Or, you could use python to read and rewrite that file without the BOM.

On 27 November 2010 18:13, sami nathan  wrote:
> encoding="UTF-8"?> should i remove this from wsdl file...? and more
> over i am trying to use my system as  server i am refering dive into
> python chapter 12 introspecting wsdl and searching google i cant find
> weather its an client side code or server side code but i am in need
> of server side code do u find any refrence for me to study server side
> code using SOAP or REST sorry if i had asked anything wrong i am
> newbee
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: WEB SERVICE IN DJANGO USING SOAP

2010-11-26 Thread Sam Lai
How was the WSDL generated? Was it done on a Windows machine? If so,
it writes a Byte Order Mark at the start of Unicode documents by
default. *nix and Python however doesn't expect BOMs, so it chokes.

You need to remove the BOM from your WSDL file.

On 27 November 2010 17:46, sami nathan  wrote:
> Thanks for notification I am trying to develop web service using
> django with soap interface i checked my code in python to open wsdl
> file but its showing error i am sure that wsdl file dosent have any
> errors this is my code>>> from SOAPpy import WSDL
>>> server=WSDL.Proxy('D/soap/FlyppSms.wsdl')
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "D:\Python25\Lib\site-packages\SOAPpy\WSDL.py", line 67, in __init__
>    self.wsdl = reader.loadFromString(str(wsdlsource))
>  File "D:\Python25\Lib\site-packages\SOAPpy\wstools\WSDLTools.py", line 47, in
> loadFromString
>    return self.loadFromStream(StringIO(data))
>  File "D:\Python25\Lib\site-packages\SOAPpy\wstools\WSDLTools.py", line 28, in
> loadFromStream
>    document = DOM.loadDocument(stream)
>  File "D:\Python25\Lib\site-packages\SOAPpy\wstools\Utility.py", line 602, in 
> l
> oadDocument
>    return xml.dom.minidom.parse(data)
>  File "D:\Python25\Lib\site-packages\_xmlplus\dom\minidom.py", line 1915, in 
> pa
> rse
>    return expatbuilder.parse(file)
>  File "D:\Python25\Lib\site-packages\_xmlplus\dom\expatbuilder.py", line 930, 
> i
> n parse
>    result = builder.parseFile(file)
>  File "D:\Python25\Lib\site-packages\_xmlplus\dom\expatbuilder.py", line 207, 
> i
> n parseFile
>    parser.Parse(buffer, 0)
> xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 
> 1
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: how to configure database?

2010-11-22 Thread Sam Lai
How does it 'not seem to work'?

Are these two apps within the same project? In that case, they should
by default use the same database.

On 23 November 2010 07:32, pa_ree  wrote:
> hello, i'm new to django framework.
>
> i want to know how can i configure a single database to two
> applications.
>
> the problem is essentially, that i first created a database and an
> application in two subparts, and configured the database to the first
> part of application. Now i want to link the second part of my app into
> the same database.
> In settings.py in INSTALLED_APPS i have included both, still it doesnt
> seem to wrk.
>
> any solution?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Problems firing up django site

2010-11-22 Thread Sam Lai
You'll have to provide more information - what site, what have you tried?

But before you do that - start with the Django tutorial. It is very
detailed, and should help you get started.

http://docs.djangoproject.com/en/1.2/intro/tutorial01/

On 23 November 2010 04:22, Bonucci  wrote:
> Hii guys, im having some problems, i downloaded a website, and its in
> django, i installed django in my ubuntu, but now i cant fire him up,
> can somenody help me?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: question about involve "vncserver" command with django

2010-11-10 Thread Sam Lai
Why can't you tell vncserver to listen on a different port?

the vncserver script passes any unknown args to Xvnc, so you can use
the argument for Xvnc to change the port (-rfbport port_number).

man vncserver: http://www.realvnc.com/products/free/4.1/man/vncserver.html
man Xvnc: http://www.realvnc.com/products/free/4.1/man/Xvnc.html

On 10 November 2010 06:33, Bill  wrote:
> Hi all,
>
> I met a problem, I can use python to execute the the command
> "vncserver " to start vncserver use subprocess,
> like this:
> process = subprocess.Popen('vncserver' , shell=True)
>
> but when I write this code to views.py it didn't work as I hope.
> The Xvnc process listened on the port which Django used.
>
> For example,  django listen on tcp port 8000, and the Xvnc also listen
> on tcp port 8000.
> It's wired.
>
> Is there any way to involve the vncserver?
>
>
> Regards,
> Bill
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Trouble accessing development server

2010-11-10 Thread Sam Lai
Do you have a dedicated IP?

If not, you're pretty much out of luck with the development server.

http://helpdesk.hostmonster.com/index.php/kb/article/000405

On 11 November 2010 04:28, Engywook  wrote:
> Hmm... none of the below work. Also doesn't seem to matter if I use
> port 8000 or port 8100 or any other.
>
> What does happen, in the browser, is that it appears to be
> continuously trying to load the page. It doesn't matter if I have the
> server running or not.
>
> On Nov 10, 4:57 am, bruno desthuilliers
>  wrote:
>> On 9 nov, 22:39, Shawn Milochik  wrote:
>>
>> > Instead of the domain try 0.0.0.0 or your public IP address.
>>
>> > python manage.py runserver 0.0.0.0:8000
>>
>> > or
>>
>> > python manage.py runserver 82.165.105.204:8000 #this is just a sample
>> > IP address for Host Monster
>>
>> 
>> It's also possible that HostMonster just blocks port 8000
>> 
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: my first (public) app: django-requires_js_css

2010-10-24 Thread Sam Lai
On 21 October 2010 16:01, Jason Persampieri  wrote:
> http://github.com/pappy74/django-requires_js_css
>
> Howdy folks,
>
> I was hoping to get some feedback on my first public app, django-
> requires_js_css.  The app's purpose is to allow 'sane' JavaScript and
> CSS requirements.  That is, require from within templates, but still
> load using 'best practices'.

Another item off my to-do list. Thanks!

> Definitely a work in progress, although we are using it at our
> startup.  My questions to you:
> - Is there another app that does this?

Not that I know of.

> - Do other devs find this worthwhile?

Yep. My use case was to allow the addition of SyntaxHighlighter
brushes as required by the posts on the page. (This is now moot as of
the new version of SH, as it will now dynamically load brushes, but I
can envision other use cases for this.)

> - What's missing?
> - I currently use a fairly gnarly hack to make this all work
> (embedding tokens in the response content, then post-processing those
> tokens using middleware).  Is there a better way?

Other than how it is implemented now, the nicer way is what Doug has
described. Not sure if it is possible though/might require some Django
patches.

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

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



Re: Path issue on Linux

2010-10-17 Thread Sam Lai
Python should already by in your PATH when you installed the package
from the Ubuntu repositories.

I think your issue is that your manage.py is not executable. In the
directory containing manage.py, type

chmod u+x manage.py

Then you should be able to just type ./manage.py 

On 18 October 2010 08:00, Sithembewena Lloyd Dube  wrote:
> Hi all,
>
> How would I set up my path so that  I don't always have to type 'python
> manage.py '? On Windows, I would add the directory containing the
> python file to my system path. How can I do this on Linux?Am working on
> Ubuntu 10.04. Thanks.
>
> --
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Using a non-DB backend

2010-10-15 Thread Sam Lai
On 16 October 2010 00:21, Damir Dezeljin  wrote:
> Hi.
> I'm working on an application tat communicates with embedded devices
> connected to the LAN. The devices are controlled by a central server written
> in C++. Django is used for the front-end or better to say the GUI for the
> server.
> Part of the data the user needs access too are stored in the database, hence
> the Django DB API to access this data; however, there are certain data and
> actions that requires direct communication with the C++ server. The
> communication is implemented using CORBA (OmniORBpy). E.g. of a situation
> where the CORBA interface between the GUI and the server is needed is the
> flush of devices configuration or update of the following and this should be
> real time and not implemented polling the DB.
> Currenly I'm instantiating the CORBA interface to my server in the views.py.
> I'm wondering if there is a better way to do it as I just don't see how
> could I put the CORBA interface in the Model part of the GUI? << I'm still
> confused by MVC approaches certain frameworks like CakePHP use. I think
> Django is not such a framework; however, I still think I should somehow
> separate the data layer from the business logic (bottomline: Django is still
> kind of a MVC framework). How can I do this?
> Of course I would also like to solve the problem I'm currently facing:
> Let's suppose both the C++ server and Django web site are up and running. If
> the C++ server is restarted the web page doesn't work any more until when I
> restart the web server too. I instantiate the CORBA object in a global
> scope; however, I thought there is no persistence for the Django code
> between the web browser calls. Am I right? Why the connection to CORBA
> ceases working in such a case? << with e.g. C++ or Python stand-alone
> clients the connection is reestablished each time the script / program / ...
> is executed.

That is an implementation detail left up to the web server. If you are
using mod-wsgi, then instances are reused for future requests (by
default), hence your problem.

There may also be some thread-safety issues with instantiating the
CORBA object in the global scope you may want to think about. I'd
probably instantiate the CORBA object once per request by doing so
inside the view (or by instantiating another class that does that, as
well as provide methods to access properties).

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

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



Re: Help with http basic authentication

2010-10-12 Thread Sam Lai
On 12 October 2010 22:29, Morten Pedersen  wrote:
> Hi everyone
> I would be very very gratefull for any help getting access to the basic http 
> user and password through Django.

As far as I know, HTTP Basic Authentication occurs at the HTTP
connection level, i.e. it is between the web server and browser. There
is no way for Django to access that.

What usually happens is people use 'forms authentication' instead.
Django has a built-in authentication app - see
http://docs.djangoproject.com/en/dev/topics/auth/

> A simple app that print out the password an user to the browser would really 
> help me very very much.
>
> Cheers
> Morten Pedersen
> Denmark
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: WANT TO SEND REQ TO URL GET RESPONSE FROM THE SAME URL

2010-10-12 Thread Sam Lai
On 12 October 2010 22:56, sami nathan  wrote:
> Hello sir,
> I need to display the reult of
>           "http://m.broov.com/wap/di/sub?word=dog=00=Submit;
> in my url which is
> http://localhost/flip/wap/di/sub?word=dog=00=Submit
> My view looks like this
> from django.http import *
> from django.template import loader, Context
> from django.shortcuts import render_to_response
>
> def current_datetime(request):
>   word = request.GET['word']
>
> url=HttpResponse('http://m.broov.com/wap/di/sub?word='+word+"type=00submit=Submit')
>   return (url)
>
>
>    i want response from this site to be displayed not url of the site
> i want to only return the response from this site but i am getting oly
> url of this site displayed

Use a HttpResponseRedirect instead to redirect the user to that URL, e.g.

from django.http import HttpResponseRedirect
url=HttpResponseRedirect("blah")
return url

That will redirect the user, i.e. the user's URL will change.

If you don't want that to happen, you'll need to use python's urllib
to make a request to that URL, get the response, and pass that
response forward using HttpResponse.

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

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



Re: convert list into a comma separated string

2010-10-05 Thread Sam Lai
On 4 October 2010 21:41, ashy  wrote:
> Hi All,
>
> I am writing a django function in which I have a following list:
> li = ['a','b','c']
> I want to create a string from the list which should look like
> str = 'a,b,c'
>
> I plan to pass this string to not in () function of my sql query.

If you're using the Django ORM, you can do this without writing your own SQL.

model.objects.exclude(field__in=li)

Where model is your model class, and field is the name of the field
you want to apply the 'not in' filter on.

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

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



Re: Upload a File using the request.POST data

2010-09-27 Thread Sam Lai
On 27 September 2010 14:31, Danny Bos <da...@stateempire.com> wrote:
> There is no form, it's entirely Javascript.
> Spoke to the creator of the script, who has popped up script examples
> for PHP and ColdFusion he reckons:
>
> "You basically have to put the whole post contents into a file."

Hmm... a little difficult seeing as Django parses the POST contents
into a string first, so it has probably done irreversible things to
it.

There is HttpRequest.raw_post_data though, but not sure what format
that is in. If it is just bytes, you could just stream that to
wherever you need it to be.

> Not altogether helpful, eh?
>
> d
>
>
> On Sep 27, 1:52 pm, Sam Lai <samuel@gmail.com> wrote:
>> Have you got the right attribute in the form?
>>
>> Fromhttp://docs.djangoproject.com/en/dev/topics/http/file-uploads/
>>
>> "Note that request.FILES will only contain data if the request method
>> was POST and the  that posted the request has the attribute
>> enctype="multipart/form-data". Otherwise, request.FILES will be
>> empty."
>>
>> On 27 September 2010 13:21, Danny Bos <da...@stateempire.com> wrote:
>>
>> > Can it even be done?
>> > It seems pretty ordinary but everything I'm trying expects it to be a
>> > request.FILE.
>>
>> > Frustrating stuff.
>>
>> > d
>>
>> > On Sep 27, 11:24 am, Danny Bos <da...@stateempire.com> wrote:
>> >> Heya,
>>
>> >> I'm using the 'Valums File Uploader' which passes the file in the
>> >> request.POST as you can see below. I'm wondering how to get that data
>> >> into an actual file. Any ideas would be great as things like "for
>> >> chunk in f.chunks()" only works on request.FILES which in this case is
>> >> empty.
>>
>> >> Thanks,
>> >> Hope all is well your side of the planet.
>>
>> >> Eg DATA:
>>
>> >> GET:,
>> >> POST:> >> \ufffd\x03\ufffd\x05\ufffd\ufffd\ufffdC\ufffdC\x1b\ufffd\ufffd\x0f/
>> >> \x1eY:\ufffdZ\ufffd \ufffd8': [u''], u'5]]\x1f\u04ff\x7f\ufffd\ufffd
>> >> \ufffd\x0f\x054\x15\u0622i\x1c\ufffd(\ufffdG\x01 \ufffd\x03u
>> >> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
>> >> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
>> >> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
>> >> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\ufffd\ufffd\ufffd$X]]
>> >> \u0775k\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdt\ufffd_2\x13\ufffd\u01cf
>> >> \x1fkkk\ufffd\ufffd\ufffdUe\ufffd\ufffd\ufffd\ufffdt2\u04ef\x1f?~|
>> >> \ufffd\u0529\ufffd\ufffd$\ufffdx}\ufffd\ufffd*\ufffdNw9': [u''],
>> >> u'\uff ... Etc ...
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Upload a File using the request.POST data

2010-09-26 Thread Sam Lai
Have you got the right attribute in the form?

>From http://docs.djangoproject.com/en/dev/topics/http/file-uploads/

"Note that request.FILES will only contain data if the request method
was POST and the  that posted the request has the attribute
enctype="multipart/form-data". Otherwise, request.FILES will be
empty."

On 27 September 2010 13:21, Danny Bos  wrote:
> Can it even be done?
> It seems pretty ordinary but everything I'm trying expects it to be a
> request.FILE.
>
> Frustrating stuff.
>
>
> d
>
> On Sep 27, 11:24 am, Danny Bos  wrote:
>> Heya,
>>
>> I'm using the 'Valums File Uploader' which passes the file in the
>> request.POST as you can see below. I'm wondering how to get that data
>> into an actual file. Any ideas would be great as things like "for
>> chunk in f.chunks()" only works on request.FILES which in this case is
>> empty.
>>
>> Thanks,
>> Hope all is well your side of the planet.
>>
>> Eg DATA:
>>
>> GET:,
>> POST:> \ufffd\x03\ufffd\x05\ufffd\ufffd\ufffdC\ufffdC\x1b\ufffd\ufffd\x0f/
>> \x1eY:\ufffdZ\ufffd \ufffd8': [u''], u'5]]\x1f\u04ff\x7f\ufffd\ufffd
>> \ufffd\x0f\x054\x15\u0622i\x1c\ufffd(\ufffdG\x01 \ufffd\x03u
>> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
>> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
>> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
>> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\ufffd\ufffd\ufffd$X]]
>> \u0775k\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdt\ufffd_2\x13\ufffd\u01cf
>> \x1fkkk\ufffd\ufffd\ufffdUe\ufffd\ufffd\ufffd\ufffdt2\u04ef\x1f?~|
>> \ufffd\u0529\ufffd\ufffd$\ufffdx}\ufffd\ufffd*\ufffdNw9': [u''],
>> u'\uff ... Etc ...
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How to use custom classes in django

2010-09-23 Thread Sam Lai
After revising python basics, here's how I'd structure it -

On 22 September 2010 18:10, jake2891  wrote:
> Hey guys, i am using extjs in django and am wondering the correct way
> to build custom classes like file upload classes and classes of
> functions.

I'm assuming by 'file upload classes' you mean file upload views, i.e.
the code responsible for receiving the file upload. If so, they're
just like any other view. In Django though, you might want to consider
putting file validation and processing code into your forms.py or
models.py for better abstraction and reusability.

For 'classes of (useful) functions', put them wherever they make
sense. As mentioned, they don't need to be classes - you can just have
files with functions in them. Use classes only when a class makes
sense. If they're only applicable in one app, put them in a file in
that app. You might want to use different files to separate the
functions into different namespaces.

> I am a bit confused does everything have to go into
> views.py by defining a function for each ajax request or what is the
> process? As with extjs like drop downs make an ajax request to
> populate them with data do all of these for all of my fields go into
> the view or can i create a custom class of methods and just use the
> views for rendering the forms. thanks

Yep, they're just like every other view. You could use some python
magic to reuse the same view for different but related AJAX requests
and avoid repetition. You might want to consider putting the code for
getting the data in your form, so you can easily create an alternative
non-AJAX form.

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

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



Re: Urlencode vs. iriencode

2010-09-05 Thread Sam Lai
On 5 September 2010 16:18, Jordon Wii <jordon...@gmail.com> wrote:
> Awesome, thank you.  So as far as escaping user-entered data for use
> in URLs...urlencode is best?

I'd say so. I haven't really found a need for iriencode personally,
and from the code, it seems that urlencode does everything iriencode
does anyway.

> On Sep 4, 8:45 pm, Sam Lai <samuel@gmail.com> wrote:
>> Here's the code for the two (the numbers at the start of each line are
>> just line numbers from the file) -
>>
>> iriencode:
>> 128     """
>> 129     Convert an Internationalized Resource Identifier (IRI) portion to a 
>> URI
>> 130     portion that is suitable for inclusion in a URL.
>> 131
>> 132     This is the algorithm from section 3.1 of RFC 3987.  However,
>> since we are
>> 133     assuming input is either UTF-8 or unicode already, we can
>> simplify things a
>> 134     little from the full method.
>> 135
>> 136     Returns an ASCII string containing the encoded result.
>> 137     """
>> 138     # The list of safe characters here is constructed from the
>> "reserved" and
>> 139     # "unreserved" characters specified in sections 2.2 and 2.3 of
>> RFC 3986:
>> 140     #     reserved    = gen-delims / sub-delims
>> 141     #     gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
>> 142     #     sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
>> 143     #                   / "*" / "+" / "," / ";" / "="
>> 144     #     unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
>> 145     # Of the unreserved characters, urllib.quote already considers all 
>> but
>> 146     # the ~ safe.
>> 147     # The % character is also added to the list of safe characters
>> here, as the
>> 148     # end of section 3.1 of RFC 3987 specifically mentions that %
>> must not be
>> 149     # converted.
>> 150     if iri is None:
>> 151         return iri
>> 152     return urllib.quote(smart_str(iri), safe="/#%[]=:;$&()+,!?*@'~")
>>
>> urlencode:
>> 11     """
>> 12     A version of Python's urllib.quote() function that can operate
>> on unicode
>> 13     strings. The url is first UTF-8 encoded before quoting. The
>> returned string
>> 14     can safely be used as part of an argument to a subsequent
>> iri_to_uri() call
>> 15     without double-quoting occurring.
>> 16     """
>> 17     return force_unicode(urllib.quote(smart_str(url), safe='/'))
>>
>> So iriencode only encodes the IRI portion (hence the longer list of
>> safe characters), while URL will encode the entire URL, including any
>> GET arguments and anchors.
>>
>> As for usage, I haven't encountered any IRIs, but I believe IRIs need
>> to be encoded before inclusion in HTML (i.e. you can't just include
>> the non-ASCII characters in HTML). As for urlencode, its main purpose
>> is if you're including a URL in a form submission, e.g. the URL to go
>> to after login. urlencode will do everything that iriencode does, but
>> sometimes you might not want it to do that.
>>
>> On 5 September 2010 08:17, Jordon Wii <jordon...@gmail.com> wrote:
>>
>>
>>
>>
>>
>>
>>
>> > Anyone?  I haven't found anything that describes the difference
>> > (except that one is for URI's and the other for URLs).
>>
>> > On Sep 4, 8:52 am, Jordon Wii <jordon...@gmail.com> wrote:
>> >> What's the difference between the template filters urlencode and
>> >> iriencode?  When should I use one over the other (or use both)?
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Urlencode vs. iriencode

2010-09-04 Thread Sam Lai
Here's the code for the two (the numbers at the start of each line are
just line numbers from the file) -

iriencode:
128 """
129 Convert an Internationalized Resource Identifier (IRI) portion to a URI
130 portion that is suitable for inclusion in a URL.
131
132 This is the algorithm from section 3.1 of RFC 3987.  However,
since we are
133 assuming input is either UTF-8 or unicode already, we can
simplify things a
134 little from the full method.
135
136 Returns an ASCII string containing the encoded result.
137 """
138 # The list of safe characters here is constructed from the
"reserved" and
139 # "unreserved" characters specified in sections 2.2 and 2.3 of
RFC 3986:
140 # reserved= gen-delims / sub-delims
141 # gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
142 # sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
143 #   / "*" / "+" / "," / ";" / "="
144 # unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
145 # Of the unreserved characters, urllib.quote already considers all but
146 # the ~ safe.
147 # The % character is also added to the list of safe characters
here, as the
148 # end of section 3.1 of RFC 3987 specifically mentions that %
must not be
149 # converted.
150 if iri is None:
151 return iri
152 return urllib.quote(smart_str(iri), safe="/#%[]=:;$&()+,!?*@'~")


urlencode:
11 """
12 A version of Python's urllib.quote() function that can operate
on unicode
13 strings. The url is first UTF-8 encoded before quoting. The
returned string
14 can safely be used as part of an argument to a subsequent
iri_to_uri() call
15 without double-quoting occurring.
16 """
17 return force_unicode(urllib.quote(smart_str(url), safe='/'))

So iriencode only encodes the IRI portion (hence the longer list of
safe characters), while URL will encode the entire URL, including any
GET arguments and anchors.

As for usage, I haven't encountered any IRIs, but I believe IRIs need
to be encoded before inclusion in HTML (i.e. you can't just include
the non-ASCII characters in HTML). As for urlencode, its main purpose
is if you're including a URL in a form submission, e.g. the URL to go
to after login. urlencode will do everything that iriencode does, but
sometimes you might not want it to do that.

On 5 September 2010 08:17, Jordon Wii  wrote:
> Anyone?  I haven't found anything that describes the difference
> (except that one is for URI's and the other for URLs).
>
> On Sep 4, 8:52 am, Jordon Wii  wrote:
>> What's the difference between the template filters urlencode and
>> iriencode?  When should I use one over the other (or use both)?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: windows7, django-admin.py, system variables, no module named django.core

2010-09-04 Thread Sam Lai
On 3 September 2010 19:42, gintare  wrote:
> Hello,
>
> I mean the correct way of running django seems to be to add to windows
> environmental variable PATH c:/first/Python26/Lib/site-packages/
> Django-1.2.1/django/bin
> and when run
> $ cmd
> $ django-admin.py startproject mysite
>
> the question, why importing management from django.core do not work?
> from django.core import management
> Error: No module django.core
>
> the module is under c:/first/Python26/Lib/site-packages/Django-1.2.1/
> django
> I mean it seems cmd must know where are all django modules. How?

How did you install Django? In c:/first/Python26/Lib/site-packages, is
there a .pth file? If so, what is in it?

It sounds like you did not install Django properly - you just unpacked
it inside c:/first/Python26/Lib/site-packages. There's a bit more to
it. The best way to do it is to use the setup script provided with
Django (if you're doing this, do NOT unpack the archive inside
site-packages; the setup script will do the copying for you), or use
easy_install or pip (which you may have to install separately).

To use the provided setup script, simply unpack the Django tarball to
somewhere temporary. The open the command prompt at that location, and
type -

python setup.py install

And Python should do the rest. You should have a working Django setup
by the end.

Also, C:\first\Python26\Scripts should be in your Windows PATH, but
none of the other Python related paths. Python already knows about its
site-packages directory. And inside C:\first\Python26\Scripts, there
should be a file named django-admin.py once the above setup script has
finished.



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

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



Re: apache, mod_wsgi, windows: config hints?

2010-08-25 Thread Sam Lai
On 25 August 2010 20:09, Reinout van Rees  wrote:
> Hi all,
>
> I normally deploy everything on linux, but a customer requires windows.  I
> have a working setup with apache and mod_wsgi, but I wonder about the
> efficiency.
>
> I see hints like "mod_wsgi, daemon mode" including "but that doesn't work on
> windows".  Similarly with other apache settings like the worker you have to
> chose.  The best one isn't available on windows.
>
> => Could someone give me a pointer on how to best set up apache and
> mod_wsgi+django on windows?  My google skills seem to let me down a bit.
>  I'm probably overlooking something obvious.

I'd stick with IIS on Windows - much better supported than Apache, not
to mention easier to manage on a Windows box, particularly if you only
have Windows sysadmins. And you get most of the advantages of daemon
mode when you use Application Pools.

Here's a pretty good overview of your options -
http://jasonmbaker.wordpress.com/2009/06/04/windows-for-python-programmers-iis/

ISAPI-WSGI would be the best option.
http://code.google.com/p/isapi-wsgi/

Don't bother with the IronPython option - Django isn't fully
compatible with it at the moment.

> Alternatives are fine, too.  But it has to be windows :-)
>
>
> Reinout
>
> --
> Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
> Programmer at http://www.nelen-schuurmans.nl
> "Military engineers build missiles. Civil engineers build targets"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: windows7, django-admin.py, system variables, no module named django.core

2010-08-25 Thread Sam Lai
If you want to understand why you are getting the error, start by
understanding Python modules -
http://docs.python.org/tutorial/modules.html

Hint - you can't just copy a script around and expect it to work. The
script depends on other files to make it all happen.

If in python, you type,

import sys
sys.path

... and you see something like C:\first\Python26\Lib\site-packages, it
should work fine assuming Django was installed using setuptools or
pip. If not, you should look into using that instead of manually
installing it.

If you insist on doing it manually, you need to look into creating a
.pth file to add the packages into the PYTHONPATH.

On 25 August 2010 18:06, gintare  wrote:
> I am not able to run django under windows7
>
> python django-admin.py  #is recognized if i paste it to c:/first/
> Python26 together with python executable.
>
> I am getting error:  No module named django.core
> File "django-admin.py", line2, in 
> from django.core import management
>
> It seems the command line do not know about variables in the path:
> Python django-admin.py    #is not recognized if i use path variable
>  "C:/first/Python26/Lib/site-packages/django-1.2.1/django/bin"
> It is recongmized as a command in if paste it to C:/first/Python26.
>
> I added paths to System Path Variable:
> C:/first/Python26
> which contains copy af django-admin.py
> C:/first/Python26/Scripts                                      which
> contains copy af django-admin.py
> C:/first/Python26/Lib/site-packages/django-1.2.1/django/bin      -
> original django-admin.py
>
> I run from command line cmd beeingin c:/first/Python26
> python  # command works
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: method on the User model?

2010-08-24 Thread Sam Lai
You need to look at SQL aggregates. See here -
http://docs.djangoproject.com/en/dev/topics/db/aggregation/

On 25 August 2010 14:44, Joel Klabo  wrote:
> I am trying to find a way to get a list of users ranked by the most
> "drinks". The drink model has a User field so I am doing this to get
> the info, based on the Drink model:
>
> http://dpaste.com/hold/233600/
>
> But, this seems like craziness. Can't I just search the
> User.objects.all().order_by('drinks') or something? Can i make a User
> method? I'm confused, obviously.

Try,

User.objects.annotate(num_drinks=Count('drink'))

(rough guess; I haven't really had a need to use this in my apps before :)

>
> Here is my Drink model so you have the whole picture:
>
> http://dpaste.com/hold/233601/
>
> Any help on this would be great, I know there is something to be
> learned from this
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: virtualenv and standalone scripts

2010-08-24 Thread Sam Lai
On 24 August 2010 06:54, Oivvio Polite  wrote:
> Following advice on this list I've moved to virtualenv+pip to manage my
> django stack, which so far is working out nicely.
>
> But what should I do about standalone scripts? Say I have a project
> called mysite. If I'm in a virtualenv and execute a standalone script,
> mysite won't be on my pythonpath and the script won't be able to import
> it.
>
> For now I've solved this by symlinking mysite from my virtualenv
> site-packages folder, but that sort of defeats the purpose of having
> using virtualenv.
>
> What's the right way to go about it?

Following on from the other replies, here's a neat blog post that sums
up your options -

http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/

It is also useful to know that if you need to activate a certain
virtualenv for a script, you can do that by simply using the python
executable in the bin/ directory of the virtualenv directory. I use
this to run cronjobs so the virtualenv environment is set up for them.

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

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



Re: What's the best way to custom the add page (in django admin site)

2010-08-24 Thread Sam Lai
On 23 August 2010 22:38, Yangmin Li  wrote:
> sorry for the previous incomplete message.
> Here is what I want to ask, thanks in advanced.
> I have a model called request, after registered in admin backend, user can
> add new request object in admin pages.
> I want to modify the request-add page to this: only some of the model fields
> will be shown to user, others are hidden and will be given default values
> before being saved to database.
> I've already custom the change_form template to hide the fields that I do
> not want to show them to users.
> what else should I do ?

Does that work? If that isn't enough, e.g. you need to add some more
logic into the template processing, you can override the view methods
to provide extra context. See
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#other-methods

> On Mon, Aug 23, 2010 at 8:31 PM, Yangmin Li  wrote:
>>
>> Hi All ,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: duplicate post_save signals

2010-08-18 Thread Sam Lai
I was looking at this over the weekend as well; isn't a problem for me
but it seems that the post_save signal is triggered even when
commit=False. Therefore when the object is saved again with
commit=True, it is fired again.

I didn't really investigate this so I could be wrong, but might be
something worth looking at.

On 18 August 2010 16:48, Kenneth Gonsalves  wrote:
> hi,
>
> I am using a two post_save signal handlers for two different models. On
> certain conditions they have to send emails to me and others. At times
> one signal is generated, at other times two or even in one instance 4
> signals were generated, which results in duplicate and triplicate
> emails. Has anyone faced this problem?
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: geodjango: windows installer for geos dependency?

2010-08-18 Thread Sam Lai
Quick Google tells me that PostGIS contains GEOS 3.2.0. I know you're
not using PostgreSQL, but installing that might do the trick, or if
you don't want to pollute your server, you can probably extract it
from the setup somehow.

http://postgis.refractions.net/download/windows/#windbinaries

On 18 August 2010 03:33, Reinout van Rees  wrote:
> Hi,
>
> (I also mailed the mapnik user list with this problem, not sure what the
> best place is)
>
> I have to install my geodjango app on a windows server for a specific
> customer.  After one day, I've almost got it working.
>
> Remaining problem: the geo database is oracle, so apparently I need the
> "geos" library. The error I'm getting is:
>
> ImproperlyConfigured: Could not import user-defined GEOMETRY_BACKEND "geos".
>
> Well, I didn't install the geos library yet, so that could be it. But I
> cannot find a windows installer for that. Either I'm blind or nobody uses
> oracle+geo stuff on windows :-)
>
> a) Do I really need that geos library? Or could there be something wrong
> with the oracle installation (like missing geo templates whatever).
>
> b) Where can I grab a windows installer for GEOS? I only see mentions of
> binary packages for osx and linux, none for windows.
>
>
> Reinout
>
> --
> Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
> Programmer at http://www.nelen-schuurmans.nl
> "Military engineers build missiles. Civil engineers build targets"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Migration: AlreadyRegistered

2010-08-18 Thread Sam Lai
This error looks like an import error in disguise. (
http://code.djangoproject.com/browser/django/tags/releases/1.2.1/django/utils/importlib.py
)

Fire up the python interpreter shell, and trying importing the
django.contrib.admin module manually and see if you get any errors.

Django seems to be installed ok according to your python path. Are you using
virtualenv at all?

On 18 August 2010 12:23, Christos Jonathan Hayward <
christos.jonathan.hayw...@gmail.com> wrote:

> I realized there may have been some pre-existing stuff in the directory, so
> I renamed it and extracted fresh from tarball. I got an error I had seen
> earlier but couldn't reproduce:
>
> AttributeError at /
>
> 'module' object has no attribute 'register'
>
>  Request Method:GET Request URL:http://localhost:8000/ Django Version:
> 1.2.1 Exception Type:AttributeError Exception Value:
>
> 'module' object has no attribute 'register'
>
>  Exception 
> Location:/Library/Python/2.6/site-packages/Django-1.2.1-py2.6.egg/django/utils/importlib.py
> in import_module, line 35 Python Executable:/usr/bin/python Python
> Version:2.6.1 Python Path:['/Users/jonathan/directory',
> '/Library/Python/2.6/site-packages/Django-1.2.1-py2.6.egg',
> '/Library/Python/2.6/site-packages/tagging-0.2.1-py2.6.egg',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',
> '/Library/Python/2.6/site-packages',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode']
>  Server
> time:Tue, 17 Aug 2010 21:20:53 -0500
>
> On Tue, Aug 17, 2010 at 8:39 PM, Christos Jonathan Hayward <
> christos.jonathan.hayw...@gmail.com> wrote:
>
>> Thank you; I'm not seeing how. My admin.py reads:
>>
>> import django.contrib.admin
>> import directory.models
>> import tagging
>>
>> django.contrib.admin.autodiscover()
>> django.contrib.admin.site.register(directory.models.Entity)
>> django.contrib.admin.site.register(directory.models.Location)
>> tagging.register(directory.models.Entity)
>>
>>
>> Commenting the tagging.register() call doesn't seem to make a difference.
>>
>> On Tue, Aug 17, 2010 at 8:27 PM, Sam Lai <samuel@gmail.com> wrote:
>>
>>> It means somehow you're calling this line in an admin.py file twice -
>>>
>>> admin.site.register(Entity)
>>>
>>> Check the admin.py file for the app that contains the Entity model.
>>>
>>> On 18 August 2010 10:57, Christos Jonathan Hayward <
>>> christos.jonathan.hayw...@gmail.com> wrote:
>>>
>>>> I am trying to migrate from one server to another: I tarred it up on the
>>>> Linux server, untarred on a Mac, got one or two complaints about missing
>>>> packages, and when I had resolved them, got the error below.
>>>>
>>>> Entity is the name of one of my models. What does this mean, and how is
>>>> this issue addressed? (I had been actively developing on the old server and
>>>> don't remember seeing this error.)
>>>>
>>>> AlreadyRegistered at /
>>>>
>>>> The model Entity is already registered
>>>>
>>>>  Request Method:GET Request URL:http://localhost:8000/ Django Version:
>>>> 1.2.1 Exception Type:AlreadyRegistered Exception Value:
>>>>
>>>> The model Entity is already registered
>>>>
>>>> Exception 
>>>> Location:/Library/Python/2.6/site-packages/Django-1.2.1-py2.6.egg/django/contrib/admin/sites.py
>>>> in register, line 78 Python Executable:/usr/bin/python Python Version:
>>>> 2.6.1 Python Path:['/Users/jonathan/directory',
>>>> '/Library/Python/2.6/site-packages/Django-1.2.1-py2.6.egg',
>>>> '/Library/Python/2.6/site-packages/tagging-0.2.1-py2.6.egg',
>>>> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',

Re: Migration: AlreadyRegistered

2010-08-17 Thread Sam Lai
It means somehow you're calling this line in an admin.py file twice -

admin.site.register(Entity)

Check the admin.py file for the app that contains the Entity model.

On 18 August 2010 10:57, Christos Jonathan Hayward <
christos.jonathan.hayw...@gmail.com> wrote:

> I am trying to migrate from one server to another: I tarred it up on the
> Linux server, untarred on a Mac, got one or two complaints about missing
> packages, and when I had resolved them, got the error below.
>
> Entity is the name of one of my models. What does this mean, and how is
> this issue addressed? (I had been actively developing on the old server and
> don't remember seeing this error.)
>
> AlreadyRegistered at /
>
> The model Entity is already registered
>
>  Request Method:GET Request URL:http://localhost:8000/ Django Version:
> 1.2.1 Exception Type:AlreadyRegistered Exception Value:
>
> The model Entity is already registered
>
> Exception 
> Location:/Library/Python/2.6/site-packages/Django-1.2.1-py2.6.egg/django/contrib/admin/sites.py
> in register, line 78 Python Executable:/usr/bin/python Python Version:
> 2.6.1 Python Path:['/Users/jonathan/directory',
> '/Library/Python/2.6/site-packages/Django-1.2.1-py2.6.egg',
> '/Library/Python/2.6/site-packages/tagging-0.2.1-py2.6.egg',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',
> '/Library/Python/2.6/site-packages',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC',
> '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode']
>  Server
> time:Tue, 17 Aug 2010 19:53:40 -0500
> --
> [image: Christos Jonathan Hayward ← An Orthodox Christian 
> author.]
> Christos Jonathan Hayward, an Orthodox Christian author.
>
> Author Bio  • 
> Books
>  • *Email * • 
> Facebook
>  • LinkedIn  • 
> Twitter
>  • *Web * • What's 
> New?
> I invite you to visit my "theology, literature, and other creative works"
> site.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Django Setup

2010-08-17 Thread Sam Lai
On 18 August 2010 07:29, Marty  wrote:
> Runing on Windows 7
> First time user of Django and Python.  Got python installed at f:
> \python27,  downloaded DJango tar file.  Used WInRAR to extract.
> Copied all of DJANGO into Python27

You actually don't need to do that; setup.py automatically copies the
files into the right location. There's no harm done, but just a waste
of space sitting in Python27 (although probably too hard now to
identify the Django files and delete them).

For reference in the future, or if someone else stumbles on to this
thread, here's the easiest way to install and use Python + Django on
Windows 7.

1. Download and install ActivePython (it's a Python distribution by
ActiveState specifically designed for Windows).
http://www.activestate.com/activepython/downloads

2. Open up the command prompt (Start -> Accessories -> Command
Prompt). [Sidenote - Windows PowerShell is not the same as the Command
Prompt; similar, but not the same]

3. Type 'pip install Django' (without the quotes) and press ENTER.
Django will start installing. [Sidenote - it will install it into
\Lib\site-packages, but you don't really need to worry
about this.]

4. Navigate to the directory you want your Django code to reside in.
If you don't like using the command prompt, find the directory in
Windows Explorer, hold SHIFT and right-click on the directory. Select
'Open Command Window Here'.

5. Type 'django-admin.py startproject project_name' (without quotes),
replacing project_name with your project name, then press ENTER.

>From here on, you should be able to follow the tutorial as it is
written because ActivePython has set up the Python environment as it
is on *nix systems (i.e. set up file associations for .py files, put
in the right PATH variables etc.)

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



Re: mod_wsgi+Apache+Postregsql on Windows

2010-08-14 Thread Sam Lai
I haven't watched Graham's video, but here's what I typically do.

On 14 August 2010 15:39, John Yeukhon Wong  wrote:
> I do plan to deploy the project on a UNIX server in the future, and I
> still do want to follow up with the previous discussion:
>
> So in general,
>
> 1. When I write a django project, for each project I need a different /
> apache/ and the content within? I know mod_wgics is a module we use to
> allow apache to run python but I am not clear how we actually use
> it.

On *nix, I typically create a separate user for each project, and
store the Django code, media, templates, and WSGI handler file in
there. Otherwise you can just create them in a single user's home.

I would then take advantage of the sites-available / sites-enabled
directory structure that is usually created by default inside
/etc/apache2 to configure rules for each website.

On Windows, I'd probably create C:\wwwroot (or something meaningful;
IIS uses inetpub), then create a directory for each project in there.
I would store the WSGI handler file inside the project directory. You
need to ensure the Apache user has read rights to access that
directory and its children.

I'm not sure where Apache settings are stored or how they are
structured though on Windows; easiest would probably be to store all
Apache config inside apache2.conf.

There is really no fixed structure necessary; apart from the directory
structure inside the Django project directory, it doesn't matter where
you put projects and the WSGI handler file.

All mod_wsgi is is a connector that Apache calls on when the
particular config rules are matched. mod_wsgi will then call load and
execute the WSGI handler file, which will in turn fire up Django and
process the request.

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



Re: mod_wsgi+Apache+Postregsql on Windows

2010-08-14 Thread Sam Lai
On 14 August 2010 15:39, John Yeukhon Wong  wrote:
> I noticed that if I have two of them co-exist simultaneously
> WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"
> WSGIScriptAlias /testproject "f:/public/testproject/apache/hello.wsgi"
>
> I will get nothing but the same default blue page. I looked the error
> log, nothing showed up. The access log, however, is interesting, but I
> couldn't get any information from the web.

The problem I think is when you request /testproject, it also matches
/ (with the testproject part passed to the WSGI handler). Try swapping
them around so the more specific one matches first, before the more
generic one.

I would be using separate config sections to do what you're doing
though, using either ServerName or port to differentiate between
sections.

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



Re: Django on Mac OS X

2010-08-08 Thread Sam Lai
2010/8/9 Daniel França :
> I tried to reinstall everything... installing python+postgres from ports
> and I get the Symbol not found: _PQbackendPID error again from psycopg.
> I guess the best solution is run Ubuntu on a virtual machine or my project
> will be stuck forever.
> python+psycopg on mac just sux.

I haven't really been following this thread, but you meant psycopg2,
not psycopg right? psycopg is old and unsupported as far as I know.

>
> 2010/8/8 Daniel França 
>>
>> tried, nothing :(
>> I'm getting crazy with Mac OS, I think I'll go back to Linux :S
>>
>> On Sun, Aug 8, 2010 at 4:34 AM, Xavier Ordoquy 
>> wrote:
>>>
>>> It won't work by commenting the timezone field since it has been created
>>> with a non null constraint on your db.
>>> Have you tried to get_or_create the account with timezone and language
>>> set to some value ?
>>> Regards,
>>> Xavier.
>>>
>>> Le 8 août 2010 à 04:09, Daniel França a écrit :
>>>
>>> More information.
>>> here:
>>> def create_account(sender, instance=None, **kwargs):
>>>     if instance is None:
>>>         return
>>>     account, created = Account.objects.get_or_create(user=instance)
>>> post_save.connect(create_account, sender=User)
>>> If I comment the post_save.connect, there's no exception =) but, of
>>> course the code doesn't do what it should do.
>>> So, I don't know why, but the error is in the connect... maybe because of
>>> timezone attribute of user
>>> anyone has any idea?
>>> 2010/8/7 Daniel França 

 Xavier, I think we are almost there :P
 because there's a timezone field in my account model:
 class Account(models.Model):

     user = models.ForeignKey(User, unique=True, verbose_name=_('user'))

     timezone = TimeZoneField(_('timezone'))
     language = models.CharField(_('language'), max_length=10,
 choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE)

     def __unicode__(self):
         return self.user.username
 I tried to comment the line, but then the create_user abort with an
 constraint timezone error.
 On Sat, Aug 7, 2010 at 2:22 PM, Xavier Ordoquy 
 wrote:
>
> And what's your Account model ?
> I noticed it is in its get_or_create that you get the error.
> Regards,
> Xavier.
>
> Le 7 août 2010 à 18:52, Daniel França a écrit :
>
> Same error =/
> but now,I don't know why.. it's saving at the db. The error still
> happens, but the data is in the database
>
> On Sat, Aug 7, 2010 at 12:54 PM, Xavier Ordoquy 
> wrote:
>>
>> Sorry, I just woke up form a sleep :)
>> I notice you get-or-create a user.
>> However, did you try to call get or create with specifying the
>> arguments ? first_name = "...", and so on ?
>> Does it still give an error ?
>> Regards,
>> Xavier.
>> Le 7 août 2010 à 17:46, Xavier Ordoquy a écrit :
>>
>> I just googled your error and found:
>> http://www.nerdydork.com/django-programmingerror-cant-adapt.html
>> According to the first comment, you might do something wrong with the
>> arguments types.
>> Unless you give a table description (\d from psql shell) and the model
>> I'm not sure I can help you further.
>> Regards,
>> Xavier.
>> As the stack seems to have a
>> Le 7 août 2010 à 17:21, Daniel França a écrit :
>>
>> I just created my db using django manage syncdb, I think it should
>> create right.
>> or how can I see the encode of each tables?
>> I'm using postgresql 8.4
>> maybe I'll need reinstall everything =S
>>
>> On Sat, Aug 7, 2010 at 6:49 AM, Xavier Ordoquy 
>> wrote:
>>>
>>> Le 7 août 2010 à 06:44, Daniel França a écrit :
>>>
>>> > My database is UTF-8, it's fine, doesn't?.
>>> > I'm afraid to reinstall everything from ports and start to get a
>>> > lot 64-32 bits incompatible issues like happened before =/
>>>
>>> I think that should be fine with a utf-8 DB.
>>> Are you sure your tables are UTF-8 ?
>>> What database are you using ? mysql ? postgres ? I had no issue with
>>> both and I have a couple of non pure ascii sites.
>>> However, when I moved to snow leopard, I recompiled mysql/postgres
>>> and the python drivers.
>>>
>>> Regards,
>>> Xavier.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>> --
>> You received this message because you are 

Re: Linkedin Search

2010-08-07 Thread Sam Lai
On 7 August 2010 22:53, kostia  wrote:
> I would like to know what search engines are used in web sites like
> Facebook, Linkedin, Twitter and so on.
>
> Are they simplistic database queries or sophisticated search solutions?

I'd say all three of those sites use custom search engines, possibly
built on well-known database platforms such as PostgreSQL or MySQL, or
a custom indexing system (this is more likely I'd say).

They aren't 'simplistic database queries' in that they try to guess
what you mean before looking for matches in an efficient manner. It
isn't a SELECT * FROM Table1 WHERE field1 LIKE "%searchterm%" query,
that's for sure.

In fact, if I remember right, twitter uses an in-memory non-SQL
database farm for its search. I'm sure Google will help with some
answers there.

Bringing it back to Django - check out Haystack
(http://haystacksearch.org). That's a general Django framework for
working with general purpose document search engines like Lucene,
Xapian and Whoosh.

Look into them; they'll most likely be more than enough for your
current needs. If you don't think they are, they're open source so
build on top of them. Otherwise, start revising data structures 101 :)

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

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



Re: overriding model.save()

2010-08-05 Thread Sam Lai
On 5 August 2010 03:05, Sells, Fred  wrote:
> I would like to prevent saving a new value if the database contains a
> specific value.  This is on a per field, per record basis.
>
> If I override the save() method; is there a way to find the existing (in
> the DB) values and the new (to be stored) values?

Just perform database queries as per normal inside the save() method.

You have access to the object to be stored as well, see
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methods

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

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



Re: cleaning html with bleach

2010-06-30 Thread Sam Lai
Nice find - I did pretty much the same thing, but using lxml.Cleaner.
This seems more configurable; I'm probably going to change mine over
to this instead.

Generally the rule with script injection is to scrub and filter on
output, because that's the last line of defense. However, for
situations like this, if you know the cleaned HTML content will not be
tampered with elsewhere or on output, I think it should be acceptable.

You can of course only scrub and filter on output instead, at the
expense of performance. That would be the safest option.

Personally, I did the former - scrub on input, and just retrieve the
cleaned string and mark it as safe on output.

On 30 June 2010 19:38, Tor Nordam  wrote:
> I'm developing a blog application in django, and I've been looking
> into ways to clean the input which will allow safe html tags, while
> removing all the evil stuff. I came across the tool bleach (
> http://github.com/jsocol/bleach ), which seems to be easy to use.
>
> I was just wondering if anyone has any experience or advice to offer.
> Also, it seems to me that the way to go about this is to filter the
> text with bleach upon input, and then store the cleaned text in the
> database, marking it as safe upon output. Is that the correct way to
> do this?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Parameters

2010-06-30 Thread Sam Lai
You need to serialize those variables and deliver them to the client
to store as a cookie. That way, when a call to draw_graph is made, it
will receive the cookie as part of the request, and you can get the
parameters.

If there is too much data, you should write those variables to the
database, and provide an ID in return to send to the client. When the
client calls draw_graph, you will receive the ID, which you can lookup
in the database and retrieve the variables.

On 29 June 2010 22:35, Waleria  wrote:
> Hi all,
>
> I have the following code below and i need receive the parameters of
> the index view: Sfase=[ ], Sserie=[ ], Sba=[ ], St=[ ] and f  to my
> view draws_graph but i don't know.
>
> Because if I pass the parameters as I am passing on draws_graph
> view(line 68,69 and 70 - view draws_graph), it works by drawing the
> image in the template but if I comment these lines does not work
>
> look my code..how can I get these parameters index view?
>
> http://paste.pocoo.org/show/231295/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Newbie Question about django-admin.py startproject

2010-06-23 Thread Sam Lai
'import django' is a command for the Python interpreter.

'django-admin.py startproject testsite' is a standard shell command.

Just open up a console window, and type the latter into it. If it
doesn't work, it means your PATH variable doesn't contain the Django
sources.

On 23 June 2010 15:27, Jacob Shiach  wrote:
> Ok, I am trying to start a project with Django and failing miserably.
>
> I open Python IDLE, Type "import django" then  type "django-admin.py
> startproject testsite" and get a SyntaxError:invalid syntax.
>
> Does anyone know where I am going wrong here?
>
> Note: I installed both Python 2.6.5 and Djang 1.1.1 with the Ubuntu
> package manager.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: PostgreSQL backend - Ident authentication failed?

2010-06-21 Thread Sam Lai
On 21 June 2010 20:16, Kenneth Gonsalves <law...@au-kbc.org> wrote:
> On Monday 21 June 2010 15:37:50 Sam Lai wrote:
>> >> You do bring up a interesting point though, and I don't know much
>> >> about the architecture of Apache and how holes are exploited when they
>> >> exist, but if the trespasser can execute arbitary code as www-data,
>> >> wouldn't they have access to settings.py anyway?
>> >
>> > and just to add to your worries, assuming that you have debug on in your
>> > production system, somewhere deep down in the traceback, you may see your
>> > database username and password! As for the apache question there are
>> > experts in this list who can anwer them.
>>
>> Thanks for mocking what was and still is a serious point.
>>
>
> I am sorry if you feel I was mocking - it was not my intention. And the point
> you were bringing up about Apache is a vast subject and I am not competent to
> answer it. As for the debug thing, it is just a warning not to run debug in
> production.

Ah I must've interpreted it incorrectly, I apologise. I'm definitely
no expert on *nix and Apache security, so I'd appreciate it if anyone
could clarify as well.

>From the PGSQL docs [1],
"On systems supporting SO_PEERCRED requests for Unix-domain sockets
(currently Linux, FreeBSD, NetBSD, OpenBSD, BSD/OS, and Solaris),
ident authentication can also be applied to local connections. In this
case, no security risk is added by using ident authentication; indeed
it is a preferable choice for local connections on such systems."

http://www.postgresql.org/docs/current/static/auth-methods.html

So it seems the postgresql people think it is ok, but I'm not sure
once you add in Apache and things like Django on top of it.

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

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



Re: PostgreSQL backend - Ident authentication failed?

2010-06-21 Thread Sam Lai
On 21 June 2010 19:47, Kenneth Gonsalves <law...@au-kbc.org> wrote:
> On Monday 21 June 2010 13:39:42 Sam Lai wrote:
>> > should be forbidden - one does not want apache to have direct access to
>> > the database
>>
>> Storing a password in plaintext file makes me uneasy, even though it
>> is locked away through file-system permissions.
>>
>> Having spent some time recently in the Windows world, I take
>> integrated auth for granted, and it works fine, making sysadmin much
>> easier.
>
> and a single point of entry to all systems for a cracker

I'm not running them all as admin (aka. root) obviously. Integrated
auth doesn't mean every user account can access every resource. It's
really just delegating an application's authentication system to the
operating system (note authentication, not authorization).

I fail to see how it is a single-point of entry to all systems. Yes,
it means there's one less layer of security, but that extra layer
provided by the DBMS isn't security anyway if as that OS user, you can
access the password to get past that extra layer of security anyway. I
don't believe this is an implementation of defense in depth.

>> You do bring up a interesting point though, and I don't know much
>> about the architecture of Apache and how holes are exploited when they
>> exist, but if the trespasser can execute arbitary code as www-data,
>> wouldn't they have access to settings.py anyway?
>>
>
> and just to add to your worries, assuming that you have debug on in your
> production system, somewhere deep down in the traceback, you may see your
> database username and password! As for the apache question there are experts
> in this list who can anwer them.

Thanks for mocking what was and still is a serious point.

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

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



Re: PostgreSQL backend - Ident authentication failed?

2010-06-21 Thread Sam Lai
On 21 June 2010 17:04, Kenneth Gonsalves  wrote:
> On Monday 21 June 2010 12:24:58 Torsten Bronger wrote:
>> > Also, is this recommended practice, to use "www-data" as the
>> > backend database username?
>>
>> No, not recommended, but not forbidden either.
>>
>
> should be forbidden - one does not want apache to have direct access to the
> database

Storing a password in plaintext file makes me uneasy, even though it
is locked away through file-system permissions.

Having spent some time recently in the Windows world, I take
integrated auth for granted, and it works fine, making sysadmin much
easier.

You do bring up a interesting point though, and I don't know much
about the architecture of Apache and how holes are exploited when they
exist, but if the trespasser can execute arbitary code as www-data,
wouldn't they have access to settings.py anyway?

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

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



Re: A Django project life cycle

2010-06-20 Thread Sam Lai
If you want to run a piece of code on receiving a view HTTP request,
and a piece of code just before the response is sent to the user, look
into Django middleware
(http://docs.djangoproject.com/en/dev/topics/http/middleware/). That
is what it is specifically designed to do.

If instead you want to run a piece of code when Django starts up, and
when it is killed, that would depend on how you are serving the page.
Are you using Apache? With mod_python, or mod_wsgi?

If you're using mod_wsgi (which you should), the mod_wsgi docs are
quite useful, e.g.
http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

Also, Django's signals functionality might be help too if middleware
is not - http://docs.djangoproject.com/en/dev/ref/signals/#ref-signals

On 20 June 2010 21:24, Sameer Rahmani  wrote:
> i want to run a peace of code in the beginning of life cycle ( may be
> in settings.py ) but i want to know about
> number process and the codes that remain on memory ? olso i want to
> run a peace of code in the ending part
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: A Django project life cycle

2010-06-20 Thread Sam Lai
I can't really help you because I don't know the internal life cycle
either. I'd just start with reading through the code, which isn't
really that hard (and it is what I've been doing for my custom admin
form behaviour).

If you have specific questions, you could post it here (or if it looks
like you need to extend something that Django doesn't currently allow,
maybe try the django-dev list).

The members here might be able to offer better solutions if you let us
know what you are trying to optimise, because someone here might have
experienced the problem before (and done the digging that you're
after).

Also, I'm sure you've heard all the bad things that are said about
premature optimisation. Write your code first according to Django
conventions, then optimise.

On 20 June 2010 19:56, Sameer Rahmani  wrote:
> thanks for your consideration ,  i know that this is a painful matter
> and need extra work
> but i need to understand this cycle to write some peace of code for my
> project that optimize
> some actions also i really love to contribute to django, so please guide me :)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: A Django project life cycle

2010-06-20 Thread Sam Lai
The onion model on the Django middleware documentation page might also help -

http://docs.djangoproject.com/en/dev/topics/http/middleware/

The rest of it (how it is handled from the WSGI handler etc.) is
really an internal matter. Unless you want to contribute to Django or
create some custom version of it, there isn't much need/point in
fiddling with it, because you'll just be asking for pain when there
are updates. There should be enough extensibility points for you
already.

On 20 June 2010 14:47, Kenneth Gonsalves  wrote:
> On Saturday 19 June 2010 18:04:33 Sameer Rahmani wrote:
>> i want to know about a django project life cycle, can any body help me
>>  please?
>>
>> i want to know how a django project run under wsgi and development server ?
>> which files runs first?
>> does a project run in each request? or it remain in memory ?
>> and any other useful information
>>
>
> well first thing is that django is a framework and not a server. So basically
> the flow is precisely the same as ordinary cgi programming. You type in a url
> which calls a function which does something and displays a page.
> --
> Regards
> Kenneth Gonsalves
> Senior Associate
> NRC-FOSS at AU-KBC
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Error I continue to get

2010-06-19 Thread Sam Lai
I quote from a previous post of mine -

"""
That error message looks like Windows to me. try adding the word
python at the start of that command.

If you are indeed on Windows, how did you install Python? The easiest
one I've used is the ActiveState's ActivePython distribution for
Windows; sets everything up properly, including proper file extension
support so the your command will just work.

http://www.activestate.com/activepython
"""

You can also try adding a file association for .py files to
C:\python26\bin\python.exe but using ActivePython means it just works.

On 19 June 2010 19:30, Mike <michaelh...@gmail.com> wrote:
> I also get this error.
>
> I have python for windows version 2.6. I am using the standard windows
> xp shell. I have installed the latest version of django from the
> command line.
>
> How can I fix this?
>
> On Jun 11, 3:40 pm, Kenneth Gonsalves <law...@au-kbc.org> wrote:
>> On Friday 11 June 2010 12:05:50 Sam Lai wrote:
>>
>> > Thaterrormessage looks like Windows to me. try adding the word
>> > python at the start of that command.
>>
>> yes, it did not look like a linuxerrormessage - although last time I looked
>> windows would say 'bad command or file name'
>> --
>> Regards
>> Kenneth Gonsalves
>> Senior Associate
>> NRC-FOSS at AU-KBC
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



  1   2   >