Re: Help regarding Login form in Django

2008-10-30 Thread Low Kian Seong

Why not use the login.html of the admin interface?

{% extends "admin/base_site.html" %}
{% load i18n %}

{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix
%}css/login.css{% endblock %}

{% block bodyclass %}login{% endblock %}

{% block content_title %}{% endblock %}

{% block breadcrumbs %}{% endblock %}

{% block content %}
{% if error_message %}
{{ error_message }}
{% endif %}


  
{% trans 'Username:' %} 
  
  
{% trans 'Password:' %} 

  
  

  



document.getElementById('id_username').focus()


{% endblock %}


On Fri, Oct 31, 2008 at 1:50 PM, sadeesh Arumugam
<[EMAIL PROTECTED]> wrote:
> Hi Friends,
>  Anybody please send me a sample login form in 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Help regarding Login form in Django

2008-10-30 Thread sadeesh Arumugam
Hi Friends,
 Anybody please send me a sample login form in 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Copies of Libraries, Apache/mod_wsgi and Performance

2008-10-30 Thread Naitik Shah
Hey Graham,

On Thu, Oct 30, 2008 at 8:36 PM, Graham Dumpleton <
[EMAIL PROTECTED]> wrote:

>
> How many processes in each daemon group and how many threads?


I'm using 2 processes and 15 threads in each group.


> Can you post the Apache configuration showing relationship between
> sites and daemon process groups? Can then possibly comment better.
>

I've attached a config file with one virtual host, others are essentially
identical.


> Also indicate how much traffic each site gets and whether any would
> potentially be idle for periods, as can then look at inactivity
> timeouts etc.


As embarrassing as it sounds, I don't have good numbers available yet. There
are definite idle periods on certain virtual hosts.


> The code size is generally not the issue, but runtime application
> data, so doubt that having .so in different installations would result
> in much being lost.


Good to hear, I like keeping things separate. I lied a little earlier, I do
have a shared directory that contains .so's - the per project site directory
is things I track via their source repositories (django and pretty much
anything related) and until now dont contain any .so. I'm gonna keep it as
is.


> Rather than event MPM, would suggest using nginx as a front end, with
> nginx serving requests for static files and then proxying other
> requests through to Apache/mod_wsgi. This is because nginx is arguably
> better at serving static files and maintaining many open connections
> with keep alive. The Apache/mod_wsgi instance would then only be
> handling dynamic requests and all connections would come from local
> nginx. Even if keep alive working there, depending on how optimised
> nginx is, it can possibly reuse the connections over time for requests
> from different originating clients in a more efficient way, thereby
> keeping the memory overhead in Apache which generally arises from
> maintaining open connections from lots of different clients.


I considered nginx, but I've been playing with S3 and I think I'm going to
use that as a poor mans edge system for my static content. But I'll keep
this in mind. Would using a event mpm help if I didnt have to serve static
content or need Keep-Alive?


Here's my apache/mod_wsgi setup:

ServerRoot /etc/httpd
User nobody
Group nobody
Listen 80
NameVirtualHost *
ErrorLog /data/log/httpd.error
ServerTokens Prod
HostnameLookups Off
KeepAlive Off

LoadModule mime_module modules/mod_mime.so
TypesConfig /etc/httpd/conf/mime.types
DefaultType text/plain

LoadModule deflate_module modules/mod_deflate.so
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
text/javascript application/x-javascript

LoadModule log_config_module modules/mod_log_config.so
LoadModule alias_module modules/mod_alias.so

LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonOptimize 1
WSGIPassAuthorization On


StartServers  30
MinSpareServers   30
MaxClients30



ServerName daaku.org

WSGIDaemonProcess daaku user=daaku group=daaku processes=2 threads=15
display-name=daaku python-path=/data/lib:/data/daaku/lib
WSGIProcessGroup daaku
WSGIScriptAlias / /data/daaku/apache/daaku_wsgi.py

Alias /media/ /data/daaku/media/

SetHandler None
Options FollowSymLinks



[I have 3 virtual hosts with identical config, and plan to add another
soon.]


Thanks for the input.

-Naitik

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django along with PHP - avoiding Apache crashes

2008-10-30 Thread DULMANDAKH Sukhbaatar

I use apache2's mpm-worker which is threaded and means very fast,
requires less resource. And use PHP5 as a fastcgi, django (through
python) also as fastcgi.

This setup maybe difficult compared to apache modules based setup. but
proven to be very fast, and no side effects.



-- 
Regards
Dulmandakh

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: appeal for help with #9232

2008-10-30 Thread Graham Dumpleton

The OP, if they don't need mod_python should also disable it and not
load it into Apache at the same time as mod_wsgi. The mod_python
versions is quite old and buggy and mod_python can interfere with
mod_wsgi especially causing certain configuration options for mod_wsgi
to not work. The mod_wsgi version is also not the latest, should try
with mod_wsgi 2.3. No known issues with uploading with mod_wsgi 2.0,
but still better to use the latest.

Just because binary distributions still only provide old versions
doesn't mean they are the best to use and bug free.

Graham

On Oct 31, 10:56 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 30, 2008 at 11:12 AM, Faheem Mitha <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Can anyone help with
>
> >http://code.djangoproject.com/ticket/9232
>
> > ? Currently I don't even know if this problem is reproducible. If someone
> > could solve it, or even indicate what was wrong, if anything, I'd be happy
> > to pay for services rendered.
>
> It's not a generally re-creatable problem. Using your project on one of my
> machines (Ubuntu) with Django 1.0, Apache 2.2 & mod_wsgi 2.3 an upload of a
> 700M file takes about a minute and a half (during which time I can see the
> tmp upload file continually growing in size), then gets an error on the
> redirect at the end of the view since "top_folders" is not reversable in the
> testproj config.
>
> Random question that cross my mind:
>
> Are you sure you have a clean install of Django 1.0 -- that is you removed
> any old level before installing 1.0?
>
> Are you trying the upload from a machine with a known good network
> connection to the server (or from the sever machine itself?).
>
> Do you see the same behavior if you run under the development server?
>
> Karen
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Copies of Libraries, Apache/mod_wsgi and Performance

2008-10-30 Thread Graham Dumpleton



On Oct 31, 10:04 am, "Naitik Shah" <[EMAIL PROTECTED]> wrote:
> I'm serving a few sites from a tiny VPS, and I'm quite happy with a
> Apache/mod_wsgi setup. I've managed to reduce the Apache footprint by having
> only a few necessary modules loaded. mod_wsgi is setup to use daemon mode
> and start multiple processes per site.

How many processes in each daemon group and how many threads? A lot of
sites would work quite happily with single daemon process with a dozen
or so threads, which is what WSGIDaemonProcess gives you as default
when you do not define number of processes and threads. Thus, don't
get carried away and create more processes than you really need to.

Can you post the Apache configuration showing relationship between
sites and daemon process groups? Can then possibly comment better.

Also indicate how much traffic each site gets and whether any would
potentially be idle for periods, as can then look at inactivity
timeouts etc.

> Currently, each site has its own python-path and the system python
> installation does not contain anything but stock python modules. Each site
> has its own copy of Django and various other libraries. Is there a
> performance gain to be had by having the sites share these libraries? They
> are different processes, so I think not, but I'm not quite sure. Also,
> another benefit that I can think of is that if the files were the same, the
> OS (Linux 2.6.27) would be able to cache them better, but again I'm not
> quite sure.

The code size is generally not the issue, but runtime application
data, so doubt that having .so in different installations would result
in much being lost.

> This is probably a micro enhancement, but I'm trying hard to keep the memory
> consumption low.
>
> -Naitik
>
> ps: Another enhancement I'm looking into when I have time is the event mpm,
> but that one requires me to give up my distro apache. Thoughts?

Rather than event MPM, would suggest using nginx as a front end, with
nginx serving requests for static files and then proxying other
requests through to Apache/mod_wsgi. This is because nginx is arguably
better at serving static files and maintaining many open connections
with keep alive. The Apache/mod_wsgi instance would then only be
handling dynamic requests and all connections would come from local
nginx. Even if keep alive working there, depending on how optimised
nginx is, it can possibly reuse the connections over time for requests
from different originating clients in a more efficient way, thereby
keeping the memory overhead in Apache which generally arises from
maintaining open connections from lots of different clients.

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



Re: How to setup django-apache-mod_wsgi without killing existing php site?

2008-10-30 Thread Graham Dumpleton



On Oct 31, 10:14 am, Håkan Waara <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I'm in the process of for the first time deploying a django site that  
> (unfortunately) needs to share its Apache with an existing PHP site.
>
> I've been reading a bunch about mod_wsgi and in many places there are  
> mentions that setting up apache with mpm-worker (basically  
> multithreaded mode) will not work if you're also hosting a PHP site on  
> the same Apache; Apache will crash, and the world will collapse...
>
> What I haven't been able to find out is if it's possible/worth it to  
> use mod_wsgi (efficiently) in this situation at all, and if so how to  
> do it?
>
> Does anyone have other suggestions on how to avoid mod_python in this  
> situation? Should I have a look at nginx for example?
>
> Any hints appreciated!

It is not necessary to be running Apache worker MPM to run mod_wsgi,
it will work quite happily in Apache prefork MPM, just like mod_python
can. Also note that if you have problems with mod_wsgi, using
mod_python will not help as it can be impacted by exactly the same
problems.

Now, which MPM you use is not the problem you seem to think it is. The
real problem is generally going to be mismatches in what versions of
shared libraries that PHP uses compared to what various Python modules
require. The main culprit for this is MySQL as PHP generally uses a
non reentrant variant of MySQL client libraries where as Python MySQL
module generally uses a reentrant variant of the library. Result of
this can be Apache crashing.

Other problems can also arise if you are using Debian and the broken
Python 2.4 that Debian released. Specifically, Debian folks fiddled
with the hash module code in Python 2.4 and caused a conflict between
it and a hash module in PHP. This can cause problems with session IDs
being generated incorrectly and causing session mechanisms to fail, or
could also crash Apache.

These issues and others can be found described in:

  http://code.google.com/p/modwsgi/wiki/ApplicationIssues

Now, although mod_wsgi can be used with Apache prefork MPM and you can
run your Django application in embedded mode, because prefork means
more Apache child processes, you might not find it desirable that your
fat Django application then causes Apache as a whole to use up so much
memory. In this situation, don't run your Django in mod_wsgi embedded
mode, instead create a mod_wsgi daemon mode process groups and
delegate Django to run in that instead. Use one multithreaded daemon
mode process, or if your Django application isn't thread safe, a small
number of single threaded processes.

For some quick examples of embedded versus daemon mode configuration
see:

  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

You should also go through other documentation on the mod_wsgi site
properly as well though. Don't assume that just reading one page, or
some ones blog on how they did it, or relying on answers to questions
you get from irc channels is going to be sufficient. This is why the
documentation exists.

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



Re: Table width when using list_filter

2008-10-30 Thread Karen Tracey
On Thu, Oct 30, 2008 at 4:28 PM, Fabio Natali
<[EMAIL PROTECTED]>wrote:

> Hi everybody!
>
> I'm a bit confused about the behaviour of my change list page.
>
> If I enable list_filter the table (the one listing my model instances)
> "shrinks" and its width is no more 100% of the space available. All
> the columns and data are perfeclty shown, it's just that everything is
> more narrow. Obviously, part of the width is taken by the list_filter
> window, but the table shrinks down far more.
>
> Is this behaviour normal? Is there any reason for it?
>
> I use trunk django and a cutting edge firefox browser.
>
>
I see the same behavior, at least for models that don't have a lot of
columns with wide text in the change list.  It appears that, with a filter
present, the columns are narrowed to only however wide they need to be to
fit the longest entry in the column, whereas without a filter the columns
are expanded so that the full set covers the whole width of the screen.  I
expect it's a side-effect of the css needed to get the filter in place;
whether it's a necessary or accidental side-effect I don't know -- I've
never cared about it enough to look into it, especially since css isn't my
favorite thing to play with.

Karen

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cannot import name call_command

2008-10-30 Thread Karen Tracey
On Thu, Oct 30, 2008 at 3:43 PM, noureddine <[EMAIL PROTECTED]> wrote:

>
> yes, i already thik in this idea
> but the application has an others bug with django 1.0 and the 1st
> developper says in his documentation that works with django 0.9
> thanks
>

You are saying this is code from someone else and they claim it runs on
0.96?  If so, I believe they are wrong.  That import won't work prior to
r5898:

http://code.djangoproject.com/changeset/5898

which is when the django.core.management package was created, along with
call_command.  Django 0.96 was tagged around r4810, about 1000 revisions and
six months earlier. It may be the original developer was using some svn
checkout of Django from between 0.96 and 1.0.

Karen


>
> On 30 oct, 17:04, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > On Thu, Oct 30, 2008 at 12:27 PM, noureddine <[EMAIL PROTECTED]>
> wrote:
> >
> > > this is what i specified :
> >
> > > from django.core.management import call_command
> >
> > OK, so you've got an import that should work on Django 1.0.  I suspect
> > you're either not running on Django 1.0 (that import doesn't work on
> 0.96)
> > or your installation is corrupt.  The former is probably more likely.
> >
> > Karen
> >
> >
> >
> > > On 29 oct, 15:39, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > > On Wed, Oct 29, 2008 at 11:05 AM, noureddine <[EMAIL PROTECTED]>
> > > wrote:
> >
> > > > > i have this problem
> > > > > is there anybody hwo know the solution.
> > > > > please tell me.
> >
> > > > You've specified the wrong import, or the wrong pythonpath, or have a
> > > > corrupt installation, or ...? Without some specifics of what you are
> > > doing
> > > > to generate this error it is a bit hard to say.
> >
> > > > Karen
> >
>

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



