Re: Help with custom validator - please, please, please

2008-05-15 Thread Brandon Taylor

Finally - someone pointing me to more than just the documentation.
Thank you!

I'll give that a shot and see where it takes me - along with
memorizing the documentation. I really appreciate you taking the time
to respond to my question. Django is just awesome. I fell in love with
Rails having done .NET and classic ASP for many years, but I think
Django is even better than Rails. I haven't written Python in a
lng time, which is why I'm struggling a bit.

Again, my thanks!
Brandon

On May 15, 5:00 pm, Brian Rosner <[EMAIL PROTECTED]> wrote:
> > I would highly recommend you read the newforms documentation [1] if you 
> > have never used newforms before.
>
> Opps, forgot the linkhttp://www.djangoproject.com/documentation/newforms/
> and while I am here check 
> outhttp://www.djangoproject.com/documentation/modelforms/
> too.
>
> >  def clean_name(self):
> >      value = self.cleaned_data["name"]
> >      if name == "Brian":
> >          raise forms.ValidationError, u"You are not allowed to be named 
> > Brian."
> >      return value
>
> Oh, and if name == "Brian" should clearly be if value == "Brian"
>
> Brian Rosnerhttp://oebfare.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: Getting error after installing on webfaction? - need help

2008-05-15 Thread Bernd

did you installl the latest release or the latest trunk on webfaction?
which version do you use locally?
I think you are working with different versions of django

 Bernd

