Re: locale aware number formats

2008-09-23 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-09-23, o godz. 17:51, przez pihentagy:

>>> How can I print a number using the locale's thousand separator and
>>> decimal?
>>
>>> Basically I hoped ther is a template filter, but floatformat doesn't
>>> have thousand separator, and seems to use decimal point always.
>>
>> Take a look at Babel package and Django helpers -http://babel.edgewall.org/
>
> Ok, but there is also the module locale.
> Should I really use other libraries for just displaying a number in a
> page? Django supports translations, doesn't it supports printing
> numbers and currency honoring the currently selected language?

Additionally to what's been said by others, Python's own locale module  
isn't that good in formatting dates and numbers. Babel uses CLDR  
database to provide most accurate l10n data for many locations and  
languages, event those not supported by standard NLS machinery. Plus  
on linux it does not require installing appropriate language support -  
you can do eg. Hungarian date, number and currency formatting without  
installing Hungarian language support package (language-pack-hu on  
Ubuntu).

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R&D, Redefine
[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
-~--~~~~--~~--~--~---



Re: get_query_set in admin/views/main trying to split a list

2008-09-23 Thread Daniel Roseman

On Sep 23, 11:06 pm, Jigsaw <[EMAIL PROTECTED]> wrote:
> Hello,
>
> After upgrading from svn 8322 to 9084, I received: 'list' object has
> no attribute 'split'
> /usr/lib/python2.5/site-packages/django/contrib/admin/views/main.py in
> get_query_set, line 187
>
> I modified line 186 from:
>         if key.endswith('__in'):
> to:
>         if key.endswith('__in') and isinstance(value, str):
> I left line187 untouched:
>                 lookup_params[key] = value.split(',')
>
> Although this appears to have resolved the error, I wonder if I have
> done so correctly?
> If so, what should I do so that I don't lose this modification when I
> next update Django?
>
> Thanks,
> -Jason

It's possible this is a bug, in which case you should raise a ticket
at http://code.djangoproject.com, but you haven't given us enough
information to determine that. What's your code? What are you passing
into this function?

--
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: denormalized data in single field

2008-09-23 Thread gearheart

yes, i think i'll do that
but the for every entity that has location i need to override form and
save method.

i think there should be more django-style solution


On 23 сент, 23:39, akonsu <[EMAIL PROTECTED]> wrote:
> hello,
>
> you can override the model's save() method.
>
> konstantin
>
> On Sep 23, 3:05 pm, "Владимир Сидоренко" <[EMAIL PROTECTED]> wrote:
>
> > hi
>
> > i need to process a set of denormalized data in single model field.
> > for example,
>
> > class Place(Model):
> >     location = LocationField()
>
> > it's rendered as one single text field, where we insert address, then by
> > this address we find out corresponding district and nearest subway station
>
> > and write to database something like:
>
> > class Location(Model):
> >     address = CharField()
> >     subway = ManyToManyField(Subway)
> >     district = ForeignKey(District)
>
> > class Place(Model):
> >     location = ForeignKey(Location)
>
> > how can i override field's save to db process to generate Location object
> > and save corresponding key to Place?
>
> > 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
-~--~~~~--~~--~--~---



json

2008-09-23 Thread yozhik

hi all,

does anyone have a very simple example of how to use json and jquery
to communicate between django and javascript. i'm trying to use
$.getJSON but getting confused what parameters to provide to it. docs
say
getJSON(url,data,func). well, func is my javascript function which
handles data from django. but I am mainly confused  about url.

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: Django-Apache configuration in Fedora 9

2008-09-23 Thread Graham Dumpleton



On Sep 24, 3:27 pm, Harish <[EMAIL PROTECTED]> wrote:
> hi folks,
>
>         i am trying to configure a project which is developed using
> django.
> Now I am trying to host it in web server (using Apache2), which is
> running in  Fedora 9.
>
> I tried with the instruction given in the following link,
>
> http://www.howtoforge.com/how-to-install-django-on-fedora9-apache2-mo
>
> but i am not able to run it. I am getting error called
>
> "Could not import settings '%s' (Is it on sys.path?)"
>
> but, it seems that the settings and system path are ok.
>
> Please help me... if anyone got the same problem

Perhaps you should also look at:

  http://docs.djangoproject.com/en/dev/howto/deployment/modpython/

Most likely you are having problems because you have set PythonPath
wrong, or your files aren't readable to user that Apache is running
as.

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



Django-Apache configuration in Fedora 9

2008-09-23 Thread Harish

hi folks,

i am trying to configure a project which is developed using
django.
Now I am trying to host it in web server (using Apache2), which is
running in  Fedora 9.

I tried with the instruction given in the following link,

http://www.howtoforge.com/how-to-install-django-on-fedora9-apache2-mod_python.

but i am not able to run it. I am getting error called

"Could not import settings '%s' (Is it on sys.path?)"

but, it seems that the settings and system path are ok.

Please help me... if anyone got the same problem

Regards
Harish Bhat

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: order_by clause to preserve order in list?

2008-09-23 Thread coan



On Sep 24, 5:10 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-09-23 at 07:01 -0700, coan wrote:
>
> > I want to fetch a list of items in my database, and I have their id
> > ready:
> > my_ids_to_get = [ 1, 3, 2, ]
>
> > In mysql I would fetch them like this:
> > SELECT * FROM table WHERE id IN (1, 3, 2)ORDERBY FIELD( id, 1, 3,
> > 2 )
>
> > This would preserve theirorder.
>
> > Can I build this query with the native django order_by?
>

> No. You can't pass arbitrary SQL functions to order_by.

> Regards,
> Malcolm

Ok! Thanks for clearing it up for me :-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



upgrading old sites

2008-09-23 Thread Kenneth Gonsalves

hi,

I have a bunch of old sites - pre MR. Some of them do not need much work, but 
now a couple need a lot of new stuff. Question is: should I go through all 
the backward incompatible fixes to the database, or should I create a fresh 
db and import the old data into it?
-- 
regards
KG
http://lawgon.livejournal.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: locale aware number formats

2008-09-23 Thread Malcolm Tredinnick


On Tue, 2008-09-23 at 08:51 -0700, pihentagy wrote:
> On Sep 23, 12:28 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> > Wiadomość napisana w dniu 2008-09-23, o godz. 12:21, przez pihentagy:
> >
> > > How can I print a number using the locale's thousand separator and
> > > decimal?
> >
> > > Basically I hoped ther is a template filter, but floatformat doesn't
> > > have thousand separator, and seems to use decimal point always.
> >
> > Take a look at Babel package and Django helpers -http://babel.edgewall.org/
> 
> Ok, but there is also the module locale.
> Should I really use other libraries for just displaying a number in a
> page? Django supports translations, doesn't it supports printing
> numbers and currency honoring the currently selected language?

We can't use Python's locale module in Django. It doesn't allow
different locale settings in different threads.

Prior to 1.1 there will be some changes made there to add support for
number and date printing and validation (Karen's already pointed to one
of the relevant tickets). Currency display is probably out of scope,
since that's not actually particularly locale-dependent: it's specific
to the currency itself, not the output locale (display USD 1.25 as JPY
125,000 or something is just wrong).

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-admin.py init ....an integer is required

2008-09-23 Thread Malcolm Tredinnick


On Tue, 2008-09-23 at 08:05 -0700, KillaBee wrote:
> I am working with .90 and when I run django-admin.py init I get this
> error on the command line:
> 
> Error: The database couldn't be initialized.
> an integer is required
> 
> I was thinking that it was a port number or host, but I get it if they
> are filled or blank.  Please help!!!
> 
> setting.py
> -
>  Django settings for intraweb project.
> 
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
> 
> ADMINS = (
> ('Bryant Ross', '[EMAIL PROTECTED]'),
> )
> 
> MANAGERS = ADMINS
> 
> DATABASE_ENGINE = 'mysql' # 'postgresql', 'mysql', 'sqlite3' or
> 'ado_mssql'.
> DATABASE_NAME = 'time' # Or path to database file if using
> sqlite3.
> DATABASE_USER = 'bryant' # Not used with sqlite3.
> DATABASE_PASSWORD = 'Startan3w' # Not used with sqlite3.
> DATABASE_HOST = '10.0.0.20' # Set to empty string for
> localhost. Not used with sqlite3.
> DATABASE_PORT = '' # Set to empty string for default. Not
> used with sqlite3.
> 
> # Local time zone for this installation. All choices can be found
> here:
> # 
> http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
> TIME_ZONE = 'America/Chicago'
> 
> # Language code for this installation. All choices can be found here:
> # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
> # http://blogs.law.harvard.edu/tech/stories/storyReader$15
> LANGUAGE_CODE = 'en-us'
> 
> SITE_ID = 1
> 
> # Absolute path to the directory that holds media.
> # Example: "/home/media/media.lawrence.com/"
> MEDIA_ROOT = ''
> 
> # URL that handles the media served from MEDIA_ROOT.
> # Example: "http://media.lawrence.com";
> MEDIA_URL = ''
> 
> # URL prefix for admin media -- CSS, JavaScript and images. Make sure
> to use a
> # trailing slash.
> # Examples: "http://foo.com/media/";, "/media/".
> ADMIN_MEDIA_PREFIX = '/media/'
> 
> # Make this unique, and don't share it with anybody.
> SECRET_KEY = '@k$u_+75_2e_y%i%el*n%l!4f_&^bmifxjn_z)[EMAIL PROTECTED])ryi@'
> 
> # List of callables that know how to import templates from various
> sources.
> TEMPLATE_LOADERS = (
> 'django.core.template.loaders.filesystem.load_template_source',
>  
> 'django.core.template.loaders.app_directories.load_template_source',
> #'django.core.template.loaders.eggs.load_template_source',
> )
> 
> MIDDLEWARE_CLASSES = (
> "django.middleware.common.CommonMiddleware",
> "django.middleware.sessions.SessionMiddleware",
> "django.middleware.doc.XViewMiddleware",
> )
> 
> ROOT_URLCONF = 'intraweb.urls'
> 
> TEMPLATE_DIRS = (
> # Put strings here, like "/home/html/django_templates".
> "/home/dev/intraweb/templates"
> "/home/bryant/Django-0.90/django-.90_templates"
> "/home/bryant/django_templates"
> )
> 
> INSTALLED_APPS = (
> #'django.contrib.auth',
> #'django.contrib.contenttypes',
> #'django.contrib.sessions',
> #'django.contrib.sites',
> 'intraweb.apps.timesheets',
> 'django.contrib.admin',
> )
> --
> I get this error in the browser:
>  File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line
> 176, in __init__
> super(Connection, self).__init__(*args, **kwargs2)
> 
> TypeError: an integer is required
> 
> 
> connections.py
> 
> client_flag = kwargs.get('client_flag', 0)
> client_version = tuple([ int(n) for n in
> _mysql.get_client_info().split('.')[:2] ])
> if client_version >= (4, 1):
> client_flag |= CLIENT.MULTI_STATEMENTS
> if client_version >= (5, 0):
> client_flag |= CLIENT.MULTI_RESULTS
> 
> kwargs2['client_flag'] = client_flag
> 
> super(Connection, self).__init__(*args, **kwargs2)line
> 176...
> 
> self.encoders = dict([ (k, v) for k, v in conv.items()
>if type(k) is not int ])
> 
> self._server_version = tuple([ int(n) for n in
> self.get_server_info().split('.')[:2] ])

This line is telling you where the problem is arising, so work backwards
from there.

Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: order_by clause to preserve order in list?

2008-09-23 Thread Malcolm Tredinnick


On Tue, 2008-09-23 at 07:01 -0700, coan wrote:
> 
> I want to fetch a list of items in my database, and I have their id
> ready:
> my_ids_to_get = [ 1, 3, 2, ]
> 
> In mysql I would fetch them like this:
> SELECT * FROM table WHERE id IN (1, 3, 2) ORDER BY FIELD( id, 1, 3,
> 2 )
> 
> This would preserve their order.
> 
> Can I build this query with the native django order_by?

No. You can't pass arbitrary SQL functions to order_by.

> 
> I can get the objects like this:
> MyObject.objects.filter(pk__in=my_ids_to_get)
> But I'm not able to build an order clause to use with it, and their
> order is not preserved.
> 
> Do I have to fall back on raw sql to do this?

At the moment, certainly. At some point in the distant future, there's a
better than average chance that there will be a general way to pass
through literal SQL fragments in various places (including order_by()).
But it's pretty far down the feature list at the moment and will always
be fairly fragile in any case (because manipulations on query sets will
have to treat such fragments as opaque strings and so won't be able to
rename aliases inside them, etc).

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: docutils extra

2008-09-23 Thread Malcolm Tredinnick


On Mon, 2008-09-22 at 16:45 -0700, aleray wrote:
> Hey,
> 
> I installed docutils svn version and I couldn't get the documention
> working (was in the python path) until I found I needed to register in
> my pythonpath the "extra" directory in the docutils package. Docutils
> team apparently moved in that directory some libraries needed for
> django documention (I read somthing about license issues, but can't
> find the quote anymore). Anyway, it could be nice to write it
> somewhere on django documentation website.

We generally wait until there's a release of anything before adding to
our documentation. Tracking the current subversion status of every
project we might conceivably use would be far too much work. Also,
there's a chance the docutils guys might change something prior to the
release to make things backwards compatible, or remove it altogether or
anything. So when they do a final release, that's the time for somebody
to open a ticket with an explanation of what has changed so that we can
update any instructions we have accordingly.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: No logging with lighttpd + fastcgi

2008-09-23 Thread erny

This problem still exists with django-1.0.

I've been researching a bit:
http://code.djangoproject.com/changeset/7297
does some changes. It works if I comment out the os.dup2 lines, but
that may not be very robust. I'm using threaded model, not fork.


On 12 ago, 18:51, Brian Victor <[EMAIL PROTECTED]> wrote:
> To answer your question from your first response, no, I don't have a
> solution for this yet.  I'm not even sure where to go from here.  (For
> those listeners just joining us, the topic of conversation is a lack
> of error messages and tracebacks in either the fastcgi or lighttpd log
> files.)
>
> That said,
>
> On Aug 12, 9:22 am, spacetaxi <[EMAIL PROTECTED]> wrote:
>
> > > - No notification email is sent to the admins listed in
> > > settings.ADMINS
> > This problem is solved. It had nothing to do with django but with our
> > mail server silently discarding some mails. So, sorry for suspecting
> > django for causing this problem!
>
> I didn't even realize this was a feature.  That may alleviate my need
> somewhat, but it would still be nice to get logging working.  Thanks
> for pointing it out!
>
> --
> Brian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: An academic journal's site