admin home page shows no permission to do anything

2008-10-30 Thread Chuck Bai2
I got the following message when login as superuser to admin home page:
*
You don't have permission to edit anything.
*


Recent Actions


  My Actions

None available



I delete all my database tables and regenerate them through syncdb, but 
it did not help. The login/logout part is working fine. I can only 
change password. No any other action I can perform. What's missing? I am 
using development trunck revision 9236.

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



S3Storage, FileField -- default_storage.exists() has unwanted side-effects

2008-10-30 Thread Info Cascade
I have a model that has a FileField storage field.
The default_storage system is S3Storage.
I noticed that I was getting unusual results when I simply tried to
verify whether the file existed on disk using the
default_storage.exists() method.
If I call it with the FileField object, it causes Django to actually try
to *get* the file, which is not what I intend.  The S3Storage module
implements exists() as a simple http HEAD request. That part works
fine.  But then Django starts getting the file which eventually results
in an error, so it appears the file doesn't exist when really it does.  
(The file is an audio file, which triggers a series of byte-range
requests, the final one having incorrect value, so I'm getting a series
of 206 codes followed by 416 error code. It causes a key error in
S3Storage or S3 on 'etag'.)

I was able to work around it by using the str() function, which results
in the correct behavior.

Anyway, it was non-intuitive for me that checking whether a file exists
would make Django do a GET on it!  Is this a bug or do I just not
understand what's going on beneath the surface?  (Which is the case,
actually.)  Can someone explain this?

Liam

>
> section_objects =
> Section.objects.in_bulk(section_ids).values()
> if len(section_ids) != len(section_objects):
> print "section count mismatch for article '%d'" %
> (art.id)
> idx = 0
> for sec in section_objects:
> idx += 1
> if sec.url:
> try:
> if not default_storage.exists(*str*(sec.url)):
> print "\tarticle '%s' missing content
> for section %d" % (art.id, idx)


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: __unicode__() method not working in models.py

2008-10-30 Thread Andrew