On Thu, 2008-05-15 at 15:47 -0700, ydjango wrote:
> I installed my app to webfaction
> I am getting this error on many of my pages, these pages are data
> entry pages with dropdowns with ModelChoiceFields.
> 
> Any clue how can I find what is causing this error.
> 
> I added data to all the tables which are linked to ModelChoiceFields.
> 
> My database in settings.py point to localhost. and DB is on MYSQL -
> same server as my app on webfaction.
> 
> Ashish
> 
> 
> IndexError at /case/viewall/
> list index out of range
> 
> Request Method:   GET
> Request URL:  http://www.woodranchit.com/case/viewall/
> Exception Type:   IndexError
> Exception Value:  list index out of range
> Exception Location:   /home/pmc/webapps/django/lib/django/db/models/
> query.py in __getitem__, line 129
> Python Executable:/usr/local/bin/python
> Python Version:   2.5.1
> Python Path:  ['/home/pmc/webapps/django', '/home/pmc/webapps/django/
> lib', '/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-
> linux-i686.egg', '/usr/local/lib/python2.5/site-packages/
> setuptools-0.6c8-py2.5.egg', '/home/pmc/webapps/django/lib', '/', '/
> usr/local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/
> lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', '/usr/
> local/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-
> packages', '/usr/local/lib/python2.5/site-packages/PIL']
> Server time:  Thu, 15 May 2008 17:30:50 -0500
> Traceback Switch to copy-and-paste view
> 
> /home/pmc/webapps/django/lib/django/core/handlers/base.py in
> get_response
> response = callback(request, *callback_args,
> **callback_kwargs) ...
> ▶ Local vars
> /home/pmc/webapps/django/lib/django/db/models/query.py in __getitem__
> return list(qs)[0] ...
> ▼ Local vars
> Variable  Value
> k
> 0
> qs
> []
> self
> []
> 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: loaddata .. columns app_label, model are not unique

2008-05-15 Thread Carl Karsten

Russell Keith-Magee wrote:
> On Fri, May 16, 2008 at 8:13 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>> Russell Keith-Magee wrote:
> 
 2. should I leave in --debug?  I really meant it for debugging, but I can 
 see it
 being handy to debug the "list of items" and such.
>>> No. That's what the verbosity option is for.
>> what verbosity option?
>>
>> ./manage.py: error: no such option: --verbosity
>> ./manage.py: error: no such option: --verbose
>>
>> Given that dumpdata dumps to stdout, any extra chars would 'corrupt' the 
>> dump,
>> and the human readable 'status' chars would get lost in the dump.  So I am 
>> not
>> sure --verbose would be good here, given that --verbose generally runs the 
>> app.
>>
>> How about --dry-run?
> 
> How about verbosity?
> 
> Consistency is an important feature. The fact that verbosity isn't
> currently available as an option to the dumpdata command doesn't
> change the fact that it is available in many other locations as the
> command to alter the amount of debug output. Inventing new option
> names for the same feature just confuses the issue.
> 
> As for corrupting the output - we can work around this by ensuring
> that the default verbosity (usually 1, but there might be an argument
> for the default to be 0 for dumpdata) can be used as-is.

I can see the consistency point.   I'll send the output to sdterr.  speaking of
consistency, any reason not to give all the make_option()'s single letter 
options?  (like make_option('-v', '--verbosity')

How does this look?

Index: dumpdata.py
===
--- dumpdata.py (revision 7534)
+++ dumpdata.py (working copy)
@@ -2,13 +2,19 @@
  from django.core import serializers

  from optparse import make_option
+from sys import stderr

  class Command(BaseCommand):
  option_list = BaseCommand.option_list + (
-make_option('--format', default='json', dest='format',
+make_option('--format', dest='format', default='json',
  help='Specifies the output serialization format for fixtures.'),
-make_option('--indent', default=None, dest='indent', type='int',
+make_option('--indent', dest='indent', type='int', default=None,
  help='Specifies the indent level to use when pretty-printing 
output'),
+make_option('-e', '--exclude', dest='exclude',action='append', 
default=None,
+help='App to exclude (use multiple --exclude to exclude multiple 
apps).'),
+make_option('-v', '--verbosity', action='store', dest='verbosity', 
default='0',
+type='choice', choices=['0', '1', '2'],
+help='Verbosity level; 0=minimal output, 1=normal output, 2=all 
output'),
  )
  help = 'Output the contents of the database as a fixture of the given 
format.'
  args = '[appname ...]'
@@ -16,15 +22,34 @@
  def handle(self, *app_labels, **options):
  from django.db.models import get_app, get_apps, get_models

-format = options.get('format', 'json')
-indent = options.get('indent', None)
-show_traceback = options.get('traceback', False)
+format = options.get('format')
+indent = options.get('indent')
+exclude = options.get('exclude')
+verbosity = int(options.get('verbosity'))
+show_traceback = options.get('traceback')

+if verbosity >= 2:
+print >>stderr, \
+"format %s\nindent %s\nexclude %s\nshow_traceback %s\n" % \
+(format, indent, exclude, show_traceback)
+print >>stderr, "apps %s" % (app_labels)
+
  if len(app_labels) == 0:
  app_list = get_apps()
  else:
  app_list = [get_app(app_label) for app_label in app_labels]

+if exclude:
+excl_apps = [get_app(app_label) for app_label in exclude]
+for excl_app in excl_apps:
+app_list.remove(excl_app)
+if verbosity >= 2:
+print >>stderr, "excluded: %s" % excl_app.__name__
+
+if verbosity >= 2:
+for app in app_list:
+print >>stderr, "included: %s" % app.__name__
+
  # Check that the serialization format exists; this is a shortcut to
  # avoid collating all the objects and _then_ failing.
  if format not in serializers.get_public_serializer_formats():
@@ -37,7 +62,11 @@

  objects = []
  for app in app_list:
+if verbosity >= 1:
+print >>stderr, "dumping %s" % (app.__name__)
  for model in get_models(app):
+if verbosity >= 1:
+print >>stderr, "dumping %s,%s" % (app.__name__, model)
  objects.extend(model._default_manager.all())
  try:
  return serializers.serialize(format, objects, indent=indent)


Carl K



--~--~-~--~~~---~--~~
You received this message because you are 

Re: Python 3000 support, any plans?

2008-05-15 Thread Graham Dumpleton


> * The bigger problem you will encounter isn't Django - it's the chain
> of support libraries. At the very least, you will need Python3000
> versions of mod_python and a database backend. To the best of my
> knowledge, these tools aren't available in Python3000 versions - until
> they are, there isn't much point having a Python3000 version of
> Django.

As was already pointed out in that discussion, mod_wsgi in subversion
trunk already supports Python 3.0. Thus there already is a Python 3.0
capable solution for Apache hosting.

Personally I can't see mod_python getting ported to Python 3.0 as the
effort would just be too much and anything using the mod_python
specific APIs directly, rather than through a constrained interface
such as WSGI, would also require a lot of rework because it is such a
broad API.

In other words, although Django may use only a subset of mod_python
API, the work in porting all the parts of mod_python it doesn't use
and the impact those changes will have on mod_python specific
frameworks, would most likely deter anyone doing it. Add on top of
this the large list of outstanding issues and problems with
mod_python, which really would want to be addressed at the same time,
and you would have quite a big project that isn't going to get done
very quickly, if at all.

The Django folks would be better off focusing on making Django a well
behaved WSGI citizen, moving away from use of global settings and
instead use a model which would allow multiple Django instances to
operate within the same process, based on per request WSGI
configuration parameters, and thus cut down on memory usage through
sharing of common code modules. They should also address problems with
WSGI SCRIPT_NAME configuration being ignored and look any
multithreading issues to give more certainty that Django will work on
the range of WSGI hosting solutions available.

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 3000 support, any plans?

2008-05-15 Thread Jeff Anderson

mardenet wrote:

I have looked on the web and I couldn't find any release date for v.
1.0. But I saw they postponed many times before deleting any date from
their FAQ.
But I believe u, I'll wait for 1.0 (not for Python 3000) and then I'll
start, I have enough to do in the mean time :).
  
The development version of django is quite stable, and is much closer to 
1.0 than 0.96 is.


You could easily start now with the development version, and learn 
enough to get a good feel for django. You won't have to unlearn all that 
much to make the transition to 1.0. There will be backwards-incompatible 
changes, but they are rigorously documented.


If you have enough to do in the mean time, it wouldn't hurt to at least 
go through the django tutorial. [0] It shows how to do most of the 
basics-- and is rather fun to do the first time you go through it. :)


Have fun!


Jeff Anderson

[0] http://www.djangoproject.com/documentation/tutorial01/



signature.asc
Description: OpenPGP digital signature


Re: loaddata .. columns app_label, model are not unique

2008-05-15 Thread Russell Keith-Magee
On Fri, May 16, 2008 at 8:13 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>
> Russell Keith-Magee wrote:

>>> 2. should I leave in --debug?  I really meant it for debugging, but I can 
>>> see it
>>> being handy to debug the "list of items" and such.
>>
>> No. That's what the verbosity option is for.
>
> what verbosity option?
>
> ./manage.py: error: no such option: --verbosity
> ./manage.py: error: no such option: --verbose
>
> Given that dumpdata dumps to stdout, any extra chars would 'corrupt' the dump,
> and the human readable 'status' chars would get lost in the dump.  So I am not
> sure --verbose would be good here, given that --verbose generally runs the 
> app.
>
> How about --dry-run?

How about verbosity?

Consistency is an important feature. The fact that verbosity isn't
currently available as an option to the dumpdata command doesn't
change the fact that it is available in many other locations as the
command to alter the amount of debug output. Inventing new option
names for the same feature just confuses the issue.

As for corrupting the output - we can work around this by ensuring
that the default verbosity (usually 1, but there might be an argument
for the default to be 0 for dumpdata) can be used as-is.

>>> Why does the current code has 'json' listed in 2 places:
>>> make_option('--format', default='json'
>>> options.get('format', 'json')
>>
>> I can't think of an obvious reason off the top of my head. It's
>> possible that this is a hangover of some old code from the
>> pre-management refactor days, or an artefact of that refactor.
>
> I'll clean it up.  Should the clean up be a separate patch?

It's a minor code cleanup in the options, an area that this patch will
touch anyway. Just leave it in this patch.

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: loaddata .. columns app_label, model are not unique

2008-05-15 Thread Carl Karsten

Russell Keith-Magee wrote:
> On Fri, May 16, 2008 at 3:47 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>> Russell Keith-Magee wrote:
>>> On Wed, May 14, 2008 at 1:20 PM, Carl Karsten <[EMAIL PROTECTED]> wrote:
 Russell Keith-Magee wrote:
> On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
 What are the chances of getting a dumpdata hack to exclude certain apps?

 I know it isn't too hard to figure out what apps I want to backup, but it 
 sounds
 like the 'exclude' feature might be useful even once this issue is 
 resolved.
>>> It's a reasonable idea - one well worth suggesting as a feature
>>> enhancement (I have a nagging feeling that there is something in there
>>> already, but I could be getting confused).
>>>
>>> What are the chances such a fix will automagically materialize out of
>>> the ether? Not high. What are the chances that a patch implementing
>>> this feature would be added to trunk? Fairly good, conditional on the
>>> quality of the patch.
>> I am not submitting here, I just want to discuss it first.
>>
>> 1. what do you think of this syntax I invented:
>>  --option "list of items"
>>
>> I don't like it, but not sure how else to do it.
> 
> I prefer the syntax from your other post.
> 
>> 2. should I leave in --debug?  I really meant it for debugging, but I can 
>> see it
>> being handy to debug the "list of items" and such.
> 
> No. That's what the verbosity option is for.

what verbosity option?

./manage.py: error: no such option: --verbosity
./manage.py: error: no such option: --verbose

Given that dumpdata dumps to stdout, any extra chars would 'corrupt' the dump, 
and the human readable 'status' chars would get lost in the dump.  So I am not 
sure --verbose would be good here, given that --verbose generally runs the app.

How about --dry-run?

>> Why does the current code has 'json' listed in 2 places:
>> make_option('--format', default='json'
>> options.get('format', 'json')
> 
> I can't think of an obvious reason off the top of my head. It's
> possible that this is a hangover of some old code from the
> pre-management refactor days, or an artefact of that refactor.

I'll clean it up.  Should the clean up be a separate patch?

Carl K

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: loaddata .. columns app_label, model are not unique

2008-05-15 Thread Carl Karsten

Just saving someone the trouble of telling me to spell multiple correctly.

> make_option('-e', '--exclude', dest='exclude', action='append',
>   help='App to exclude (use mutiple --exclude to exclude mutiple apps).'),

  help='App to exclude (use multiple --exclude to exclude multiple apps).'),

Carl K

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: loaddata .. columns app_label, model are not unique

2008-05-15 Thread Russell Keith-Magee
On Fri, May 16, 2008 at 3:47 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>
> Russell Keith-Magee wrote:
>> On Wed, May 14, 2008 at 1:20 PM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>>> Russell Keith-Magee wrote:
 On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>>> What are the chances of getting a dumpdata hack to exclude certain apps?
>>>
>>> I know it isn't too hard to figure out what apps I want to backup, but it 
>>> sounds
>>> like the 'exclude' feature might be useful even once this issue is resolved.
>>
>> It's a reasonable idea - one well worth suggesting as a feature
>> enhancement (I have a nagging feeling that there is something in there
>> already, but I could be getting confused).
>>
>> What are the chances such a fix will automagically materialize out of
>> the ether? Not high. What are the chances that a patch implementing
>> this feature would be added to trunk? Fairly good, conditional on the
>> quality of the patch.
>
> I am not submitting here, I just want to discuss it first.
>
> 1. what do you think of this syntax I invented:
>  --option "list of items"
>
> I don't like it, but not sure how else to do it.

I prefer the syntax from your other post.

> 2. should I leave in --debug?  I really meant it for debugging, but I can see 
> it
> being handy to debug the "list of items" and such.

No. That's what the verbosity option is for.

> Why does the current code has 'json' listed in 2 places:
> make_option('--format', default='json'
> options.get('format', 'json')

I can't think of an obvious reason off the top of my head. It's
possible that this is a hangover of some old code from the
pre-management refactor days, or an artefact of that refactor.

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: loaddata .. columns app_label, model are not unique

2008-05-15 Thread Russell Keith-Magee

On Fri, May 16, 2008 at 5:58 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>
> Carl Karsten wrote:
>> Russell Keith-Magee wrote:
>>> On Wed, May 14, 2008 at 1:20 PM, Carl Karsten <[EMAIL PROTECTED]> wrote:
 Russell Keith-Magee wrote:
> On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
 What are the chances of getting a dumpdata hack to exclude certain apps?

 I know it isn't too hard to figure out what apps I want to backup, but it 
 sounds
 like the 'exclude' feature might be useful even once this issue is 
 resolved.
>>> It's a reasonable idea - one well worth suggesting as a feature
>>> enhancement (I have a nagging feeling that there is something in there
>>> already, but I could be getting confused).
>>>
>>> What are the chances such a fix will automagically materialize out of
>>> the ether? Not high. What are the chances that a patch implementing
>>> this feature would be added to trunk? Fairly good, conditional on the
>>> quality of the patch.
>>
>> I am not submitting here, I just want to discuss it first.
>
> I think I like this better:
>
> make_option('-e', '--exclude', dest='exclude', action='append',
>  help='App to exclude (use mutiple --exclude to exclude mutiple apps).'),
>
> ./manage.py dumpdata -e core -e countries -e sessions -e sites

I prefer this syntax too.

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: Python 3000 support, any plans?

2008-05-15 Thread Russell Keith-Magee

On Thu, May 15, 2008 at 10:57 PM, mardenet <[EMAIL PROTECTED]> wrote:
>
> Hello,
> I am new to Python and Django, I am a ASP.NET C# programmer actually
> tired of following Microsoft's unnatural and crazy page model that
> tries to hide the page from you as much as possible.. seriously how
> did they came up with that?!
>
> I am very interested in Python and Django for a future project but  I
> am noticing this is a period of big changes in this community. Python
> 3000 and Django 1.0 will really be a major change.
> I am not afraid of using Alpha versions, and I want to use latest
> technologies and my mind rejects any forced changes in the code due to
> new releases. If I do something I don't want to touch it again.
> So I want to start straight with Python 3000.
>
> Would this be compatible with Djanga? If not when do you expect it to
> be compatible?
> I prefer waiting than recoding, so I wanted an idea on timelines...
> any thoughts?

This came up a little while ago (around the time of PyCon 2008), so if
you search the archives, you can find a lot more discussion on the
topic.

However, the short version:

* There are currently no formal plans to support Python 3000. Efforts
are currently focussed on Django 1.0.

* There isn't a huge need to be on the cutting edge here - we still
maintain Python 2.3 support because it is used by a few deployment
environments that are in common usage. It will be some time before
Python3000 is in common usage everywhere.

* Exploratory work has been done on porting Django to Python 3000 -
initial reports are that there isn't a huge amount of work to be done
on our code base.

* The bigger problem you will encounter isn't Django - it's the chain
of support libraries. At the very least, you will need Python3000
versions of mod_python and a database backend. To the best of my
knowledge, these tools aren't available in Python3000 versions - until
they are, there isn't much point having a Python3000 version of
Django.

* If you follow the official Python guidelines for handling the
2->3000 transition, you shouldn't need to do much recoding of your own
code.

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



Secure file access with contrib.auth

2008-05-15 Thread Julien

Hi,

I'm building a website where users can create projects and upload
files for their projects. I already have a system in place so that
only members of a project can access the project related pages. Now,
I'd like it to be more secure by only giving access to the files of a
project to its members.

It appears to me that simply serving the files with Apache is not
enough. Does Django provide a way to achieve that? Does it mean I'll
have to serve the files with 'static.serve' with a layer of
authorization checking?

What do you think is the best approach?

Thank you very much,

Julien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Code works with Django's server, but not with Apache+mod_python?

2008-05-15 Thread Graham Dumpleton

On May 16, 5:56 am, mw <[EMAIL PROTECTED]> wrote:
> Yeah I'm still at a loss on this bug.
>
> I ran the code provided in the thread.
> Django's
> django
> /Library/Python/2.5/site-packages/django/__init__.pyc
> pil
> /Library/Python/2.5/site-packages/PIL/__init__.pyc
>
> And then Apache's is
> django
> /Library/Python/2.5/site-packages/django/__init__.pyc
> pil
> /Library/Python/2.5/site-packages/PIL/__init__.pyc
>
> As far as I can tell there is no difference!  Apache still seems to be
> rejecting the image as an invalid image while the Django test server
> doesn't.  What could the problem possibly be between the two
> servers?  :-(

Sounds like you are having 32/64 bit issues. You need to take extra
steps to ensure on MacOSX Leopard that Python modules are compiled
with 64 bit support as well as 32 bit support. For further information
see:

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

This is from mod_wsgi documentation but has same issues as mod_python.

Read section 'Missing Code For Architecture'. Mentions PIL as an
example.

Graham

> On May 6, 12:38 pm, mw <[EMAIL PROTECTED]> wrote:
>
> > Ahh, after running the code with both the django server and apache and
> > mod_python there are different paths listed.
>
> > I shall investigate on my own and come back if I need more help!
>
> > Thank you both very much!
> > mw
>
> > On May 5, 7:13 pm, "Chatchai Neanudorn" <[EMAIL PROTECTED]> wrote:
>
> > > When I installed my web at webfaction I did this to see which module 
> > > python
> > > use,
>
> > > at settings.py
>
> > > import os
> > > import django, PIL
> > > logfile = open('path.log', 'w')
>
> > > django_path = django.__file__
> > > pil_path = PIL.__file__
>
> > > logfile.write('django - %\n pil - %s\n' % (django_path, pil_path))
>
> > > logfile.close()
>
> > > ...
>
> > > With this code, you can see which module you are using.
>
> > > I can successfully install my web with this trip.
>
> > > Regards
>
> > > 2008/5/5 TP <[EMAIL PROTECTED]>:
>
> > > > Could you have different PYTHONPATH settings for mod_python vs command
> > > > line where you're running the admin server? Different versions of PIL
> > > > or something between those two versions? libjpeg and friends installed
> > > > in non-standard locations where they're found by the command line
> > > > python but not the python being loaded by mod_python?
>
> > > > On May 2, 5:02 pm, mw <[EMAIL PROTECTED]> wrote:
> > > > > Hello,
>
> > > > > I've emailed the mailing list in the past because of problems with PIL
> > > > > and and image field upload in the admin interface.  The problem, just
> > > > > got weirder.
>
> > > > > I noticed that images were never validating as actual images and were
> > > > > constantly being rejected.  Out of a hunch, I fired up the django
> > > > > built-in server and tried the same page with the same image.  This
> > > > > time, the image validated and it was correctly uploaded.
>
> > > > > Does anyone happen to know what would then be stopping the code from
> > > > > validating the image upload when run through apache instead of the
> > > > > django development server?
>
> > > > > I'm using the SVN of django on OS X.
>
> > > > > Thanks in advance,
> > > > > mw
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: where does this caching come?

2008-05-15 Thread Graham Dumpleton



On May 16, 8:44 am, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Graham Dumpleton wrote:
> > On May 16, 12:21 am, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> >> Alex Morega wrote:
> >>> On May 15, 2008, at 02:24 , David Zhou wrote:
>  Are you restarting the server between module changes?
> >>> By default Django does no caching of responses. It's probably what  
> >>> Viktor says: the server (mod_python,mod_wsgi, whatever) won't  
> >>> automatically reload the python code if you change it. The automatic  
> >>> reload behaviour only happens with Django's built-in development server.
> >> Not strictly true.  With mod_python there's a directive to control
> >> whether apache automatically reloads python code.  You *don't* want to
> >> set this on for production code(large performance penalty).
>
> >>          PythonAutoReload On
>
> >> I'm guessingmod_wsgiand others have something similar.
>
> > That option for mod_python does absolutely nothing for Django. This is
> > because Django and your application modules for it don't fall into the
> > category of modules thats are candidates for reloading.
>
> I didn't believe it so I tested and it seems you're right.
>
> Doh!  That's what I get for misreading docs.
>
> I'm guessing that in "If set to Off, instructs mod_python not to check
> the modification date of the module file." 
> fromhttp://www.modpython.org/live/current/doc-html/dir-other-par.html
> "module file" referes to a mod_apache module you write using mod python
> and/or the PythonHandler???
>
> Thanks for setting me straight.

It doesn't help that Django documentation is a bit misleading in
saying:

  "You can also add directives such as PythonAutoReload Off for
performance."

Again, for Django it makes no difference, even to performance.

For further information read the documentation on import_module()
function, as that is what underlays the module importer used for the
Python*Handler directives.

  http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html

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: MySQL Boolean vs. PostgresQL Boolean

2008-05-15 Thread Szaijan

I see it in my views.  When I return the set and saved values for a
model, I get True or False from my app on the MacBook (Postgres) and 1
or 0 from the exact same code on my Slicehost site (MySQL.)

So, if I add something like:

m = Model.objects.get(id=id)
print m.boolean_field_name

I get True/False on my MacBook and 1/0 on my Slicehost site.  I have
also confirmed this in python manage.py shell.

>>> from visionary.harp.models import Combatant_Template
>>> ct = Combatant_Template.objects.all()
>>> ct[0]

>>> ct[0].party <--- A BooleanField
0 <-- result on Slicehost site using MySQL

>>> ct[0].party <--- A BooleanField
True <-- result on MacBook Pro using PostgreSQL

Perhaps there's a setting I need that is missing?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Printing out HTML that doesn't get converted to

2008-05-15 Thread Alex

Wow, that was incredibly simple. Thanks for the help! I have a strong
feeling I'm not going back to PHP...

--Alex

On May 15, 4:47 pm, jonknee <[EMAIL PROTECTED]> wrote:
> On May 15, 6:17 pm, Alex <[EMAIL PROTECTED]> wrote:
>
> > I'm working on my first Django project and I can't seem to get
> > information printed out as I would like it. I'm trying to print out
> > quotes to a page with the newlines turned into HTML  tags (similar
> > to PHP's nl2br function).
>
> You're looking for linebreaks, a filter in Django templates:
>
> http://www.djangoproject.com/documentation/templates/#linebreaks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Printing out HTML that doesn't get converted to

2008-05-15 Thread jonknee

On May 15, 6:17 pm, Alex <[EMAIL PROTECTED]> wrote:
> I'm working on my first Django project and I can't seem to get
> information printed out as I would like it. I'm trying to print out
> quotes to a page with the newlines turned into HTML  tags (similar
> to PHP's nl2br function).

You're looking for linebreaks, a filter in Django templates:

http://www.djangoproject.com/documentation/templates/#linebreaks

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



Getting error after installing on webfaction? - need help

2008-05-15 Thread ydjango

I installed my app to webfaction
I am getting this error on many of my pages, these pages are data
entry pages with dropdowns with ModelChoiceFields.

Any clue how can I find what is causing this error.

I added data to all the tables which are linked to ModelChoiceFields.

My database in settings.py point to localhost. and DB is on MYSQL -
same server as my app on webfaction.

Ashish


IndexError at /case/viewall/
list index out of range

Request Method: GET
Request URL:http://www.woodranchit.com/case/viewall/
Exception Type: IndexError
Exception Value:list index out of range
Exception Location: /home/pmc/webapps/django/lib/django/db/models/
query.py in __getitem__, line 129
Python Executable:  /usr/local/bin/python
Python Version: 2.5.1
Python Path:['/home/pmc/webapps/django', '/home/pmc/webapps/django/
lib', '/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-
linux-i686.egg', '/usr/local/lib/python2.5/site-packages/
setuptools-0.6c8-py2.5.egg', '/home/pmc/webapps/django/lib', '/', '/
usr/local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/
lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', '/usr/
local/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-
packages', '/usr/local/lib/python2.5/site-packages/PIL']
Server time:Thu, 15 May 2008 17:30:50 -0500
Traceback Switch to copy-and-paste view

/home/pmc/webapps/django/lib/django/core/handlers/base.py in
get_response
response = callback(request, *callback_args,
**callback_kwargs) ...
▶ Local vars
/home/pmc/webapps/django/lib/django/db/models/query.py in __getitem__
return list(qs)[0] ...
▼ Local vars
VariableValue
k
0
qs
[]
self
[]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: where does this caching come?

2008-05-15 Thread Norman Harman

Graham Dumpleton wrote:
> On May 16, 12:21 am, "Norman Harman" <[EMAIL PROTECTED]> wrote:
>> Alex Morega wrote:
>>> On May 15, 2008, at 02:24 , David Zhou wrote:
 Are you restarting the server between module changes?
>>> By default Django does no caching of responses. It's probably what  
>>> Viktor says: the server (mod_python,mod_wsgi, whatever) won't  
>>> automatically reload the python code if you change it. The automatic  
>>> reload behaviour only happens with Django's built-in development server.
>> Not strictly true.  With mod_python there's a directive to control
>> whether apache automatically reloads python code.  You *don't* want to
>> set this on for production code(large performance penalty).
>>
>>  PythonAutoReload On
>>
>> I'm guessingmod_wsgiand others have something similar.
> 
> That option for mod_python does absolutely nothing for Django. This is
> because Django and your application modules for it don't fall into the
> category of modules thats are candidates for reloading.

I didn't believe it so I tested and it seems you're right.

Doh!  That's what I get for misreading docs.

I'm guessing that in "If set to Off, instructs mod_python not to check 
the modification date of the module file." from 
http://www.modpython.org/live/current/doc-html/dir-other-par.html
"module file" referes to a mod_apache module you write using mod python 
and/or the PythonHandler???


Thanks for setting me straight.
-- 
Norman J. Harman Jr.  512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

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



Printing out HTML that doesn't get converted to

2008-05-15 Thread Alex

I'm working on my first Django project and I can't seem to get
information printed out as I would like it. I'm trying to print out
quotes to a page with the newlines turned into HTML  tags (similar
to PHP's nl2br function). So far I've been able to do this using the
__str__ function for the Quote model, but it escapes the tags into
html entities that I see the tags in my browser instead of the line
breaks. I'm using the development version of Django.

Here's what my __str__ function looks like:

return self.quote.replace('\n', '')

And I'm just printing them out with a generic view that looks like
this:

{% for quote in object_list %}
{{ quote }}
  
  {% for a in quote.authors.all %}
  {{ a }}
  {% endfor %}
  

{% endfor %}

I'd appreciate any suggestions. I'm rather new to Python, so I
appreciate all the help I can get :)

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



Re: Help with custom validator - please, please, please

2008-05-15 Thread Brian Rosner

> I would highly recommend you read the newforms documentation [1] if you have 
> never used newforms before.

Opps, forgot the link http://www.djangoproject.com/documentation/newforms/
and while I am here check out 
http://www.djangoproject.com/documentation/modelforms/
too.

>  def clean_name(self):
>  value = self.cleaned_data["name"]
>  if name == "Brian":
>  raise forms.ValidationError, u"You are not allowed to be named 
> Brian."
>  return value

Oh, and if name == "Brian" should clearly be if value == "Brian"

Brian Rosner
http://oebfare.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: loaddata .. columns app_label, model are not unique

2008-05-15 Thread Carl Karsten

Carl Karsten wrote:
> Russell Keith-Magee wrote:
>> On Wed, May 14, 2008 at 1:20 PM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>>> Russell Keith-Magee wrote:
 On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>>> What are the chances of getting a dumpdata hack to exclude certain apps?
>>>
>>> I know it isn't too hard to figure out what apps I want to backup, but it 
>>> sounds
>>> like the 'exclude' feature might be useful even once this issue is resolved.
>> It's a reasonable idea - one well worth suggesting as a feature
>> enhancement (I have a nagging feeling that there is something in there
>> already, but I could be getting confused).
>>
>> What are the chances such a fix will automagically materialize out of
>> the ether? Not high. What are the chances that a patch implementing
>> this feature would be added to trunk? Fairly good, conditional on the
>> quality of the patch.
> 
> I am not submitting here, I just want to discuss it first.
> 
> 1. what do you think of this syntax I invented:
>   --option "list of items"
> 
> I don't like it, but not sure how else to do it.

I think I like this better:

make_option('-e', '--exclude', dest='exclude', action='append',
  help='App to exclude (use mutiple --exclude to exclude mutiple apps).'),

./manage.py dumpdata -e core -e countries -e sessions -e sites

previous way:
./manage.py dumpdata --exclude "core countries sessions sites"

Carl K

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 avoid uploading .py source files to shared hosting server

2008-05-15 Thread jonknee

> I want to upload only .pyc and no source files. Whats the best way to
> make sure my .pyc works there.

Your best bet is to probably upload the .py files, run the app and
then delete the .py files. That way you're sure that the .pyc files
are compatible. But unless you really need to get rid of the .py
files, you should leave them be.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with custom validator - please, please, please

2008-05-15 Thread Brian Rosner


On May 14, 2008, at 5:28 PM, Brandon Taylor wrote:

>
> Hi everyone,


Hi :) Okay, let first begin by explaining some fundamental basics  
about Django itself. The admin in trunk uses oldforms. To use custom  
validation there you would write a validator that would go in  
validator_list on the model field. That no longer works in newforms- 
admin. The admin in newforms-admin uses newforms. Surprise! :) I would  
highly recommend you read the newforms documentation [1] if you have  
never used newforms before.

Here is a very quick way to do some custom validation (not specific to  
your example, that is your exercise):


from django.db import models
from django import newforms as forms
from django.contrib import admin

class Person(models.Model):
 name = models.CharField(max_length=100)

class PersonForm(forms.ModelForm):
 class Meta:
 model = Person

 def clean_name(self):
 value = self.cleaned_data["name"]
 if name == "Brian":
 raise forms.ValidationError, u"You are not allowed to be  
named Brian."
 return value

class PersonAdmin(admin.ModelAdmin):
 form = PersonForm
admin.site.register(Person, PersonAdmin)

That is the code required, I haven't tested it, but it should work.  
Clearly don't drop it into one file as it is best to split that code  
out, but shown for ease of coding ;) Let me know if you have any  
further questions.

Brian Rosner
http://oebfare.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: Python 3000 support, any plans?

2008-05-15 Thread mardenet

> I'd posit with fair confidence that Django 1.0 will come long, long
> before Python 3000 reaches a non-alpha state.

Wow that's a strong statement... the "long long" seems a bit
exagerated since if Python 3000 sticks to schedule it would release
Beta in a month or so.
Anyway I like strong statements, you might have insider info.

I have looked on the web and I couldn't find any release date for v.
1.0. But I saw they postponed many times before deleting any date from
their FAQ.
But I believe u, I'll wait for 1.0 (not for Python 3000) and then I'll
start, I have enough to do in the mean time :).

Thanks!

On 15 Mag, 16:41, "Quentin Gallet-Gilles" <[EMAIL PROTECTED]> wrote:
> On Thu, May 15, 2008 at 5:16 PM, David Zhou <[EMAIL PROTECTED]> wrote:
>
> > On May 15, 2008, at 10:57 AM, mardenet wrote:
>
> > > I am very interested in Python and Django for a future project but  I
> > > am noticing this is a period of big changes in this community. Python
> > > 3000 and Django 1.0 will really be a major change.
>
> > They will be big changes, but don't really align in terms of timeline.
>
> > > I am not afraid of using Alpha versions, and I want to use latest
> > > technologies and my mind rejects any forced changes in the code due to
> > > new releases. If I do something I don't want to touch it again.
> > > So I want to start straight with Python 3000.
>
> > Even if you coded in Python 3000, it's not like Django doesn't
> > sometimes introduce backwards incompatible changes. Plus, I highly
> > doubt any serious effort will be made to make sure Django works on
> > Python 3000 until after Django 1.0 and (likely) until after Python
> > 3000 exits alpha state.
>
> > > Would this be compatible with Djanga? If not when do you expect it to
> > > be compatible?
> > > I prefer waiting than recoding, so I wanted an idea on timelines...
> > > any thoughts?
>
> > I'd posit with fair confidence that Django 1.0 will come long, long
> > before Python 3000 reaches a non-alpha state.
>
> > If you want to use Django for something, I'd start now -- or with
> > 1.0.  Waiting for Python 3000 is a bit silly.
>
> > ---
> > David Zhou
> > [EMAIL PROTECTED]
>
> Django'd better hurry, because the first beta release of Python 3000 is due
> next month ! And the final release is scheduled for September.
>
> However, that's just a start. Porting the libraries (batteries excluded, of
> course) is the next big step and it is expected that we will have to wait
> for 3.1 or 3.2 before the major libraries and frameworks are all ported.
>
> Anyway, I agree it's silly to wait for Python 3000. The 2.x release is not
> that different and everything is done to make adjusting to Python 3000 as
> seamless as possible.
>
> Quentin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: encrypting form data

2008-05-15 Thread jonknee

> I am not concerned if they can send the hash back. I dont want them to
> be able to access the underling value that the hash is based on.
>
> I am also not concerned about spam, but rather just dont want to expose
> raw database ids to the public.


Gotcha, I mis-understood your original question then. So you don't
need to encrypt your database IDs, you just need them to be non-
sequential. I would use a UUID. Django doesn't have that option built
in for use as the pk, so it'd have to be another column, but it's easy
enough. There is a uuid module as well which makes generating them
quite simple. You can override the save() method in your model to
automatically generate the UUID which is what I did.

http://zesty.ca/python/uuid.html

And usage:

...
import uuid

def save(self):
if not self.id:
self.uuid = uuid.uuid1()
super(Model, self).save()

This makes it pretty painless.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: encrypting form data

2008-05-15 Thread Richard Dahl
Forgive my feeble mind, but I am trying to understand, what is the point of
substituting 'walewadu' for 1 or 2 or 3855?  What security does this
provide?
-richard



On 5/15/08, Norman Harman <[EMAIL PROTECTED]> wrote:
>
>
> Gabriel wrote:
> > Mike Chambers  gmail.com> writes:
> >
> >>
> >> I am not concerned if they can send the hash back. I dont want them to
> >> be able to access the underling value that the hash is based on.
> >>
> >> I am also not concerned about spam, but rather just dont want to expose
> >> raw database ids to the public.
> >>
> >
> >
> > Hi Mike
> >
> > I think you are right to be cautious about not exposing DB IDs publicly.
> My
> > suggestion is to create another column in the table with the IDs and make
> it a
> > unique ID, something like a SHA1 hash of the DB ID + Username +email for
> > instance. Then base all requests and DB lookups on this. It won't stop
> users
> > from using a hash they know about, but it will stop them from guessing
> others.
> > You could even index the DB column for performance. Hope that help, if
> not I
> > apologise for not reading your post more carefully!
>
> Creating db column is what I did for storymash.com, for example this url
>
> http://storymash.com/u/huskerlayd/wolewadu/
>
> "wolewadu" is a unique string used to reference individual chapters in
> urls and other places.  It's not a hash.  It's not related to id.
> Wanted less ugly urls than either ids or hashes provide.  So it's always
> 8 alternating constanants/vowels with a bunch of undesirable
> words/substrings disallowed.
>
> We create this once in the save method of Chapter model
>
>if self.hash is None:
>self.hash = self._generate_hash()
>
> And queries are:
>
>chapter = Chapter.objects.get(hash="wolewadu")
>
>
> Definitely make it indexed column though.
>
>
> The business case is different from what I think Mike wants but similar
> methods can apply.
>
> --
> Norman J. Harman Jr.  512 912-5939
> Technology Solutions Group, Austin American-Statesman
> ___
> Get out and about this spring with the Statesman! In print and online,
> the Statesman has the area's Best Bets and recreation events.
> Pick up your copy today or go to statesman.com 24/7.
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: where does this caching come?

2008-05-15 Thread Graham Dumpleton

On May 16, 12:21 am, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Alex Morega wrote:
> > On May 15, 2008, at 02:24 , David Zhou wrote:
> >> Are you restarting the server between module changes?
>
> > By default Django does no caching of responses. It's probably what  
> > Viktor says: the server (mod_python,mod_wsgi, whatever) won't  
> > automatically reload the python code if you change it. The automatic  
> > reload behaviour only happens with Django's built-in development server.
>
> Not strictly true.  With mod_python there's a directive to control
> whether apache automatically reloads python code.  You *don't* want to
> set this on for production code(large performance penalty).
>
>          PythonAutoReload On
>
> I'm guessingmod_wsgiand others have something similar.

That option for mod_python does absolutely nothing for Django. This is
because Django and your application modules for it don't fall into the
category of modules thats are candidates for reloading.

In mod_wsgi, when using daemon mode, the default behaviour in mod_wsgi
2.0 is a process reloading feature. This is only triggered though when
the WSGI script file acting as entry point is changed, and again not
arbitrary code. Thus, what you would do is make all your code changes
then touch the WSGI script file (ie., update modification time using
'touch' command) and the application will be reloaded on next request.

See:

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

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: encrypting form data

2008-05-15 Thread Norman Harman

Gabriel wrote:
> Mike Chambers  gmail.com> writes:
> 
>>
>> I am not concerned if they can send the hash back. I dont want them to 
>> be able to access the underling value that the hash is based on.
>>
>> I am also not concerned about spam, but rather just dont want to expose 
>> raw database ids to the public.
>>
> 
> 
> Hi Mike
> 
> I think you are right to be cautious about not exposing DB IDs publicly. My
> suggestion is to create another column in the table with the IDs and make it a
> unique ID, something like a SHA1 hash of the DB ID + Username +email for
> instance. Then base all requests and DB lookups on this. It won't stop users
> from using a hash they know about, but it will stop them from guessing others.
> You could even index the DB column for performance. Hope that help, if not I
> apologise for not reading your post more carefully!

Creating db column is what I did for storymash.com, for example this url

 http://storymash.com/u/huskerlayd/wolewadu/

"wolewadu" is a unique string used to reference individual chapters in 
urls and other places.  It's not a hash.  It's not related to id. 
Wanted less ugly urls than either ids or hashes provide.  So it's always 
8 alternating constanants/vowels with a bunch of undesirable 
words/substrings disallowed.

We create this once in the save method of Chapter model

if self.hash is None:
self.hash = self._generate_hash()

And queries are:

chapter = Chapter.objects.get(hash="wolewadu")


Definitely make it indexed column though.


The business case is different from what I think Mike wants but similar 
methods can apply.

-- 
Norman J. Harman Jr.  512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: where does this caching come?

2008-05-15 Thread V

Actually, I use the built-in server (as I am still developing).

My guess was the pyc files are not rebuilt, but even when I delete
them, I still get the same behaviour.

Just a minute ago, I've tried to switch off browser caching, before I
just Ctrl+R-ed the page. This seems to work. :)

Thanks for your help, at least I've learned something about
mod_python. ;)

V

On May 15, 4:21 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Alex Morega wrote:
> > On May 15, 2008, at 02:24 , David Zhou wrote:
> >> Are you restarting the server between module changes?
>
> > By default Django does no caching of responses. It's probably what
> > Viktor says: the server (mod_python, mod_wsgi, whatever) won't
> > automatically reload the python code if you change it. The automatic
> > reload behaviour only happens with Django's built-in development server.
>
> Not strictly true.  With mod_python there's a directive to control
> whether apache automatically reloads python code.  You *don't* want to
> set this on for production code(large performance penalty).
>
>  PythonAutoReload On
>
> I'm guessing mod_wsgi and others have something similar.
>
> --
> Norman J. Harman Jr.  512 912-5939
> Technology Solutions Group, Austin American-Statesman
> ___
> Get out and about this spring with the Statesman! In print and online,
> the Statesman has the area's Best Bets and recreation events.
> Pick up your copy today or go to statesman.com 24/7.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: encrypting form data

2008-05-15 Thread Richard Dahl
Norman,
Thanks for your clarification, however, comments inline...

> You check that the hash sent back is correct by (re)hashing the id, duh.

Of course the hash will be correct, the bot will simply return what it
recieved.  The point is that this does not prevent anyone from being able to
submit a form based on the id or hash or encrypted key.  A hidden field or
hash of a value in a web form does nothing for securty in this (or nearly
any other) case.  Think about how http works.

>
> Since only you have the secret part it is computationally difficult for
> others to create hashes for arbitrary ids.

Granted, but this was never mentioned as the issue.

>
> One reason to hash id's is that you don't want people / bots whatever
> spidering all your data, this can be security(weak) or load related.
>
How does this work, he has said that his app does not have logged in users.
Presumably any web client can do a GET to a relevant URL and view all of the
data in the DB. His issue is with people POSTing data to the DB based on the
form they GET.


> Another is CSRF http://www.djangoproject.com/documentation/csrf/

See my earlier comments for why this may not help in this case.

>
> A reason to not reveal primary keys is to not let competitors know how
> many records you have.
> http://www.guardian.co.uk/world/2006/jul/20/secondworldwar.tvandradio

Why not just set your sequence number to 50 before you load data into
the db or pre-load the first record with a high PK, and keep the competition
guessing as to how many records you have:)
-richard


On 5/15/08, Norman Harman <[EMAIL PROTECTED]> wrote:
>
> Richard Dahl wrote:
> > Mike,
> > I concur with jonknee, the attribute 'hidden' on a form field simply
> > tells a browser that is following the standards not to display it.
> > The form field and all of the data within it is still sent via http.
> > Any script or proxy (i.e. webscarab) or other mechanism such as a
> > sniffer can get at the information within any http response or request
> > and view that information.  Whether or not the id is sent back as '1'
> > or '9ghieus78yurhfyjdn' is irrelevant to solving your problem because
> > a script or bot can just as easily return either.  The *accepted*
> > solution for this is CAPTCHA.
> > -richard
>
> You check that the hash sent back is correct by (re)hashing the id, duh.
>
> Since only you have the secret part it is computationally difficult for
> others to create hashes for arbitrary ids.
>
> One reason to hash id's is that you don't want people / bots whatever
> spidering all your data, this can be security(weak) or load related.
>
> Another is CSRF http://www.djangoproject.com/documentation/csrf/
>
> A reason to not reveal primary keys is to not let competitors know how
> many records you have.
> http://www.guardian.co.uk/world/2006/jul/20/secondworldwar.tvandradio
>
>
>
> --
> Norman J. Harman Jr.  512 912-5939
> Technology Solutions Group, Austin American-Statesman
>
___
> Get out and about this spring with the Statesman! In print and online,
> the Statesman has the area's Best Bets and recreation events.
> Pick up your copy today or go to statesman.com 24/7.
>
> >
>

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

2008-05-15 Thread Norman Harman

Gabriel wrote:
> Mike Chambers  gmail.com> writes:
> 
>>
>> I am not concerned if they can send the hash back. I dont want them to 
>> be able to access the underling value that the hash is based on.
>>
>> I am also not concerned about spam, but rather just dont want to expose 
>> raw database ids to the public.
>>
> 
> 
> Hi Mike
> 
> I think you are right to be cautious about not exposing DB IDs publicly. My
> suggestion is to create another column in the table with the IDs and make it a
> unique ID, something like a SHA1 hash of the DB ID + Username +email for
> instance. Then base all requests and DB lookups on this. It won't stop users
> from using a hash they know about, but it will stop them from guessing others.
> You could even index the DB column for performance. Hope that help, if not I
> apologise for not reading your post more carefully!

Creating db column is what I did for storymash.com, for example this url

 http://storymash.com/u/huskerlayd/wolewadu/

"wolewadu" is a unique string used to reference individual chapters in 
urls and other places.  It's not a hash.  It's not related to id. 
Wanted less ugly urls than either ids or hashes provide.  So it's always 
8 alternating constanants/vowels with a bunch of undesirable 
words/substrings disallowed.

We create this once in the save method of Chapter model

if self.hash is None:
self.hash = self._generate_hash()

And queries are:

chapter = Chapter.objects.get(hash="wolewadu")


Definitely make it indexed column though.


The business case is different from what I think Mike wants but similar 
methods can apply.

-- 
Norman J. Harman Jr.  512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

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

2008-05-15 Thread Chris

Cool I resolved the error. So when you have a drop down list for an
IntegerField that is an optional IntegerField in the database, you
must set some sort of validation to tell this optional field to be
None (for the obvious reasons). What I didn't realize is when I had a
choices list set in the Choicefield which was optional, django puts in
a (("","--"),) at the top of the list. So for others who might
have this problem make sure to set None to an optional IntegerField in
your model when validating or right before saving.

This is a general question to the Django Community? Should there be
some automation that realizes that it is a choices list for an
IntegerField and should not include this " " but should include this
None as the default blank field?




On May 15, 12:21 pm, Chris <[EMAIL PROTECTED]> wrote:
> Hi Karen,
>
> I have a form with first_name, last_name and email and once the user
> presses submit, it will then save the 3 required fields to the
> database and send the data to another form containing additional
> fields suchas year_of_birth, phone_number, address,city, state, etc...
> The 3 required fields have already been filled out by a user in the
> first form, the next form it sends data to contains optional fields. I
> am not using form wizard either, just a render_to_response that passes
> data to the next form. Why it works on my local dev and not on the
> company dev makes no sense.
>
> model field declaration looks like this:
>
> year_of_birth = models.IntegerField(blank=True, null=True,
> choices=YEAR_OF_BIRTH)
>
> also I I noticed when I take out the ChoicesField altogether it seems
> to process fine or if I change field to a textfield it works too.
>
> Thanks for helping me with this strange issue.
>
> Chris
>
> On May 15, 9:38 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Wed, May 14, 2008 at 6:14 PM, Chris <[EMAIL PROTECTED]> wrote:
>
> > > Hello I created a new forms form and I am having uses with this
> > > statement:
>
> > >year_of_birth = forms.ChoiceField(required=False,
> > > choices=YEAR_OF_BIRTH)
>
> > > and tuple looks like so:
> > >year_of_birth = ((1990, '1990'), (1989, '1989'), ...)
>
> > > On my local dev server, I have latest django and use sqllite, this
> > > works fine but when I push code to our company dev server and try to
> > > run code it, it breaks and give me the following message. On the
> > > company dev we use mysql. This almost looks like it could be a mysql
> > > specific bug but the error is so vague who knows. I don't understand
> > > how I can pass a tuple through and it think that I am giving it a ''
> > > value.
>
> > > Exception Type: Warning
> > > Exception Value:Incorrect integer value: '' for column
> > > 'year_of_birth' at row 1
> > > Exception Location: /usr/lib/python2.5/site-packages/MySQLdb/
> > > cursors.py in _warning_check, line 80
>
> > > Could someone please help. This error is driving me crazy!
>
> > > Thanks in advance.
>
> > You don't mention when you get this error: all of the time, regardless of
> > the choice, only when the 'blank' choice is chosen, etc?  MySQL is
> > complaining that it is being handed and empty string to put in an integer
> > field.  I notice you have required=False on the form field, so I'd guess you
> > are seeing this only when the 'blank' choice is chosen, in which case I
> > suspect the fix would be to specify null=True in the model field, so that
> > blank will be stored as null in the database.
>
> > 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: encrypting form data

2008-05-15 Thread Gabriel

Mike Chambers  gmail.com> writes:

> 
> 
> Thanks for the input. I was considering doing this, but my only concern 
> was if the key changed for some reason, I would have to regenerate the 
> hashes. I might try it out though, and see how well it works.
> 
> Of course, Im not sure why the key would get reset.
> 

But if it is a one-way hash the key shouldn't matter. In fact there is no
concept of a key, just perhaps a salt. Normally if you wanted to find the ID for
the hash you would lookup the hash in the DB and select the ID, this wouldn't
put too much pressure on the DB, and as I mentioned you can index the hash
column to make these lookups quicker.

If you do need keys then I think I have misunderstood you.


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

2008-05-15 Thread Norman Harman

Richard Dahl wrote:
> Mike,
> I concur with jonknee, the attribute 'hidden' on a form field simply
> tells a browser that is following the standards not to display it.
> The form field and all of the data within it is still sent via http.
> Any script or proxy (i.e. webscarab) or other mechanism such as a
> sniffer can get at the information within any http response or request
> and view that information.  Whether or not the id is sent back as '1'
> or '9ghieus78yurhfyjdn' is irrelevant to solving your problem because
> a script or bot can just as easily return either.  The *accepted*
> solution for this is CAPTCHA.
> -richard

You check that the hash sent back is correct by (re)hashing the id, duh.

Since only you have the secret part it is computationally difficult for 
others to create hashes for arbitrary ids.

One reason to hash id's is that you don't want people / bots whatever 
spidering all your data, this can be security(weak) or load related.

Another is CSRF http://www.djangoproject.com/documentation/csrf/

A reason to not reveal primary keys is to not let competitors know how 
many records you have. 
http://www.guardian.co.uk/world/2006/jul/20/secondworldwar.tvandradio



-- 
Norman J. Harman Jr.  512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

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



how to avoid uploading .py source files to shared hosting server

2008-05-15 Thread ydjango

Hi,

I am developing on python 2.4.4 and django svn branch.
I want to upload to webfaction which if I ssh and run python is python
2.4.3.

Application installed is Django trunk/mod python 3.3.1/ python 2.5

I want to upload only .pyc and no source files. Whats the best way to
make sure my .pyc works there.


thanks
Ashish

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



Invalid block tag: 'include_admin_script' in newforms admin?

2008-05-15 Thread Brandon Taylor

Anyone else receiving this error:

Invalid block tag: 'include_admin_script'

when loading the change form in newforms-admin?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: encrypting form data

2008-05-15 Thread Mike Chambers

Thanks for the input. I was considering doing this, but my only concern 
was if the key changed for some reason, I would have to regenerate the 
hashes. I might try it out though, and see how well it works.

Of course, Im not sure why the key would get reset.

Thanks for all of the input and suggestions.

mike


Gabriel wrote:
> Mike Chambers  gmail.com> writes:
> 
>>
>> I am not concerned if they can send the hash back. I dont want them to 
>> be able to access the underling value that the hash is based on.
>>
>> I am also not concerned about spam, but rather just dont want to expose 
>> raw database ids to the public.
>>
> 
> 
> Hi Mike
> 
> I think you are right to be cautious about not exposing DB IDs publicly. My
> suggestion is to create another column in the table with the IDs and make it a
> unique ID, something like a SHA1 hash of the DB ID + Username +email for
> instance. Then base all requests and DB lookups on this. It won't stop users
> from using a hash they know about, but it will stop them from guessing others.
> You could even index the DB column for performance. Hope that help, if not I
> apologise for not reading your post more carefully!
> 
> 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
> -~--~~~~--~~--~--~---
> 

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

2008-05-15 Thread Gabriel

Mike Chambers  gmail.com> writes:

> 
> 
> I am not concerned if they can send the hash back. I dont want them to 
> be able to access the underling value that the hash is based on.
> 
> I am also not concerned about spam, but rather just dont want to expose 
> raw database ids to the public.
> 


Hi Mike

I think you are right to be cautious about not exposing DB IDs publicly. My
suggestion is to create another column in the table with the IDs and make it a
unique ID, something like a SHA1 hash of the DB ID + Username +email for
instance. Then base all requests and DB lookups on this. It won't stop users
from using a hash they know about, but it will stop them from guessing others.
You could even index the DB column for performance. Hope that help, if not I
apologise for not reading your post more carefully!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Multi-user blog creation system

2008-05-15 Thread k0001
On Thu, May 15, 2008 at 4:57 PM, Arckam <[EMAIL PROTECTED]> wrote:

>
> Hey guys,


Hey!

I need to support a custom blog creation system. Each user would have
> the possibility to create his own blog (like what Blogger does) and to
> post on it. In return there would be an integration of the blog events
> (i.e. posting a new entry) in the global app.
>
> Since I don't feel like reinventing the wheel (again :-) ), does any of
> you have info about an existing tool, written in Django, that allows a
> user to create his own personnal blog and post on it?
>

Well, I don't know about any preexisting implementation, but doing it should
be pretty straightforward, just always keep a ForeignKey to the UserBlog in
your posts/templates/tags/etc...

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Getting back to the same page after completing a task in another page

2008-05-15 Thread Adi J. Sieker

M.Ganesh wrote:
> 6. The login page that comes with contrib.auth is too colourful compared 
> to other pages, and also exposes the admin page to the users unnecessarily.

The login page doesn't have anything todo with the admin page and if 
it's colorful or not is up to you.

The admin has a login page that uses the contrib.auth login page.
But you can still use contrib.auth even if the admin app is disabled.
admin uses contrib.auth but it's not the other way around.

adi
--
Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
Freelance developer   skype:  adijsieker
SAP-Consultantweb:http://www.sieker.info/profile
   openbc: https://www.openbc.com/hp/AdiJoerg_Sieker/

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

2008-05-15 Thread Richard Dahl

Why don't you want to expose raw database ids to the public?
-richard


On 5/15/08, Mike Chambers <[EMAIL PROTECTED]> wrote:
>
> I am not concerned if they can send the hash back. I dont want them to
> be able to access the underling value that the hash is based on.
>
> I am also not concerned about spam, but rather just dont want to expose
> raw database ids to the public.
>
> mike
>
> Richard Dahl wrote:
> > Mike,
> > I concur with jonknee, the attribute 'hidden' on a form field simply
> > tells a browser that is following the standards not to display it.
> > The form field and all of the data within it is still sent via http.
> > Any script or proxy (i.e. webscarab) or other mechanism such as a
> > sniffer can get at the information within any http response or request
> > and view that information.  Whether or not the id is sent back as '1'
> > or '9ghieus78yurhfyjdn' is irrelevant to solving your problem because
> > a script or bot can just as easily return either.  The *accepted*
> > solution for this is CAPTCHA.
> > -richard
> >
> >
> > On 5/15/08, Mike Chambers <[EMAIL PROTECTED]> wrote:
> >> The value is encrypted in the form. The secret key, used to either
> >> decrypt or hash the value, is on the server, and not in the form.
> >>
> >> My application does not have the concept of logged in users.
> >>
> >> mike
> >>
> >> jonknee wrote:
> >>
> >>> How would that help if the "secret" value was in the form already?
> >>> Bots and what not would see it all the same. If you want to stop spam
> >>> posts (which is what I'm assuming you're up to) you can limit comments
> >>> to logged in users, run the data through something like Akismet, use a
> >>> CAPTCHA, etc. But obfuscating the ID is not going to accomplish much--
> >>> if it's available in the HTML that means a bot is going to see it to.
> >>>
> >>> You're probably better off just limiting users to X comments per hour
> >>> or something.
> >
> > >
>
> >
>

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

2008-05-15 Thread Mike Chambers

I am not concerned if they can send the hash back. I dont want them to 
be able to access the underling value that the hash is based on.

I am also not concerned about spam, but rather just dont want to expose 
raw database ids to the public.

mike

Richard Dahl wrote:
> Mike,
> I concur with jonknee, the attribute 'hidden' on a form field simply
> tells a browser that is following the standards not to display it.
> The form field and all of the data within it is still sent via http.
> Any script or proxy (i.e. webscarab) or other mechanism such as a
> sniffer can get at the information within any http response or request
> and view that information.  Whether or not the id is sent back as '1'
> or '9ghieus78yurhfyjdn' is irrelevant to solving your problem because
> a script or bot can just as easily return either.  The *accepted*
> solution for this is CAPTCHA.
> -richard
> 
> 
> On 5/15/08, Mike Chambers <[EMAIL PROTECTED]> wrote:
>> The value is encrypted in the form. The secret key, used to either
>> decrypt or hash the value, is on the server, and not in the form.
>>
>> My application does not have the concept of logged in users.
>>
>> mike
>>
>> jonknee wrote:
>>
>>> How would that help if the "secret" value was in the form already?
>>> Bots and what not would see it all the same. If you want to stop spam
>>> posts (which is what I'm assuming you're up to) you can limit comments
>>> to logged in users, run the data through something like Akismet, use a
>>> CAPTCHA, etc. But obfuscating the ID is not going to accomplish much--
>>> if it's available in the HTML that means a bot is going to see it to.
>>>
>>> You're probably better off just limiting users to X comments per hour
>>> or something.
> 
> > 

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

2008-05-15 Thread Richard Dahl

The CSRF middleware probably would not provide a solution for this
problem.  It sets a hidden field with a value that is derived from
hashing the session id with a secret, but I do not believe it sets a
unique key per form.  As long as the session was valid (assuming the
app in question is using sessions) the CSRF may allow any number of
form posts provided the correct hidden value is present.

Even if the middleware sets a form-specific key, a bot could be
written to simply request a new form for each submission, thereby
ensuring that all form posts are accepted.

-richard


On 5/15/08, Norman Harman <[EMAIL PROTECTED]> wrote:
>
> Mike Chambers wrote:
> > I have a commenting app that requires that the item id, and content type
> > id be passed through the form.
> >
> > This works fine, but i would like to encrypt that data to make it a
> > little more difficult for people to programatically submit the form.
> >
> > Does anyone have any info on how to encrypted form data? I know how to
> > hash it using MD5, and SHA1, etc... but that is only a one way hash. I
> > dont want to have to loop through all of the possible values to compare
> > the hashes as that could get to be expensive.
> >
> > Any suggestions?
>
> The standard http://www.djangoproject.com/documentation/csrf/ CSRF
> protection middleware does something like that.
>
> Don't know details but could look there.
>
> If you're gonna 1way hash things such as 'id' and worry about speed then
> store the 1way hashed value in database and do your lookups on that.
>
> --
> Norman J. Harman Jr.  512 912-5939
> Technology Solutions Group, Austin American-Statesman
> ___
> Get out and about this spring with the Statesman! In print and online,
> the Statesman has the area's Best Bets and recreation events.
> Pick up your copy today or go to statesman.com 24/7.
>
> >
>

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

2008-05-15 Thread Chad Parker

found this in the djangoproject.com source and it works well for me:
(goes in settings.py; change webfaction.com to whatever you get from
your server)

# Far too clever trick to know if we're running on the deployment server.
import platform
DEVELOPMENT_MODE = (platform.node() != "web22.webfaction.com")

if DEVELOPMENT_MODE:  # local dev:
DEBUG = True
else:  # on the server:
DEBUG = False



On Wed, May 14, 2008 at 7:41 AM, Bob <[EMAIL PROTECTED]> wrote:
>
> At Django startup, before any requests are handled.
>
> On May 13, 7:02 am, "Chatchai Neanudorn" <[EMAIL PROTECTED]> wrote:
>> Which phase do you want to access? Http request parsing, request
>> object initializing...
>>
>> 2008/5/13, Bob <[EMAIL PROTECTED]>:
>>
>>
>>
>> > Thanks, Any way to do this without access to a request object, since I
>> > want to use this information to do some server-specific initialization
>> > before I have a request object to look at?
>>
>> > On May 12, 6:56 pm, "Chatchai Neanudorn" <[EMAIL PROTECTED]> wrote:
>> > > mod_python (django.core.handlers.modpython),
>>
>> > > request.META['GATEWAY_INTERFACE'] = 'CGI/1.1'
>>
>> > > or
>>
>> > > request.META['SERVER_SOFTWARE'] = 'mod_python''
> >
>

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

2008-05-15 Thread Richard Dahl

Mike,
I concur with jonknee, the attribute 'hidden' on a form field simply
tells a browser that is following the standards not to display it.
The form field and all of the data within it is still sent via http.
Any script or proxy (i.e. webscarab) or other mechanism such as a
sniffer can get at the information within any http response or request
and view that information.  Whether or not the id is sent back as '1'
or '9ghieus78yurhfyjdn' is irrelevant to solving your problem because
a script or bot can just as easily return either.  The *accepted*
solution for this is CAPTCHA.
-richard


On 5/15/08, Mike Chambers <[EMAIL PROTECTED]> wrote:
>
> The value is encrypted in the form. The secret key, used to either
> decrypt or hash the value, is on the server, and not in the form.
>
> My application does not have the concept of logged in users.
>
> mike
>
> jonknee wrote:
>
> >
> > How would that help if the "secret" value was in the form already?
> > Bots and what not would see it all the same. If you want to stop spam
> > posts (which is what I'm assuming you're up to) you can limit comments
> > to logged in users, run the data through something like Akismet, use a
> > CAPTCHA, etc. But obfuscating the ID is not going to accomplish much--
> > if it's available in the HTML that means a bot is going to see it to.
> >
> > You're probably better off just limiting users to X comments per hour
> > or something.
>
> >
>

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



Multi-user blog creation system

2008-05-15 Thread Arckam

Hey guys,

I need to support a custom blog creation system. Each user would have 
the possibility to create his own blog (like what Blogger does) and to 
post on it. In return there would be an integration of the blog events 
(i.e. posting a new entry) in the global app.

Since I don't feel like reinventing the wheel (again :-) ), does any of 
you have info about an existing tool, written in Django, that allows a 
user to create his own personnal blog and post on it?

A fairly simple implementation would be fine. The user should be allowed 
to create his blog, give it a template and post a message straight away. 
Not via the default admin interface obviously.

I'll then have to integrate it into the global application itself, but 
it shouldn't be a big deal, I believe.

Thanks!

Cheers,
- Arck.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Code works with Django's server, but not with Apache+mod_python?

2008-05-15 Thread mw

Yeah I'm still at a loss on this bug.

I ran the code provided in the thread.
Django's
django
/Library/Python/2.5/site-packages/django/__init__.pyc
pil
/Library/Python/2.5/site-packages/PIL/__init__.pyc

And then Apache's is
django
/Library/Python/2.5/site-packages/django/__init__.pyc
pil
/Library/Python/2.5/site-packages/PIL/__init__.pyc

As far as I can tell there is no difference!  Apache still seems to be
rejecting the image as an invalid image while the Django test server
doesn't.  What could the problem possibly be between the two
servers?  :-(





On May 6, 12:38 pm, mw <[EMAIL PROTECTED]> wrote:
> Ahh, after running the code with both the django server and apache and
> mod_python there are different paths listed.
>
> I shall investigate on my own and come back if I need more help!
>
> Thank you both very much!
> mw
>
> On May 5, 7:13 pm, "Chatchai Neanudorn" <[EMAIL PROTECTED]> wrote:
>
> > When I installed my web at webfaction I did this to see which module python
> > use,
>
> > at settings.py
>
> > import os
> > import django, PIL
> > logfile = open('path.log', 'w')
>
> > django_path = django.__file__
> > pil_path = PIL.__file__
>
> > logfile.write('django - %\n pil - %s\n' % (django_path, pil_path))
>
> > logfile.close()
>
> > ...
>
> > With this code, you can see which module you are using.
>
> > I can successfully install my web with this trip.
>
> > Regards
>
> > 2008/5/5 TP <[EMAIL PROTECTED]>:
>
> > > Could you have different PYTHONPATH settings for mod_python vs command
> > > line where you're running the admin server? Different versions of PIL
> > > or something between those two versions? libjpeg and friends installed
> > > in non-standard locations where they're found by the command line
> > > python but not the python being loaded by mod_python?
>
> > > On May 2, 5:02 pm, mw <[EMAIL PROTECTED]> wrote:
> > > > Hello,
>
> > > > I've emailed the mailing list in the past because of problems with PIL
> > > > and and image field upload in the admin interface.  The problem, just
> > > > got weirder.
>
> > > > I noticed that images were never validating as actual images and were
> > > > constantly being rejected.  Out of a hunch, I fired up the django
> > > > built-in server and tried the same page with the same image.  This
> > > > time, the image validated and it was correctly uploaded.
>
> > > > Does anyone happen to know what would then be stopping the code from
> > > > validating the image upload when run through apache instead of the
> > > > django development server?
>
> > > > I'm using the SVN of django on OS X.
>
> > > > Thanks in advance,
> > > > mw
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: MySQL Boolean vs. PostgresQL Boolean

2008-05-15 Thread Carl Karsten

Szaijan wrote:
> Hi, I developed my first Django app on my mapbook using PostgreSQL and
> have recently moved it to a production site which uses MySQL.
> PostgreSQL stores boolean values and True and False, just like Python
> and JS, while MySQL uses 1 and 0.

Where are you seeing this?

I think you are confusing what gets stored on disk with a human readable 
version 
of the value.

Good chance that both store a 0001 for true, and even that is a human 
readable version made up of 8 chars :)

> 
> Is there some automated way to get the models to understand this and
> present/save boolean values to and from views, or do I need to
> override the save and get methods so that they translate 0 to False, 1
> to True, and vice versa?  This seems to be a barrier to portability if
> I have to hard code DB awareness into my models.

I have flipped between sqlite, MySql and Postgresql with no such problems.

Carl K

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: loaddata .. columns app_label, model are not unique

2008-05-15 Thread Carl Karsten

Russell Keith-Magee wrote:
> On Wed, May 14, 2008 at 1:20 PM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>> Russell Keith-Magee wrote:
>>> On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>> What are the chances of getting a dumpdata hack to exclude certain apps?
>>
>> I know it isn't too hard to figure out what apps I want to backup, but it 
>> sounds
>> like the 'exclude' feature might be useful even once this issue is resolved.
> 
> It's a reasonable idea - one well worth suggesting as a feature
> enhancement (I have a nagging feeling that there is something in there
> already, but I could be getting confused).
> 
> What are the chances such a fix will automagically materialize out of
> the ether? Not high. What are the chances that a patch implementing
> this feature would be added to trunk? Fairly good, conditional on the
> quality of the patch.

I am not submitting here, I just want to discuss it first.

1. what do you think of this syntax I invented:
  --option "list of items"

I don't like it, but not sure how else to do it.

2. should I leave in --debug?  I really meant it for debugging, but I can see 
it 
being handy to debug the "list of items" and such.

Why does the current code has 'json' listed in 2 places:
make_option('--format', default='json'
options.get('format', 'json')

note: "default - Deprecated; use parser.set_defaults() instead. "
http://docs.python.org/lib/optparse-option-attributes.html


Index: dumpdata.py
===
--- dumpdata.py (revision 7534)
+++ dumpdata.py (working copy)
@@ -9,6 +9,10 @@
  help='Specifies the output serialization format for fixtures.'),
  make_option('--indent', default=None, dest='indent', type='int',
  help='Specifies the indent level to use when pretty-printing 
output'),
+make_option('--exclude', default=None, dest='exclude',
+help='List of apps to exclude ("space seperated").'),
+make_option('--debug', dest='debug', action='store_true',
+help='Prints the list of apps excluded, to be processed, and 
exits.'),
  )
  help = 'Output the contents of the database as a fixture of the given 
format.'
  args = '[appname ...]'
@@ -18,6 +22,8 @@

  format = options.get('format', 'json')
  indent = options.get('indent', None)
+exclude = options.get('exclude')
+debug = options.get('debug')
  show_traceback = options.get('traceback', False)

  if len(app_labels) == 0:
@@ -25,6 +31,18 @@
  else:
  app_list = [get_app(app_label) for app_label in app_labels]

+if exclude:
+excl_apps = [get_app(app_label) for app_label in exclude.split()]
+for excl_app in excl_apps:
+app_list.remove(excl_app)
+if debug:
+print "excluded: %s" % excl_app.__name__
+
+if debug:
+for app in app_list:
+print "included: %s" % app.__name__
+return
+
  # Check that the serialization format exists; this is a shortcut to
  # avoid collating all the objects and _then_ failing.
  if format not in serializers.get_public_serializer_formats():

Carl K

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

2008-05-15 Thread Norman Harman

Mike Chambers wrote:
> I have a commenting app that requires that the item id, and content type 
> id be passed through the form.
> 
> This works fine, but i would like to encrypt that data to make it a 
> little more difficult for people to programatically submit the form.
> 
> Does anyone have any info on how to encrypted form data? I know how to 
> hash it using MD5, and SHA1, etc... but that is only a one way hash. I 
> dont want to have to loop through all of the possible values to compare 
> the hashes as that could get to be expensive.
> 
> Any suggestions?

The standard http://www.djangoproject.com/documentation/csrf/ CSRF 
protection middleware does something like that.

Don't know details but could look there.

If you're gonna 1way hash things such as 'id' and worry about speed then 
store the 1way hashed value in database and do your lookups on that.

-- 
Norman J. Harman Jr.  512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

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

2008-05-15 Thread J . Pablo Fernández

I would have thought Django did it by itself, or actually, manage.py.
After all, when I do manage.py shell, the pythonpath seems to be
correct for me to do import bonvortaro.

On May 15, 8:20 am, Alex Morega <[EMAIL PROTECTED]> wrote:
> On May 15, 2008, at 09:52 , J. Pablo Fernández wrote:
>
> > ImportError: 'No module named bonvortaro'
>
> > In the process of getting the commands, it tries to import the package
> > and it fails. I could try setting up the pythonpath or something like
> > that, but that would be only a workaround. There should be a better
> > solution (and doesn't everybody have this same problem?)
>
> You have to set your pythonpath to include your project. Or you can  
> symlink/move your project to a folder on the python path.
>
> In production, if you use mod_python or mod_wsgi, you can set the  
> pythonpath using their configuration options. What I do, for quick  
> development, is modify manage.py to set its own pythonpath. Add  
> something like this before the line  "from django.core.management  
> import execute_manager":
>
> import sys
> sys.path.append('/the/path/to/my/project')
>
> Cheers,
> -- Alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: encrypting form data

2008-05-15 Thread Mike Chambers

The value is encrypted in the form. The secret key, used to either 
decrypt or hash the value, is on the server, and not in the form.

My application does not have the concept of logged in users.

mike

jonknee wrote:

> 
> How would that help if the "secret" value was in the form already?
> Bots and what not would see it all the same. If you want to stop spam
> posts (which is what I'm assuming you're up to) you can limit comments
> to logged in users, run the data through something like Akismet, use a
> CAPTCHA, etc. But obfuscating the ID is not going to accomplish much--
> if it's available in the HTML that means a bot is going to see it to.
> 
> You're probably better off just limiting users to X comments per hour
> or something.

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



passing a string to model.objects.filter() method

2008-05-15 Thread M.Ganesh

Hi All

#my function code
def object_list(request, object, filter_string = None):
if filter:
object_list = object.objects.filter(filter_string)
else:
object_list = object.objects.all()
   
return render_to_response(object.__name__ + '_list.html',
  {object.__name__ + '_list': object_list},
  RequestContext(request))

When I call this with a string value for filter_string like below:

def location_list(request):
if request.has_key('entity'):
return object_list(request, location, 'entity_id=' + 
request['entity'])
else:
return object_list(request, location)
   
I get the following error message.

'unicode' object has no attribute 'get_sql'



How to pass on a string to the filter() method?

Thanks in advance

Regards Ganesh


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

2008-05-15 Thread jonknee


On May 15, 2:02 pm, Mike Chambers <[EMAIL PROTECTED]> wrote:
> Sorry for not being more specific.
>
> I am talking about data in hidden fields:
>
> 
>
> I would like to encrypt the value.
>
> I could hash it using md5 or sha1 and a secret key, and then on the
> server, loop through the values in the DB to find the match. But that
> does not seem very performant.
>
> I could also store the hash in the DB, but then if for some reason my
> secret key changes, all of that data becomes useless.
>
> The values would not be viewable. Instead of:
>
> 
>
> it would be
>
>  value="dflif8hf534iublfjsdblfsdjhvbfdsjhl" />
>

How would that help if the "secret" value was in the form already?
Bots and what not would see it all the same. If you want to stop spam
posts (which is what I'm assuming you're up to) you can limit comments
to logged in users, run the data through something like Akismet, use a
CAPTCHA, etc. But obfuscating the ID is not going to accomplish much--
if it's available in the HTML that means a bot is going to see it to.

You're probably better off just limiting users to X comments per hour
or something.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Getting back to the same page after completing a task in another page

2008-05-15 Thread M.Ganesh

Adi Jörg Sieker wrote:
>
> On 13.05.2008, at 16:18, phillc wrote:
>
>>
>> "I am new to web programming"
>> "I am trying to use my own loginpage "
>>
>> is there a reason that contrib.auth doesnt meet your needs?
>>
> Good question. :)
>
> adi
>
Yes, I do agree, these two statements put next to each other sound very 
inconsistent. My reasons for having a my own login page:
1. I trying to develop an address book kind of application for our 
internal use.
2. It turns out I am mostly doing CRUD.
3. Actually 'admin as the app' should suit my requirement. The catch 
was, I want to show only selected models to the selected people, where 
as the admin (with oldforms) shows all the models. Of course I can auth 
middleware to restrict access, but people will know what models exist.
4. newforms-admin was promising, but I got repeatedly bitten by a bug 
which was about some modules getting reloaded more than once (sorry, I 
don't remember the ticket number, but the ticket confirm it to be a yet 
to be fixed bug)
5. So I decided to roll-out my own admin kind of functionality, but 
without nice css formatting etc (Frankly I don't know css yet)
6. The login page that comes with contrib.auth is too colourful compared 
to other pages, and also exposes the admin page to the users unnecessarily.
The reason may be unconvincing, but that is what it is.

Anyway thanks for having a close look

Regards Ganesh


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: MySQL Boolean vs. PostgresQL Boolean

2008-05-15 Thread Scott Moonen
You should find that Django's BooleanField understands the difference
between the databases and does the right thing.

  -- Scott

On Thu, May 15, 2008 at 1:57 PM, Szaijan <[EMAIL PROTECTED]> wrote:

>
> Hi, I developed my first Django app on my mapbook using PostgreSQL and
> have recently moved it to a production site which uses MySQL.
> PostgreSQL stores boolean values and True and False, just like Python
> and JS, while MySQL uses 1 and 0.
>
> Is there some automated way to get the models to understand this and
> present/save boolean values to and from views, or do I need to
> override the save and get methods so that they translate 0 to False, 1
> to True, and vice versa?  This seems to be a barrier to portability if
> I have to hard code DB awareness into my models.
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

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



Re: error with custom sql

2008-05-15 Thread msoulier

On May 15, 2:13 pm, msoulier <[EMAIL PROTECTED]> wrote:
> Actually, it fails in the Django shell, and there only, regardless of
> the db backend.

Oh, scratch that. I just got it to fail consistently in a simple
script that runs only that code.

So, custom SQL in Django can't include a LIKE statement with a %
unless it's escaped? I'm
looking in the docs and I can't seem to find anything that mentions
that.

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

2008-05-15 Thread Marty Alchin

On Thu, May 15, 2008 at 12:29 PM, Chris Farley <[EMAIL PROTECTED]> wrote:
> My Django app needs to read a cookie that is written by a JavaScript
> script in another part of my website. The JavaScript code that
> generates the cookie is something like this:
>
> document.cookie='ShoppingCart=[7008|2][7120|3]; path=/;
> domain=mydomain.com';
>
> I can see the cookie and its content from Firefox and Safari when I
> "view cookies". Django's request.COOKIES dictionary contains a key for
> the 'ShoppingCart' cookie, but the content is always an empty string.
>
> Is this a feature or a bug?

I'm not sure if it's a feature or a bug, but it's certainly not
Django's doing. If you try the following in a Python shell, you'll see
that this behavior is part of Python's own cookie handling.

>>> from Cookie import SimpleCookie
>>> SimpleCookie('ShoppingCart=[7008|2][7120|3]; path=/; domain=mydomain.com')


But, if you quote the cookie's value ...

>>> SimpleCookie('ShoppingCart="[7008|2][7120|3]"; path=/; domain=mydomain.com')


I don't know if it'd be easier for you to quote the value or just
avoid square brackets (since that's where SimpleCookie seems to
choke), but it looks like it should be easy enough to work around.

-Gul

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

2008-05-15 Thread msoulier

On May 14, 10:27 pm, msoulier <[EMAIL PROTECTED]> wrote:
> This seems to work in production with postgreSQL, but on my laptop
> with sqlite I'm seeing an issue.

Actually, it fails in the Django shell, and there only, regardless of
the db backend.

Can anyone think of why?

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

2008-05-15 Thread Mike Chambers

Sorry for not being more specific.

I am talking about data in hidden fields:



I would like to encrypt the value.

I could hash it using md5 or sha1 and a secret key, and then on the 
server, loop through the values in the DB to find the match. But that 
does not seem very performant.

I could also store the hash in the DB, but then if for some reason my 
secret key changes, all of that data becomes useless.

The values would not be viewable. Instead of:



it would be



And searching on google and this list, only turned up one way hashes.

mike


Richard Dahl wrote:
> I am not sure what you mean by 'passed through the form', are you
> reffering to some sort of hidden form-field?  I am not sure exactly
> how encryption of these two fields is going to help you.  If the form
> processing view is publicly available, and these two values are
> availble to a user (or script) then whether they are encrypted or not
> they can be captured and submitted.  This would help if you encrypted
> the values with something else, like some piece of information
> concerning the logged-in user, but you could much easier just limit
> the form processing to logged in users and if you see activity on an
> account that suggests script-based submissions, disable the offending
> account.
> 
> There are python implementations of various encryption algorithms as
> well as some javascript functions.  I would try google-ing for these,
> if you think this will help.
> hth,
> -richard
> 
> 
> On 5/15/08, Mike Chambers <[EMAIL PROTECTED]> wrote:
>> I have a commenting app that requires that the item id, and content type
>> id be passed through the form.
>>
>> This works fine, but i would like to encrypt that data to make it a
>> little more difficult for people to programatically submit the form.
>>
>> Does anyone have any info on how to encrypted form data? I know how to
>> hash it using MD5, and SHA1, etc... but that is only a one way hash. I
>> dont want to have to loop through all of the possible values to compare
>> the hashes as that could get to be expensive.
>>
>> Any suggestions?
>>
>> mike
>>
> 
> > 

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



Boolean Values: PostgreSQL vs. MySQL

2008-05-15 Thread Szaijan

Hi, I developed my first Django app on my Macbook Pro using PostgreSQL
and
have recently moved it to a production site which uses MySQL.
PostgreSQL stores boolean values as True and False, just like Python
and JS, while MySQL uses 1 and 0.

Is there some automated way to get the models to understand this and
present/save boolean values to and from views, or do I need to
override the save and get methods so that they translate 0 to False, 1
to True, and vice versa?  This seems to be a barrier to portability if
I have to hard code DB awareness into my models.

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



MySQL Boolean vs. PostgresQL Boolean

2008-05-15 Thread Szaijan

Hi, I developed my first Django app on my mapbook using PostgreSQL and
have recently moved it to a production site which uses MySQL.
PostgreSQL stores boolean values and True and False, just like Python
and JS, while MySQL uses 1 and 0.

Is there some automated way to get the models to understand this and
present/save boolean values to and from views, or do I need to
override the save and get methods so that they translate 0 to False, 1
to True, and vice versa?  This seems to be a barrier to portability if
I have to hard code DB awareness into my models.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: encrypting form data

2008-05-15 Thread Richard Dahl

I am not sure what you mean by 'passed through the form', are you
reffering to some sort of hidden form-field?  I am not sure exactly
how encryption of these two fields is going to help you.  If the form
processing view is publicly available, and these two values are
availble to a user (or script) then whether they are encrypted or not
they can be captured and submitted.  This would help if you encrypted
the values with something else, like some piece of information
concerning the logged-in user, but you could much easier just limit
the form processing to logged in users and if you see activity on an
account that suggests script-based submissions, disable the offending
account.

There are python implementations of various encryption algorithms as
well as some javascript functions.  I would try google-ing for these,
if you think this will help.
hth,
-richard


On 5/15/08, Mike Chambers <[EMAIL PROTECTED]> wrote:
>
> I have a commenting app that requires that the item id, and content type
> id be passed through the form.
>
> This works fine, but i would like to encrypt that data to make it a
> little more difficult for people to programatically submit the form.
>
> Does anyone have any info on how to encrypted form data? I know how to
> hash it using MD5, and SHA1, etc... but that is only a one way hash. I
> dont want to have to loop through all of the possible values to compare
> the hashes as that could get to be expensive.
>
> Any suggestions?
>
> mike
>
> >
>

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

2008-05-15 Thread mintuk

Hi,

I have a resource (an Experiment, for instance), that requires an
exact number of Players to play, 5 say.  The idea is that the
Experiment resource sits there accepting requests from Players to play
until it has the correct number of Players - no more and no less.

I've implemented this as follows:

a Player requests to play by visiting: experiment/{experiment_name}/
start
the associated view calls an add_player(p) method on the named
Experiment object

class Experiment:
  players = models.ManyToManyField(Player...)
  required_players = models.PositiveIntegerField()
  ...
  def add_player(self,p):
if |self.players| < self.required_players then
  self.players.add(p)
  if |self.players| == required_players:
# 
  self.save()

My problem is: is there any way to make this function atomic? i.e.
consider the case where the Experiment only requires one more Player,
and two Players make requests at the same time, then provided the
second passes the |Players| < 5 test before the first writes, then
they'll both be added, violating my Model.

>From what I understand of django.db.transaction, this wouldn't protect
me from the above situation, since it only protects commits to the
database.  Is that correct?

Thanks for your time,

Ian Murray.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: IntegerField - SQL type changed?

2008-05-15 Thread Amit Ramon

* Marty Alchin <[EMAIL PROTECTED]> [2008-05-15 10:45 -0400]:
> 
> On Thu, May 15, 2008 at 10:25 AM, Amit Ramon <[EMAIL PROTECTED]> wrote:
> > Now, if I subclass an existing field and I want to define the database type 
> > myself, how do I do that? Is there a place to add mapping between a name 
> > returned by get_internal_type and a database type, like in creation.py?
> 
> Well, there are two ways to do it. First, like you now know,
> get_internal_type() is preferred, if there's an existing mapping that
> suits your needs. That allows the field to be used with multiple
> databases, which is a big plus.
> 
Thanks again for your elaborated answer. I did learn a couple of new things...

I asked this question not because I cannot find an existing mapping - currently 
the db type of django's PhoneNumberField is perfectly fine for what I need - 
but because I wanted to be sure I'm using a type that won't change. I feel 
confident to use generic types, but I was hesitating to use an existing 
mapping, which was created for some specialized field (for instance, what will 
happen if the implementation of django's PhoneNumberField will be modified in a 
way that would break my code...). It might be I'm just too suspicious.

Anyway, for now I'll just go with the existing mapping.

Many thanks again,

Amit

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

2008-05-15 Thread Michael Pryfogle

Thanks for the pointer, I swear I had tried that quite a few times;
but it started me in the right direction. I had a few issues with my
__init__ declaration as well. I'll clean it up and post it on django
snippets.

On May 15, 11:18 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, May 15, 2008 at 10:53 AM, mikelostcause <[EMAIL PROTECTED]> wrote:
>
> > I have been searching and unable to find out why my script is not
> > working correctly
>
> > If i take the required = False off of the image, the error "This field
> > is required" get's thrown,  else the 'image' field seems to not exist
> > in the data as I now get 'No Data in Cleaned Data' error from the
> > clean_image function.
>
> > Changing my image_clean function to pass back
> > self.cleaned_data['image'] no matter what:
> > post_data: {u'overview': [u''], u'image': [{'content': '',
> > 'content-type': 'image/jpeg', 'filename': 'test.jpg'}], u'blurb':
> > [u''], u'title': [u'Test 3']}
>
> > cleaned_data: {'blurb': u'', 'image': None, 'overview': u'', 'public':
> > False, 'team': [], 'title': u'Test 3'}
>
> > So the image looks to be in my post_data passed to the form, but it
> > doesn't seem to make it out of the cleaning process.
>
> > *** In my view 
> > if pk:
> > object_instance =
> > get_object_or_404(model_class.objects.filter(parent_object=parent_object),
> > pk=pk)
> > else:
> > object_instance = model_class()
>
> > if request.POST or request.FILES:
> > post_data = request.POST.copy()
> > post_data.update(request.FILES)
> > form = ImportedModelForm(data=post_data,
> > instance=object_instance, parent_object=parent_object)
>
> > if form.is_valid():
> >  clean_data = form.cleaned_data
> >  error_list = form._errors
>
> >  return render_to_response('template.html', {'profile':
> > request.user, 'staff': staffUser, parent_object parent_object 'form':
> > form, 'clean_data': clean_data, 'error_list': error_list })
>
> > * In my forms *
> > class ImportedModelForm(forms.ModelForm):
> >image = forms.FileField(widget = forms.FileInput, required=False)
>
> >def __init__(self, parent_object=None, *args, **kwargs):
> >super(ImportedModelForm, self).__init__(*args, **kwargs)
> >self.fields['team'].queryset =
> > Team.objects.filter(parent_object=parent_object)
>
> >def clean_image(self):
> >if self.cleaned_data.get('image'):
> >image_data = self.cleaned_data['image']
> >return image_data
> >else:
> >raise forms.ValidationError(_('No Data in Cleaned
> > Data'))
>
> >class Meta:
> >model = ImportedModel
> >exclude = ('object1', 'object2')
>
> You're not following the correct recipe for binding uploaded file data to a
> form.  See:
>
> http://www.djangoproject.com/documentation/newforms/#binding-uploaded...
>
> 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
-~--~~~~--~~--~--~---



Strange cookie problem

2008-05-15 Thread Chris Farley

My Django app needs to read a cookie that is written by a JavaScript
script in another part of my website. The JavaScript code that
generates the cookie is something like this:

document.cookie='ShoppingCart=[7008|2][7120|3]; path=/;
domain=mydomain.com';

I can see the cookie and its content from Firefox and Safari when I
"view cookies". Django's request.COOKIES dictionary contains a key for
the 'ShoppingCart' cookie, but the content is always an empty string.

If I change the content of the cookie to something else, Django can
see it!

document.cookie='ShoppingCart=ssdf; path=/; domain=mydomain.com';

Is this a feature or a bug? I can certainly use different delimiters
in my cookie if there's something weird about brackets or pipe
symbols. Other webapps (JavaScript and Java Struts) read this cookie
with 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
-~--~~~~--~~--~--~---



Re: Strange New Forms Issue

2008-05-15 Thread Chris

Hi Karen,

I have a form with first_name, last_name and email and once the user
presses submit, it will then save the 3 required fields to the
database and send the data to another form containing additional
fields suchas year_of_birth, phone_number, address,city, state, etc...
The 3 required fields have already been filled out by a user in the
first form, the next form it sends data to contains optional fields. I
am not using form wizard either, just a render_to_response that passes
data to the next form. Why it works on my local dev and not on the
company dev makes no sense.

model field declaration looks like this:

year_of_birth = models.IntegerField(blank=True, null=True,
choices=YEAR_OF_BIRTH)

also I I noticed when I take out the ChoicesField altogether it seems
to process fine or if I change field to a textfield it works too.

Thanks for helping me with this strange issue.

Chris



On May 15, 9:38 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, May 14, 2008 at 6:14 PM, Chris <[EMAIL PROTECTED]> wrote:
>
> > Hello I created a new forms form and I am having uses with this
> > statement:
>
> >year_of_birth = forms.ChoiceField(required=False,
> > choices=YEAR_OF_BIRTH)
>
> > and tuple looks like so:
> >year_of_birth = ((1990, '1990'), (1989, '1989'), ...)
>
> > On my local dev server, I have latest django and use sqllite, this
> > works fine but when I push code to our company dev server and try to
> > run code it, it breaks and give me the following message. On the
> > company dev we use mysql. This almost looks like it could be a mysql
> > specific bug but the error is so vague who knows. I don't understand
> > how I can pass a tuple through and it think that I am giving it a ''
> > value.
>
> > Exception Type: Warning
> > Exception Value:Incorrect integer value: '' for column
> > 'year_of_birth' at row 1
> > Exception Location: /usr/lib/python2.5/site-packages/MySQLdb/
> > cursors.py in _warning_check, line 80
>
> > Could someone please help. This error is driving me crazy!
>
> > Thanks in advance.
>
> You don't mention when you get this error: all of the time, regardless of
> the choice, only when the 'blank' choice is chosen, etc?  MySQL is
> complaining that it is being handed and empty string to put in an integer
> field.  I notice you have required=False on the form field, so I'd guess you
> are seeing this only when the 'blank' choice is chosen, in which case I
> suspect the fix would be to specify null=True in the model field, so that
> blank will be stored as null in the database.
>
> 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
-~--~~~~--~~--~--~---



Displaying a many to many relationship using checkboxes...

2008-05-15 Thread Gabriel

Hi all

I have a model called Task and a model called User. Between them is a many to
many relationship to simulate assigning tasks to users.

Basically I want to list all tasks in an HTML page. Each task will then have a
set of checkboxes representing every user, if that particular user is already
linked to that particular task then the checkbox should be ticked.

I have managed to do this, but using a really ugly hack, and I'm hoping for some
advice on how to better go about it. What I did was create a template filter
called is_assigned() using this code:
@register.filter
def is_assigned( user_id, task_id ):
"""We want to find out whether the given user ID is assigned to the given
task."""
task = Task.objects.filter( id = task_id ).get()
users = task.users.values( 'id' )
ids = []
for i in users: ids.append( i['id'] )
if user_id in ids: return True
else: return False

The view passes the template variables containing all users called all_users,
and all tasks called all_tasks. In the template I have the following code that
will set the checkbox to checked depending on whether the user is linked to the
task:
{% for task in all_tasks %}
{% for user in all_users %}

{% endfor %}
{% endfor %}

How might I refactor all this code to make it more efficient and generally
 better?

Thanks

Gabriel


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



encrypting form data

2008-05-15 Thread Mike Chambers

I have a commenting app that requires that the item id, and content type 
id be passed through the form.

This works fine, but i would like to encrypt that data to make it a 
little more difficult for people to programatically submit the form.

Does anyone have any info on how to encrypted form data? I know how to 
hash it using MD5, and SHA1, etc... but that is only a one way hash. I 
dont want to have to loop through all of the possible values to compare 
the hashes as that could get to be expensive.

Any suggestions?

mike

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 3000 support, any plans?

2008-05-15 Thread Quentin Gallet-Gilles
On Thu, May 15, 2008 at 5:16 PM, David Zhou <[EMAIL PROTECTED]> wrote:

>
> On May 15, 2008, at 10:57 AM, mardenet wrote:
>
> > I am very interested in Python and Django for a future project but  I
> > am noticing this is a period of big changes in this community. Python
> > 3000 and Django 1.0 will really be a major change.
>
> They will be big changes, but don't really align in terms of timeline.
>
> > I am not afraid of using Alpha versions, and I want to use latest
> > technologies and my mind rejects any forced changes in the code due to
> > new releases. If I do something I don't want to touch it again.
> > So I want to start straight with Python 3000.
>
> Even if you coded in Python 3000, it's not like Django doesn't
> sometimes introduce backwards incompatible changes. Plus, I highly
> doubt any serious effort will be made to make sure Django works on
> Python 3000 until after Django 1.0 and (likely) until after Python
> 3000 exits alpha state.
>
> > Would this be compatible with Djanga? If not when do you expect it to
> > be compatible?
> > I prefer waiting than recoding, so I wanted an idea on timelines...
> > any thoughts?
>
> I'd posit with fair confidence that Django 1.0 will come long, long
> before Python 3000 reaches a non-alpha state.
>

> If you want to use Django for something, I'd start now -- or with
> 1.0.  Waiting for Python 3000 is a bit silly.
>

> ---
> David Zhou
> [EMAIL PROTECTED]
>
>

Django'd better hurry, because the first beta release of Python 3000 is due
next month ! And the final release is scheduled for September.

However, that's just a start. Porting the libraries (batteries excluded, of
course) is the next big step and it is expected that we will have to wait
for 3.1 or 3.2 before the major libraries and frameworks are all ported.

Anyway, I agree it's silly to wait for Python 3000. The 2.x release is not
that different and everything is done to make adjusting to Python 3000 as
seamless as possible.


Quentin

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



newforms-admin: {{ original.exemplar_text }} Object Error

2008-05-15 Thread mbdtsmh

Hi all,

I'm using the newforms-admin branch and have come across this
annoyance.

When I am trying to add a custom form value to the form text; i.e.,

{{ original.exemplar_text }}

it gives me an Object expected error.

This causes certain javascript elements that are also on the page not
to display properly (calendar & horizontal_filter to be specific).

When I remove this line or indeed if the value is "" then the calendar
& horizontal_filter js elements load and no error in the page occurs.

I'm nearly finished my prototype so this is the last piece of the
puzzle if anyone could help me out?!

Thanks,

Martin


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

2008-05-15 Thread Karen Tracey
On Thu, May 15, 2008 at 10:53 AM, mikelostcause <[EMAIL PROTECTED]> wrote:

>
> I have been searching and unable to find out why my script is not
> working correctly
>
> If i take the required = False off of the image, the error "This field
> is required" get's thrown,  else the 'image' field seems to not exist
> in the data as I now get 'No Data in Cleaned Data' error from the
> clean_image function.
>
> Changing my image_clean function to pass back
> self.cleaned_data['image'] no matter what:
> post_data: {u'overview': [u''], u'image': [{'content': '',
> 'content-type': 'image/jpeg', 'filename': 'test.jpg'}], u'blurb':
> [u''], u'title': [u'Test 3']}
>
> cleaned_data: {'blurb': u'', 'image': None, 'overview': u'', 'public':
> False, 'team': [], 'title': u'Test 3'}
>
> So the image looks to be in my post_data passed to the form, but it
> doesn't seem to make it out of the cleaning process.
>
>
>
> *** In my view 
> if pk:
> object_instance =
> get_object_or_404(model_class.objects.filter(parent_object=parent_object),
> pk=pk)
> else:
> object_instance = model_class()
>
> if request.POST or request.FILES:
> post_data = request.POST.copy()
> post_data.update(request.FILES)
> form = ImportedModelForm(data=post_data,
> instance=object_instance, parent_object=parent_object)
>
> if form.is_valid():
>  clean_data = form.cleaned_data
>  error_list = form._errors
>
>  return render_to_response('template.html', {'profile':
> request.user, 'staff': staffUser, parent_object parent_object 'form':
> form, 'clean_data': clean_data, 'error_list': error_list })
>
> * In my forms *
> class ImportedModelForm(forms.ModelForm):
>image = forms.FileField(widget = forms.FileInput, required=False)
>
>def __init__(self, parent_object=None, *args, **kwargs):
>super(ImportedModelForm, self).__init__(*args, **kwargs)
>self.fields['team'].queryset =
> Team.objects.filter(parent_object=parent_object)
>
>def clean_image(self):
>if self.cleaned_data.get('image'):
>image_data = self.cleaned_data['image']
>return image_data
>else:
>raise forms.ValidationError(_('No Data in Cleaned
> Data'))
>
>class Meta:
>model = ImportedModel
>exclude = ('object1', 'object2')
>

You're not following the correct recipe for binding uploaded file data to a
form.  See:

http://www.djangoproject.com/documentation/newforms/#binding-uploaded-files-to-a-form

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: Python 3000 support, any plans?

2008-05-15 Thread David Zhou

On May 15, 2008, at 10:57 AM, mardenet wrote:

> I am very interested in Python and Django for a future project but  I
> am noticing this is a period of big changes in this community. Python
> 3000 and Django 1.0 will really be a major change.

They will be big changes, but don't really align in terms of timeline.

> I am not afraid of using Alpha versions, and I want to use latest
> technologies and my mind rejects any forced changes in the code due to
> new releases. If I do something I don't want to touch it again.
> So I want to start straight with Python 3000.

Even if you coded in Python 3000, it's not like Django doesn't  
sometimes introduce backwards incompatible changes. Plus, I highly  
doubt any serious effort will be made to make sure Django works on  
Python 3000 until after Django 1.0 and (likely) until after Python  
3000 exits alpha state.

> Would this be compatible with Djanga? If not when do you expect it to
> be compatible?
> I prefer waiting than recoding, so I wanted an idea on timelines...
> any thoughts?

I'd posit with fair confidence that Django 1.0 will come long, long  
before Python 3000 reaches a non-alpha state.

If you want to use Django for something, I'd start now -- or with  
1.0.  Waiting for Python 3000 is a bit silly.

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



Re: which python version?

2008-05-15 Thread Valts Mazurs
Latest stable Python version.
Currently it is Python 2.5.2

Regards,
Valts.

On Thu, May 15, 2008 at 6:03 PM, bcurtu <[EMAIL PROTECTED]> wrote:

>
> Which python version do you use with your django project? Any special
> issue with anyone?
>
> Cheers.
> >
>

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



which python version?

2008-05-15 Thread bcurtu

Which python version do you use with your django project? Any special
issue with anyone?

Cheers.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 3000 support, any plans?

2008-05-15 Thread mardenet

Hello,
I am new to Python and Django, I am a ASP.NET C# programmer actually
tired of following Microsoft's unnatural and crazy page model that
tries to hide the page from you as much as possible.. seriously how
did they came up with that?!

I am very interested in Python and Django for a future project but  I
am noticing this is a period of big changes in this community. Python
3000 and Django 1.0 will really be a major change.
I am not afraid of using Alpha versions, and I want to use latest
technologies and my mind rejects any forced changes in the code due to
new releases. If I do something I don't want to touch it again.
So I want to start straight with Python 3000.

Would this be compatible with Djanga? If not when do you expect it to
be compatible?
I prefer waiting than recoding, so I wanted an idea on timelines...
any thoughts?

Thanks

mardenet

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



File Upload Issues - ModelForm

2008-05-15 Thread mikelostcause

I have been searching and unable to find out why my script is not
working correctly

If i take the required = False off of the image, the error "This field
is required" get's thrown,  else the 'image' field seems to not exist
in the data as I now get 'No Data in Cleaned Data' error from the
clean_image function.

Changing my image_clean function to pass back
self.cleaned_data['image'] no matter what:
post_data: {u'overview': [u''], u'image': [{'content': '',
'content-type': 'image/jpeg', 'filename': 'test.jpg'}], u'blurb':
[u''], u'title': [u'Test 3']}

cleaned_data: {'blurb': u'', 'image': None, 'overview': u'', 'public':
False, 'team': [], 'title': u'Test 3'}

So the image looks to be in my post_data passed to the form, but it
doesn't seem to make it out of the cleaning process.



*** In my view 
if pk:
 object_instance =
get_object_or_404(model_class.objects.filter(parent_object=parent_object),
pk=pk)
else:
 object_instance = model_class()

if request.POST or request.FILES:
 post_data = request.POST.copy()
 post_data.update(request.FILES)
 form = ImportedModelForm(data=post_data,
instance=object_instance, parent_object=parent_object)

 if form.is_valid():
  clean_data = form.cleaned_data
  error_list = form._errors

  return render_to_response('template.html', {'profile':
request.user, 'staff': staffUser, parent_object parent_object 'form':
form, 'clean_data': clean_data, 'error_list': error_list })

* In my forms *
class ImportedModelForm(forms.ModelForm):
image = forms.FileField(widget = forms.FileInput, required=False)

def __init__(self, parent_object=None, *args, **kwargs):
super(ImportedModelForm, self).__init__(*args, **kwargs)
self.fields['team'].queryset =
Team.objects.filter(parent_object=parent_object)

def clean_image(self):
if self.cleaned_data.get('image'):
image_data = self.cleaned_data['image']
return image_data
else:
raise forms.ValidationError(_('No Data in Cleaned 
Data'))

class Meta:
model = ImportedModel
exclude = ('object1', 'object2')
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Search Result Pagination

2008-05-15 Thread Michael Ellis

Adi. That got the pagination working on the first page! Thank you!

I'm getting no results on page 2, however. I know this is in the way
I'm handling GET requests (see the 'else' statement). I'm just not
sure how this should be handled. I'll be reading some docs and
searching around for a solution.

Thanks again!
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
-~--~~~~--~~--~--~---



Re: IntegerField - SQL type changed?

2008-05-15 Thread Marty Alchin

On Thu, May 15, 2008 at 10:25 AM, Amit Ramon <[EMAIL PROTECTED]> wrote:
> Now, if I subclass an existing field and I want to define the database type 
> myself, how do I do that? Is there a place to add mapping between a name 
> returned by get_internal_type and a database type, like in creation.py?

Well, there are two ways to do it. First, like you now know,
get_internal_type() is preferred, if there's an existing mapping that
suits your needs. That allows the field to be used with multiple
databases, which is a big plus.

On the other hand, if there's no existing mapping that's appropriate
for you *and* and you know for a fact that you won't be distributing
this code, then you can write a db_type() method instead. It returns a
string that's used to create the column in the database directly.
Internally, db_type() is where Django does the get_internal_type()
mapping, so it providing your own db_type() will completely replace
that process.

Unfortunately, using db_type() means your field will be tightly
coupled to a specific database implementation. If you're only working
on your own stuff that will never be released, that may be fine. But
keep in mind that it also means you can't, for instance, use SQLite in
development and PostgreSQL in production; at least, not without either
changing code between the two, or writing your own code to determine
which environment is being used. All this makes db_type() a bit tricky
to work with, so only go there if you're sure you need it.

-Gul

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: IntegerField - SQL type changed?

2008-05-15 Thread Amit Ramon

* Marty Alchin <[EMAIL PROTECTED]> [2008-05-15 07:15 -0400]:
> 
> On Thu, May 15, 2008 at 6:45 AM, James Bennett <[EMAIL PROTECTED]> wrote:
> > On Thu, May 15, 2008 at 5:34 AM, Amit Ramon <[EMAIL PROTECTED]> wrote:
> >> Was there any change in django in the recent months that could explain 
> >> this? Namely, could it be that a couple of months ago django would indeed 
> >> generate a varchar(20) for this field, and now it generates int(11)?
> >
> > I'll bet money that at the time the table was created you were using
> > Django's built-in PhoneNumberField, which is specified as VARCHAR(20):
> >
> > http://code.djangoproject.com/browser/django/trunk/django/db/backends/mysql/creation.py#L21
> 
> Actually, it wouldn't have mattered if it was Django's own
> PhoneNumberField or not. Prior to [7133] (Feb 18, 2008), Django used
> the name of the field class to determine which entry in creation.py to
> use, regardless of what they inherited from. After that revision,
> however, fields that specify a get_internal_type() will always use
> that value for all their subclasses, regardless of what they're named,
> unless they override it.
> 
> This was in fact detailed on the backwards-incompatible changes
> page,[1] as would be expected. You have two options. Just provide your
> own get_internal_type() to return "PhoneNumberField" or, better yet,
> just inherit from Django's PhoneNumberField. You'll probably get
> better stuff that way, anyway.
> 
> -Gul
> 

Thanks, that was very quick and clear. The problem was probably the lack of 
get_internal_type() (James, you would've lose). Now, if I subclass an existing 
field and I want to define the database type myself, how do I do that? Is there 
a place to add mapping between a name returned by get_internal_type and a 
database type, like in creation.py?

Thanks again,

Amit

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: where does this caching come?

2008-05-15 Thread Norman Harman

Alex Morega wrote:
> On May 15, 2008, at 02:24 , David Zhou wrote:
>> Are you restarting the server between module changes?
> 
> By default Django does no caching of responses. It's probably what  
> Viktor says: the server (mod_python, mod_wsgi, whatever) won't  
> automatically reload the python code if you change it. The automatic  
> reload behaviour only happens with Django's built-in development server.

Not strictly true.  With mod_python there's a directive to control 
whether apache automatically reloads python code.  You *don't* want to 
set this on for production code(large performance penalty).

 PythonAutoReload On

I'm guessing mod_wsgi and others have something similar.


-- 
Norman J. Harman Jr.  512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

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



Re: Help with custom validator - please, please, please

2008-05-15 Thread Brandon Taylor

Hi Maciej,

Yes, I've looked at the validator-list code before, but I don't
understand how to implement it.

The example code is:
from django.core import validators
from django import forms

class ContactManipulator(forms.Manipulator):
def __init__(self):
self.fields = (
# ... snip fields as above ...
forms.EmailField(field_name="to",
validator_list=[self.isValidToAddress])
)

def isValidToAddress(self, field_data, all_data):
if not field_data.endswith("@example.com"):
raise validators.ValidationError("You can only send
messages to example.com e-mail addresses.")

...but if I wanted to use this with a model I have written, where in
the world does this code go? Is class ContactManipulator a subclass of
my Model? Is the sample code a separate file that I reference? I'm
using the newforms admin, so I'm assuming this code would be a
subclass of my admin.ModelAdmin...? I can hack away at this, but I
want to make sure I'm staying as close to best practices for Django as
I can, and I'm only two months into it.

Thanks for your help and patience,
Brandon

On May 15, 8:05 am, Pigletto <[EMAIL PROTECTED]> wrote:
> On 15 Maj, 03:43, Brandon Taylor <[EMAIL PROTECTED]> wrote:> I saw this 
> example in the 
> documentation:http://www.djangoproject.com/documentation/forms/#validators
>
> > But where does this code live? Does this go into my models.py as a
> > subclass of my Model, or is it a separate file?
>
> Link you've submitted is referenced 
> by:http://www.djangoproject.com/documentation/model-api/#validator-list
>
> You may also take a look at: django/db/models/fields/__init__.py to
> see how validators are processed.
>
> --
> Maciej Wisniowski
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: LatestFreeCommentsFeed

2008-05-15 Thread Matt Davies
Ok, I remember now that in order to output different things in feeds you
specify what to output in the corresponding template in the feeds folder.

I'm guessing that the freecomments is using the tite and description.html
files in the templates/feeds folder.

Can anyone confirm this?  Also, is there any way to overide this behaviour?

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

2008-05-15 Thread Karen Tracey
On Wed, May 14, 2008 at 6:14 PM, Chris <[EMAIL PROTECTED]> wrote:

>
> Hello I created a new forms form and I am having uses with this
> statement:
>
>year_of_birth = forms.ChoiceField(required=False,
> choices=YEAR_OF_BIRTH)
>
> and tuple looks like so:
>year_of_birth = ((1990, '1990'), (1989, '1989'), ...)
>
> On my local dev server, I have latest django and use sqllite, this
> works fine but when I push code to our company dev server and try to
> run code it, it breaks and give me the following message. On the
> company dev we use mysql. This almost looks like it could be a mysql
> specific bug but the error is so vague who knows. I don't understand
> how I can pass a tuple through and it think that I am giving it a ''
> value.
>
> Exception Type: Warning
> Exception Value:Incorrect integer value: '' for column
> 'year_of_birth' at row 1
> Exception Location: /usr/lib/python2.5/site-packages/MySQLdb/
> cursors.py in _warning_check, line 80
>
> Could someone please help. This error is driving me crazy!
>
> Thanks in advance.
>

You don't mention when you get this error: all of the time, regardless of
the choice, only when the 'blank' choice is chosen, etc?  MySQL is
complaining that it is being handed and empty string to put in an integer
field.  I notice you have required=False on the form field, so I'd guess you
are seeing this only when the 'blank' choice is chosen, in which case I
suspect the fix would be to specify null=True in the model field, so that
blank will be stored as null in the database.

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



partially edit an object

2008-05-15 Thread Robin Becker

I have a colleague who wishes to restrict the editability of fields 
dynamically. 
I can see how this arises by considering a Person object. The supervisor role 
might be allowed to edit more than the individual concerned.

We looked in vain for an 'easy' way to do this using old forms, newforms, 
generic views etc etc, but eventually started writing our own views to do this.

Sure I could probably start trying to grok the inner horrors of update_object 
and minulators etc etc, but that seems really overkill for such a simple 
requirement.

I expected to be able to pass in a list of fields that were to be left alone or 
something as easy. Is there no easy way to do these simple extensions; if not 
what's the 'right' way to do this in the various contexts?
-- 
Robin Becker

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

2008-05-15 Thread Chris

Could someone help me out with this error or Warning as it states in
the exception?

On May 14, 6:14 pm, Chris <[EMAIL PROTECTED]> wrote:
> Hello I created a new forms form and I am having uses with this
> statement:
>
> year_of_birth = forms.ChoiceField(required=False,
> choices=YEAR_OF_BIRTH)
>
> and tuple looks like so:
> year_of_birth = ((1990, '1990'), (1989, '1989'), ...)
>
> On my local dev server, I have latest django and use sqllite, this
> works fine but when I push code to our company dev server and try to
> run code it, it breaks and give me the following message. On the
> company dev we use mysql. This almost looks like it could be a mysql
> specific bug but the error is so vague who knows. I don't understand
> how I can pass a tuple through and it think that I am giving it a ''
> value.
>
> Exception Type: Warning
> Exception Value:Incorrect integer value: '' for column
> 'year_of_birth' at row 1
> Exception Location: /usr/lib/python2.5/site-packages/MySQLdb/
> cursors.py in _warning_check, line 80
>
> Could someone please help. This error is driving me crazy!
>
> Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with custom validator - please, please, please

2008-05-15 Thread Pigletto

On 15 Maj, 03:43, Brandon Taylor <[EMAIL PROTECTED]> wrote:
> I saw this example in the 
> documentation:http://www.djangoproject.com/documentation/forms/#validators
>
> But where does this code live? Does this go into my models.py as a
> subclass of my Model, or is it a separate file?
Link you've submitted is referenced by:
http://www.djangoproject.com/documentation/model-api/#validator-list

You may also take a look at: django/db/models/fields/__init__.py to
see how validators are processed.

--
Maciej Wisniowski

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



Formwizard and dynamic initial data

2008-05-15 Thread Hanne Moa

Is Formwizard designed for new content only, or is it possible to use
it for changing existing content? I haven't been able to find an
obvious way to pass in run-time determined initial data anywhere, nor
how to pass in an instance (for ModelForms).

Have anyone found a way to pass in run-time initial or instance data?


HM

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



I18N: date (Python + HTML + Javascript)

2008-05-15 Thread Tourneur Henry-Nicolas

Hi,

I would like to be able to do a clean I18N with date format.
The problem is that the date format (dd/mm/) is used in javascript
(for a date picker), in html (with the template tag now, for its format
too) and in python, to parse a date and transform it into Python date
using python-dateutil.

So I have absolutely no idea about how to do that, can anybody help me ?

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: IntegerField - SQL type changed?

2008-05-15 Thread Marty Alchin

On Thu, May 15, 2008 at 6:45 AM, James Bennett <[EMAIL PROTECTED]> wrote:
> On Thu, May 15, 2008 at 5:34 AM, Amit Ramon <[EMAIL PROTECTED]> wrote:
>> Was there any change in django in the recent months that could explain this? 
>> Namely, could it be that a couple of months ago django would indeed generate 
>> a varchar(20) for this field, and now it generates int(11)?
>
> I'll bet money that at the time the table was created you were using
> Django's built-in PhoneNumberField, which is specified as VARCHAR(20):
>
> http://code.djangoproject.com/browser/django/trunk/django/db/backends/mysql/creation.py#L21

Actually, it wouldn't have mattered if it was Django's own
PhoneNumberField or not. Prior to [7133] (Feb 18, 2008), Django used
the name of the field class to determine which entry in creation.py to
use, regardless of what they inherited from. After that revision,
however, fields that specify a get_internal_type() will always use
that value for all their subclasses, regardless of what they're named,
unless they override it.

This was in fact detailed on the backwards-incompatible changes
page,[1] as would be expected. You have two options. Just provide your
own get_internal_type() to return "PhoneNumberField" or, better yet,
just inherit from Django's PhoneNumberField. You'll probably get
better stuff that way, anyway.

-Gul

[1] 
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedField.get_internal_typedefault

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: IntegerField - SQL type changed?

2008-05-15 Thread James Bennett

On Thu, May 15, 2008 at 5:34 AM, Amit Ramon <[EMAIL PROTECTED]> wrote:
> Was there any change in django in the recent months that could explain this? 
> Namely, could it be that a couple of months ago django would indeed generate 
> a varchar(20) for this field, and now it generates int(11)?

I'll bet money that at the time the table was created you were using
Django's built-in PhoneNumberField, which is specified as VARCHAR(20):

http://code.djangoproject.com/browser/django/trunk/django/db/backends/mysql/creation.py#L21



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

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



Re: custom tag error related to import

2008-05-15 Thread Jonathan Lukens

I *was* importing from datababy.utils.photologue.  (datababy is the
project package.)  Anything I imported from anywhere in the project
path would cause a similar error.  Eventually I went through the
entire project and made every single import absolute -- there were a
few that were relative -- and that did it.  I guess there was a
conflict somewhere.  Thanks for the help!

On May 14, 11:21 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, May 14, 2008 at 6:09 PM, Jonathan Lukens <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > Karen,
>
> > You were right about the .pyc's -- I had Pydev clean them up and the
> > error changed.  Here's the new traceback:
>
> >http://dpaste.com/50033/
>
> > I don't have any other nav.py files -- but anyway, there are other
> > tags in this file, and with the contenttypes workaround, this one
> > works too, so long as I get rid of the import path for the Photo
> > model.
>
> That's because the error is now:
>
> No module named utils.photologue
>
> I assume utils/photologue has an __init__.py file?  Perhaps you need to be
> importing from datababy.utils.photologue not utils.photologue?
>
> Karen
>
>
>
> > On May 14, 3:17 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > On Wed, May 14, 2008 at 10:40 AM, Jonathan Lukens <
> > [EMAIL PROTECTED]>
> > > wrote:
>
> > > > I have a custom tag called {% photo %}.  It takes two arguments: an
> > > > object and a size.
> > > > I've tinkered with django-photologue to use a GenericForeignKey.  The
> > > > tag returns the get_SIZE_url() for the Photo instance associated with
> > > > a given object.  I've posted the code for the tag here:
>
> > > >http://dpaste.com/49892/
>
> > > > This raises an error with the following traceback:
>
> > > >http://dpaste.com/49894/
>
> > > > What is particularly confusing to me is that the line referenced as
> > > > raising the error does not exist anywhere in my code tree.
>
> > > It's got to, the traceback reporting code can't manufacture code that
> > > doesn't exist.  You must have (or have had at one time) a file with this
> > > line:
>
> > > photo = photos.objects.all()[0]
>
> > > somewhere in your tree. Traceback says it is on line 120 of this file:
>
> > /home/jonathan/workspace/datababy/src/datababy/../datababy/templatetags/templatetags/nav.py
>
> > > Notice the two "templatetags" on the end, since you have an app named
> > > datababy.templatetags and then Django adds another 'templatetags' on the
> > end
> > > when it's searching for template tag libraries.  Now, there is some
> > > screwiness in the way Django searches for and loads template tag
> > libraries,
> > > but I don't think that could mess up the reporting of what code was
> > running
> > > in the traceback.  But I could be wrong -- if that file really does not
> > have
> > > the line listed, then perhaps there is another nav.py file in a
> > templatetags
> > > subdirectory of one of your other apps that is the one that is actually
> > > being used?  If I were you I would delete all .pyc files from my tree and
> > > search and verify that there was one and only one nav.py file to be found
> > > anywhere.
>
> > > Karen
>
> > > Stranger
>
> > > > yet is the fact that if I fiddle with contenttypes to access the Photo
> > > > model without the import path, everything works exactly as intended.
> > > > I don't want to do this permanently, however, both because I would
> > > > like to know what I'm doing wrong and because this is an extra hit on
> > > > the database.
>
> > > > I would gladly provide any more information if anyone is able to
> > > > assist.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



IntegerField - SQL type changed?

2008-05-15 Thread Amit Ramon

Hello,

A couple of months ago I created a custom field class which inherited 
models.IntegerField:

class PhoneNumberField(models.IntegerField)

What this class does is simply verifying a correct format for its data. Today I 
tried to use it in a new model, and I noticed that the database column for this 
field is created as int(11). I looked at a couple of months old database, for a 
model that was also using this field, and I found that in the old database the 
column was created as varchar(20).

I didn't make any changes to the above class since first creating it.

The database is MySql, and the current django revision I'm using is 7435. I 
don't know what was the older revision.

Was there any change in django in the recent months that could explain this? 
Namely, could it be that a couple of months ago django would indeed generate a 
varchar(20) for this field, and now it generates int(11)?

I looked at the list of incompatible changes but could not find a clue.

Thanks,

Amit

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



all about softwere

2008-05-15 Thread candra

www.candraheryani.blogspot.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: Cusom SQL in test

2008-05-15 Thread Vitaliy



On May 15, 12:08 pm, Alex Morega <[EMAIL PROTECTED]> wrote:
> IPBlock.objects.all().count()
Yea, I know it's just a typo...
The table is realy empty, I checked it by all() and I looked directly
into db.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Cusom SQL in test

2008-05-15 Thread Alex Morega


On May 15, 2008, at 11:56 , Vitaliy wrote:

> but when i run tests '$python manage.py test' - IPBlock's table is
> empty (self.assertTrue(IPBlock.objects.all().count > 0) - failed)

"count" is a method - you need to write smth like  
IPBlock.objects.all().count()
You can also skip the .all() part, but it should work either way.


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



Cusom SQL in test

2008-05-15 Thread Vitaliy

Hi

I created model called 'IPBlock'
I created file 'sql/IPBlock.slq' with some sql inserts
when I run '$python manage.py syncdb' - it works fine IPBlock's table
filled with data
but when i run tests '$python manage.py test' - IPBlock's table is
empty (self.assertTrue(IPBlock.objects.all().count > 0) - failed)

(db backends: mysql, sqlite3)

So what does I need to do to install cusomt sql in test ?

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



LatestFreeCommentsFeed

2008-05-15 Thread Matt Davies
Hello peeps

I've got a news applications that is accepting comments on the posts.

I need to build a feed of the comments so I can monitor them and answer any
questions asked in the comments.

So, in my main URLS file I'm doing this

from django.contrib.comments.feeds import LatestFreeCommentsFeed

feeds = {
'latestcomments': LatestFreeCommentsFeed,
}

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

Now when people are adding a comment to a news item, I'm getting an updated
feed.  But it shows as FreeComment Object instead of the comment text.

Can anyone point me in the right direction here?  I think I'm getting myself
a bit confused.

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