2008-09-23 Thread Malcolm Tredinnick


On Tue, 2008-09-23 at 19:41 -0700, Rodrigo Culagovski wrote:
> I'm starting work on a site for an academic journal that will both
> publish the articles from the paper version and also allow authors to
> submit new articles for review and publication. Looking for specific
> advice as well as general experience with this kind of site.
> 
> Question 1
> The articles' text has been traditionally submitted in .doc format,
> but I'm planning on changing it to RTF, for simplicity and openness'
> sake. How hard would it be to read these RTF files' contents into the
> database so the articles can be displayed on the site? The files will
> have minimal formatting, just Bold and Italic. Have you done this in
> Django, and if so, how?

This is something that is really independent of Django. Django has
nothing to work with .doc or .rtf formats, but that's because that isn't
the area Django covers. So use whatever tools/libraries you like to do
the conversion.

However, you might also wish to consider whether storing the text in the
database is really necessary or useful. Maybe just storing the files on
disk and storing the filenames in the database is a simpler approach.
That way people can download/upload as they have always done and you
don't end with megabyte-sized rows in the database. Django's FileField
field is going to make this relatively straightforwards.

> 
> Question 2
> There's a some fairly basic functionality that I'm sure could be done
> via 3rd party apps such as:
> 
> 1) Letting authors create accounts, confirm them via email.

django-registration is about as simple as it gets. Might want to also
hook it up with django-profiles. Both are available on Google code.

> 2) Workflow (submission -> initial review -> peer review ->
> corrections -> final approval -> publication).

I've done this a few times for clients, but it's never turned into a
separate application. There's been a model for each article or item or
what have you and one of the fields on that model is the current state,
which is a Django field with a "choices" attribute mapping to the stage.

Regards,
Malcolm


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



An academic journal's site

2008-09-23 Thread Rodrigo Culagovski

I'm starting work on a site for an academic journal that will both
publish the articles from the paper version and also allow authors to
submit new articles for review and publication. Looking for specific
advice as well as general experience with this kind of site.

Question 1
The articles' text has been traditionally submitted in .doc format,
but I'm planning on changing it to RTF, for simplicity and openness'
sake. How hard would it be to read these RTF files' contents into the
database so the articles can be displayed on the site? The files will
have minimal formatting, just Bold and Italic. Have you done this in
Django, and if so, how?

Question 2
There's a some fairly basic functionality that I'm sure could be done
via 3rd party apps such as:

1) Letting authors create accounts, confirm them via email.
2) Workflow (submission -> initial review -> peer review ->
corrections -> final approval -> publication).

I would appreciate recommendations for 3rd party applications or your
experience with these topics, as well as any general experience /
advice from similar projects.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Two Django visions running at once.

2008-09-23 Thread David Durham, Jr.

On Wed, Sep 17, 2008 at 3:21 PM, KillaBee
<[EMAIL PROTECTED]> wrote:
>
> Is it possible to have two versions of django running at the same time
> on an Ubuntu server(9.0 and 1.0)?
> It is taking to long to recode, and until I do I wanted It up and
> running with the old version.
> I got the tar.gz from the web site, but do I have to get rid of the
> new version?

This is the kind of thing that 'virtualenv' deals with.  On ubuntu you
can set that up with:

$ sudo apt-get install python-setuptools
$ sudo easy_install virtualenv
$ virtualenv --no-site-packages /path/to/sandbox1
$ virtualenv --no-site-packages /path/to/sandbox2

then, checkout or download the different django version and place/link them in:

/path/to/sandbox1/lib/pythonX.X/site-packages/
/path/to/sandbox2/lib/pythonX.X/site-packages/

you can test with

/path/to/sandbox1/bin/python manage.py runserver
/path/to/sandbox2/bin/python manage.py runserver

As far as apache configuration goes, this kind of thing is pretty
easily configured with mod_wsgi.

-Dave

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



Verbose names of fields in admin object history

2008-09-23 Thread zendak

The change_messages logged in the admin site's object history use the
actual Python model field names. Is there a more or less trivial way
to force it to use the fields' verbose_names instead?

This would make history pages more meaningful for non-developers who
use the admin site. Additionally, it could then benefit from L10n if
used in the project, specifically: if the verbose_name gets translated
nicely. At the moment, the worst case is when a non-English speaking
user comes across a history entry that is pretty much uninformative as
there's no way to guess what that perhaps rather technical field name
actually represents.

OTOH, for a dev debugging the app, the status quo might be preferable,
so not I'm sure about opening a ticket.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: url capture + query set and generic views

2008-09-23 Thread aleray

Ok, It is solved.

for those interested I did so:

(mysite/urls.py)

urlpatterns += patterns('mysite.views',
(r'^news/(?P\w+)/$', 'news_category', {})
)

(mysite/views.py)

from mysite.news.models import New, NewCategory
from django.views.generic.list_detail import object_list

def news_category(request, cat_slug=None):
news_list =
New.objects.filter(category__slug=cat_slug).exclude(is_active=False).order_by('pub_date')
return object_list(
request,
queryset = news_list,
template_name = 'news.html'
)

Hope it'll help somehow

On Sep 24, 1:51 am, aleray <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying capture urls patterns with generic views, something like
> this:
>
> info_dict = {
>     'queryset':
> New.objects.filter(category__slug=cat_slug).exclude(is_active=False).order_by('pub_date'),
>     'template_name': 'news.html',
>     'paginate_by': 1,
>
> }
>
> urlpatterns += patterns('django.views.generic.list_detail',
>     (r'^news/(?P\w+)/$', 'object_list', info_dict),
> )
>
> However, this is not working. Is there a solution?
>
> 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: Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-23 Thread Graham Dumpleton

How are you hosting Django? It would help to know if you are using
builtin development server or whether you are hosting under Apache
using mod_python or mod_wsgi. If under Apache then use of certain
Apache configuration settings can cause 500 errors to be returned
instead of 404 errors. No point explaining though if not using Apache.

Graham

On Sep 24, 2:14 am, Huuuze <[EMAIL PROTECTED]> wrote:
> There are no tracebacks in this instance.  I can see the non-descript
> 500 errors appearing in my terminal window.
>
> On Sep 23, 12:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Tue, Sep 23, 2008 at 11:53 AM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > > I'm preparing to deploy my Django app and I noticed that when I change
> > > the "DEBUG" setting to False, all references to static files (i.e.,
> > > JavaScript, CSS, etc..) result in HTTP 500 errors.
>
> > > Any idea what's causing that issue (and how to fix it)?
>
> > No. An idea for getting enough information to figure it out, though, is to
> > configure things in settings.py (ADMINS, the various EMAIL_HOST,
> > EMAIL_HOST_USER, etc. settings) so that you get the tracebacks for these
> > errors mailed to you.
>
> > 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: Admin redirecting to wrong URL?

2008-09-23 Thread Graham Dumpleton



On Sep 24, 5:43 am, Allan <[EMAIL PROTECTED]> wrote:
> My application is working well at mysite.com/django/, and I get
> an admin login at            mysite.com/django/admin/ -- but when I
> enter my credentials, I seem to be redirected to            mysite.com/
> admin/ (which is a 404 error).  Did I miss an admin config setting
> somewhere?
>
> A relevant excerpt from urls.py appears below.
>
> Allan
>
> import os
> from django.conf.urls.defaults import *
> from django.conf import settings
> from django.contrib import admin
>
> admin.autodiscover()
>
> urlpatterns = patterns('',
>
>     (r'^contact/$', 'careers_contact.views.contact'),
>     (r'^careers/$', 'careers_contact.views.careers'),
>
>     (r'^admin/(.*)', admin.site.root),
> )

How are you hosting Django and what version of Django are you using?

Depending on how you are hosting Django and what version, you may have
to set special configuration or use hacks to allow it to properly host
at a sub URL of an Apache installation.

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: python-ldap + Apache causing errors

2008-09-23 Thread Graham Dumpleton



On Sep 24, 4:39 am, Jashugan <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am having a problem when using python-ldap with Apache. I added an
> authentication backend based on ldapauth.py, and it works fine when
> running from the Django server. However, when I use Apache I get the
> following error in the Apache error.log:
>
> child pid 2941 exit signal Bus error (10)
>
> It seems to be the following line that causes the problem:
>
> l.simple_bind_s(self.settings['LDAP_PREBINDDN'],
>     self.settings['LDAP_PREBINDPW'])
>
> I have tried the following without any luck:
>
> + changing from a synchronous bind to a asynchronous bind
> + setting the host by IP address (I thought it may have been due to
> some kind of domain problem)
>
> Has anyone experienced anything like this? Any suggestions on where to
> begin troubleshooting?

The problem is most like because some other Apache module, eg. PHP or
mod_auth_ldap, is loading an incompatible version/variant of LDAP
client libraries before the Python ldap module does.

Thus, check what versions of LDAP client libraries Python ldap module
is compiled against and then also look at what PHP or other Apache
modules are using.

To really get to the problem, you may need to start up Apache in
single process mode and run it in a debugger. For details see:

http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Debugging_Crashes_With_GDB

BTW, you don't say whether you are using mod_python or mod_wsgi.

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: geodjango apache vs lighttpd

2008-09-23 Thread Graham Dumpleton

On Sep 24, 6:47 am, Jashugan <[EMAIL PROTECTED]> wrote:
> Did you switched from Apache + mod_python to Lighttpd + FCGI? If so,
> are you sure it wasn't a problem with mod_python versus Apache in
> general? I'm having some issues with mod_python unrelated to
> geodjango. It seems there are certain modules that work in the python
> interpreter that will cause Apache+mod_python to stall.

To explain the issue if this is indeed it, the problem is that any
third party C extension modules for Python which use the simplified
GIL API functions at C code level, cannot be used in secondary sub
interpreters in Python. If they are, they can either crash the
interpreter or cause it to dead lock. This is a limitation of the
simplified GIL API in Python and not mod_python.

If using mod_python, you can force Django to run in main interpreter
instance by setting:

  PythonInterpreter main_interpreter

This however may not completely solve the problem as mod_python still
has some bugs in it in relation to how it itself uses Python C
threading APIs. Thus, you may still see dead locks occur.

If this occurs, one option is to use mod_wsgi instead. You still have
to force application to run in main interpreter using:

  WSGIApplicationGroup %{GLOBAL}

but it doesn't have the bugs related to Python C threading APIs that
mod_python does, so should work.

As others have pointed out, you could also use FASTCGI, be it with
Apache, lighttpd or nginx.

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



url capture + query set and generic views

2008-09-23 Thread aleray

Hi,

I'm trying capture urls patterns with generic views, something like
this:

info_dict = {
'queryset':
New.objects.filter(category__slug=cat_slug).exclude(is_active=False).order_by('pub_date'),
'template_name': 'news.html',
'paginate_by': 1,
}

urlpatterns += patterns('django.views.generic.list_detail',
(r'^news/(?P\w+)/$', 'object_list', info_dict),
)

However, this is not working. Is there a solution?

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 / GIS Garbage Collection Error

2008-09-23 Thread Andrew Fong

When a Django process terminates, I get the following error message:

Exception exceptions.TypeError: "'NoneType' object is not callable"
in  ignored

I poked around and there appears to be a problem with garbage
collecting instances of django.contrib.gis.geos.base.GEOSGeometry
objects.

To reproduce, create a Django project with two apps installed in the
settings file. Then add / change the following:

- django_project/consts.py -

from django.contrib.gis.geos import Point
SOME_CONST = Point(1,1)

- django_project/app_one/models.py -

from django_project.consts import SOME_CONST

- django_project/app_two/models.py -

from django_project.consts import SOME_CONST

--

Start the shell up. Everything should load just fine. When you close
however, you should get the TypeError. If you run python with the
verbose option, you'll notice that it throws the error when it tries
to clean up django_project.app_two.models (or maybe app_one.models).

If you switch SOME_CONST to some other object (like a datetime), you
won't get the exception. You will get it however so long as SOME_CONST
is a Point, Polygon, or any other instance of
django.contrib.gis.geos.base.GEOSGeometry.

It seems like when app_one is garbage collected, SOME_CONST is
removed / set to None. Then when app_two is collected, it also tries
to garbage collect SOME_CONST but can't find it.

Any ideas? It doesn't seem to be breaking anything in the app, but it
is really annoying.

-- Andrew

P.S. This seems to be the same problem as here, except with GeoDjango
instead of wxPython: 
http://mail.python.org/pipermail/python-list/2003-March/192239.html


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



get_query_set in admin/views/main trying to split a list

2008-09-23 Thread Jigsaw

Hello,

After upgrading from svn 8322 to 9084, I received: 'list' object has
no attribute 'split'
/usr/lib/python2.5/site-packages/django/contrib/admin/views/main.py in
get_query_set, line 187

I modified line 186 from:
if key.endswith('__in'):
to:
if key.endswith('__in') and isinstance(value, str):
I left line187 untouched:
lookup_params[key] = value.split(',')

Although this appears to have resolved the error, I wonder if I have
done so correctly?
If so, what should I do so that I don't lose this modification when I
next update Django?

Thanks,
-Jason

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 assign "": "Character.user_profile" must be a "UserProfile" instance.

2008-09-23 Thread Simon Forman

Thanks Karen,  I must have gotten it just as you posted your reply,

Thanks anyhow,
~Simon

On Sep 23, 2:59 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Sep 23, 2008 at 5:47 PM, Simon Forman <[EMAIL PROTECTED]> wrote:
>
> > I'm getting an error I can't figure out.
>
> > I have a "UserProfile" class that is the AUTH_PROFILE_MODULE setting,
> > but then when I am trying to create an object from a model class that
> > has a ForeignKey for that UserProfile class
>
> > char = Character(
> >    user_profile = request.user.profile,
> > ...
>
> > where
>
> > class Character(Model):
> >    user_profile = ForeignKey(UserProfile, related_name='characters')
> > ...
>
> > I get a ValueError:
>
> > Cannot assign " > at 0x552b9a0b10>": "Character.user_profile" must be a "UserProfile"
> > instance.
>
> > The user is logged in, and has a UserProfile according to the admin
> > interface.
>
> Apparently request.user.profile is a RelatedManager type thing, not an
> instance of your user profile.  Per the docs 
> (http://www.djangoproject.com/documentation/authentication/#storing-ad...)
> it appears you should be using the get_profile() method on a User instance
> to retrieve the user's profile, so I'd try:
>
> char = Character(
>    user_profile = request.user.get_profile(),
> ...
>
> instead of what you have.
>
> 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 assign "": "Character.user_profile" must be a "UserProfile" instance.

2008-09-23 Thread Simon Forman

profile = user.get_profile()

D'oh,  got it.

~Simon

On Sep 23, 2:47 pm, Simon Forman <[EMAIL PROTECTED]> wrote:
> I'm getting an error I can't figure out.
>
> I have a "UserProfile" class that is the AUTH_PROFILE_MODULE setting,
> but then when I am trying to create an object from a model class that
> has a ForeignKey for that UserProfile class
>
> char = Character(
>     user_profile = request.user.profile,
> ...
>
> where
>
> class Character(Model):
>     user_profile = ForeignKey(UserProfile, related_name='characters')
> ...
>
> I get a ValueError:
>
> Cannot assign " at 0x552b9a0b10>": "Character.user_profile" must be a "UserProfile"
> instance.
>
> The user is logged in, and has a UserProfile according to the admin
> interface.
>
> TIA
> ~Simon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 assign "": "Character.user_profile" must be a "UserProfile" instance.

2008-09-23 Thread Karen Tracey
On Tue, Sep 23, 2008 at 5:47 PM, Simon Forman <[EMAIL PROTECTED]> wrote:

>
> I'm getting an error I can't figure out.
>
> I have a "UserProfile" class that is the AUTH_PROFILE_MODULE setting,
> but then when I am trying to create an object from a model class that
> has a ForeignKey for that UserProfile class
>
> char = Character(
>user_profile = request.user.profile,
> ...
>
>
> where
>
>
> class Character(Model):
>user_profile = ForeignKey(UserProfile, related_name='characters')
> ...
>
>
> I get a ValueError:
>
> Cannot assign " at 0x552b9a0b10>": "Character.user_profile" must be a "UserProfile"
> instance.
>
> The user is logged in, and has a UserProfile according to the admin
> interface.
>
>
Apparently request.user.profile is a RelatedManager type thing, not an
instance of your user profile.  Per the docs (
http://www.djangoproject.com/documentation/authentication/#storing-additional-information-about-users)
it appears you should be using the get_profile() method on a User instance
to retrieve the user's profile, so I'd try:

char = Character(
   user_profile = request.user.get_profile(),
...

instead of what you have.

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 apache vs lighttpd

2008-09-23 Thread Ben Eliott

Yup as you say, it was apache + mod_python switched to lighttpd +  
fastcgi. Sounds like it could well be mod_python / Apache issue at the  
root of it.



On 23 Sep 2008, at 21:47, Jashugan wrote:

>
> Did you switched from Apache + mod_python to Lighttpd + FCGI? If so,
> are you sure it wasn't a problem with mod_python versus Apache in
> general? I'm having some issues with mod_python unrelated to
> geodjango. It seems there are certain modules that work in the python
> interpreter that will cause Apache+mod_python to stall.
> >


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



Cannot assign "": "Character.user_profile" must be a "UserProfile" instance.

2008-09-23 Thread Simon Forman

I'm getting an error I can't figure out.

I have a "UserProfile" class that is the AUTH_PROFILE_MODULE setting,
but then when I am trying to create an object from a model class that
has a ForeignKey for that UserProfile class

char = Character(
user_profile = request.user.profile,
...


where


class Character(Model):
user_profile = ForeignKey(UserProfile, related_name='characters')
...


I get a ValueError:

Cannot assign "": "Character.user_profile" must be a "UserProfile"
instance.

The user is logged in, and has a UserProfile according to the admin
interface.

TIA
~Simon

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ModelChoiceField with Unique Results

2008-09-23 Thread Daniel Roseman

On Sep 23, 4:44 pm, BobZ <[EMAIL PROTECTED]> wrote:
> Thanks Daniel.  I've found solutions similar to yours in other threads
> on the net, and everytime I test them, I literally get no form at all
> in my rendered template.
> My template appears to have all the correct code in it as you can see
> in the link "search.html" at the bottom of this post.
> Looking at the code you provided, it seems like the
> "queryset=Vehicle.objects.order_by('-year').distinct()" pulls all
> distinct fields from the Vehicle table and sorts them by year.  What
> I'm actually after is a way to filter out only the years and list them
> in descending order.
>
> In my forms.py file, I've kept all variations of the code I've tested
> for this app commented out for my own reference, but maybe it will
> help you see what's happening and what I'm trying to do.
>
> Here's all of my code in dpaste:
> http://dpaste.com/80010/";>models.py -http://dpaste.com/80010/
> http://dpaste.com/80009/";>forms.py -http://dpaste.com/80009/
> http://dpaste.com/80011/";>views.py -http://dpaste.com/80011/
> http://dpaste.com/80013/";>search.html -http://dpaste.com/80013/

I think you're misunderstanding the point of ModelForms.

A ModelForm (as opposed to a standard form) is specifically for
creating or editing a model instance. So if you had a model with a
foreignkey to Vehicle, you could use this model as the base for a
modelform with the modelchoice field we have defined.

However, you have defined a ModelForm based on the Vehicle model, with
a modelchoice field also pointing at Vehicle. That doesn't make sense,
as the year field on Vehicle isn't a ForeignKey, it's an IntegerField.
This could be why you're not getting any output in the rendered
template.

Luckily, your use case doesn't warrant a ModelForm anyway. You're not
editing a model, you are using the form to create a search box. So you
just want a standard Form. In which case, something akin to dmorozov's
solution may be best after all. How about this:

class SearchForm(forms.Form):
year=forms.ChoiceField()

def __init__(self, *args, **kwargs):
super(SearchForm, self) .__init__(*args, **kwargs)
self.fields['year'].choices =
Vehicle.objects.values_list('year', 'year').distinct().order_by('-
year')

--
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: Many-To-Many with extra fields

2008-09-23 Thread akonsu

this is untested:

m = Membership.objects.select_related().get(person__name='ringo')
ringo = m.person

i agree, this is not as convenient as could be. may be it will be in
the next version?

konstantin

On Sep 23, 5:16 pm, Nate Thelen <[EMAIL PROTECTED]> wrote:
> Yeah, that would work, too.  I was thinking more like if you got the
> ringo like this:
>
> ringo = Person.objects.select_related(depth=2).get(name='ringo')
>
> how could you get the data without having to make another DB call.
>
> Ideas?
>
> Thanks,
> Nate
>
> On Sep 23, 2:04 pm, akonsu <[EMAIL PROTECTED]> wrote:
>
> > hello,
>
> > how about
>
> > for m in Membership.objects.filter(person=ringo) : print m.date_joined
>
> > konstantin
>
> > On Sep 23, 4:58 pm, Nate Thelen <[EMAIL PROTECTED]> wrote:
>
> > > So if I have a Person object "ringo" and I want to get info about the
> > > Groups he is a member of, I would do this:
>
> > > for group in ringo.group_set.all()
> > >     print( group.name )
>
> > > My question is, how do I print the "date_joined" without having to do
> > > this:
>
> > > for group in ringo.group_set.all()
> > >     print( Membership.objects.get(person=ringo,
> > > group=group).date_joined )
>
> > > That seems very DB inefficient.
>
> > > Nate
>
> > > On Sep 19, 9:43 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > On Sat, Sep 20, 2008 at 8:37 AM, Nate Thelen <[EMAIL PROTECTED]> wrote:
>
> > > > > Looking at the docs here:
>
> > > > >http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-o...
>
> > > > > I cannot find any reference to how to access the data in the
> > > > > "Membership" table.  For example, if I have a reference to the
> > > > > "beatles" object, how do I find the "date_joined" for each of the
> > > > > "Person" objects.  I have looked through the other sections of the
> > > > > documentation, searched this group, and searched via Google, but
> > > > > couldn't find the info.
>
> > > > Short version: You access the membership table using the foreign key
> > > > relationship that the membership defines.
>
> > > > Long version: Your question ("the date_joined for each person object")
> > > > is actually ill posed - a person doesn't have a date_joined without a
> > > > group to also give context. "The date person X joined group Y" can be
> > > > answered as:
>
> > > > >>> Membership.objects.get(person=X, group=y).date_joined
>
> > > > It might help to think about it like this - m2m-intermediate tables
> > > > don't add extra data to an m2m relation, they make a 2-step foreign
> > > > key relation behave like an m2m relation.
>
> > > > 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
-~--~~~~--~~--~--~---



Re: Re: Two Django visions running at once.

2008-09-23 Thread ra21vi

just extract & put them in diff directories.open two shells, add python path to 
django dir, and runserver. in other term, do the same, define python path to 
othr django,and run the servr.on apache2, you can do the same with two diff 
virtua'l host defined. hope this will work fine. try google for
 setting pythonpath envvars. hope i undrstood your requirement genuinely

-Original Message-
From: KillaBee <[EMAIL PROTECTED]>
Sent: 2008-09-19 04:34:48 GMT+08:00
To: Django users 
Subject: Re: Two Django visions running at once.


For right now I don't care if the new version is running I just want
the old one installed.
I am running VMware on this laptop to test some things out, but
haven't been able to put it on Ubuntu.

On Sep 18, 3:14 pm, Faheem Mitha <[EMAIL PROTECTED]> wrote:
> On Wed, 17 Sep 2008 13:21:50 -0700 (PDT), KillaBee
>
> <[EMAIL PROTECTED]> wrote:
> > Is it possible to have two versions of django running at the same time
> > on an Ubuntu server(9.0 and 1.0)?
> > It is taking to long to recode, and until I do I wanted It up and
> > running with the old version.
> > I got the tar.gz from the web site, but do I have to get rid of the
> > new version?
>
> I'm doing something like this. I'd recommend using a virtual machine
> setup. Something like Linux vservers is not difficult to setup and
> I've found the developers in IRC very helpful.
>                                                               Faheem.

For right now I don't care if the new version is running I just want
the old one installed.
I am running VMware on this laptop to test some things out, but
haven't been able to put it on Ubuntu.

I am working with django .90, but I have a Mysql db in setting.py and
I am
trying to link Django with this DB. I run this command to do this.

export DJANGO_SETTINGS_MODULE=app.settingsNo errors
then
django-admin.py init --settings=app.settings  I get this error.

EnvironmentError: Could not import DJANGO_SETTINGS_MODULE
'app.settings' (is it on sys.path?): No module named app.settings

I edited the httpd.conf and put this in:



SetHandler python-program

PythonHandler django.core.handlers.modpython

SetEnv DJANGO_SETTINGS_MODULE app.settings

PythonPath "['/home/bryant/Django-0.90/django.90_projects'] +
sys.path"



Do you thing I need to get rid of 1.0?




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



Re: Many-To-Many with extra fields

2008-09-23 Thread Nate Thelen

Yeah, that would work, too.  I was thinking more like if you got the
ringo like this:

ringo = Person.objects.select_related(depth=2).get(name='ringo')

how could you get the data without having to make another DB call.

Ideas?

Thanks,
Nate

On Sep 23, 2:04 pm, akonsu <[EMAIL PROTECTED]> wrote:
> hello,
>
> how about
>
> for m in Membership.objects.filter(person=ringo) : print m.date_joined
>
> konstantin
>
> On Sep 23, 4:58 pm, Nate Thelen <[EMAIL PROTECTED]> wrote:
>
> > So if I have a Person object "ringo" and I want to get info about the
> > Groups he is a member of, I would do this:
>
> > for group in ringo.group_set.all()
> >     print( group.name )
>
> > My question is, how do I print the "date_joined" without having to do
> > this:
>
> > for group in ringo.group_set.all()
> >     print( Membership.objects.get(person=ringo,
> > group=group).date_joined )
>
> > That seems very DB inefficient.
>
> > Nate
>
> > On Sep 19, 9:43 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Sat, Sep 20, 2008 at 8:37 AM, Nate Thelen <[EMAIL PROTECTED]> wrote:
>
> > > > Looking at the docs here:
>
> > > >http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-o...
>
> > > > I cannot find any reference to how to access the data in the
> > > > "Membership" table.  For example, if I have a reference to the
> > > > "beatles" object, how do I find the "date_joined" for each of the
> > > > "Person" objects.  I have looked through the other sections of the
> > > > documentation, searched this group, and searched via Google, but
> > > > couldn't find the info.
>
> > > Short version: You access the membership table using the foreign key
> > > relationship that the membership defines.
>
> > > Long version: Your question ("the date_joined for each person object")
> > > is actually ill posed - a person doesn't have a date_joined without a
> > > group to also give context. "The date person X joined group Y" can be
> > > answered as:
>
> > > >>> Membership.objects.get(person=X, group=y).date_joined
>
> > > It might help to think about it like this - m2m-intermediate tables
> > > don't add extra data to an m2m relation, they make a 2-step foreign
> > > key relation behave like an m2m relation.
>
> > > 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
-~--~~~~--~~--~--~---



Re: Many-To-Many with extra fields

2008-09-23 Thread akonsu

hello,

how about

for m in Membership.objects.filter(person=ringo) : print m.date_joined

konstantin

On Sep 23, 4:58 pm, Nate Thelen <[EMAIL PROTECTED]> wrote:
> So if I have a Person object "ringo" and I want to get info about the
> Groups he is a member of, I would do this:
>
> for group in ringo.group_set.all()
>     print( group.name )
>
> My question is, how do I print the "date_joined" without having to do
> this:
>
> for group in ringo.group_set.all()
>     print( Membership.objects.get(person=ringo,
> group=group).date_joined )
>
> That seems very DB inefficient.
>
> Nate
>
> On Sep 19, 9:43 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>
> > On Sat, Sep 20, 2008 at 8:37 AM, Nate Thelen <[EMAIL PROTECTED]> wrote:
>
> > > Looking at the docs here:
>
> > >http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-o...
>
> > > I cannot find any reference to how to access the data in the
> > > "Membership" table.  For example, if I have a reference to the
> > > "beatles" object, how do I find the "date_joined" for each of the
> > > "Person" objects.  I have looked through the other sections of the
> > > documentation, searched this group, and searched via Google, but
> > > couldn't find the info.
>
> > Short version: You access the membership table using the foreign key
> > relationship that the membership defines.
>
> > Long version: Your question ("the date_joined for each person object")
> > is actually ill posed - a person doesn't have a date_joined without a
> > group to also give context. "The date person X joined group Y" can be
> > answered as:
>
> > >>> Membership.objects.get(person=X, group=y).date_joined
>
> > It might help to think about it like this - m2m-intermediate tables
> > don't add extra data to an m2m relation, they make a 2-step foreign
> > key relation behave like an m2m relation.
>
> > 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
-~--~~~~--~~--~--~---



Re: Many-To-Many with extra fields

2008-09-23 Thread Nate Thelen

So if I have a Person object "ringo" and I want to get info about the
Groups he is a member of, I would do this:

for group in ringo.group_set.all()
print( group.name )

My question is, how do I print the "date_joined" without having to do
this:

for group in ringo.group_set.all()
print( Membership.objects.get(person=ringo,
group=group).date_joined )

That seems very DB inefficient.

Nate


On Sep 19, 9:43 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Sat, Sep 20, 2008 at 8:37 AM, Nate Thelen <[EMAIL PROTECTED]> wrote:
>
> > Looking at the docs here:
>
> >http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-o...
>
> > I cannot find any reference to how to access the data in the
> > "Membership" table.  For example, if I have a reference to the
> > "beatles" object, how do I find the "date_joined" for each of the
> > "Person" objects.  I have looked through the other sections of the
> > documentation, searched this group, and searched via Google, but
> > couldn't find the info.
>
> Short version: You access the membership table using the foreign key
> relationship that the membership defines.
>
> Long version: Your question ("the date_joined for each person object")
> is actually ill posed - a person doesn't have a date_joined without a
> group to also give context. "The date person X joined group Y" can be
> answered as:
>
> >>> Membership.objects.get(person=X, group=y).date_joined
>
> It might help to think about it like this - m2m-intermediate tables
> don't add extra data to an m2m relation, they make a 2-step foreign
> key relation behave like an m2m relation.
>
> 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
-~--~~~~--~~--~--~---



Re: geodjango apache vs lighttpd

2008-09-23 Thread Jashugan

Did you switched from Apache + mod_python to Lighttpd + FCGI? If so,
are you sure it wasn't a problem with mod_python versus Apache in
general? I'm having some issues with mod_python unrelated to
geodjango. It seems there are certain modules that work in the python
interpreter that will cause Apache+mod_python to stall.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: denormalized data in single field

2008-09-23 Thread akonsu

hello,

you can override the model's save() method.

konstantin

On Sep 23, 3:05 pm, "Владимир Сидоренко" <[EMAIL PROTECTED]> wrote:
> hi
>
> i need to process a set of denormalized data in single model field.
> for example,
>
> class Place(Model):
>     location = LocationField()
>
> it's rendered as one single text field, where we insert address, then by
> this address we find out corresponding district and nearest subway station
>
> and write to database something like:
>
> class Location(Model):
>     address = CharField()
>     subway = ManyToManyField(Subway)
>     district = ForeignKey(District)
>
> class Place(Model):
>     location = ForeignKey(Location)
>
> how can i override field's save to db process to generate Location object
> and save corresponding key to Place?
>
> 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: strategy for deploying to production server

2008-09-23 Thread akonsu

hello,

i set up an SVN repository and checked out the files on to my dev
machine as well as in to the directory where the web server can find
them.

i do not have setting.py in my repository, and i have different
versions of settings.py on my dev machine and on the server. so al the
differences are stored in settings.py.

when i make a checkin from the dev machine, i update the checked out
copy on the web server and restart the server.

this is about it. i have my svn repo publicly available if you wish to
take a look let me know.

konstantin

On Sep 23, 1:22 pm, sotirac <[EMAIL PROTECTED]> wrote:
> Just trying to get a feel for what other developers are doing when
> deploying to a production server.  There are some differences between
> my development machine and production server such as the location of
> my media files, the database settings, and if I want to enable caching
> or not.   Right now my option is to comment out some of the code and
> uncomment the other values.  This is time consuming and error proned.
> How do you deal with this issue of working in your development machine
> and then having to deploy the same code into your production server.
>
> Some files I modify are the settings.py/url.py/views.py.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Impact of a CustomManager on the RelatedManager

2008-09-23 Thread bruno desthuilliers

On 23 sep, 01:26, gaz <[EMAIL PROTECTED]> wrote:
> Thanks Bruno,
>
> I'd already tried that - I noticed that with or without the
> use_for_related_field

FWIW, it's a plural, ie "use_for_related_field*s*" - but I assume the
typo wasn't in your code.

Out of curiousity, which Django version are you using ?

>  being set on the Custom Manager the effect was
> the same - ie. the RelatedManager fires off it's own code without
> actually using the MyCurrentSiteManager instance that is already
> associated with the Model Class.
>
> At the moment my solution has been to do:
>
>   def _get_conferences(self):
> return Conference.objects.filter(venue=self)
>   conferences = property(_get_conferences)


You could refactor it to

   conferences = property(lambda self:
Conference.objects.filter(venue=self))



But this doesn't really answer your question...

> I'm not sure this is the best way, but I am basing that on my reading
> athttp://docs.djangoproject.com/en/dev/topics/db/managers/#adding-extra...
> andhttp://docs.djangoproject.com/en/dev/topics/db/models/#model-methods
>
> Any advice on as to whether or not this is the best way to get the
> solution I am after appreciated!

Well... A working solution is by all means better than a broken one,
ins't it !-)

This being said, I'm afraid I can't help much more without installing
your code and tracing it.

Any Django guru around ???

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: OS path in python

2008-09-23 Thread bruno desthuilliers

On 23 sep, 02:42, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> > import os
> > os.environ['SERVER_NAME']
>
> > See how that goes.
>
> I get:
> KeyError: 'SERVER_NAME'
>
> So i'm assuming we aren't

You mean you don't know which web development solution you're using ???
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 apache vs lighttpd

2008-09-23 Thread [EMAIL PROTECTED]

I found apache stalled pages whenever i tried to touch a geodjango
field in the templates. Switched to lighttpd and everything is
perfect. Anyone else find this, or know the reason? I confess i didn't
try reinstalling apache so it could have been a bad install, but
otherwise apache was working no problems...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 redirecting to wrong URL?

2008-09-23 Thread Allan

My application is working well at mysite.com/django/, and I get
an admin login atmysite.com/django/admin/ -- but when I
enter my credentials, I seem to be redirected tomysite.com/
admin/ (which is a 404 error).  Did I miss an admin config setting
somewhere?

A relevant excerpt from urls.py appears below.

Allan


import os
from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',

(r'^contact/$', 'careers_contact.views.contact'),
(r'^careers/$', 'careers_contact.views.careers'),

(r'^admin/(.*)', admin.site.root),
)

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



denormalized data in single field

2008-09-23 Thread Владимир Сидоренко
hi

i need to process a set of denormalized data in single model field.
for example,

class Place(Model):
location = LocationField()

it's rendered as one single text field, where we insert address, then by
this address we find out corresponding district and nearest subway station

and write to database something like:

class Location(Model):
address = CharField()
subway = ManyToManyField(Subway)
district = ForeignKey(District)

class Place(Model):
location = ForeignKey(Location)

how can i override field's save to db process to generate Location object
and save corresponding key to Place?

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



python-ldap + Apache causing errors

2008-09-23 Thread Jashugan

Hello,

I am having a problem when using python-ldap with Apache. I added an
authentication backend based on ldapauth.py, and it works fine when
running from the Django server. However, when I use Apache I get the
following error in the Apache error.log:

child pid 2941 exit signal Bus error (10)

It seems to be the following line that causes the problem:

l.simple_bind_s(self.settings['LDAP_PREBINDDN'],
self.settings['LDAP_PREBINDPW'])

I have tried the following without any luck:

+ changing from a synchronous bind to a asynchronous bind
+ setting the host by IP address (I thought it may have been due to
some kind of domain problem)

Has anyone experienced anything like this? Any suggestions on where to
begin troubleshooting?

TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 1.0 and Stdimage does not work

2008-09-23 Thread Iapain

picture = Picture(gallery = gallery, image =
request.FILES['image'])

Should be

picture = Picture(gallery = gallery, image =
request.FILES['image'].name)


On Sep 23, 4:55 pm, mwebs <[EMAIL PROTECTED]> wrote:
> Hello,
> I am using Stdimage instead of the native models.ImageField to have
> scaling and thumbnail support. With the former 0.97 release Stdimage
> just worked perfect. Now I tried to use it with Django 1.0, and of
> course I also updated Stdimage to the newest svn-release.
>
> But when uploading an Image I run into trubble: I get an TypeError
> unsubscriptable object.
>
> Traceback:
> File "C:\Programme\Python24\lib\site-packages\django\core\handlers
> \base.py" in get_response
>   86.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "D:\projects\openContext\src\pictures\views.py" in add_picture
>   46.             picture = Picture(gallery = gallery, image =
> request.FILES['image'])
> File "C:\Programme\Python24\lib\site-packages\django\db\models
> \base.py" in __init__
>   266.         signals.post_init.send(sender=self.__class__,
> instance=self)
> File "C:\Programme\Python24\lib\site-packages\django\dispatch
> \dispatcher.py" in send
>   148.             response = receiver(signal=self, sender=sender,
> **named)
> File "C:\Programme\Python24\lib\site-packages\stdimage\fields.py" in
> _set_thumbnail
>   110.             filename = self.generate_filename(instance,
> os.path.basename(getattr(instance, self.name).path))
> File "C:\Programme\Python24\lib\site-packages\django\db\models\fields
> \files.py" in _get_path
>   49.         return self.storage.path(self.name)
> File "C:\Programme\Python24\lib\site-packages\django\core\files
> \storage.py" in path
>   202.             path = safe_join(self.location, name)
> File "C:\Programme\Python24\lib\site-packages\django\utils\_os.py" in
> safe_join
>   13.     final_path = normcase(abspath(join(base, *paths)))
> File "C:\Programme\Python24\lib\ntpath.py" in join
>   67.         elif isabs(b):
> File "C:\Programme\Python24\lib\ntpath.py" in isabs
>   53.     s = splitdrive(s)[1]
> File "C:\Programme\Python24\lib\ntpath.py" in splitdrive
>   119.     if p[1:2] == ':':
>
> Any ideas how to fix this bug, or better - what am I doing 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: A question about spaces and passing variables...

2008-09-23 Thread djandrow

Ok, thanks Karen, i;ll have a go with messing about.
If someone else with more time could explain it to me that would be
great, otherwise i'll just try playing about with it.

regards,

Andrew
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-23 Thread Ramiro Morales

On Tue, Sep 23, 2008 at 1:36 PM, h <[EMAIL PROTECTED]> wrote:
>
> I suspect you have something like this in your urls.py and your static
> media is not being served
>
>
> if not settings.DEBUG:
>urlpatterns += patterns('',(r'^media/(.*)$',
> 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),)
>
>

I was going to suggest the same. If so, we  should consider renaming the
http://docs.djangoproject.com/en/dev/howto/static-files/
document from "Serving static files" to "Serving static files with the
Django development server".
to avoid helping people making wrong assumptions based in
the generality of the document title.

Regards,

-- 
 Ramiro Morales

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: strategy for deploying to production server

2008-09-23 Thread Dmitry Dzhus

sotirac wrote:
> Just trying to get a feel for what other developers are doing when
> deploying to a production server.  There are some differences between
> my development machine and production server such as the location of
> my media files, the database settings, and if I want to enable caching
> or not.   Right now my option is to comment out some of the code and
> uncomment the other values.  This is time consuming and error proned.
> How do you deal with this issue of working in your development machine
> and then having to deploy the same code into your production server.
>
> Some files I modify are the settings.py/url.py/views.py.

I use hostname-based automatic configuration.

I place settings shared across my local dev box and remote host in
`settings.py`, and in `site_settings.py` I use something like that:

from socket import gethostname

hostname = gethostname()

if hostname == dev_box_host':
# set VAR1, VAR2 etc.
elif hostname == 'remote_host':
# set VAR1, VAR2 etc.

One may place settings for each site in separate module, use
`__import__` to load the appropriate settings, etc.
-- 
Happy Hacking.

http://sphinx.net.ru
む


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: strategy for deploying to production server

2008-09-23 Thread Norman Harman

sotirac wrote:
> Just trying to get a feel for what other developers are doing when
> deploying to a production server.  There are some differences between
> my development machine and production server such as the location of
> my media files, the database settings, and if I want to enable caching
> or not.   Right now my option is to comment out some of the code and
> uncomment the other values.  This is time consuming and error proned.
> How do you deal with this issue of working in your development machine
> and then having to deploy the same code into your production server.

Most systems I work on are complex multidev setups, testing setup, 
production (multiple web boxes, db, etc.)

I have found capistrano to be an excellent tool for automating all the 
steps needed to deploy to the various above targets.  It's in Ruby, but 
I was able to use it effectively and I don't know Ruby(At least I don't 
think I do :).  It is not a simple tool though.  Probably overkill for 
people with just a simple hosted server.


I have a proj_base_settings.py that has strangely  enough the base 
settings for project proj

Each dev/test/production environment has a proj_settings.py that imports 
proj_base_settings.py and overrides whatever is required.  This is often 
just setting DEBUG, email addy, and db.  This file is not checked into 
source control.


I prepend proj_ to all the settings files so I can have multiple 
projects in same python path with out conflicts.


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Get off the sidelines and huddle up with the Statesman all season long
for complete high school, college and pro coverage in print and online!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Sending HTML email

2008-09-23 Thread Berco Beute

> You might try reading the 
> documentation:http://docs.djangoproject.com/en/dev/topics/email/#sending-alternativ...

Oops, completely overlooked that. Thanks for the pointer.

2B
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Sending HTML email

2008-09-23 Thread Matthias Kestenholz

On Tue, Sep 23, 2008 at 7:38 PM, Berco Beute <[EMAIL PROTECTED]> wrote:
>
> Currently I'm sending plain text mails using:
>
> ###
> from django.core.mail import EmailMessage
> email = EmailMessage('hi', 'howdy', host, to)
> email.send()
> ###
>
> But now I want to use HTML in the body of the email. How do I format
> such a message and can I just send it like above?
>

Yes, or at least in a similar way. You might try reading the documentation:
http://docs.djangoproject.com/en/dev/topics/email/#sending-alternative-content-types

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Sending HTML email

2008-09-23 Thread Jeff Gentry


On Tue, 23 Sep 2008, Berco Beute wrote:
> But now I want to use HTML in the body of the email. How do I format
> such a message and can I just send it like above?

Emails should be plain text, not HTML ;)


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



Sending HTML email

2008-09-23 Thread Berco Beute

Currently I'm sending plain text mails using:

###
from django.core.mail import EmailMessage
email = EmailMessage('hi', 'howdy', host, to)
email.send()
###

But now I want to use HTML in the body of the email. How do I format
such a message and can I just send it like above?

2B
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: strategy for deploying to production server

2008-09-23 Thread Jay Parlar

On Tue, Sep 23, 2008 at 1:22 PM, sotirac <[EMAIL PROTECTED]> wrote:
>
> Just trying to get a feel for what other developers are doing when
> deploying to a production server.  There are some differences between
> my development machine and production server such as the location of
> my media files, the database settings, and if I want to enable caching
> or not.   Right now my option is to comment out some of the code and
> uncomment the other values.  This is time consuming and error proned.
> How do you deal with this issue of working in your development machine
> and then having to deploy the same code into your production server.
>
> Some files I modify are the settings.py/url.py/views.py.

Remember that all of these are just Python files, there's nothing
special. So I usually have files called dbsettings.py and
mediasettings.py, that hold all my database and media info, then I
just have settings.py import them. The stuff common between
environments lives in settings.py, and the custom stuff only has to
live in one place.

Jay P.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 forloop variable to get the provide special tags for the 4th element.

2008-09-23 Thread sotirac

Hi Steve, the cycle tag fixed the issue.
Thanks.

On Sep 15, 1:00 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Lee Hinde wrote:
>
> > On Sun, Sep 14, 2008 at 10:00 PM, sotirac <[EMAIL PROTECTED]
> > > wrote:
>
> >     In the django template where I am using a for loop, I have to use a
> >     special tag (div class="yui-u first" instead of div class="yui") for
> >     every forth item.  Im trying to create a table with three columns.  I
> >     can access the first loop but how do I do it for every third.
> >     --
> >     
> >     {% extends "base.html" %}
>
> >     {% block content %}
> >            {% for website in websites %}
> >            {% if forloop.first %}
> >            
> >            {% else %}
> >            
> >            {% endif %}
> [...]
> > Check the template tags. I think divisibleby might work for you.
>
> An easy way to implement this feature is the "cycle" tag.
>
> >            {% if forloop.first %}
> >            
> >            {% else %}
> >            
> >            {% endif %}
>
> would then become
>
> 
>
> However I'm not really able to understand the rest of your logic enough
> to determine how the remainder of the code would change, because I'm not
> sure I understand it well enough.
>
> 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
-~--~~~~--~~--~--~---



strategy for deploying to production server

2008-09-23 Thread sotirac

Just trying to get a feel for what other developers are doing when
deploying to a production server.  There are some differences between
my development machine and production server such as the location of
my media files, the database settings, and if I want to enable caching
or not.   Right now my option is to comment out some of the code and
uncomment the other values.  This is time consuming and error proned.
How do you deal with this issue of working in your development machine
and then having to deploy the same code into your production server.

Some files I modify are the settings.py/url.py/views.py.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Postgresql 'missing FROM-clause entry in subquery for table' error on lookup that spans relationships

2008-09-23 Thread cfobel

Malcolm,

I've posted a new ticket and assigned it to you at:
http://code.djangoproject.com/ticket/9188

I look forward to hearing from you.

Thanks again!
Christian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Updates not working

2008-09-23 Thread Rajesh Dhawan

Hi Adam,

On Sep 22, 6:05 pm, "Adam Findley" <[EMAIL PROTECTED]> wrote:
> So I have a pretty simple case here in a view:
>
> event = Event.Objects.get(id='23')
> event.end_date = datetime.now()
> event.save()
>
> It should just work right?

Yes.

>
> When looking at the queries, the UPDATE command has all of the keys
> quoted, but not the values.  This causes the query to fail.
>
> For some reason this fails in the view, but doesn't fail in the
> shell... I'm at such a loss here.  Any ideas here?

What version of Django are you on?

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



MySQLdb installation problems on mac leopard

2008-09-23 Thread Nico

Hello,

I've installed Django 1.0, and have Python 2.5 running fine on my
Intel Mac with Leopard.

I have downloaded and installed the latest package from the official
MySQL site, and I'm trying to install MySQLdb to get it working with
python, but its not working

I have followed these instructions (which are all nearly identical)
http://antoniocangiano.com/2007/12/22/how-to-install-django-with-mysql-on-mac-os-x/
http://www.keningle.com/?p=11

But I keep getting this error message when I attempt to build and
install MySQLdb:



host46:MySQL-python-1.2.2 Nico$ python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb
running build_ext
building '_mysql' extension
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -
DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -pipe -
Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/local/mysql/
include -I/System/Library/Frameworks/Python.framework/Versions/2.5/
include/python2.5 -c _mysql.c -o build/temp.macosx-10.5-i386-2.5/
_mysql.o -g -Os -arch i386 -fno-common -D_P1003_1B_VISIBLE -
DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -
DIGNORE_SIGHUP_SIGQUIT
i686-apple-darwin9-gcc-4.2.1: unrecognized option '-no-cpp-precomp'
i686-apple-darwin9-gcc-4.2.1: error trying to exec 'as': execvp: No
such file or directory
cc1: error: unrecognized command line option "-Wno-long-double"
error: command 'gcc' failed with exit status 1



I think it is maybe a problem with GCC, but I don't know much about
this area

Help please!?!?

nico

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 field error messages

2008-09-23 Thread Donn

On Tuesday, 23 September 2008 18:16:19 barbara shaurette wrote:
> Question 1: What are you using in your template to display the errors?
In the render to response I put {'formbugs': form.non_field_errors() } and in 
the template {{formbugs}}.

It really looks like the self.validate_unique() in clean does not do anything. 
I have not had time to look at the source.

> Question 2: Did you start working on this app on Talk Like a Pirate
> Day?
A ye have me matey! :D

\d

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Postgresql 'missing FROM-clause entry in subquery for table' error on lookup that spans relationships

2008-09-23 Thread cfobel

Thanks for your quick reply.  I will submit a bug report.

Thanks!
Christian

On Sep 22, 9:45 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-09-22 at 18:22 -0700, cfobel wrote:
> > Hello,
>
> > I'm encountering anerrorwhen performing a lookup that spans
> > relationships.  The query is as follows:
>
> > myitems =
> > MyItem.objects_all.exclude(user__somemodel__created__gte=(datetime.now()
> > - timedelta(days=3)))
>
> > With the following (stripped) models:
>
> > class MyItem(models.Model):
> >     user = models.ForeignKey(user, unique=True)
>
> > class SomeModel(models.Model):
> >     created = models.DateTimeField('Date created',
> > default=datetime.now)
> >     user = models.ForeignKey(User)
>
> This is a pretty good test case, but the looks of it. The only thingmissingis 
> the custom manager (since you're calling MyItem.objects_all,
> not MyItem.objects) and that possibly affects something, too.
>
> In any case, any time we're generating invalid SQL instead of raising
> some othererror(or doing the right thing for valid code -- and the
> above looks valid at first glance), it's a bug.
>
> Could you please open a ticket for this so that I remember to look at it
> (assign it to "mtredinnick" straight away, if you like).
>
>
>
>
>
> > TheerrorI get is:
>
> > Traceback (most recent call last):
> >   
> >   File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
> > line 179, in _result_iter
> >     self._fill_cache()
> >   File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
> > line 612, in _fill_cache
> >     self._result_cache.append(self._iter.next())
> >   File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
> > line 269, in iterator
> >     for row in self.query.results_iter():
> >   File "/usr/lib/python2.5/site-packages/django/db/models/sql/
> > query.py", line 206, in results_iter
> >     for rows in self.execute_sql(MULTI):
> >   File "/usr/lib/python2.5/site-packages/django/db/models/sql/
> > query.py", line 1723, in execute_sql
> >     cursor.execute(sql, params)
> >   File "/usr/lib/python2.5/site-packages/django/db/backends/util.py",
> > line 19, in execute
> >     return self.cursor.execute(sql, params)
> > psycopg2.ProgrammingError:missingFROM-clauseentryinsubqueryfor
> >table"u1"
> > LINE 1: ..._myitem" U0 INNER JOIN "notes_note" U2 ON (U1."id" = ...
>
> > ^
>
> > To debug the issue, I looked at the SQL generated by the 'myitems'
> > queryset above.  The generated SQL is:
>
> > SELECT "users_myitem"."id", "users_myitem"."user_id"
> > FROM "users_myitem"
> > WHERE NOT (
> >   "users_myitem"."user_id" IN (
> >     SELECT U2."user_id"
> >     FROM "users_myitem" U0
> >     INNER JOIN "myapp_somemodel" U2 ON (U1."id" = U2."user_id")
> >     WHERE U2."created" >= 2008-09-19 19:57:43.111687
> >   )
> > )
>
> > It looks like thetable"users_myitem" is being improperly labeled as
> > 'U0',
>
> Well, not really. The users_myitemtablein the main query and
> users_myitem in thesubqueryare different instances of thetable, so it
> has to have an alias. The maintablefrom the outer query is always
> going to end up being "U0" in an inner query like this (since it's the
> first in a list of names and the number is the index in the list).
>
> >  and then is referred to as 'U1' on the next line.
>
> The interesting bit is what happened to U1. I have a suspicion this
> might be related to another optimisation that isn't working reliably,
> but which I thought wasn't harming anything (just generating less than
> optimal code): we shouldn't really need U0 in the above query, since we
> can just test against the thing it's joining to.
>
> There's definitely something going wrong here. Again, we shouldn't ever
> be sending malformed SQL to the database. That's always a Django bug. I
> can't drop everything right this minute to look at it, but if you open a
> ticket I'll certainly take a look, since SQL bugs are something I take
> very personally.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: A question about spaces and passing variables...

2008-09-23 Thread Karen Tracey
On Tue, Sep 23, 2008 at 12:22 PM, djandrow <[EMAIL PROTECTED]>wrote:

>
> Thanks Karen, how does urlencode work though?
> I imangine its a filter, but what does it do?
>
>
Yes well the doc is a bit sparse for that filter, but if you do a little
playing around with it and research into how spaces (and other characters
not allowed in urls) are generally handled, I think you will see it does
what you need.  Sorry but I don't have time to dig up pointers to various
references right now.

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: Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-23 Thread h

I suspect you have something like this in your urls.py and your static
media is not being served


if not settings.DEBUG:
urlpatterns += patterns('',(r'^media/(.*)$',
'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),)



On Sep 23, 5:29 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Sep 23, 2008 at 12:14 PM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > There are no tracebacks in this instance.  I can see the non-descript
> > 500 errors appearing in my terminal window.
>
> I don't understand.  Are you saying you have configured ADMINS, etc. in
> settings.py so that 500 error tracebacks are mailed to you, but these
> particular ones are not?  What terminal window are you referring to?
> Perhpas a cut and paste of what you are seeing, exactly, will help, as it is
> I am completely in the dark as to what is going on.
>
> Plenty of people run with DEBUG off and are able to serve static media, so
> there's something particular about your setup that is causing this.  Are you
> testing this with the development server or are you using Apache or
> something else?  Do you have anything related to configuring serving of
> static media that is bracketed by "if debug is on" type statements?  This is
> not a commonly encountered problem so I can't give any general advice based
> on why others have run into this -- you need to provide more information
> about your setup if you want any real guidance on what might be causing
> this.
>
> 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: Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-23 Thread Karen Tracey
On Tue, Sep 23, 2008 at 12:14 PM, Huuuze <[EMAIL PROTECTED]> wrote:

>
> There are no tracebacks in this instance.  I can see the non-descript
> 500 errors appearing in my terminal window.
>

I don't understand.  Are you saying you have configured ADMINS, etc. in
settings.py so that 500 error tracebacks are mailed to you, but these
particular ones are not?  What terminal window are you referring to?
Perhpas a cut and paste of what you are seeing, exactly, will help, as it is
I am completely in the dark as to what is going on.

Plenty of people run with DEBUG off and are able to serve static media, so
there's something particular about your setup that is causing this.  Are you
testing this with the development server or are you using Apache or
something else?  Do you have anything related to configuring serving of
static media that is bracketed by "if debug is on" type statements?  This is
not a commonly encountered problem so I can't give any general advice based
on why others have run into this -- you need to provide more information
about your setup if you want any real guidance on what might be causing
this.

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: A question about spaces and passing variables...

2008-09-23 Thread djandrow

Thanks Karen, how does urlencode work though?
I imangine its a filter, but what does it do?

regards,

Andrew
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 field error messages

2008-09-23 Thread barbara shaurette

Question 1: What are you using in your template to display the errors?

Question 2: Did you start working on this app on Talk Like a Pirate
Day?


On Sep 23, 3:13 am, Donn <[EMAIL PROTECTED]> wrote:
> On Tuesday, 23 September 2008 11:42:19 Daniel Roseman wrote:> The __all__ 
> error messages are available via form.non_field_errors().
>
> I sent that along to the template, but it's still oddly silent.
>
> Some code:
> def clean(self):
>         try:
>                 self.validate_unique()
>         except forms.ValidationError:
>                 raise forms.ValidationError("Here be sea monsters!")
>
>         # If I unremark below it does raise the error, so it's running clean()
>         # but self.validate_unique() seems to have no effect.
>         # My model's field does have unique = True
>         # And the normal form error for a violation shows up -- the one I want
>         # to change.
>
>         #raise forms.ValidationError("This one will work.")
>         return self.cleaned_data
>
> I'm sure I've done something daft :)
> \d
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ModelChoiceField with Unique Results

2008-09-23 Thread BobZ

I had SOME luck with "queryset=Vehicle.objects.filter(year=True)" in
that the form actually rendered in my template, but the year select
box is empty now.  All other select boxes load fine (Make and Model)
with their data...only year still won't work.

On Sep 23, 10:44 am, BobZ <[EMAIL PROTECTED]> wrote:
> Thanks Daniel.  I've found solutions similar to yours in other threads
> on the net, and everytime I test them, I literally get no form at all
> in my rendered template.
> My template appears to have all the correct code in it as you can see
> in the link "search.html" at the bottom of this post.
> Looking at the code you provided, it seems like the
> "queryset=Vehicle.objects.order_by('-year').distinct()" pulls all
> distinct fields from the Vehicle table and sorts them by year.  What
> I'm actually after is a way to filter out only the years and list them
> in descending order.
>
> In my forms.py file, I've kept all variations of the code I've tested
> for this app commented out for my own reference, but maybe it will
> help you see what's happening and what I'm trying to do.
>
> Here's all of my code in dpaste:
> http://dpaste.com/80010/";>models.py -http://dpaste.com/80010/
> http://dpaste.com/80009/";>forms.py -http://dpaste.com/80009/
> http://dpaste.com/80011/";>views.py -http://dpaste.com/80011/
> http://dpaste.com/80013/";>search.html -http://dpaste.com/80013/
>
> On Sep 23, 1:32 am, Daniel Roseman <[EMAIL PROTECTED]>
> wrote:
>
> > On Sep 22, 10:58 pm, BobZ <[EMAIL PROTECTED]> wrote:
>
> > > Thanks dmorozov, that worked fine in the sense that it returned only
> > > unique years in a select box, but it still didn't order them properly
> > > (getting non-duplicate years as 1961, 1931, 2000, 1975, 1995, etc.).
>
> > > Somehow the order_by section of  "set([(obj.year, obj.year) for obj in
> > > Vehicle.objects.all().order_by('-year')]) " isn't performing its
> > > function.
>
> > > Any ideas?
>
> > > Thanks again!
>
> > To be honest, dmorozov's solution sounds like overkill for what you
> > need. Try something like this:
>
> > class SearchForm(forms.ModelForm):
> >     year = forms.ModelChoiceField(queryset=Vehicle.objects.order_by('-
> > year').distinct())
>
> > You'll need to be sure Vehicle has a __unicode__ method for this to
> > work.
> > --
> > 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: Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-23 Thread Huuuze

There are no tracebacks in this instance.  I can see the non-descript
500 errors appearing in my terminal window.

On Sep 23, 12:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Sep 23, 2008 at 11:53 AM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > I'm preparing to deploy my Django app and I noticed that when I change
> > the "DEBUG" setting to False, all references to static files (i.e.,
> > JavaScript, CSS, etc..) result in HTTP 500 errors.
>
> > Any idea what's causing that issue (and how to fix it)?
>
> No. An idea for getting enough information to figure it out, though, is to
> configure things in settings.py (ADMINS, the various EMAIL_HOST,
> EMAIL_HOST_USER, etc. settings) so that you get the tracebacks for these
> errors mailed to you.
>
> 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: Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-23 Thread Karen Tracey
On Tue, Sep 23, 2008 at 11:53 AM, Huuuze <[EMAIL PROTECTED]> wrote:

>
> I'm preparing to deploy my Django app and I noticed that when I change
> the "DEBUG" setting to False, all references to static files (i.e.,
> JavaScript, CSS, etc..) result in HTTP 500 errors.
>
> Any idea what's causing that issue (and how to fix it)?
>

No. An idea for getting enough information to figure it out, though, is to
configure things in settings.py (ADMINS, the various EMAIL_HOST,
EMAIL_HOST_USER, etc. settings) so that you get the tracebacks for these
errors mailed to you.

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: locale aware number formats

2008-09-23 Thread Karen Tracey
2008/9/23 pihentagy <[EMAIL PROTECTED]>

>
> On Sep 23, 12:28 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> > Wiadomość napisana w dniu 2008-09-23, o godz. 12:21, przez pihentagy:
> >
> > > How can I print a number using the locale's thousand separator and
> > > decimal?
> >
> > > Basically I hoped ther is a template filter, but floatformat doesn't
> > > have thousand separator, and seems to use decimal point always.
> >
> > Take a look at Babel package and Django helpers -
> http://babel.edgewall.org/
>
> Ok, but there is also the module locale.
> Should I really use other libraries for just displaying a number in a
> page? Django supports translations, doesn't it supports printing
> numbers and currency honoring the currently selected language?
>
>
Not yet, see:

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

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



Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-23 Thread Huuuze

I'm preparing to deploy my Django app and I noticed that when I change
the "DEBUG" setting to False, all references to static files (i.e.,
JavaScript, CSS, etc..) result in HTTP 500 errors.

Any idea what's causing that issue (and how to fix it)?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: locale aware number formats

2008-09-23 Thread pihentagy

On Sep 23, 12:28 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Wiadomość napisana w dniu 2008-09-23, o godz. 12:21, przez pihentagy:
>
> > How can I print a number using the locale's thousand separator and
> > decimal?
>
> > Basically I hoped ther is a template filter, but floatformat doesn't
> > have thousand separator, and seems to use decimal point always.
>
> Take a look at Babel package and Django helpers -http://babel.edgewall.org/

Ok, but there is also the module locale.
Should I really use other libraries for just displaying a number in a
page? Django supports translations, doesn't it supports printing
numbers and currency honoring the currently selected language?

thanks
Gergo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: A question about spaces and passing variables...

2008-09-23 Thread Karen Tracey
On Tue, Sep 23, 2008 at 11:23 AM, djandrow <[EMAIL PROTECTED]>wrote:

>
> I have a list of categories, which entries are filed into, then some
> can click a category link in a template and it will take them to a
> list of entries in that particular category. The problem is one of
> this categories is "About Me", what I have so far in my view is:
>
> current_entries =
> Entry.objects.filter(entry_cat__cat_name=category).order_by("-
> entry_date")
>
> Since you can't have a space in a url the I apply the following filter
> to the category name for the link:
>
> |cut:" "|lower
>
> This means the link location changes from url/About Me to url/aboutme,
> this now passes into the view fine, but obviously it won't match About
> Me in the database, from what i have gathered so far it seems to be
> case insensitive so the problem is the space.
>
> So, how can i get the  URL to match whats in the database?
>
>
Use the urlencode filter:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#urlencode

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: ModelChoiceField with Unique Results

2008-09-23 Thread BobZ

Thanks Daniel.  I've found solutions similar to yours in other threads
on the net, and everytime I test them, I literally get no form at all
in my rendered template.
My template appears to have all the correct code in it as you can see
in the link "search.html" at the bottom of this post.
Looking at the code you provided, it seems like the
"queryset=Vehicle.objects.order_by('-year').distinct()" pulls all
distinct fields from the Vehicle table and sorts them by year.  What
I'm actually after is a way to filter out only the years and list them
in descending order.

In my forms.py file, I've kept all variations of the code I've tested
for this app commented out for my own reference, but maybe it will
help you see what's happening and what I'm trying to do.

Here's all of my code in dpaste:
http://dpaste.com/80010/";>models.py - http://dpaste.com/80010/
http://dpaste.com/80009/";>forms.py - http://dpaste.com/80009/
http://dpaste.com/80011/";>views.py - http://dpaste.com/80011/
http://dpaste.com/80013/";>search.html - http://dpaste.com/80013/

On Sep 23, 1:32 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Sep 22, 10:58 pm, BobZ <[EMAIL PROTECTED]> wrote:
>
> > Thanks dmorozov, that worked fine in the sense that it returned only
> > unique years in a select box, but it still didn't order them properly
> > (getting non-duplicate years as 1961, 1931, 2000, 1975, 1995, etc.).
>
> > Somehow the order_by section of  "set([(obj.year, obj.year) for obj in
> > Vehicle.objects.all().order_by('-year')]) " isn't performing its
> > function.
>
> > Any ideas?
>
> > Thanks again!
>
> To be honest, dmorozov's solution sounds like overkill for what you
> need. Try something like this:
>
> class SearchForm(forms.ModelForm):
>     year = forms.ModelChoiceField(queryset=Vehicle.objects.order_by('-
> year').distinct())
>
> You'll need to be sure Vehicle has a __unicode__ method for this to
> work.
> --
> 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: limit the foreign key select in admin

2008-09-23 Thread Ottavio Campana

On 23 Set, 13:41, Ottavio Campana <[EMAIL PROTECTED]> wrote:
> Hi, I just started studying django and I'm having a problem with its
> admin interface. In my model I have two classes, let's say
>
> class ClassA (models.Model):
>     user = models.ForeignKey(User, help_text=_('ClassA owner'))
>     ...
>
> class ClassB (models.Model):
>     classa = models.ForeignKey(ClassA)
>     
>
> Now I'm trying to give the possibility of editing to each user his
> instances of ClassB, even though only the superuser will create ClassA
> objects. To achieve this, I had to overwrite queryset in the
> modelAdmin of ClassB and it works.
>
> The problem that now I'm having is that if a user modifies a ClassB
> object he will see in the admin a select for all possible ClassA
> objects, not only those owned by him. I tried to overwrite queryset in
> the modelAdmin of ClassA, but is doesn't work.
>
> I think that the admin is calling another function, and I'm not able
> to understand which one it is.
>
> Do you have a hint?

after several tests, I found a working solution, but I don't know if
it is correct. I overwrote the following function in ClassBAdmin

def render_change_form(self, request, context, add=False,
change=False, form_url='', obj=None):
if not request.user.is_superuser:
adminform = context.__getitem__('adminform')
qs = context['adminform'].form['classa'].field.queryset
qs = qs.filter (user=request.user)
context['adminform'].form['classa'].field.queryset = qs
return super(ClassBAdmin, self).render_change_form(request,
context, add, change, form_url, obj)

Is there any better solution?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



A question about spaces and passing variables...

2008-09-23 Thread djandrow

I have a list of categories, which entries are filed into, then some
can click a category link in a template and it will take them to a
list of entries in that particular category. The problem is one of
this categories is "About Me", what I have so far in my view is:

current_entries =
Entry.objects.filter(entry_cat__cat_name=category).order_by("-
entry_date")

Since you can't have a space in a url the I apply the following filter
to the category name for the link:

|cut:" "|lower

This means the link location changes from url/About Me to url/aboutme,
this now passes into the view fine, but obviously it won't match About
Me in the database, from what i have gathered so far it seems to be
case insensitive so the problem is the space.

So, how can i get the  URL to match whats in the database?

thanks,

Andrew
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Slow uploading at Webfaction?

2008-09-23 Thread worksology

Yes, same issue here. Very very slow at times. Yesterday I uploaded a
60mb file in less than 2 minutes, but today I've been waiting over an
hour for an 80mb file to upload. Ridiculous.  Not sure what's going
on, but I'd like to find a fix.


On Aug 6, 1:07 pm, David Zhou <[EMAIL PROTECTED]> wrote:
> Has anyone else experienced slow file uploading on a Django site  
> hosted with Webfaction using a version of trunk that has the latest  
> streaming upload changes?
>
> Uploading a 5mb file and monitoring the temp file Django creates, the  
> file size increases at an agonizingly slow pace.  Upstream bandwidth  
> doesn't seem to be the issue.
>
> ---
> David Zhou
> [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
-~--~~~~--~~--~--~---



django-admin.py init ....an integer is required

2008-09-23 Thread KillaBee

I am working with .90 and when I run django-admin.py init I get this
error on the command line:

Error: The database couldn't be initialized.
an integer is required

I was thinking that it was a port number or host, but I get it if they
are filled or blank.  Please help!!!

setting.py
-
 Django settings for intraweb project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
('Bryant Ross', '[EMAIL PROTECTED]'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'mysql' # 'postgresql', 'mysql', 'sqlite3' or
'ado_mssql'.
DATABASE_NAME = 'time' # Or path to database file if using
sqlite3.
DATABASE_USER = 'bryant' # Not used with sqlite3.
DATABASE_PASSWORD = 'Startan3w' # Not used with sqlite3.
DATABASE_HOST = '10.0.0.20' # Set to empty string for
localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.

# Local time zone for this installation. All choices can be found
here:
# 
http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com";
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '@k$u_+75_2e_y%i%el*n%l!4f_&^bmifxjn_z)[EMAIL PROTECTED])ryi@'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.core.template.loaders.filesystem.load_template_source',
 
'django.core.template.loaders.app_directories.load_template_source',
#'django.core.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
"django.middleware.common.CommonMiddleware",
"django.middleware.sessions.SessionMiddleware",
"django.middleware.doc.XViewMiddleware",
)

ROOT_URLCONF = 'intraweb.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates".
"/home/dev/intraweb/templates"
"/home/bryant/Django-0.90/django-.90_templates"
"/home/bryant/django_templates"
)

INSTALLED_APPS = (
#'django.contrib.auth',
#'django.contrib.contenttypes',
#'django.contrib.sessions',
#'django.contrib.sites',
'intraweb.apps.timesheets',
'django.contrib.admin',
)
--
I get this error in the browser:
 File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line
176, in __init__
super(Connection, self).__init__(*args, **kwargs2)

TypeError: an integer is required


connections.py

client_flag = kwargs.get('client_flag', 0)
client_version = tuple([ int(n) for n in
_mysql.get_client_info().split('.')[:2] ])
if client_version >= (4, 1):
client_flag |= CLIENT.MULTI_STATEMENTS
if client_version >= (5, 0):
client_flag |= CLIENT.MULTI_RESULTS

kwargs2['client_flag'] = client_flag

super(Connection, self).__init__(*args, **kwargs2)line
176...

self.encoders = dict([ (k, v) for k, v in conv.items()
   if type(k) is not int ])

self._server_version = tuple([ int(n) for n in
self.get_server_info().split('.')[:2] ])
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Django 1.0 and Stdimage does not work

2008-09-23 Thread mwebs

Hello,
I am using Stdimage instead of the native models.ImageField to have
scaling and thumbnail support. With the former 0.97 release Stdimage
just worked perfect. Now I tried to use it with Django 1.0, and of
course I also updated Stdimage to the newest svn-release.

But when uploading an Image I run into trubble: I get an TypeError
unsubscriptable object.



Traceback:
File "C:\Programme\Python24\lib\site-packages\django\core\handlers
\base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "D:\projects\openContext\src\pictures\views.py" in add_picture
  46. picture = Picture(gallery = gallery, image =
request.FILES['image'])
File "C:\Programme\Python24\lib\site-packages\django\db\models
\base.py" in __init__
  266. signals.post_init.send(sender=self.__class__,
instance=self)
File "C:\Programme\Python24\lib\site-packages\django\dispatch
\dispatcher.py" in send
  148. response = receiver(signal=self, sender=sender,
**named)
File "C:\Programme\Python24\lib\site-packages\stdimage\fields.py" in
_set_thumbnail
  110. filename = self.generate_filename(instance,
os.path.basename(getattr(instance, self.name).path))
File "C:\Programme\Python24\lib\site-packages\django\db\models\fields
\files.py" in _get_path
  49. return self.storage.path(self.name)
File "C:\Programme\Python24\lib\site-packages\django\core\files
\storage.py" in path
  202. path = safe_join(self.location, name)
File "C:\Programme\Python24\lib\site-packages\django\utils\_os.py" in
safe_join
  13. final_path = normcase(abspath(join(base, *paths)))
File "C:\Programme\Python24\lib\ntpath.py" in join
  67. elif isabs(b):
File "C:\Programme\Python24\lib\ntpath.py" in isabs
  53. s = splitdrive(s)[1]
File "C:\Programme\Python24\lib\ntpath.py" in splitdrive
  119. if p[1:2] == ':':

Any ideas how to fix this bug, or better - what am I doing 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
-~--~~~~--~~--~--~---



Django 1.0 and Stdimage does not work

2008-09-23 Thread mwebs

Hello,
I am using Stdimage instead of the native models.ImageField to have
scaling and thumbnail support. With the former 0.97 release Stdimage
just worked perfect. Now I tried to use it with Django 1.0, and of
course I also updated Stdimage to the newest svn-release.

But when uploading an Image I run into trubble: I get an TypeError
unsubscriptable object.



Traceback:
File "C:\Programme\Python24\lib\site-packages\django\core\handlers
\base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "D:\projects\openContext\src\pictures\views.py" in add_picture
  46. picture = Picture(gallery = gallery, image =
request.FILES['image'])
File "C:\Programme\Python24\lib\site-packages\django\db\models
\base.py" in __init__
  266. signals.post_init.send(sender=self.__class__,
instance=self)
File "C:\Programme\Python24\lib\site-packages\django\dispatch
\dispatcher.py" in send
  148. response = receiver(signal=self, sender=sender,
**named)
File "C:\Programme\Python24\lib\site-packages\stdimage\fields.py" in
_set_thumbnail
  110. filename = self.generate_filename(instance,
os.path.basename(getattr(instance, self.name).path))
File "C:\Programme\Python24\lib\site-packages\django\db\models\fields
\files.py" in _get_path
  49. return self.storage.path(self.name)
File "C:\Programme\Python24\lib\site-packages\django\core\files
\storage.py" in path
  202. path = safe_join(self.location, name)
File "C:\Programme\Python24\lib\site-packages\django\utils\_os.py" in
safe_join
  13. final_path = normcase(abspath(join(base, *paths)))
File "C:\Programme\Python24\lib\ntpath.py" in join
  67. elif isabs(b):
File "C:\Programme\Python24\lib\ntpath.py" in isabs
  53. s = splitdrive(s)[1]
File "C:\Programme\Python24\lib\ntpath.py" in splitdrive
  119. if p[1:2] == ':':

Any ideas how to fix this bug, or better - what am I doing 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
-~--~~~~--~~--~--~---



order_by clause to preserve order in list?

2008-09-23 Thread coan


I want to fetch a list of items in my database, and I have their id
ready:
my_ids_to_get = [ 1, 3, 2, ]

In mysql I would fetch them like this:
SELECT * FROM table WHERE id IN (1, 3, 2) ORDER BY FIELD( id, 1, 3,
2 )

This would preserve their order.

Can I build this query with the native django order_by?

I can get the objects like this:
MyObject.objects.filter(pk__in=my_ids_to_get)
But I'm not able to build an order clause to use with it, and their
order is not preserved.

Do I have to fall back on raw sql to do this?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Auto Discover on MediaTemple

2008-09-23 Thread krylatij

make sure that you use Django 1.0
this mechanizm was changed since 0.96
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Auto Discover on MediaTemple

2008-09-23 Thread Karen Tracey
On Tue, Sep 23, 2008 at 8:31 AM, <[EMAIL PROTECTED]> wrote:

>
> Using the gs and Django container on MediaTemple, got my project
> installed, it works when I don't have the admin info in the URLS.py,
> when I add all of the info in the URLS.py and go to the site I get
> this error:
>
> AttributeError at /
> 'module' object has no attribute 'autodiscover'
>
> Here's my URLS
>
> http://dpaste.com/79956/
>

It would appear your MediaTemple grid container is configured to use a
pre-1.0 version of Django.  From their FAQ (
http://mediatemple.net/webhosting/gs/faq.htm#103):

"Your Django Container uses Python version 2.4.4. You can easily choose
between bleeding-edge nightly versions or stable releases of the Django
framework. You can also switch to a specific Django release at any time."

what level of Django you are running is apparently somehow configurable by
you.  The error you are getting indicates you are running a level that is
from before newforms-admin was merged to trunk, so probably a 0.96 level.
If you want to use 1.0 level constructs like admin.autodiscover(), you'll
need to switch to a 1.0 level in your setup.  How to do that, exactly,
requires more knowledge of MediaTemple grid containers than I have.

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: MySQLdb + AMD64

2008-09-23 Thread Alex

Try using Linux then.  I just created an Ubuntu dev platform for
Django on my AMD64 and everything worked very easily.  You can even
install Ubuntu from windows using Wubi -- practically a one-click
install.  Python, MySQL, and all the libs are all ready to go for
AMD64, you just install using the package manager that comes with
Ubuntu.  Not sure what you use for an editor but most are available
for Linux also.

I found that MySQL for Windows was very tough to get working under
Vista.

Plus, if you are going to go live then chances are your hoster will be
using unix-like software over Windows.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Fwd: GeoDjango, installation error

2008-09-23 Thread Владимир Сидоренко
ok, if ound it

class District(models.Model):
point = gis_models.PointField()
objects = gis_models.GeoManager()


-- Forwarded message --
From: Владимир Сидоренко <[EMAIL PROTECTED]>
Date: 2008/9/23
Subject: GeoDjango, installation error
To: django-users@googlegroups.com


hi

i have a model:

from django.contrib.gis.db import models as gis_models
class District(models.Model):
point = gis_models.PointField()

and then:

> d = District()
> d.point = "POINT(1 2)"
> d.save()
> d2 = District.objects.get(pk=1)
> d2.point
...
: String or unicode input unrecognized as WKT
EWKT, and HEXEWKB.

what's wrong?

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: Error in : Porting your apps from Django 0.96 to 1.0

2008-09-23 Thread Karen Tracey
On Tue, Sep 23, 2008 at 3:55 AM, laspal <[EMAIL PROTECTED]> wrote:

>
> Hi,
> I am trying to port my apps from django 0.96 to 1.0.
> I have made all the changes required for it but when I run
>
> /usr/bin/python manage.py runserver
> I am getting error :
>
> Error: Can't find the file 'settings.py' in the directory containing
> 'manage.py'. It appears you've customized things.
> You'll have to run django-admin.py, passing it your settings module.
> (If the file settings.py does indeed exist, it's causing an
> ImportError somehow.)
>
> How can I fix it? changes I made is in model.py, url.py, form.py,
> views.py
> Do I have to run syncdb again??
>
>
No, there's no need to run syncdb to migrate from .96 to 1.0.  The error
message is detailing exactly what manage.py is having trouble with.
manage.py is a simple script that assumes there's a settings.py file in the
same directory as it.  If there is not, you get this message, because it
can't load any settings.  Are you saying you do have a settings.py file in
the same directory as manage.py?

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: Pre-empting Fixture execution in Django with nosetests.

2008-09-23 Thread Russell Keith-Magee

On Tue, Sep 23, 2008 at 4:07 PM, proteus guy <[EMAIL PROTECTED]> wrote:
> Here's a fun one for you testing gurus! I have a Django app that uses an
> irc server to communicate events to a system. My models utilize the django
> model save signal to post an irc message when something is updated. For unit
> testing I've been able to monkey-patch the IRC connection object no problem
> and everything's dandy. However, most of the tests require fixture objects
> so a certain state is established prior to each test. Since fixtures get
> loaded prior to my unit test code getting loaded the monkey-patching hasn't
> occurred yet and the save signal for the fixture model objects is causing
> the system to attempt to talk to a real irc server. According to the Django
> documentation I can use settings.TEST_RUNNER to get control of the
> fixture/test discovery/execution but this only works for manage.py and is
> ignored by nosetests (and its Django plugin).
>
> Appreciate any ideas...

The solution here is easy - write your own custom test runner. The
default Django test runner monkeypatches the mail sending libraries
and the template generation. You need to monkeypatch one of your
internal capabilites, so you will need to write a custom test runner
that does so. I haven't looked at the nosetests test runner, but I'd
be surprised if it can't be substantially reused (or at the very
least, copied) for your own custom test runner.

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



Re: View error in tutorial 3 (URLCONF)

2008-09-23 Thread Caisys

Thanks a lot !!

On Sep 22, 6:19 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 22, 2008 at 11:52 AM, Caisys <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> > I am following the tutorials on django website. My problem is that
> > when i create url conf for views that do not exist, the admin site
> > ceases to work.
> > Mysite\urls.py includes:
> > (r'^admin/(.*)', admin.site.root),
> > (r'^polls/', include('mysite.polls.urls')),
> > Mysite\Polls\urls.py includes:
> > urlpatterns = patterns('mysite.polls.views',
> >    (r'^$', 'index'),
> >    (r'^(?P\d+)/$', 'detail'),
> >    (r'^(?P\d+)/results/$', 'results'),
> >    (r'^(?P\d+)/vote/$', 'vote'),
>
> > )
>
> > The thing is results & votes views do not exist yet, so I can
> > understand if they generate an error, but why does a reequest to http:\
> > \127.0.0.1:8000\admin generate an error :  'module' object has no
> > attribute 'vote'
> > ???
> > Thanks
>
> Admin uses reverse url lookups to generate links on the admin pages.
> Reverse lookups require that all your urlpatters be valid, since it scans
> through them all.  Therefore it's best not to include not-yet-implemented
> stuff in your urlpatters, just comment them out until you really do
> implement the functions.
>
> 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
-~--~~~~--~~--~--~---



Access help_text in template (for a custom form field)

2008-09-23 Thread Berco Beute

I have one custom field in my form and I can't get the help_text in a
template. In the admin the help_text shows up fine so I assume it has
something todo with my custom field:

###template
{{ form.guests.help_text }} #where 'guests' is a
CommaSeparatedEmailField as specified below


###custom formField###
class CommaSeparatedEmailField(forms.Field):
'''A form field for multiple, comma-separated email adresses'''
widget = forms.Textarea(attrs={'rows':
2,'cols':settings.TEXTAREA_COLS})

def __init__(self, *args, **kwargs):
super(CommaSeparatedEmailField, self).__init__(*args,
**kwargs)

def clean(self, value):
'''
Checks whether all email adresses are valid and returns the
original string with abundant whitespaces removed
'''
if not value:
#this field may be blank
return ''
#remove leading/trailing whitespaces and empty emails
emails = [email.strip() for email in value.split(',') if
email.strip()]
if len(emails) > settings.EMAIL_MAX_NR_RECIPIENTS:
raise forms.ValidationError('Too many e-mail addresses
(%s), maximum number is %s' %
(len(emails),
settings.EMAIL_MAX_NR_RECIPIENTS))
for email in emails:
if not self.isValidEmail(email):
raise forms.ValidationError('%s is not a valid e-mail
address.' % email)
return ','.join(emails)

def isValidEmail(self, email):
if len(email) > 7:
import re
if re.match("[EMAIL PROTECTED]
{2,6}$", email) != None:
return True
return False
##


thanks,
2B
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: OS path in python

2008-09-23 Thread Bobby Roberts

I wasn't aware of that group.  Thanks for posting the info.

On Sep 23, 5:08 am, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> On 23 sep, 02:01, Bobby Roberts <[EMAIL PROTECTED]> wrote:
>
> > On Sep 22, 6:11 pm, Erik Allik <[EMAIL PROTECTED]> wrote:
>
> > > Shouldn't that be os.path.abspath(os.path.dirname(__file__)) instead
> > > just in case the .py file is executed with a relative path?
>
> > > And Bobby, I would instead use the Sites framework to compute the URL
> > > of the site, not rely on a local folder name.
>
> > Hi all -
>
> > let me clarify things.  this is a straight python platform at the
> > moment.
>
> Err... Then why are you asking on the Django's newsgroup ???
> comp.lang.py is the place for general Python questions, you know ?
>
> (snip OT question)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Auto Discover on MediaTemple

2008-09-23 Thread mccomas . chris

Using the gs and Django container on MediaTemple, got my project
installed, it works when I don't have the admin info in the URLS.py,
when I add all of the info in the URLS.py and go to the site I get
this error:

AttributeError at /
'module' object has no attribute 'autodiscover'

Here's my URLS

http://dpaste.com/79956/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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, installation error

2008-09-23 Thread Владимир Сидоренко
hi

i have a model:

from django.contrib.gis.db import models as gis_models
class District(models.Model):
point = gis_models.PointField()

and then:

> d = District()
> d.point = "POINT(1 2)"
> d.save()
> d2 = District.objects.get(pk=1)
> d2.point
...
: String or unicode input unrecognized as WKT
EWKT, and HEXEWKB.

what's wrong?

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



limit the foreign key select in admin

2008-09-23 Thread Ottavio Campana

Hi, I just started studying django and I'm having a problem with its
admin interface. In my model I have two classes, let's say

class ClassA (models.Model):
user = models.ForeignKey(User, help_text=_('ClassA owner'))
...

class ClassB (models.Model):
classa = models.ForeignKey(ClassA)


Now I'm trying to give the possibility of editing to each user his
instances of ClassB, even though only the superuser will create ClassA
objects. To achieve this, I had to overwrite queryset in the
modelAdmin of ClassB and it works.

The problem that now I'm having is that if a user modifies a ClassB
object he will see in the admin a select for all possible ClassA
objects, not only those owned by him. I tried to overwrite queryset in
the modelAdmin of ClassA, but is doesn't work.

I think that the admin is calling another function, and I'm not able
to understand which one it is.

Do you have a hint?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: name '_' is not defined

2008-09-23 Thread Daniel Hepper

from django.utils.translation import ugettext_lazy as _

HTH,
Daniel

Am Dienstag, den 23.09.2008, 04:12 -0700 schrieb laspal:
> Hi,
> I am using 1.0 version ran into problem.
> 
> My model :
> from django.db import models
> 
> from django.contrib.auth.models import User
> 
> 
> 
> IPSecurity = True
> 
> 
> 
> class IPAccess(models.Model):
> 
> ip = models.IPAddressField(_('ip'), unique=True, db_index=True)
> 
> location = models.CharField(max_length = 100)
> 
> 
> 
> def __unicode__(self):
> 
> return self.ip
> 
> 
> 
> class Meta:
> 
> verbose_name = _('IP Access')
> 
> verbose_name_plural = _('IP Accesses')
> 
> 
> 
> #class Admin:
> 
> #list_display = ('ip', 'user')
> 
> 
> 
> admin.site.register(IPAccess)
> 
> 
> 
> class AuthorisedUser(models.Model):
> 
> user = models.ForeignKey(User, verbose_name=_('Authorised User.
> Access from anywhere'))
> 
> Getting error: name '_' is not defined.
> Can someone help me out.
> 
> 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
-~--~~~~--~~--~--~---



name '_' is not defined

2008-09-23 Thread laspal

Hi,
I am using 1.0 version ran into problem.

My model :
from django.db import models

from django.contrib.auth.models import User



IPSecurity = True



class IPAccess(models.Model):

ip = models.IPAddressField(_('ip'), unique=True, db_index=True)

location = models.CharField(max_length = 100)



def __unicode__(self):

return self.ip



class Meta:

verbose_name = _('IP Access')

verbose_name_plural = _('IP Accesses')



#class Admin:

#list_display = ('ip', 'user')



admin.site.register(IPAccess)



class AuthorisedUser(models.Model):

user = models.ForeignKey(User, verbose_name=_('Authorised User.
Access from anywhere'))

Getting error: name '_' is not defined.
Can someone help me out.

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: foreign key exception where objects manager is customized

2008-09-23 Thread Gio

I had a similar issue, solved with a trick.
Try to explicit a save() method for your SuperDelegate this way:

def save(self, *args, **kwargs):
super(SuperDelegate, self).save(*args, **kwargs)

Giovanni

On 6 Set, 12:09, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> A foreignkey in a model with a customised objects manager is causing
> an exception when that parent model is saved.
>
> Model 'SuperDelegate' has a boolean field 'is_active'. 'Delegate'
> model has a ForeignKey to SuperDelegate. I only want to ever show
> active SuperDelegates so the objects manager has the default query
> is_active=True.  Saving a SuperDelegate.is_active = False is fine. But
> trying to save is.active = True (having been false) throws the
> following exception:
>
> >>> sd = SuperDelegate.all.all()[0]    # a manager to pull out 
> >>> is_active=False instances
> >>> sd.is_active
> False
> >>> sd.is_active = True
> >>> sd.save()
>
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
> lib/python2.4/site-packages/django/db/models/base.py", line 307, in
> save
>     self.save_base(force_insert=force_insert,
> force_update=force_update)
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
> lib/python2.4/site-packages/django/db/models/base.py", line 379, in
> save_base
>     result = manager._insert(values, return_id=update_pk)
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
> lib/python2.4/site-packages/django/db/models/manager.py", line 138, in
> _insert
>     return insert_query(self.model, values, **kwargs)
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
> lib/python2.4/site-packages/django/db/models/query.py", line 888, in
> insert_query
>     return query.execute_sql(return_id)
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
> lib/python2.4/site-packages/django/db/models/sql/subqueries.py", line
> 308, in execute_sql
>     cursor = super(InsertQuery, self).execute_sql(None)
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
> lib/python2.4/site-packages/django/db/models/sql/query.py", line 1700,
> in execute_sql
>     cursor.execute(sql, params)
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/
> lib/python2.4/site-packages/django/db/backends/util.py", line 19, in
> execute
>     return self.cursor.execute(sql, params)
> IntegrityError: duplicate key value violates unique constraint
> "delegate_superdelegate_pkey"
>
> Removing the default is_active=True objects manager removes this
> problem, so it's fine i can use a different manager for each
> SuperDelegate listing. But what's going on here? (postgresql 8.3/
> Django 1.0)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to simulate recursive inlines in admin?

2008-09-23 Thread Itai Tavor

On Sep 23, 7:05 am, "Petar Marić" <[EMAIL PROTECTED]> wrote:
> Hi everybody,
>
> I'm creating a Django based web application for my Master thesis and I've got
> a hard problem. This is my model (greatly simplified):
>
> class Questionnaire(models.Model):
> title = models.CharField()
> description = models.TextField()
> created_by = models.ForeignKey(User, editable=False)
>
> class Question(models.Model):
> title = models.CharField()
> questionnaire = models.ForeignKey(Questionnaire)
> position = PositionField(unique_for_field='questionnaire')
>
> class Answer(models.Model):
> title = models.CharField()
> question = models.ForeignKey(Question)
> position = PositionField(unique_for_field='question')
>
> I'm using theadminapp for creating Questionnaires and I'd like to let users
> edit questions and answers in the same form. AFAIKrecursiveinlinesaren't
> supported in Django (a hard problem by itself) so the only other way I could
> think of is to inject a TextArea form field inside of the QuestionInline and
> then do the processing of it manually. Answers would then be separated by
> newlines and the positions would be determined by the order of lines in the
> TextArea.
>
> The problem is I don't know how to inject the TextArea in the inline. I tried
> many things from simple to complex - and the otherwise excellent documentation
> doesn't give much help.

Hi Petar,

Like, wow, talk about crazy timing.

I'm working on an exam generation app which, being young and naive,
thinks it can grow up to cover everything from basic quizzes to
questionnaires, surveys and graded tests. It's still about a week or
two from a preview release (and much more than that from being really
ready) but since I think it's very relevant to your question, I guess
I'll have to break security. Oh well, the best laid plans of mice et
cetera.

The part you'd probably be interested in uses a custom ModelAdmin
which displays a sortable list of questions and sub-modules in a test,
with an "edit" link for each item, and an "add question" popup menu
for the test and for each sub-module. Creating and editing questions
and modules is done via this custom admin - there are no Question or
Module links in the admin app list - and users never see a "test"
field in the question forms. I actually spent some time working on a
nested-inline form for this, but realized rather quickly that it
wasn't just really hard to write (and even harder to maintain) but
will result in a complicated and unfriendly UI.

I don't know if you might be more interested in the full app or just
the admin code, so let me know if you'd like to see any of it. And,
like I said above, code at Google and a demo site are probably a
couple of weeks away.

Itai


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: locale aware number formats

2008-09-23 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-09-23, o godz. 12:21, przez pihentagy:

> How can I print a number using the locale's thousand separator and
> decimal?
>
> Basically I hoped ther is a template filter, but floatformat doesn't
> have thousand separator, and seems to use decimal point always.


Take a look at Babel package and Django helpers - http://babel.edgewall.org/

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R&D, Redefine
[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
-~--~~~~--~~--~--~---



locale aware number formats

2008-09-23 Thread pihentagy

Hi all!

How can I print a number using the locale's thousand separator and
decimal?

Basically I hoped ther is a template filter, but floatformat doesn't
have thousand separator, and seems to use decimal point always.

thanks
Gergo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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   >