> I do not know if this will work for Japanese Windows, but for the English
> version, the two things I have found that need to be done to ensure a
> command prompt properly displays utf-8
> are first:
>
> chcp 65001
>
> in the command prompt to change the active code page to the one that works
> for utf-8 (65001 is apparently Windows' spelling of utf-8) and second change
> the font properties of the command prompt (left click upper left corner of
> the window, choose Properties, then Font tab) to use Lucida Console, not
> Raster Fonts.  If I do those two things then utf-8 data looks correct in my
> command prompts.
>
> Karen-

Hi Karen. Since I'm using a Japanese version of windows, the command
prompt already displays messages and file names in Japanese
characters. I didn't know about the commands you mentioned, thanks for
letting me know. However, when I made the two changes you describe,
Japanese characters become unreadable.

As I said before, if I write a simple function in python which outputs
a Japanese string, I can call that function in a normal python shell
and everything works. It's only when I use the manage.py shell and try
to perform the code above that things go wrong.

Any other suggestions greatly appreciated.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: __unicode__() method not working in models.py

2008-10-30 Thread Andrew

>
> Are you declaring the encoding of your source file?
>
> Try putting
>
> # -*- coding: UTF-8 -*-
>
> at the top of your file.
>
> regards
>  Steve

Hi Steve, thanks for the reply. Exceptions are raised if you input
Japanese characters into a file and fail to declare the coding. That
was the first thing I fixed. Thanks for the suggestion.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to setup django-apache-mod_wsgi without killing existing php site?

2008-10-30 Thread Naitik Shah
On Thu, Oct 30, 2008 at 4:14 PM, Håkan Waara <[EMAIL PROTECTED]> wrote:

>
> Hi folks,
>
> I'm in the process of for the first time deploying a django site that
> (unfortunately) needs to share its Apache with an existing PHP site.
>
> I've been reading a bunch about mod_wsgi and in many places there are
> mentions that setting up apache with mpm-worker (basically
> multithreaded mode) will not work if you're also hosting a PHP site on
> the same Apache; Apache will crash, and the world will collapse...


The problem is with PHP, not mod_wsgi. The PHP manual has this FAQ entry: "*Why
shouldn't I use Apache2 with a threaded MPM in a production
environment?"*.
Because PHP has a high number of C extensions, which in turn use existing
libraries, your success really depends on the php modules, the libraries
they use, and how they were all compiled. If you need to run PHP and
mod_wsgi together, the prefork mpm is best.

mod_wsgi alone will will work safely in a threaded environment and any of
the non-experimental mpms.


-Naitik

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: appeal for help with #9232

2008-10-30 Thread Karen Tracey
On Thu, Oct 30, 2008 at 11:12 AM, Faheem Mitha <[EMAIL PROTECTED]> wrote:

>
>
> Hi,
>
> Can anyone help with
>
> http://code.djangoproject.com/ticket/9232
>
> ? Currently I don't even know if this problem is reproducible. If someone
> could solve it, or even indicate what was wrong, if anything, I'd be happy
> to pay for services rendered.
>

It's not a generally re-creatable problem. Using your project on one of my
machines (Ubuntu) with Django 1.0, Apache 2.2 & mod_wsgi 2.3 an upload of a
700M file takes about a minute and a half (during which time I can see the
tmp upload file continually growing in size), then gets an error on the
redirect at the end of the view since "top_folders" is not reversable in the
testproj config.

Random question that cross my mind:

Are you sure you have a clean install of Django 1.0 -- that is you removed
any old level before installing 1.0?

Are you trying the upload from a machine with a known good network
connection to the server (or from the sever machine itself?).

Do you see the same behavior if you run under the development server?

Karen

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template syntax question

2008-10-30 Thread Robocop

I like the suggestions, Thanks!

On Oct 28, 12:47 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Oct 27, 10:04 pm, Robocop <[EMAIL PROTECTED]> wrote:
>
> > So i'm looking to have an admin controlled news list, and one thing in
> > particular i'd like them to be able to control is how many headlines
> > are shown on the front page, and my current code is not doing that.
>
> > The line i care about is:
>
> >         {% for New in news_list|slice:":{{limit}}"%}
>
> > where limit is some admin controlled variable that i'm certain is an
> > integer.  Is this possible?  Or is there just some error in my code
> > somewhere  that i have not seen?  Thanks!
>
> You can't nest tags like that.
>
> There are various options - have you tried defining a string in your
> view which is ":" + limit, and passing that to thetemplate? Or
> perhaps limiting news_list in your view?
>
> Or, you could define a custom filter which takes a value and returns a
> list sliced to that length. Something like (untested):
> def slice_to_var(lst, lngth):
>     return lst[:lngth]
> --
> DR.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to setup django-apache-mod_wsgi without killing existing php site?

2008-10-30 Thread Brian Neal

On Oct 30, 6:14 pm, Håkan Waara <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I'm in the process of for the first time deploying a django site that  
> (unfortunately) needs to share its Apache with an existing PHP site.
>
> I've been reading a bunch about mod_wsgi and in many places there are  
> mentions that setting up apache with mpm-worker (basically  
> multithreaded mode) will not work if you're also hosting a PHP site on  
> the same Apache; Apache will crash, and the world will collapse...
>
> What I haven't been able to find out is if it's possible/worth it to  
> use mod_wsgi (efficiently) in this situation at all, and if so how to  
> do it?
>
> Does anyone have other suggestions on how to avoid mod_python in this  
> situation? Should I have a look at nginx for example?
>
> Any hints appreciated!
> /Håkan

Well it might also just work. I am running a site with PHP, django via
mod_python, and MySQL without any problems on Fedora Core 6.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to setup django-apache-mod_wsgi without killing existing php site?

2008-10-30 Thread Håkan Waara

Hi folks,

I'm in the process of for the first time deploying a django site that  
(unfortunately) needs to share its Apache with an existing PHP site.

I've been reading a bunch about mod_wsgi and in many places there are  
mentions that setting up apache with mpm-worker (basically  
multithreaded mode) will not work if you're also hosting a PHP site on  
the same Apache; Apache will crash, and the world will collapse...

What I haven't been able to find out is if it's possible/worth it to  
use mod_wsgi (efficiently) in this situation at all, and if so how to  
do it?

Does anyone have other suggestions on how to avoid mod_python in this  
situation? Should I have a look at nginx for example?

Any hints appreciated!
/Håkan
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multiple Copies of Libraries, Apache/mod_wsgi and Performance

2008-10-30 Thread Naitik Shah
I'm serving a few sites from a tiny VPS, and I'm quite happy with a
Apache/mod_wsgi setup. I've managed to reduce the Apache footprint by having
only a few necessary modules loaded. mod_wsgi is setup to use daemon mode
and start multiple processes per site.

Currently, each site has its own python-path and the system python
installation does not contain anything but stock python modules. Each site
has its own copy of Django and various other libraries. Is there a
performance gain to be had by having the sites share these libraries? They
are different processes, so I think not, but I'm not quite sure. Also,
another benefit that I can think of is that if the files were the same, the
OS (Linux 2.6.27) would be able to cache them better, but again I'm not
quite sure.

This is probably a micro enhancement, but I'm trying hard to keep the memory
consumption low.


-Naitik

ps: Another enhancement I'm looking into when I have time is the event mpm,
but that one requires me to give up my distro apache. Thoughts?

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding properties to models at run-time.

2008-10-30 Thread Alex G

Thanks for the reply, DR.

How would I use the generic relationship without the backward link?

I have the normal auth.user class, and I have the my.user class that
extends it and has a polymorphic link pointing at auth.user.  The
problem occurs when I collect a login/password, because I can't lookup
my.user without the backward link, that is I can't
my.user.filter(account__username = x, account__password = y) because
polymorphic links don't allow this.  I also can't move in reverse, the
auth.user.authenticate(username, password) function returns an
auth.user, and I am unclear as to how I would get a my.user from this
information without calling for my.user.objects.all() and comparing
the link (which seems terribly, terribly inefficient...).  Is there a
way to start with the target (auth.user) and get to my.user backward
via the contenttype?

I know about AUTH_PROFILE_MODULE, but the problem is that the goal is
to have multiple user classes.  Ideally there would be a way to
specify the user model as an attribute of the auth.user model (which
would be the heretofore missing backward link), but barring that this
isn't much use to me because the AUTH_PROFILE_MODULE would have
multiple values.

Any clues?

Thanks,

Alex.



On Oct 30, 4:33 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Oct 30, 8:11 pm, Alex G <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > I've been trying for some time to create a polymorphic link with a
> > backwards-link from the associated model.  The problem is the model is
> > django.contrib.auth.models.User...  Is there any way to add this
> > functionality without changing the django core?  Trying to call
> > setattr(django.contrib.auth.models.User, 'target',
> > generic.GenericRelation(MyUser) does not work.  It instantiates an
> > attribute named 'target', but it doesn't work in the manner
> > intended...
>
> > from django.contrib.auth.models import User as Account
> > from django.contrib.contenttypes.models import ContentType
> > from django.contrib.contenttypes import generic
> > class User(models.Model):
> >         account_polymorphic_link = models.ForeignKey(ContentType)
> >         account_id = models.PositiveIntegerField()
> >         account = generic.GenericForeignKey('account_polymorphic_link',
> > 'account_id')
>
> > setattr(Account, 'target', generic.GenericRelation(User)) #this
> > doesn't seem to work
>
> > My problem is that I'm using auth.User (Account in the above example)
> > to store username/password and to leverage permissions and such, but I
> > can't look someone up by username and get at the information in my
> > derivative class...
>
> > Does anyone have any ideas/suggestions?
>
> > Thank you,
>
> > Alex.
>
> Well, you can use generic relations without the backwards link, by
> simply looking up the content_type/object_id in the related class.
>
> But for your use case, a much better way is to use the built-in
> AUTH_PROFILE_MODULE setting, which allows you to nominate a class
> which extends User, and enables a user.get_profile() method. 
> Seehttp://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-...
>
> --
> DR.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multiselect populated by another app

2008-10-30 Thread webcomm

Bump.

There must be a way to do this, right?  I have looked all over... the
documentation seems to indicate that there is no way to do this in
django, which is surprising, since this is a necessary part of so many
programs.

Is there really no way to populate a mutiselect with values from
another app?

The Definitive Guide to Django says that a ManyToManyField will take
as its one argument only the name of a class from the same app.  If
that's true, I don't see how anyone could develop a categories app in
django... perhaps I'm missing something?

Thanks in advance for your help,
Ryan



On Oct 27, 11:03 am, webcomm <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have created a simple categories app, and now I want to be able to
> categorize my articles, which are handled by a different app.  I'd
> like to create a multiselect categories field in my articles admin
> that is populated by the category entries from my categories app.
>
> In my categories app, I have to ability to create category groups.
> This is the models.py for the categories app...
>
> from django.db import models
>
> class Group(models.Model):
>     name = models.CharField(max_length=200)
>
>     def __str__(self):
>         return self.name
>
> class Category(models.Model):
>     group = models.ForeignKey(Group)
>     name = models.CharField(max_length=200)
>
>     def __str__(self):
>         return self.name
>
>     class Meta:
>         verbose_name_plural = 'categories'
>
> I want to set up my articles admin interface so there is a different
> multiselect box for each category group, or one large multiselect with
> the categories organized in groups.
>
> I am not quite sure what to do in articles/admin.py and/or elsewhere
> to achieve this.
>
> Any ideas?
>
> Thanks,
> Ryan
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple types of output (HTML, JS), same view.

2008-10-30 Thread bruno desthuilliers



On 30 oct, 20:22, Joe Murphy <[EMAIL PROTECTED]> wrote:
> Hi,
>
> So I've got a bunch of views that I need to output in three forms:
> HTML with the site wrapper (header, footer etc.), HTML without the
> site wrapper, and JS. The templates are really, really similar.
>
> I'm thinking of using a url pattern like:
> r'^blog/blah(?P[-\.\/\w]+)$'
> so that blog/blah/ would return the HTML with site wrapper, blog/
> blah.html would return the HTML without wrapper, and blog/blah.js
> would return the javascript.
>
> Doing this means I'm putting logic in all the views that need this
> functionality -- and, then, building slightly-different templates for
> each of the three outputs.
>
> There's something about this that seems wrong, but I can't imagine a
> cleaner solution. Any thoughts?

I've been thinking about this recently (going to have a working
solution for the same problem pretty soon...). The cleanest solution
I've came with so far is to make the view function only return a
context, then wrap the view function in a decorator that takes care of
rendering, based on request informations. The points I'm yet really
happy with are:
- how to tell the rendering decorator what we want to render
- how to avoid template duplication for 'full' rendering and 'partial'
rendering

wrt/ first point, the simplest solution IMHO is to pass a render=json
or render=partial argument in the query string (default being
rendering the 'full' page). My main problem is with second point. I
have a working scheme using two templates, the 'full' one doing an
include of the 'partial' one. This should work, but I still don't like
having two distinct templates.

I don't have the (prototype) code at hand here, but from memory it's
something like:

class render_with(object):
def __init__(self, partial, full):
self.partial_template_path=fragment
self.full_template_path = full

def __call__(self, view):
self.view = view
return self.render

def render_json(self, request, context):
# this is in djangosnippets IIRC
return JsonResponse(context)

def render_partial(self, request, context):
return render_to_response(
self.partial_template_path,
context,
context_instance=RequestContext(request)
)

def render_full(self, request, context):
context['partial_include'] = self.partial_template_path
return render_to_response(
self.full_template_path,
context,
context_instance=RequestContext(request)
)

def render(self, request, *args, **kw)
context = self.view(request, *args, **kw)
#  the view can still return a response object
if isinstance(context, HttpResponse):
return context
# ok, it's really a context
render_mode = request.REQUEST.get('render', 'full')
render_method = getattr(self, 'render_%s' % render_mode)
return render_method(request, context)


Then you use it that way:

# myview.py
@render_with(partial='mypartial.html', full='myfull.html')
def myview(request, somearg):
   return dict(yadda='yadda')

# mypartial.html

Yadda : {{ yadda }}


# myfull.html
{% extends 'base.html' %}

{% block stuff %}
{{ yadday }} stuff here
{% endblock %}

{% block main %}
{% include partial_include %}
{% endblock %}

{% block other %}
other {{ yadda }} stuff here
{% endblock %}

HTH
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trying to avoid duplicate form posts/database inserts

2008-10-30 Thread Stan Dyck

Thomas Guettler wrote:
> Stan Dyck schrieb:
>   
>> I'm converting a simple database-backed web form to Django. Each form 
>> submit inserts a row into a database.
>>
>>   
>> 
>
> Hi,
>
> you can use yourmodel.objects.get_or_create(...)
> To force the uniqueness on database level you should use unique_together.
>
>   
Perfect! This appears to be what I'm looking for. Thanks.

>> To avoid multiple posts inserting duplicate rows I calculate a checksum 
>> on selected fields in the form and insert the checksum value into the 
>> database along with the form data itself. The checksum field is set in 
>> the database schema to be unique so that if an attempt is made to insert 
>> a duplicate row, the database will reject the insert.
>>   
>> 
> I think that this is not a good solution. Most databases can check
> uniqueness
> over several columns.

> My first impulse is that I could override the save method on the form 
> and use it to check the database for a checksum value. If I don't find 
> it, I insert the row along with the checksum. If I find it, I just 
> reject the insert and send the appropriate message to the response.
>   
> This might be possible, but I would handle this outside the save method.
>
>
>   Thomas
>
>
>   


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding properties to models at run-time.

2008-10-30 Thread Daniel Roseman

On Oct 30, 8:11 pm, Alex G <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've been trying for some time to create a polymorphic link with a
> backwards-link from the associated model.  The problem is the model is
> django.contrib.auth.models.User...  Is there any way to add this
> functionality without changing the django core?  Trying to call
> setattr(django.contrib.auth.models.User, 'target',
> generic.GenericRelation(MyUser) does not work.  It instantiates an
> attribute named 'target', but it doesn't work in the manner
> intended...
>
> from django.contrib.auth.models import User as Account
> from django.contrib.contenttypes.models import ContentType
> from django.contrib.contenttypes import generic
> class User(models.Model):
>         account_polymorphic_link = models.ForeignKey(ContentType)
>         account_id = models.PositiveIntegerField()
>         account = generic.GenericForeignKey('account_polymorphic_link',
> 'account_id')
>
> setattr(Account, 'target', generic.GenericRelation(User)) #this
> doesn't seem to work
>
> My problem is that I'm using auth.User (Account in the above example)
> to store username/password and to leverage permissions and such, but I
> can't look someone up by username and get at the information in my
> derivative class...
>
> Does anyone have any ideas/suggestions?
>
> Thank you,
>
> Alex.

Well, you can use generic relations without the backwards link, by
simply looking up the content_type/object_id in the related class.

But for your use case, a much better way is to use the built-in
AUTH_PROFILE_MODULE setting, which allows you to nominate a class
which extends User, and enables a user.get_profile() method. See
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

--
DR.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Table width when using list_filter

2008-10-30 Thread Fabio Natali

Hi everybody!

I'm a bit confused about the behaviour of my change list page.

If I enable list_filter the table (the one listing my model instances)
"shrinks" and its width is no more 100% of the space available. All
the columns and data are perfeclty shown, it's just that everything is
more narrow. Obviously, part of the width is taken by the list_filter
window, but the table shrinks down far more.

Is this behaviour normal? Is there any reason for it?

I use trunk django and a cutting edge firefox browser.

Cheers, Fabio.

-- 
Fabio Natali

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Adding properties to models at run-time.

2008-10-30 Thread Alex G

Hi,

I've been trying for some time to create a polymorphic link with a
backwards-link from the associated model.  The problem is the model is
django.contrib.auth.models.User...  Is there any way to add this
functionality without changing the django core?  Trying to call
setattr(django.contrib.auth.models.User, 'target',
generic.GenericRelation(MyUser) does not work.  It instantiates an
attribute named 'target', but it doesn't work in the manner
intended...

from django.contrib.auth.models import User as Account
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
class User(models.Model):
account_polymorphic_link = models.ForeignKey(ContentType)
account_id = models.PositiveIntegerField()
account = generic.GenericForeignKey('account_polymorphic_link',
'account_id')

setattr(Account, 'target', generic.GenericRelation(User)) #this
doesn't seem to work

My problem is that I'm using auth.User (Account in the above example)
to store username/password and to leverage permissions and such, but I
can't look someone up by username and get at the information in my
derivative class...

Does anyone have any ideas/suggestions?

Thank you,

Alex.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



error message: Can't pickle ...

2008-10-30 Thread Jim

Hello,

I am getting an error message that has got me a bit stumped.  If you
have any ideas, I would be very clad of any help.  The error is:


Traceback (most recent call last):

  File "/usr/local/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)

  File "/usr/local/lib/python2.5/site-packages/django/core/servers/
basehttp.py", line 635, in __call__
return self.application(environ, start_response)

  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
wsgi.py", line 243, in __call__
response = middleware_method(request, response)

  File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/
middleware.py", line 35, in process_response
request.session.save()

  File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/
backends/db.py", line 53, in save
session_data =
self.encode(self._get_session(no_load=must_create)),

  File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/
backends/base.py", line 88, in encode
pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL)

PicklingError: Can't pickle : attribute lookup
django.forms.formsets.AuthorWithIdFormFormSet failed


I have just updated to the latest svn version ten minutes ago, and I
still get the same error.

The referenced form is for showing authors of packages.  It is below;
I apologize if the formatting is off.  The only twist that I see is
that I need to have a custom clean() so I make the formset with
formset_factory(AuthorWithIdForm, extra=2, formset=BaseAuthorFormSet).

..
class AuthorWithIdForm(forms.Form):
  author_id=forms.CharField(required=False,widget=HiddenInput)
 
display_name=forms.CharField(max_length=60,required=False,widget=widgets.AuthorWidget,help_text="Author's
name")
 
email=forms.EmailField(max_length=72,min_length=1,required=False,widget=widgets.EmailWidget,help_text="Email
(not shown publicly)")
active=forms.BooleanField(required=False,help_text="Active?")

# The author id is encrypted as some protection against people
# messing with my mind.
def encrypt_id(self,x):
return encrypter().asciiEncrypt(x)
def clean_author_id(self):
x=self.cleaned_data.get('author_id',None)
try:
if x is None:
return u''
else:
unencodedId=encrypter().asciiDecrypt(x)
unencodedId=unencodedId.rstrip()
return unencodedId
except:
raise forms.ValidationError(u'The author id field is
corrupted.')

# This allows me to add a custom clean() method to the formset made of
# AuthorWithIdForm's.  The clean() method checks that there is at
least
# one author with a display name and of the authors at least one has a
# email.
class BaseAuthorFormSet(BaseFormSet):
def clean(self):
super(BaseAuthorFormSet,self).clean()
cd=[]
try:
if self.cleaned_data:
for dct in self.cleaned_data:
if ('display_name' in dct.keys()
and dct['display_name']
and 'email' in dct.keys()
and dct['email']
and fields.email_re.search(dct['email'])):
cd.append(dct)
if cd:
return cd
except:
pass
raise forms.ValidationError, u'You must name at least one
author, by giving the display name, and at least one of your authors
must have an email.'
.

If anyone has a hint, or has run across a similar circumstance, I
would be most grateful.  No doubt I'm doing something dopey, but I
can't see it.

Thanks,
Jim

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: [PyCon-Organizers] PyCon 2009 (US) - Call for tutorials Extended to 11/3

2008-10-30 Thread Douglas Napoleone

We should get an announcement out on the blog:
http://pycon.blogspot.com/

and note that the deadline is approaching for both talks and tutorials.

For some reason blogger does not like my google account, so I cant
seem to do it :-(

-Doug

On Thu, Oct 30, 2008 at 3:28 PM, Greg Lindstrom <[EMAIL PROTECTED]> wrote:
> We have had requests to extend the deadline for submitting Tutorial
> Proposals for PyCon 2009 (US) through the weekend and are willing to do so.
> We will accept tutorial proposals through Monday, November 3.
>
> --greg
>
> ==
>
> The period for submitting tutorial proposals for Pycon 2009 (US) is open and
> will continue through Monday, November 3rd. This year features two
> "pre-conference" days devoted to tutorials on Wednesday March 25 & Thursday
> March 26 in Chicago. This allows for more classes than ever.
>
> Tutorials are 3-hours long on a specific topic of your choice. Last year we
> featured classes on Learning Python, Web Development, Scientific Computing,
> and many more. Class size varied from 10 to over 60 students. The extended
> time spent in class allows teachers to cover a lot of material while
> allowing for interaction with students.
>
> The full Call for Tutorial Proposals, including submission details, an
> example proposal as well as a template, is available at
> .
>
> Tutorial selections will be announced in early December to give you time to
> prepare your class and PyCon will compensate instructors US$1,500 per
> tutorial.
>
> If you have any questions, please contact [EMAIL PROTECTED]
>
> Greg Lindstrom
>
> Tutorial Coordinator, PyCon 2009 (US)
>
> ___
> PyCon-organizers mailing list
> [EMAIL PROTECTED]
> http://mail.python.org/mailman/listinfo/pycon-organizers
>
>

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cannot import name call_command

2008-10-30 Thread noureddine

yes, i already thik in this idea
but the application has an others bug with django 1.0 and the 1st
developper says in his documentation that works with django 0.9
thanks


On 30 oct, 17:04, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 30, 2008 at 12:27 PM, noureddine <[EMAIL PROTECTED]> wrote:
>
> > this is what i specified :
>
> > from django.core.management import call_command
>
> OK, so you've got an import that should work on Django 1.0.  I suspect
> you're either not running on Django 1.0 (that import doesn't work on 0.96)
> or your installation is corrupt.  The former is probably more likely.
>
> Karen
>
>
>
> > On 29 oct, 15:39, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > On Wed, Oct 29, 2008 at 11:05 AM, noureddine <[EMAIL PROTECTED]>
> > wrote:
>
> > > > i have this problem
> > > > is there anybody hwo know the solution.
> > > > please tell me.
>
> > > You've specified the wrong import, or the wrong pythonpath, or have a
> > > corrupt installation, or ...? Without some specifics of what you are
> > doing
> > > to generate this error it is a bit hard to say.
>
> > > Karen
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



PyCon 2009 (US) - Call for tutorials Extended to 11/3

2008-10-30 Thread Greg Lindstrom
We have had requests to extend the deadline for submitting Tutorial
Proposals for PyCon 2009 (US) through the weekend and are willing to do so.
We will accept tutorial proposals through Monday, November 3.

--greg

==

The period for submitting tutorial proposals for Pycon 2009 (US) is open and
will continue through Monday, November 3rd. This year features two
"pre-conference" days devoted to tutorials on Wednesday March 25 & Thursday
March 26 in Chicago. This allows for more classes than ever.

Tutorials are 3-hours long on a specific topic of your choice. Last year we
featured classes on Learning Python, Web Development, Scientific Computing,
and many more. Class size varied from 10 to over 60 students. The extended
time spent in class allows teachers to cover a lot of material while
allowing for interaction with students.

The full Call for Tutorial Proposals, including submission details, an
example proposal as well as a template, is available at <
http://us.pycon.org/2009/tutorials/proposals/>.

Tutorial selections will be announced in early December to give you time to
prepare your class and PyCon will compensate instructors US$1,500 per
tutorial.

If you have any questions, please contact [EMAIL PROTECTED]

Greg Lindstrom
Tutorial Coordinator, PyCon 2009 (US)

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multiple types of output (HTML, JS), same view.

2008-10-30 Thread Joe Murphy

Hi,

So I've got a bunch of views that I need to output in three forms:
HTML with the site wrapper (header, footer etc.), HTML without the
site wrapper, and JS. The templates are really, really similar.

I'm thinking of using a url pattern like:
r'^blog/blah(?P[-\.\/\w]+)$'
so that blog/blah/ would return the HTML with site wrapper, blog/
blah.html would return the HTML without wrapper, and blog/blah.js
would return the javascript.

Doing this means I'm putting logic in all the views that need this
functionality -- and, then, building slightly-different templates for
each of the three outputs.

There's something about this that seems wrong, but I can't imagine a
cleaner solution. Any thoughts?

Joe
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Migrate app from MySQL to PostgreSQL

2008-10-30 Thread Naitik Shah
I ran into issues with this approach as well - first uniqueness constraints
were failing, which I managed to fix manually. Next I got ContentType
matching query issues, which I have not fixed yet.

I was hoping to come up with a generic migration process since I have a few
other sites on MySQL. But this is my first foray into PostgreSQL, so maybe I
should just take a simpler approach and write a task specific migration
script until I'm convinced I should move all my sites to PostgreSQL.


-Naitik

On Thu, Oct 30, 2008 at 12:59 AM, Brot <[EMAIL PROTECTED]> wrote:

>
> This doesn't work as expected. I tried the migration with dumpdata
> month ago.
> The problem is, that mysql and postgres writes another, incompatible
> boolean values. I believe sqlite and postgres has the same problem!
> I reworked the dumpdata output-file. In my case this was possible,
> because the amount of data was not too big
>
> On 30 Okt., 08:44, David Christiansen <[EMAIL PROTECTED]> wrote:
> > Why not just dump the data using manage.py dumpdata, switch your
> > settings file to point to the new DB, run syncdb, and then use
> > manage.py loaddata to get it all back?  That should be pretty easy.
> >
> > -David Christiansen
> >
> > On Oct 30, 2:39 am, "Naitik Shah" <[EMAIL PROTECTED]> wrote:
> >
> > > I looked around but didn't find anything obvious or simple. This is a
> live
> > > Django app with data in MySQL which I want to migrate to PostgreSQL.
> > > Suggestions? (Before I do my own thing :))
> >
> > > -Naitik
>

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ManyToMany views

2008-10-30 Thread ndarkduck

Hi, thanks for making a mailing list about inqueries.

I want to know if is possible to autogenerate a view that allows a
many to many relationship with an extra field to be captured.

ie:

class statictests(models.Model):
   statictests_id = models.AutoField(primary_key=True);
statictests_name = models.CharField(max_length=90);

class proyect(models.Model):
   tests = models.ManyToManyField(statictests, through =
'num_tests');

class num_tests_unidades(models.Model):
un_alt_tec = models.ForeignKey(statictests);
res_proy_ver = models.ForeignKey(proyect);
num_tests = models.IntegerField();

The view that results from this code is:
--

bababa.
bebe.
bibi
etc1.
etc2.

-
I need something that specifies the attribute of the relationship.

Thanks in advance


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



Re: Using TEMPLATE_DIRS and impact on admin pages path

2008-10-30 Thread RossGK

Sorry - more info in dribs and drabs as i get it.

I thought I could add a path to the admin templates, but no luck.
Tried adding

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
packages/django/contrib/admin/templates

to the TEMPLATE_DIRS  and it has no effect.
Interestingly with my template path in there, I'm still able to get
the admin log-in page, but then it fails with this info:


'adminapplist' is not a valid tag library: Could not load template
library from django.templatetags.adminapplist, No module named
adminapplist

Request Method: GET
Request URL:http://localhost:8000/admin/
Exception Type: TemplateSyntaxError
etc...

Hope that sparks some recognition for someone.  I guess for now, I'll
just have to comment out my template dir whenever I need the admin
functions :(


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Handling multiple sites branched off of one main site

2008-10-30 Thread Håkan Waara


30 okt 2008 kl. 19.23 skrev Wayne M:



> exactly this and it makes fixing anything insanely difficult.
>
> Any suggestions to point me in the right direction would be
> appreciated... like I said I'm not sure if Django fits my needs in
> this case.

I think Django sounds ideal in your situation.

* A django "app" is generally something that is reusable. A set of  
views, models, forms that do one function, and do it well. Read more  
about this here: 
http://stackoverflow.com/questions/64237/when-to-create-a-new-app-with-startapp-in-django

* To use the same set of objects (products) but a subset for each  
different site, you can use the built-in sites framework. Basically  
each product will have a ManyToMany-relation to a set of sites  
(foo.com, bar.com) that tags which site(s) it belongs to. See 
http://docs.djangoproject.com/en/dev/ref/contrib/sites/?from=olddocs 
.

Finally, hopefully you've gone through the tutorial? There's some  
great docs over here that help you wrap your head around django and  
the usual workflow: http://docs.djangoproject.com/en/dev/

Hope this helps and good luck!
/Håkan
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: test_gdal.run() output question

2008-10-30 Thread palewire

Oh pish. I figured this one out by -- surprise -- reading the innerds
of the test_gdal py file. Forgive me for the list pollution.

Geographic Admin app up and running! GeoDjango is awesome!

On Oct 30, 10:59 am, palewire <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> Excited to get kicking with GeoDjango, and just drew this error
> message when running the initial test. I'm not totally sure whether I
> need to be concerned or not with the output. Anybody know what to make
> of it?
>
> """>>> test_gdal.run()
>
> .
> BEGIN - expecting out of range feature id error; safe to ignore.
>
> ERROR 1: Attempt to read shape with feature id (5) out of
> available range.
> ERROR 1: Attempt to read shape with feature id (5) out of
> available range.
>
> END - expecting out of range feature id error; safe to ignore.
> ...
> BEGIN - expecting IllegalArgumentException; safe to ignore.
>
> GEOS_ERROR: IllegalArgumentException: points must form a closed
> linestring
>
> END - expecting IllegalArgumentException; safe to ignore.
>
> ..
> --
> Ran 46 tests in 0.096s
>
> OK
> """
>
> Thanks, django users!
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using TEMPLATE_DIRS and impact on admin pages path

2008-10-30 Thread RossGK

Should also mention that in moving from win32 to darwin, I also
migrated from 0.96 to 1.0, and made the appropriate changes to make
admin work, as per the porting guide on docs.djangoproject.com.

Ross.

On Oct 30, 2:26 pm, RossGK <[EMAIL PROTECTED]> wrote:
> Moving development from win32 to mac and one little thing I don't
> understand about template paths.
> Got django set up and DB in place etc, and was able to use the admin
> functions to populate some DB content. Everything seemed fine.
>
> But, initially on the Mac, my templates weren't being found, though my
> urls.py seemed to be pointing in the right direction.
>
> I'm probably forgetting something I knew when on win32 a few months
> back - but I noticed that the settings.py has a TEMPLATE_DIRS
> variable, and so I put the path to my templates and server-side
> content there.
>
> Everything is working fine now, and development continues.  BUT if I
> try to go and use the admin feature to do database stuff, I get a
> failure to connect from my browser.   If I comment out the
> TEMPLATE_DIRS path that I added, admin pages can again connect.
>
> Now, sure I can find and add the path to the admin templates to
> TEMPLATE_DIRS - is that the right approach, or am I getting into
> kludgy land here?   Any thoughts about how django was finding my
> templates back when I was on PC (which I don't have anymore) without
> using TEMPLATE_DIRS?
>
> Any help is appreciated.
>
> Ross.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using TEMPLATE_DIRS and impact on admin pages path

2008-10-30 Thread RossGK

Moving development from win32 to mac and one little thing I don't
understand about template paths.
Got django set up and DB in place etc, and was able to use the admin
functions to populate some DB content. Everything seemed fine.

But, initially on the Mac, my templates weren't being found, though my
urls.py seemed to be pointing in the right direction.

I'm probably forgetting something I knew when on win32 a few months
back - but I noticed that the settings.py has a TEMPLATE_DIRS
variable, and so I put the path to my templates and server-side
content there.

Everything is working fine now, and development continues.  BUT if I
try to go and use the admin feature to do database stuff, I get a
failure to connect from my browser.   If I comment out the
TEMPLATE_DIRS path that I added, admin pages can again connect.

Now, sure I can find and add the path to the admin templates to
TEMPLATE_DIRS - is that the right approach, or am I getting into
kludgy land here?   Any thoughts about how django was finding my
templates back when I was on PC (which I don't have anymore) without
using TEMPLATE_DIRS?

Any help is appreciated.

Ross.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Handling multiple sites branched off of one main site

2008-10-30 Thread Wayne M

I'm looking at using Django for a project at work, which is an e-
commerce storefront that *must* be able to support multiple
storefronts, each storefront filtering a subset of the master products
database.  For example, we might have a furniture store with the URL
furniture.mycompany.com or a recycled products store with the URL
green.mycompany.com.  There is also the requirement to allow different
full domain names that point to a certain storefront, e.g.
www.mycompanyfurniture.com should be the same as
furniture.mycompany.com

In addition, one site needs to have certain tables kept separate (it's
another company that we do the processing work for) than the rest, but
use the master products and categories table.  Orders, customers,
pricing, etc. need to be separate entities since they will be
different from the other tables.

Technically speaking, how would I best go about doing this?  The view
for each subsection would need to be different to filter specific
products, but the models are the same (e.g. products) and there is
only one database table.  Basically each storefront would have its own
base template that sets the look and feel, but all the other templates
(list, details, search, etc) would be the same as the "main"
storefront.

In Django, is the concept of an "app" analogous to the "module"
mindset I'm referring to here?  For example, would a directory
structure like this fulfil this requirement?:

myproject
 |- manage.py
 |- urls.py
 |- main_store
  |- models.py
  |- views.py
  |- templates
   |- base.html
   |- index.html
 |- furniture_store
  |- models.py (not used, uses main_store's)
  |- views.py
  |- templates
   |- base.html (?? use main_store's templates for everything except
base ??)
 |- green_store
  |- models.py (not used, uses main_store's)
  |- views.py
  |- templates
   |- base.html (?? use main_store's templates for everything except
base ??)
 |- companyb
  |- models.py (only what differs, since products et all are
identical)
  |- views.py
  |- templates
   |- base.html
   |- index.html

Running this over in my head is giving me a headache because it seems
very convoluted.  I'm not even sure if Django would be my best choice
in a situation like this because of the almost infinite flexibility
required and the fact that there needs to be separate pieces of the
same application (the main store) as well as a totally separate
application (the other company's store) but I don't want to duplicate
the entire thing; our current spaghetti-code system (VBScript) does
exactly this and it makes fixing anything insanely difficult.

Any suggestions to point me in the right direction would be
appreciated... like I said I'm not sure if Django fits my needs in
this case.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



test_gdal.run() output question

2008-10-30 Thread palewire

Hey all,

Excited to get kicking with GeoDjango, and just drew this error
message when running the initial test. I'm not totally sure whether I
need to be concerned or not with the output. Anybody know what to make
of it?

"""
>>> test_gdal.run()
.
BEGIN - expecting out of range feature id error; safe to ignore.

ERROR 1: Attempt to read shape with feature id (5) out of
available range.
ERROR 1: Attempt to read shape with feature id (5) out of
available range.

END - expecting out of range feature id error; safe to ignore.
...
BEGIN - expecting IllegalArgumentException; safe to ignore.

GEOS_ERROR: IllegalArgumentException: points must form a closed
linestring

END - expecting IllegalArgumentException; safe to ignore.

..
--
Ran 46 tests in 0.096s

OK
"""

Thanks, django users!
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Blank content from unit testing

2008-10-30 Thread jeffhg58
Here is the pasted code. I am wondering how to verify the content of 
search_form when I initially go to
that url

http://dpaste.com/87795/

-- Original message -- 
From: "Karen Tracey" <[EMAIL PROTECTED]> 
On Thu, Oct 30, 2008 at 11:50 AM, <[EMAIL PROTECTED]> wrote:

But, when I initialling go to '/resultsdb/search_form/' and the request is not 
a get but I a WSGIRequest how to test the content? Because in my view the only 
redirect after a request.GET occurs during an if conditional of when a certain 
button is pressed


I can't parse your question in the first sentence.  Code snippets might help.  
There is no content if you are getting a 302, it is a redirect and the only 
thing you can then examine would be the redirect Location.  Somehow the path 
your code is taking in response to a get on '/resultsdb/search_form/' is 
getting to a point where it returns a redirect, not a response.

You've also got another thread that I hadn't seen when I first responded on 
this one, where someone responded pointing out the likely line in your view you 
are hitting.  I gather from your last sentence you don't believe you can be 
hitting that line, but apparently you are. I couldn't get that far in reading 
the view code because it gets badly mangled in an email interface; dpaste.com 
would be a better place for putting code.

Karen



--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cannot import name call_command

2008-10-30 Thread Karen Tracey
On Thu, Oct 30, 2008 at 12:27 PM, noureddine <[EMAIL PROTECTED]> wrote:

>
> this is what i specified :
>
> from django.core.management import call_command
>

OK, so you've got an import that should work on Django 1.0.  I suspect
you're either not running on Django 1.0 (that import doesn't work on 0.96)
or your installation is corrupt.  The former is probably more likely.

Karen


>
>
> On 29 oct, 15:39, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > On Wed, Oct 29, 2008 at 11:05 AM, noureddine <[EMAIL PROTECTED]>
> wrote:
> >
> > > i have this problem
> > > is there anybody hwo know the solution.
> > > please tell me.
> >
> > You've specified the wrong import, or the wrong pythonpath, or have a
> > corrupt installation, or ...? Without some specifics of what you are
> doing
> > to generate this error it is a bit hard to say.
> >
> > Karen
> >
>

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FileField doesn't repopulate after a ValidationError on another field

2008-10-30 Thread Karen Tracey
On Thu, Oct 30, 2008 at 12:19 PM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> Ok, this sounds logical to me.
>
> I guess the best way to handle this is to make the uploading process
> require 2 separate submission pages, the first one for all the regular
> input, and then have a second page just to upload the file.
>
> Perhaps somebody has a better idea?
>

At the expense of some additional complexity in your view & template, you
can maintain a one-step submission for your users.  I'd probably look at
adding an additional hidden input field to the form that starts out empty
but is used in cases where a file has already been uploaded through a prior
submission which failed validation for some non-filefield-related problem.
The value in the hidden field would allow the server view code to locate the
previously-uploaded file when the form is re-submitted.  The template would
display the File input field only when necessary, if a file has already been
uploaded then the template would display a note to that effect instead.

So if there are no errors on the initial submission, it's a one-step process
for the user.

If there is an error (not related to the uploaded file), the server stashes
the uploaded file somewhere and sets the value of the hidden field so that
the file can be found on resubmit.  From a user's point of view the form is
redisplayed but they do not have to re-select the file -- rather the form
shows that the file has been uploaded and the other error messages on the
form show what needs to be corrected to complete the submission.

On resubmit, the server locates the previously-uploaded file via the
information in the hidden field instead of getting it from the post data.
Your view logic is a bit more complicated than for simple forms, and your
template has to be a little more involved than {{ form.as_p }}, but it's
probably more intuitive for users than a 2-step default submission process.

Karen

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: geodjango on cough-vista-cough?

2008-10-30 Thread 7timesTom

Thanks for the help mate, unfortunately I still get exactly the same
errors.

What I don't understand, is that it's complaining about the lack of
geo and postgis files, while installing postgis!

Anyone have any more advise?

On 30 Oct, 13:36, Jeff Johnson <[EMAIL PROTECTED]> wrote:
> 7timesTom wrote:
> > I'm trying to install geodjango on windows vista business (I know!
> > sorry!). Firstly is this a futile attempt to begin with?
>
> > If not, here's the problem I'm getting:
>
> > I've installed PostgreSQL using the windows xp instructions at
> >http://geodjango.org/docs/install.html#windows. And then done a full
> > install of all available pgSQL options. But when I come to install
> > PostGIS I get the error:
>
> > """PostGIS 1.3.3 for PostgresSQL 8.3
>
> > Error opening file for writing:
>
> > C:\Program Files\PostgreSQL\8.3\bin\libgeos-3-0-0.dll
>
> > [Abort] [Retry] [Ignore]"""
>
> > And indeed that file and others (libgeos_c-1.dll, libiconv-2.dll,
> > libproj.dll, pgsql2shp.exe, shp2pgsql.exe, etc etc) mentioned if I
> > click ignore are indeed missing.
>
> > Does anyone know if they are supposed to come with PostgreSQL 8.3 and
> > which component I may be missing?
>
> > Many thanks.
>
> This may or may not be your problem, but I am keeping all of my
> applications out of \program files.  It is my understanding that this is
> now reserved for "works with Vista" applications.  I install everything
> in \users\public.  So I would install PostgreSQL in
> \users\public\postgresql.  I also put my apps in something like
> \users\public\myapps.
>
> I am sure you can find other recommendations for postgresql.
>
> HTH
>
> --
> Jeff
>
> Jeff Johnson
> [EMAIL PROTECTED]
> Phoenix Python User Group - [EMAIL PROTECTED] Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get site's root path in Django

2008-10-30 Thread bruno desthuilliers



On 28 oct, 07:38, "yuanyun.ken" <[EMAIL PROTECTED]> wrote:
> Steve, Thanks for your expeditious reply.
> because our apache server includes other apps, I can not deploy my app
> to the root of the server.

This won't fix http://code.djangoproject.com/ticket/8906, but there's
at least one possible workaround in the meantime : use a sub domain
(ie subdomain.yourdomain.tld).



--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cannot import name call_command

2008-10-30 Thread noureddine

this is what i specified :

from django.core.management import call_command


On 29 oct, 15:39, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 29, 2008 at 11:05 AM, noureddine <[EMAIL PROTECTED]> wrote:
>
> > i have this problem
> > is there anybody hwo know the solution.
> > please tell me.
>
> You've specified the wrong import, or the wrong pythonpath, or have a
> corrupt installation, or ...? Without some specifics of what you are doing
> to generate this error it is a bit hard to say.
>
> Karen
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FileField doesn't repopulate after a ValidationError on another field

2008-10-30 Thread [EMAIL PROTECTED]

Ok, this sounds logical to me.

I guess the best way to handle this is to make the uploading process
require 2 separate submission pages, the first one for all the regular
input, and then have a second page just to upload the file.

Perhaps somebody has a better idea?

Thanks

On Oct 30, 5:42 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 30, 2008 at 10:52 AM, [EMAIL PROTECTED] <
>
>
>
> [EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I've having a problem with FileField and ImageField. Basically, I have
> > a form for uploading images:
>
> > Name: _a_  (throws ValidationError('This name is already taken. Choose
> > another'))
> > Notes: _test notes_
> > Filename:  _abc123.txt_
>
> > When I press SUBMIT, I get the form again, but it looks like this:
>
> > -This name is already taken. Choose another
> > Name: _a_
> > Notes: _test notes_
> > Filename:  _ (blank Not sure why)
>
> > The FileField is not repopulated for some reason, but the other fields
> > are.
>
> I believe this is a browser security measure.  The browser won't allow a
> server to pre-load a value into a File input, because that would mean a
> naive user could easily submit a form which uploads some key file from their
> machine to the server.  So for a File input the browser requires that the
> user actually go and select a file to upload.  (I do not know if there are
> any tricks one can play to get around this, I've never looked for one.)
>
> Karen
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: inspect a model's field's option's values

2008-10-30 Thread bruno desthuilliers



On 30 oct, 14:26, Mark Wolgemuth <[EMAIL PROTECTED]> wrote:
> It seems like I'm missing something, but here's what I'm trying to do:
>
> In creating a Form object, I'm setting size limit validation
> (max_length). I'd like to recover the value for that from the
> corresponding Model's Field's max_length. So basically I want a symbol
> lookup that will inspect in the options of a field I have defined for
> a model, without having an instance of the model, just it's type.
>
> This is to avoid the 2 having to share a common separately defined
> constant, or just using an integer that I have to coordinate in both
> places, or in place of always using auto forms.
>
> eg
>
> class MyModel(Model):
>  myfield = CharField(max_length=128)
>
> --
>
> class MyForm(Form):
>  myfield = CharField(max_length=**GET.FROM.MODEL**)
>

def get_model_field_option(model, field, option, default=None):
field = model._meta.get_field_by_name(field)[0]
return getattr(field, option, default)

class MyForm(Form):
 myfield = CharField(
 max_length=get_model_field_option(MyModel, 'myfield',
'max_length', 100)
 )

Caveat : Not sure it works on all possible options for all possible
fields - testing left as an exercise to to OP !-)

HTH
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Blank content from unit testing

2008-10-30 Thread Karen Tracey
On Thu, Oct 30, 2008 at 11:50 AM, <[EMAIL PROTECTED]> wrote:

> But, when I initialling go to '/resultsdb/search_form/' and the request is
> not a get but I a WSGIRequest how to test the content? Because in my view
> the only redirect after a request.GET occurs during an if conditional of
> when a certain button is pressed
>

I can't parse your question in the first sentence.  Code snippets might
help.  There is no content if you are getting a 302, it is a redirect and
the only thing you can then examine would be the redirect Location.  Somehow
the path your code is taking in response to a get on
'/resultsdb/search_form/' is getting to a point where it returns a redirect,
not a response.

You've also got another thread that I hadn't seen when I first responded on
this one, where someone responded pointing out the likely line in your view
you are hitting.  I gather from your last sentence you don't believe you can
be hitting that line, but apparently you are. I couldn't get that far in
reading the view code because it gets badly mangled in an email interface;
dpaste.com would be a better place for putting code.

Karen

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Blank content from unit testing

2008-10-30 Thread jeffhg58
But, when I initialling go to '/resultsdb/search_form/' and the request is not 
a get but I a WSGIRequest how to test the content? Because in my view the only 
redirect after a request.GET occurs during an if conditional of when a certain 
button is pressed

Jeff
-- Original message -- 
From: "Karen Tracey" <[EMAIL PROTECTED]> 
On Thu, Oct 30, 2008 at 10:25 AM, jeffhg58 <[EMAIL PROTECTED]> wrote:


I am currently the django test client and I have run across a
stumbling block.

When I do a get command for my main screen which is get('/resultsdb/
search_form/'), the status code
returns a 302 with no content.
But, if a do a get on say ('/login/') or a subsequent window besides
the main window such as ('/resultsdb/newresults/') and get a status
code of 200 with the content of the window.

Any help would be greatly appreciated. I am stumped on this.



Well a 302 is a redirect, so it won't have content.  response['Location'] will 
tell you where it is redirecting to, which might give you a hint.


Karen


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FileField doesn't repopulate after a ValidationError on another field

2008-10-30 Thread Karen Tracey
On Thu, Oct 30, 2008 at 10:52 AM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> Hello,
>
> I've having a problem with FileField and ImageField. Basically, I have
> a form for uploading images:
>
> Name: _a_  (throws ValidationError('This name is already taken. Choose
> another'))
> Notes: _test notes_
> Filename:  _abc123.txt_
>
> When I press SUBMIT, I get the form again, but it looks like this:
>
> -This name is already taken. Choose another
> Name: _a_
> Notes: _test notes_
> Filename:  _ (blank Not sure why)
>
> The FileField is not repopulated for some reason, but the other fields
> are.
>

I believe this is a browser security measure.  The browser won't allow a
server to pre-load a value into a File input, because that would mean a
naive user could easily submit a form which uploads some key file from their
machine to the server.  So for a File input the browser requires that the
user actually go and select a file to upload.  (I do not know if there are
any tricks one can play to get around this, I've never looked for one.)

Karen

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



302 status code in django test client

2008-10-30 Thread jeffhg58

I am having difficulty trying to test out the content of the main
window because it returns the status code
of 302. Here is the snippet of my view. So, when I first call the
search_form the request falls out of the
if request. GET. Does anyone have an idea on how I can test the
content of this page?

Thanks,
Jeff

def search_form(request):



if request.GET:

global_vars.search_data = request.GET.copy()
form = SearchForm(global_vars.search_data) # Instantiate
and load POST data

if form.is_valid(): # Validate data
 page_num = search(global_vars.search_data)

 if request.has_key('getrecs'):

  rl = ResultList(request, page_num, 'Result')



  c = template.RequestContext(request, {
  'count': rl.result_count,
  'rl': rl,
  })
  renderfile = resultsdir + '/results_list.html'
  return render_to_response([renderfile],
context_instance=c)

 if request.has_key('getcsv'):
  # Create the HttpResponse object with the
appropriate CSV header.
  response = HttpResponse(mimetype='text/csv')
  response['Content-Disposition'] = 'attachment;
filename=somefilename.csv'

  qs = Result.objects.filter(**global_vars.query_dict)
  qs = qs.exclude(**global_vars.exclude_query_dict)


  writer = csv.writer(response)
  writer.writerow(['row 1', 'ID', 'Test Name',
'Project', 'Phase', 'Test Type', 'Station',
  'Start Date', 'Owner', 'Status',
'Test Configuration'])
  for i in range(len(qs)):
  rowtext = 'row ' + str(i+2)
  id = str(qs[i].id)
  tname = qs[i].TestName
  projname = str(qs[i].ProjectId)
  phase = str(qs[i].PhaseId)
  testtype = str(qs[i].TestTypeId)
  station = str(qs[i].StationId)
  startdate = str(qs[i].ExecutionStartDate)
  owner = qs[i].Owner
  status = str(qs[i].StatusId)
  configdata =
ConfigResult.objects.filter(ResultsId='%s' %qs[i].id)
  Configstr = ''
  for configresult in configdata:
  if Configstr != '':
  Configstr += ','
  Configstr += str(configresult)
  writer.writerow([rowtext, id, tname, projname,
phase, testtype, station,
  startdate, owner, status,
Configstr])



  return response
 if request.has_key('newresults'):
  #redirectaddr = resultsdir + '/newresults/'
  return HttpResponseRedirect('/resultsdb/newresults')

else:

form = SearchForm()


# Create the FormWrapper, template, context, response.


s = template.RequestContext(request, {
 'form': form})

renderfile = resultsdir + '/search_form.html'
return render_to_response([renderfile], context_instance=s)
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding a custom permission to the User model

2008-10-30 Thread Benedict Verheyen

Benedict Verheyen wrote:
> 
> Now i need to find out how i can make the syndb command aware of the
> models in that subdirectory. Can i trigger this from the __init__.py
> file that lives in the main application directory?

I added the directory (project.app.modeldir) to the INSTALLED_APPS apps
and then the permissions are created. Problem solved.

Thanks,
Benedict


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 302 status code in django test client

2008-10-30 Thread Thomas Guettler

jeffhg58 schrieb:
> I am having difficulty trying to test out the content of the main
> window because it returns the status code
> of 302. Here is the snippet of my view. So, when I first call the
> search_form the request falls out of the
> if request. GET. Does anyone have an idea on how I can test the
> content of this page?
>
>   

302 is redirect. There is no content.

You hit this line:
>   return HttpResponseRedirect('/resultsdb/newresults')
>   


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Blank content from unit testing

2008-10-30 Thread Karen Tracey
On Thu, Oct 30, 2008 at 10:25 AM, jeffhg58 <[EMAIL PROTECTED]> wrote:

>
> I am currently the django test client and I have run across a
> stumbling block.
>
> When I do a get command for my main screen which is get('/resultsdb/
> search_form/'), the status code
> returns a 302 with no content.
> But, if a do a get on say ('/login/') or a subsequent window besides
> the main window such as ('/resultsdb/newresults/') and get a status
> code of 200 with the content of the window.
>
> Any help would be greatly appreciated. I am stumped on this.
>
>
Well a 302 is a redirect, so it won't have content.  response['Location']
will tell you where it is redirecting to, which might give you a hint.

Karen

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django model version control

2008-10-30 Thread christian

I tried it out David, and it is simple and it works, I was just about
to make the same exact thing. Thank you!

On 4 okt, 15:21, David Hall <[EMAIL PROTECTED]> wrote:
> I've created a Google group for discussing possible improvements to the
> django-reversion project.  The group is called 'django-reversion', and
> is a good place to let your views be heard about enhancements to the system.
>
> At some point I would like to put the project forward as a candidate for
> the currently-inactive fullhistory branch.  As such, your feedback and
> suggestions are vital to making this application as bombproof as possible.
>
> David.
>
>
>
>
>
> David Hall wrote:
> > I've just released an open-sourceversioncontrolapplication for
> > Django.  It is available for download from Google code.
>
> >http://code.google.com/p/django-reversion/
>
> > Features include:
>
> >   - Roll back to any point in a model's history - an unlimited undo
> > facility!
> >   - Recover deleted models - never lose data again!
> >   - Admin integration for maximum usability.
> >   - Group related changes into revisions that can be rolled back in a
> > single transaction.
> >   - Automatically save a newversionwhenever your model changes using
> > Django's flexible signalling framework.
> >   - Automate your revision management with easy-to-use middleware.
>
> > It can be easily added to your existing Django project with an
> > absolute minimum of code changes.
>
> > It's so far been previewed by a half dozen developers, with good
> > feedback.  I'd appreciate any comments / suggestions you may have to
> > offer.
>
> --
>   David Hall
>   Technical Lead
>   Etianen.com
>   Tel: 07896 106290
>
>   Email   [EMAIL PROTECTED]
>   Web      www.etianen.com
> ---
>   Ask for help at [EMAIL PROTECTED]
>   Etianen.com is a small, professional web development agency that
>   specialises in fast-paced, creative development.
> - enlightened website development -- Tekst 
> uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding a custom permission to the User model

2008-10-30 Thread Benedict Verheyen

Benedict Verheyen wrote:

> When i do python manage.py syncdb i don't see anything written to the
> db. The permission is also not visible from within the users part of the
> admin site.

I found out that the syncdb command didn't work. I deleted a table and
after i did the syncdb, the table wasn't created.

It's because i've put the models.py file in a subdirectory. Because it
doesn't live in the applications main directory, it's not detected.
When i move the models.py file out of that subdirectory, the table is
created again and the permissions are added.

Now i need to find out how i can make the syndb command aware of the
models in that subdirectory. Can i trigger this from the __init__.py
file that lives in the main application directory?

Regards,
Benedict




--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



appeal for help with #9232

2008-10-30 Thread Faheem Mitha


Hi,

Can anyone help with

http://code.djangoproject.com/ticket/9232

? Currently I don't even know if this problem is reproducible. If someone 
could solve it, or even indicate what was wrong, if anything, I'd be happy 
to pay for services rendered.

Thanks, Faheem

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Don't mix *args and **kwargs in call to reverse()!

2008-10-30 Thread Håkan W

On 1 Sep, 15:47, Adrián Ribao <[EMAIL PROTECTED]> wrote:
> I'll write an example of the problem. All my urls are prepared
> following the best SEO rules, so in many places I have urls like:
> (r'^(.*)-f(?P\d+)\.html$','view_photo')
>
> this would make the url:
> my-photo-f2.html
>
> I get the url using:
> reverse('app.views.view_photo', args=[slugify(photo.title),],
> kwargs={'id':id} )
> (Note: I don't want to use a slug field.)
>
> Now this won't work. Well, IMHO this is a bug, I don't see the point.
> Besides this makes rev:8760 backwards incompatible and it wasn't
> suppose to.

I just hit this too. There seems to be no information or hint in the
docs about this (neither in the docs about reverse or permalink), from
what I can find...

/Håkan
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Syndication Feed-Problem

2008-10-30 Thread Eric Abrahamsen


On Oct 30, 2008, at 7:04 PM, [EMAIL PROTECTED] wrote:

>
> Hi,
> i hope any one can help me.
> I want to generate a rss-feed.
> The url ist http://localhost:8000/isf/info/.
> All works fine but the title of an Item and the Description are still
> the same!
> How can i change the title of an feed item in the feed to the title
> from the model
> and the description of the feed item to the description from the
> model.
> I get only the String from the __unicode__(self): Method. An this
> string represent
> the title and the description, why ?

You need to provide some templates in order to display the feed items  
as you want them to look, check out the documentation here:

http://docs.djangoproject.com/en/dev/ref/contrib/syndication/#a-simple-example



>
>
> Please help me!
>
>
>
> My urls.py config:
> feeds = {
>'rss': Rss2Feed,
>
>}
>
> urlpatterns = patterns('django.contrib.syndication.views',
>url(r'^(?P.*)/$', 'feed', {'feed_dict': feeds},
> name="fh_feeds",),
> )
>
> Thats my models.py class:
>
> class Item(models.Model):
>title = models.CharField(max_length=30)
>banner = models.CharField(max_length=30, null=True)
>description = models.TextField(null=True)
>pub_date = models.DateTimeField(auto_now=True,
> verbose_name="Public Date")
>expire_date = models.DateTimeField(verbose_name="Expire Date")
>author = models.ForeignKey(User, editable=False)
>
>def authors_email(self):
>return "%s"%(self.author.email)
>
>def get_absolute_url(self):
>return "%s/"%(self.id)
>
>def __unicode__(self):
>return self.title
>
>class Meta:
>ordering = ['-pub_date']
>
> class Item_Category(models.Model):
>item = models.ForeignKey(Item)
>category = models.ForeignKey(Category)
>
>def __unicode__(self):
>return "%s"%self.item.id
>
> And thats my feed.py class:
>
> class Rss2Feed(Feed):
>#thats my hard-coded title,link and description for my info feed
>title = "Info"
>link = "/info/"
>description = "Info-Site"
>
># i want to show all items of my model with the slug info
>def items(self):
>listOfItems = []
>itemToCategoryForInfo =
> Item_Category.objects.select_related().filter(category__slug = "info")
>for selectedItem in itemToCategoryForInfo:
>listOfItems.append(selectedItem.item)
>return listOfItems

You can return a queryset directly here, all you need is:

def items(self):
   return Item_Category.objects.select_related().filter(category__slug  
= "info")

>
>
>
>
>
>
> >


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: __unicode__() method not working in models.py

2008-10-30 Thread Karen Tracey
2008/10/30 Andrew <[EMAIL PROTECTED]>

>
> I am currently working through the django book and I've got to the
> fifth chapter where I would like to replace the __str__() methods with
> __unicode__() methods instead. The reason is that my database will
> hold a great deal of Japanese text, UTF-8 encoded. After declaring the
> UTF-8 encoding at the top of models.py, as a test, I replace
>
> def __str__(self):
>return self.name
>
> with
>
> def __unicode__(self):
>return u'テスト'
>
> Entering the following code into the manage.py shell doesn't give the
> expected output.
>
> >>> from books.models import Publisher
> >>> publisher_list = Publisher.objects.all()
> >>> publisher_list
>
> I expect:
>
> [, ]
>
> but instead, the テスト is replaced with random Japanese characters that
> are not the ones I expected.
>
> I am using a Japanese version of Windows XP with PostgreSQL installed.
> The encoding of the database and the file are both UTF-8. The cmd.exe
> prompt doesn't let me type in Japanese but it does display Japanese if
> print out something I've saved in a file for example.
>
> Any ideas on where I'm going wrong?
>
>
I do not know if this will work for Japanese Windows, but for the English
version, the two things I have found that need to be done to ensure a
command prompt properly displays utf-8
are first:

chcp 65001

in the command prompt to change the active code page to the one that works
for utf-8 (65001 is apparently Windows' spelling of utf-8) and second change
the font properties of the command prompt (left click upper left corner of
the window, choose Properties, then Font tab) to use Lucida Console, not
Raster Fonts.  If I do those two things then utf-8 data looks correct in my
command prompts.

Karen

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



FileField doesn't repopulate after a ValidationError on another field

2008-10-30 Thread [EMAIL PROTECTED]

Hello,

I've having a problem with FileField and ImageField. Basically, I have
a form for uploading images:

Name: _a_  (throws ValidationError('This name is already taken. Choose
another'))
Notes: _test notes_
Filename:  _abc123.txt_

When I press SUBMIT, I get the form again, but it looks like this:

-This name is already taken. Choose another
Name: _a_
Notes: _test notes_
Filename:  _ (blank Not sure why)

The FileField is not repopulated for some reason, but the other fields
are.

Using django-1.0

I bind the data as specified at
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#topics-file-uploads:

form = UploadNewImageForm(request.POST, request.FILES)

My view function is identical to the one on the example page.
Everything else works, the file is properly uploaded and there are no
other problems. It is really just a user interface issue I would like
to fix because it is very annoying to have to repopulate the form
every time there is an input error, especially if there are many
fields.
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Blank content from unit testing

2008-10-30 Thread jeffhg58

I am currently the django test client and I have run across a
stumbling block.

When I do a get command for my main screen which is get('/resultsdb/
search_form/'), the status code
returns a 302 with no content.
But, if a do a get on say ('/login/') or a subsequent window besides
the main window such as ('/resultsdb/newresults/') and get a status
code of 200 with the content of the window.

Any help would be greatly appreciated. I am stumped on this.

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



Re: Execute a java program

2008-10-30 Thread Simon Brunning

2008/10/30 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> I have to execute a java program very simple look something like this:

(snip)

> How Can I do that? Do I have to use JVM ? How ?

You'll need a JVM - Python doesn't speak Java!

You can either just use the Subprocess module to call the JVM, just as
you would from the command line, or you might perhaps take a look at
 or .

-- 
Cheers,
Simon B.
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Execute a java program

2008-10-30 Thread Horst Gutmann

Hi :-)

Take a look at Python's subprocess module which lets you execute other
processes and communicate with them.
http://docs.python.org/library/subprocess.html#module-subprocess

-- Horst

On Thu, Oct 30, 2008 at 11:12 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Hi everyone I am newbie to django and I am italian so excuse me for my
> english :P
> I have to execute a java program very simple look something like this:
>
>
> public class Book {
>public static void main(String[] args) {
>
> int year = 2008;
>
> List list =  Booklist.fetchbook(year);
> Iterator it = list.iterator();
>
> while (it.hasNext()) {
> Book book = (Book) it.next();
> System.out.println( book.getTitle()  + " " +
> book.getAuthor() );
>}
>
> } }
>
>
> and I have to retrieve 2 strings ( book.getTitle() and
> book.getAuthor() ) for use its in django application.
> How Can I do that? Do I have to use JVM ? How ?
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: geodjango on cough-vista-cough?

2008-10-30 Thread Jeff Johnson

7timesTom wrote:
> I'm trying to install geodjango on windows vista business (I know!
> sorry!). Firstly is this a futile attempt to begin with?
> 
> If not, here's the problem I'm getting:
> 
> I've installed PostgreSQL using the windows xp instructions at
> http://geodjango.org/docs/install.html#windows. And then done a full
> install of all available pgSQL options. But when I come to install
> PostGIS I get the error:
> 
> """PostGIS 1.3.3 for PostgresSQL 8.3
> 
> Error opening file for writing:
> 
> C:\Program Files\PostgreSQL\8.3\bin\libgeos-3-0-0.dll
> 
> [Abort] [Retry] [Ignore]"""
> 
> And indeed that file and others (libgeos_c-1.dll, libiconv-2.dll,
> libproj.dll, pgsql2shp.exe, shp2pgsql.exe, etc etc) mentioned if I
> click ignore are indeed missing.
> 
> Does anyone know if they are supposed to come with PostgreSQL 8.3 and
> which component I may be missing?
> 
> Many thanks.
This may or may not be your problem, but I am keeping all of my 
applications out of \program files.  It is my understanding that this is 
now reserved for "works with Vista" applications.  I install everything 
in \users\public.  So I would install PostgreSQL in 
\users\public\postgresql.  I also put my apps in something like 
\users\public\myapps.

I am sure you can find other recommendations for postgresql.

HTH

-- 
Jeff

Jeff Johnson
[EMAIL PROTECTED]
Phoenix Python User Group - [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



can't delete many-to-many related record from admin inline

2008-10-30 Thread chris

Hi there,

I am still pretty new to django and just trying to figure out how it
is all supposed to work.

I have the following models:

*models.py:

class Char(models.Model):
char = models.CharField(max_length=10)
variants = models.ManyToManyField("self", symmetrical=False,
through="Variant", related_name="varchars", blank=True, null=True)

class Variant(models.Model):
 char = models.ForeignKey(Char)
 variant = models.ForeignKey(Char, related_name="vars")

*admin.py:

class CharVarInline(admin.StackedInline):
  model = Variant
  fk_name = "char"
  raw_id_fields=("variant", "char",)
  extra = 1

class CharAdmin(admin.ModelAdmin):
inlines = (CharVarInline,)


This causes the variants part to be displayed with a char record in
admin.  I also get a check-box there, which can be checked to delete
the inlined related recorded.   However, when I try to used this to
delete the record and click save, the following error occurs:

ValueError at /admin/chardb/char/70524/

'Variant' instance needs to have a primary key value before a many-to-
many relationship can be used.

Apparently, something is going wrong with the deletion, which lets
part of the record hang in empty air.  But I have no idea where to
look or how to fix this.  Does anybody has any idea?

Any help appreciated,

Chris

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: content type

2008-10-30 Thread [EMAIL PROTECTED]

thank you redmonkey

that is exactly what i was looking for.
have a nice day

redmonkey wrote:
> You need to set a 'Content-Disposition' header.
>
> http://docs.djangoproject.com/en/dev/howto/outputting-pdf/?from=olddocs#complex-pdfs
>
> Look within the 'some_view' definition. You need to generate a
> HttpResponse object, set the response mimetype to the correct type of
> file you're serving, and then set the 'Content-Disposition' key to
> something like it says. Notice you can also set the filename if you
> need to.
>
> On Oct 30, 9:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>   
>> hi all i am using debian stable version 0.95
>>
>> and i would like know, how to tell django not to open some file types as
>> JPG, PNG or MP3 in browser after click and rather open a classic menu to
>> save the file.
>>
>> thank you very much pavel
>> 
> >
>   


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Create/update/delete generic views

2008-10-30 Thread sugi

Can any one help me , how to use
django.views.generic.create_update.create_object and
django.views.generic.create_update.update_object in an application
with examples.

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



inspect a model's field's option's values

2008-10-30 Thread Mark Wolgemuth

It seems like I'm missing something, but here's what I'm trying to do:

In creating a Form object, I'm setting size limit validation
(max_length). I'd like to recover the value for that from the
corresponding Model's Field's max_length. So basically I want a symbol
lookup that will inspect in the options of a field I have defined for
a model, without having an instance of the model, just it's type.

This is to avoid the 2 having to share a common separately defined
constant, or just using an integer that I have to coordinate in both
places, or in place of always using auto forms.

eg

class MyModel(Model):
 myfield = CharField(max_length=128)

--

class MyForm(Form):
 myfield = CharField(max_length=**GET.FROM.MODEL**)

I assume that by using the Meta:  model = logic in Form for auto form,
that this is being done, but it wasn't obvious to me how.

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Execute a java program

2008-10-30 Thread [EMAIL PROTECTED]

Hi everyone I am newbie to django and I am italian so excuse me for my
english :P
I have to execute a java program very simple look something like this:


public class Book {
public static void main(String[] args) {

 int year = 2008;

 List list =  Booklist.fetchbook(year);
 Iterator it = list.iterator();

 while (it.hasNext()) {
 Book book = (Book) it.next();
 System.out.println( book.getTitle()  + " " +
book.getAuthor() );
}

} }


and I have to retrieve 2 strings ( book.getTitle() and
book.getAuthor() ) for use its in django application.
How Can I do that? Do I have to use JVM ? How ?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



geodjango on cough-vista-cough?

2008-10-30 Thread 7timesTom

I'm trying to install geodjango on windows vista business (I know!
sorry!). Firstly is this a futile attempt to begin with?

If not, here's the problem I'm getting:

I've installed PostgreSQL using the windows xp instructions at
http://geodjango.org/docs/install.html#windows. And then done a full
install of all available pgSQL options. But when I come to install
PostGIS I get the error:

"""PostGIS 1.3.3 for PostgresSQL 8.3

Error opening file for writing:

C:\Program Files\PostgreSQL\8.3\bin\libgeos-3-0-0.dll

[Abort] [Retry] [Ignore]"""

And indeed that file and others (libgeos_c-1.dll, libiconv-2.dll,
libproj.dll, pgsql2shp.exe, shp2pgsql.exe, etc etc) mentioned if I
click ignore are indeed missing.

Does anyone know if they are supposed to come with PostgreSQL 8.3 and
which component I may be missing?

Many 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: changing the Manager the admin-site should use

2008-10-30 Thread Dennis Schmidt

thanks a lot :-)

just created a ticket for this: #9476

On 30 Okt., 13:48, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 30, 2008 at 7:31 AM, Dennis Schmidt
>
> <[EMAIL PROTECTED]> wrote:
> > Well that does work, though in the Manager documentation it's said:
>
> > "If you use custom Manager objects, take note that the first Manager
> > Django encounters (in the order in which they're defined in the model)
> > has a special status. Django interprets this first Manager defined in
> > a class as the "default" Manager, and several parts of Django (though
> > not the admin application) will use that Manager exclusively for that
> > model."
>
> This is actually incorrect (open a ticket as a reminder and I'll fix
> the docs); by default, the admin now uses the default manager for the
> model, same as everything else in Django.
>
> As to your original question, ModelAdmin has a method named
> 'queryset()', which is used to obtain the QuerySet of objects for
> display in the admin lists and for looking up objects to edit.
> Overriding that method on your ModelAdmin subclass is the correct way
> to do this.
>
> This method receives the incoming HTTP request as an argument, so you
> can use it to filter based on some attribute of the request (e.g., the
> logged-in user). This also means that when overriding, you must define
> the method as "def queryset(self, request)", not just "def
> queryset(self)".
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python calls an older script?

2008-10-30 Thread bruno desthuilliers

On 30 oct, 13:14, Alessandro <[EMAIL PROTECTED]> wrote:
> I'm getting weird errors about a script that I've changed recently (a
> template_tag).
> It's strange because it refers to a line that I've deleted, so I think
> it comes from some cache, but I cannot find nothing.

Did you restart Apache ?


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: changing the Manager the admin-site should use

2008-10-30 Thread James Bennett

On Thu, Oct 30, 2008 at 7:31 AM, Dennis Schmidt
<[EMAIL PROTECTED]> wrote:
> Well that does work, though in the Manager documentation it's said:
>
> "If you use custom Manager objects, take note that the first Manager
> Django encounters (in the order in which they're defined in the model)
> has a special status. Django interprets this first Manager defined in
> a class as the "default" Manager, and several parts of Django (though
> not the admin application) will use that Manager exclusively for that
> model."

This is actually incorrect (open a ticket as a reminder and I'll fix
the docs); by default, the admin now uses the default manager for the
model, same as everything else in Django.

As to your original question, ModelAdmin has a method named
'queryset()', which is used to obtain the QuerySet of objects for
display in the admin lists and for looking up objects to edit.
Overriding that method on your ModelAdmin subclass is the correct way
to do this.

This method receives the incoming HTTP request as an argument, so you
can use it to filter based on some attribute of the request (e.g., the
logged-in user). This also means that when overriding, you must define
the method as "def queryset(self, request)", not just "def
queryset(self)".


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: changing the Manager the admin-site should use

2008-10-30 Thread Dennis Schmidt

Well that does work, though in the Manager documentation it's said:

"If you use custom Manager objects, take note that the first Manager
Django encounters (in the order in which they're defined in the model)
has a special status. Django interprets this first Manager defined in
a class as the "default" Manager, and several parts of Django (though
not the admin application) will use that Manager exclusively for that
model."

Which I understand as "Everything in django uses the first manager,
but the admin uses objects".
The thing is that I'm a bit curious about changing the default
manager. How shall I know this won't raise Exceptions anywhere in the
django code if my Manager behaves differently from "objects"?


On 30 Okt., 12:59, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote:
> On 30.10.2008 12:07 Uhr, Dennis Schmidt wrote:> Hello there,
>
> > I want the admin-site (and only the admin-site) to use ony of my own
> > custom Managers. Is there a way to do this except by changing the
> > default Manager "objects"?
>
> As far as I know, the admin site uses the first manager not necessarily
> the one called objects.
> If you do set a none default manager, be sure to also set an objects
> manager, since django won't create the objects manager if it already
> finds a different manager.
>
> adi
>
> --
> Adi J. Sieker         mobile: +49 - 178 - 88 5 88 13
> Freelance developer   web:    http://www.sieker.info/profile
> SAP-Developer
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mod_python calls an older script?

2008-10-30 Thread Alessandro
I'm getting weird errors about a script that I've changed recently (a
template_tag).
It's strange because it refers to a line that I've deleted, so I think
it comes from some cache, but I cannot find nothing.

the pyc file is no more compiled, so the directory with that files has
only a .py.

Where can I search for mod_python or django cached compiled scripts?

Thanks in advance!

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why is my string not auto escaped?

2008-10-30 Thread Rajesh Dhawan

On Oct 30, 1:30 am, shabda <[EMAIL PROTECTED]> wrote:
> So if these built in filters are marking my strings safe, inspite of
> unsafe data being passed in, should they not handle escaping as well?

The problem seems to be that your filter function doesn't mark itself
with an is_safe attribute (defaulting it to False). So try marking
your filter with is_safe=True which means that your filter doesn't
introduce any HTML unsafe characters by itself (not including the ones
that are already in the input):

filterxx.is_safe = True

Also, it's easier for people to follow a discussion thread if you
don't top post your responses.

-RD
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



custom auth

2008-10-30 Thread Gabriel Rossetti

Hello everyone,

I'm trying to get a custom auth handler to work but I keep on getting 
this error when accessing request.user.get_profile() :

DoesNotExist: User matching query does not exist.

I followed the following tutorials :

http://garage.pimentech.net/mdm_src_dj_auth_documentation/
http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/

Here is my auth handler :

from proj.app.models import User as MyUser
from django.contrib.auth.models import User, check_password

def authenticate(self, username=None, password=None):
try:
myUser = MyUser.objects.get(email=username)
except MyUser.DoesNotExist:
return None
pwdValid = check_password(password, myUser.password)
if(pwdValid):
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
user = User(username=username,
email=username,
first_name=myUser.firstName,
last_name=myUser.lastName,
password="none")
user.is_staff = False
user.is_superuser = False
user.save()
myUser.user = user # Not sure if this is really needed, 
I tried it since it didn't work and it still doesn't
myUser.save() # Not sure if this is really needed, I 
tried it since it didn't work and it still doesn't
return user
return None

def get_user(self, userId):
try:
return User.objects.get(pk=userId)
except User.DoesNotExist:
return None

here is my model :

from django.db import models
from django.contrib.auth.models import User as DjangoUser

class User(models.Model):
id = models.AutoField(primary_key=True)
firstname = models.CharField(maxlength=20)
lastname = models.CharField(maxlength=20)
email = models.CharField(maxlength=50)
password = models.CharField(maxlength=20)
user = models.ForeignKey(DjangoUser, unique=True)
#user = models.OneToOneField(DjangoUser, core=True) # This doesn't 
work either

I really don't see why it doesn't work...does anyone have a clue?

Thank you,
Gabriel

PS I've already looked at past posts on the subject but the common 
answer is to create the profile, but in my case it's already created, 
maybe I'm linking it wrong?

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: changing the Manager the admin-site should use

2008-10-30 Thread Adi Jörg Sieker

On 30.10.2008 12:07 Uhr, Dennis Schmidt wrote:
> Hello there,
>
> I want the admin-site (and only the admin-site) to use ony of my own
> custom Managers. Is there a way to do this except by changing the
> default Manager "objects"?
>
As far as I know, the admin site uses the first manager not necessarily 
the one called objects.
If you do set a none default manager, be sure to also set an objects 
manager, since django won't create the objects manager if it already 
finds a different manager.

adi

-- 
Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
Freelance developer   web:http://www.sieker.info/profile
SAP-Developer

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: __unicode__() method not working in models.py

2008-10-30 Thread Steve Holden

Andrew wrote:
> I am currently working through the django book and I've got to the
> fifth chapter where I would like to replace the __str__() methods with
> __unicode__() methods instead. The reason is that my database will
> hold a great deal of Japanese text, UTF-8 encoded. After declaring the
> UTF-8 encoding at the top of models.py, as a test, I replace
> 
> def __str__(self):
> return self.name
> 
> with
> 
> def __unicode__(self):
> return u'テスト'
> 
> Entering the following code into the manage.py shell doesn't give the
> expected output.
> 
 from books.models import Publisher
 publisher_list = Publisher.objects.all()
 publisher_list
> 
> I expect:
> 
> [, ]
> 
> but instead, the テスト is replaced with random Japanese characters that
> are not the ones I expected.
> 
> I am using a Japanese version of Windows XP with PostgreSQL installed.
> The encoding of the database and the file are both UTF-8. The cmd.exe
> prompt doesn't let me type in Japanese but it does display Japanese if
> print out something I've saved in a file for example.
> 
> Any ideas on where I'm going wrong?
> 
Are you declaring the encoding of your source file?

Try putting

# -*- coding: UTF-8 -*-

at the top of your file.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with pyExcelerator and response

2008-10-30 Thread Steve Holden

laspal wrote:
> Any one can help me out.
> Thanks.
> 
> On Oct 29, 11:41 am, laspal <[EMAIL PROTECTED]> wrote:
>> Hi,
>> I am trying to create Excel file usingpyExceleratorbut my problem is
>> I am not able
>> to attach file to response.
>>
>> code :
>> workbook = Workbook()
>> worksheet = workbook.add_sheet('My Test Sheet')
>>
>> worksheet.write(0,0, 'Company', font_style('left', 1, 'red'))
>> worksheet.write(1,1, 'Hello World!', font_style('left', 1,
>> 'black'))
>> worksheet.write(1,0, 'Hello World!', font_style('left', 1, 'red'))
>>
>> response = HttpResponse( mimetype='application/vnd.ms-excel')
>> response['Content-Disposition'] = 'attachment;
>> filename=output.xls'
>> workbook.save('output.xls')
>>
>>return response.
>>
>> I am able to generate output.xl file but without any data.
>> Can anyone help me out
>> Thanks.

Correction: the "Content-Disposition" header is fine, but you do need to
write the file contents to the response.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



changing the Manager the admin-site should use

2008-10-30 Thread Dennis Schmidt

Hello there,

I want the admin-site (and only the admin-site) to use ony of my own
custom Managers. Is there a way to do this except by changing the
default Manager "objects"?

greetings, Dennis
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with pyExcelerator and response

2008-10-30 Thread Steve Holden

I suspect the issue is the response you are returning. I have never seen
attachments on HTTP responses: can't you just return the contents of the
"output.xls" file by writing it to response before returning it? You
would also need to remove the "Content-Disposition" header.

Just a thought.

regards
 Steve

laspal wrote:
> Any one can help me out.
> Thanks.
> 
> On Oct 29, 11:41 am, laspal <[EMAIL PROTECTED]> wrote:
>> Hi,
>> I am trying to create Excel file usingpyExceleratorbut my problem is
>> I am not able
>> to attach file to response.
>>
>> code :
>> workbook = Workbook()
>> worksheet = workbook.add_sheet('My Test Sheet')
>>
>> worksheet.write(0,0, 'Company', font_style('left', 1, 'red'))
>> worksheet.write(1,1, 'Hello World!', font_style('left', 1,
>> 'black'))
>> worksheet.write(1,0, 'Hello World!', font_style('left', 1, 'red'))
>>
>> response = HttpResponse( mimetype='application/vnd.ms-excel')
>> response['Content-Disposition'] = 'attachment;
>> filename=output.xls'
>> workbook.save('output.xls')
>>
>>return response.
>>
>> I am able to generate output.xl file but without any data.
>> Can anyone help me out
>> Thanks.
> > 
> 


-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: content type

2008-10-30 Thread redmonkey

You need to set a 'Content-Disposition' header.

http://docs.djangoproject.com/en/dev/howto/outputting-pdf/?from=olddocs#complex-pdfs

Look within the 'some_view' definition. You need to generate a
HttpResponse object, set the response mimetype to the correct type of
file you're serving, and then set the 'Content-Disposition' key to
something like it says. Notice you can also set the filename if you
need to.

On Oct 30, 9:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> hi all i am using debian stable version 0.95
>
> and i would like know, how to tell django not to open some file types as
> JPG, PNG or MP3 in browser after click and rather open a classic menu to
> save the file.
>
> thank you very much pavel
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help to Upload image

2008-10-30 Thread Giles Thomas

please smile wrote:
> Can anybody please tell how to upload a image ?

I'm new to this myself, but I got something working using Django's forms 
mechanism.

My view function looks something like this:

---
class MyForm(ModelForm):
class Meta:
model = photos

def upload(request):
if request.method == "POST":
form = MyForm(request.POST, request.FILES)
if form.is_valid():
sheet = form.save()
return HttpResponseRedirect(reverse('upload_thanks'))

return render_to_response(
"upload.html",
{
"form" : MyForm(),
}
)
---

This is then rendered by a template, upload.html, that looks something 
like this:

---

  
{% for field in form %}
  



{{ field.errors }}

  
  

  {{ field.label_tag }}:


  {{ field }}

  
{% endfor %}
  

  

---

Finally, my urls.py specifies "names" for both the upload and the 
upload_thanks pages:

---
urlpatterns = patterns('',
# ...
url(
r'^upload/$',
'my.app.views.upload',
name="upload"
),
url(
r'^upload/thanks/$', 
'django.views.generic.simple.direct_to_template',
{ 'template' : 'upload_thanks.html' },
name="upload_thanks"
),
)
---

Hope this helps.


Cheers,

Giles

-- 
Giles Thomas
MD & CTO, Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

Try out Resolver One! 

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 
Registered in England and Wales as company number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK



--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Syndication Feed-Problem

2008-10-30 Thread [EMAIL PROTECTED]

Hi,
i hope any one can help me.
I want to generate a rss-feed.
The url ist http://localhost:8000/isf/info/.
All works fine but the title of an Item and the Description are still
the same!
How can i change the title of an feed item in the feed to the title
from the model
and the description of the feed item to the description from the
model.
I get only the String from the __unicode__(self): Method. An this
string represent
the title and the description, why ?

Please help me!



My urls.py config:
feeds = {
'rss': Rss2Feed,

}

urlpatterns = patterns('django.contrib.syndication.views',
url(r'^(?P.*)/$', 'feed', {'feed_dict': feeds},
name="fh_feeds",),
)

Thats my models.py class:

class Item(models.Model):
title = models.CharField(max_length=30)
banner = models.CharField(max_length=30, null=True)
description = models.TextField(null=True)
pub_date = models.DateTimeField(auto_now=True,
verbose_name="Public Date")
expire_date = models.DateTimeField(verbose_name="Expire Date")
author = models.ForeignKey(User, editable=False)

def authors_email(self):
return "%s"%(self.author.email)

def get_absolute_url(self):
return "%s/"%(self.id)

def __unicode__(self):
return self.title

class Meta:
ordering = ['-pub_date']

class Item_Category(models.Model):
item = models.ForeignKey(Item)
category = models.ForeignKey(Category)

def __unicode__(self):
return "%s"%self.item.id

And thats my feed.py class:

class Rss2Feed(Feed):
#thats my hard-coded title,link and description for my info feed
title = "Info"
link = "/info/"
description = "Info-Site"

# i want to show all items of my model with the slug info
def items(self):
listOfItems = []
itemToCategoryForInfo =
Item_Category.objects.select_related().filter(category__slug = "info")
for selectedItem in itemToCategoryForInfo:
listOfItems.append(selectedItem.item)
return listOfItems





--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get site's root path in Django

2008-10-30 Thread yuanyun.ken

hi, Karen, Thanks for your reply.
I am sure I hit that problem, http://code.djangoproject.com/ticket/8906
and I wish some excellent gays have time to investigate, and provide a
fix.
For now, I would just include root path in LOGIN_URL and LOGOUT_URL
variable.

On Oct 29, 12:46 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> Sounds like:
>
> http://code.djangoproject.com/ticket/8906
>
> So (assuming you are not "levity") someone else has reported the same
> thing.  It sounds like there may be a problem in Django code here, but no
> one has yet investigated far enough to confirm that or suggest a fix.
>
> Karen
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get value of query string in template

2008-10-30 Thread yuanyun.ken


hi, bruno, Thanks very much for your reply, it does help a lot...

On Oct 29, 1:29 am, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> If you add "django.core.context_processors.request" to your
> settings.CONTEXT_PROCESSORS and use RequestContext objects in your
> views, you'll have access to the request object in your templates.
> Then it's just a matter of using the appropriate request attribute, in
> your case probably something like request.REQUEST['next'] (or, since
> it's in a template, {{ request.REQUEST.next }}
>
> cfhttp://docs.djangoproject.com/en/dev/ref/request-response/for more
> on the request object.
>
> Now note that if you use your own login view, this should be handled
> in the view function itself, and passed to the template via the
> context.
>
> HTH
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to run testcases of %Django_Home%/tests/* ?

2008-10-30 Thread Russell Keith-Magee

On Thu, Oct 30, 2008 at 5:37 PM, GAEFans <[EMAIL PROTECTED]> wrote:
>
> How to run testcases of %Django_Home%/tests/* ?

By following the instructions:

http://docs.djangoproject.com/en/dev/internals/contributing/#running-the-unit-tests

Yours,
Russ Magee %-)

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



content type

2008-10-30 Thread [EMAIL PROTECTED]

hi all i am using debian stable version 0.95

and i would like know, how to tell django not to open some file types as 
JPG, PNG or MP3 in browser after click and rather open a classic menu to 
save the file.

thank you very much pavel

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Decimal * Decimal

2008-10-30 Thread Matthew Talbert

I am having the problem discussed in this thread:
http://groups.google.com/group/django-users/browse_thread/thread/91aa6c088f6c090/929f2fd69307cd22?pli=1
as well as this one:
http://groups.google.com/group/django-developers/browse_thread/thread/63046b2fca27673c/898dbf8da327ce71

and I was curious to know if there has been any progress with this, or
if the solution is still either run in separate processes, or patch
and compile my own version of psycopg2.

Thanks
Matthew

I might note that there is currently no bug tracker for psycopg, so
I'm unaware of any way to check on the problem upstream.

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to run testcases of %Django_Home%/tests/* ?

2008-10-30 Thread GAEFans

How to run testcases of %Django_Home%/tests/* ?
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to pass a special character in url

2008-10-30 Thread Thomas Guettler

Hi,

you can use django.http.urlencode() to create the part behind the
question mark.
If you want to pass a list in a value you need urlencode(..., True).

 HTH,
   Thomas

Zeal schrieb:
> Hi, All,
>
> I just want to pass a special character by using url to the proper
> view. For example,
>
> "http://127.0.0.1/sampleview/?obj=xxx; , but seems django cannot
> handle such pattern.
>
> Does any one know this, or are there any relevant doc I can learn for
> this.  Your precious suggestion would be highly appreciated!
>
>   


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Help to Upload image

2008-10-30 Thread please smile
Hi All,
Can anybody please tell how to upload a image ?
models.py

class photos(models.Model):
caption = models.CharField(max_length=10)
photo  = models.ImageField(upload_to= 'Path')

It works at Admin Side .But not working at client side.

MyHtml.html





Caption :

 





Image :

 







 







What would be the views.py code ?

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Migrate app from MySQL to PostgreSQL

2008-10-30 Thread Brot

This doesn't work as expected. I tried the migration with dumpdata
month ago.
The problem is, that mysql and postgres writes another, incompatible
boolean values. I believe sqlite and postgres has the same problem!
I reworked the dumpdata output-file. In my case this was possible,
because the amount of data was not too big

On 30 Okt., 08:44, David Christiansen <[EMAIL PROTECTED]> wrote:
> Why not just dump the data using manage.py dumpdata, switch your
> settings file to point to the new DB, run syncdb, and then use
> manage.py loaddata to get it all back?  That should be pretty easy.
>
> -David Christiansen
>
> On Oct 30, 2:39 am, "Naitik Shah" <[EMAIL PROTECTED]> wrote:
>
> > I looked around but didn't find anything obvious or simple. This is a live
> > Django app with data in MySQL which I want to migrate to PostgreSQL.
> > Suggestions? (Before I do my own thing :))
>
> > -Naitik
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



__unicode__() method not working in models.py

2008-10-30 Thread Andrew

I am currently working through the django book and I've got to the
fifth chapter where I would like to replace the __str__() methods with
__unicode__() methods instead. The reason is that my database will
hold a great deal of Japanese text, UTF-8 encoded. After declaring the
UTF-8 encoding at the top of models.py, as a test, I replace

def __str__(self):
return self.name

with

def __unicode__(self):
return u'テスト'

Entering the following code (from the django book) into the manage.py
shell doesn't give the expected output.

>>> from books.models import Publisher
>>> publisher_list = Publisher.objects.all()
>>> publisher_list

I expect:

[, ]

but instead, the テスト part is replaced with random Japanese characters
that are not the ones I expected.

I am using a Japanese version of Windows XP with PostgreSQL installed.
The encoding of the database and the file are both UTF-8. The cmd.exe
prompt doesn't let me type in Japanese but it does display Japanese if
I print out something I've saved in a file for example.

Any ideas on where I'm going wrong? Apologies if this has been asked
before.

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



Re: Admin won't display datetime widget with custom form?

2008-10-30 Thread lapucho

Can I use AdminDateWidget outside admin app?

from django.contrib.admin import widgets
from models import AvisoPublicitario
from django.forms import ModelForm

class AvisoPublicitarioForm(ModelForm):

fecha = forms.DateField(label=u"Fecha del aviso",
input_formats=['%d-%m-%Y'], widget=widgets.AdminDateWidget)

class Meta:
model = AvisoPublicitario

then I use the form in my views.

But It's not working.. I get a text input

Any clue?

Cecilia from Arg.

PD: I`m new here. 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



__unicode__() method not working in models.py

2008-10-30 Thread Andrew

I am currently working through the django book and I've got to the
fifth chapter where I would like to replace the __str__() methods with
__unicode__() methods instead. The reason is that my database will
hold a great deal of Japanese text, UTF-8 encoded. After declaring the
UTF-8 encoding at the top of models.py, as a test, I replace

def __str__(self):
return self.name

with

def __unicode__(self):
return u'テスト'

Entering the following code into the manage.py shell doesn't give the
expected output.

>>> from books.models import Publisher
>>> publisher_list = Publisher.objects.all()
>>> publisher_list

I expect:

[, ]

but instead, the テスト is replaced with random Japanese characters that
are not the ones I expected.

I am using a Japanese version of Windows XP with PostgreSQL installed.
The encoding of the database and the file are both UTF-8. The cmd.exe
prompt doesn't let me type in Japanese but it does display Japanese if
print out something I've saved in a file for example.

Any ideas on where I'm going wrong?

--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Migrate app from MySQL to PostgreSQL

2008-10-30 Thread David Christiansen

Why not just dump the data using manage.py dumpdata, switch your
settings file to point to the new DB, run syncdb, and then use
manage.py loaddata to get it all back?  That should be pretty easy.

-David Christiansen

On Oct 30, 2:39 am, "Naitik Shah" <[EMAIL PROTECTED]> wrote:
> I looked around but didn't find anything obvious or simple. This is a live
> Django app with data in MySQL which I want to migrate to PostgreSQL.
> Suggestions? (Before I do my own thing :))
>
> -Naitik
--~--~-~--~~~---~--~~
You 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >