Re: variable tag / filter

2008-10-23 Thread ramya

I wanted to write one all purpose generic template..

Now I have split that and extended multiple specific templates.. :(

Thanks,
~ramyak/


On Oct 23, 6:34 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
> To my knowledge, no, it's not possible to do that.  Even if it was,
> however, I would strongly argue against it, as it would make your
> templates unreadable--how would you know what filter/tag would be
> called without mucking through the rest of your code? Maybe there's a
> better way to get the effect you want--what are you trying to achieve?
>
> -Jeff
>
> On Oct 23, 6:59 am, ramya <[EMAIL PROTECTED]> wrote:
>
> > Is it possible to have variable tags / filters
>
> > {{ my_value | my_filter }}
> > where c['my_filter'] = 'formatDateTime'
> > formatDateTime is the actual filter function defined in templatetags
>
> > similarly
>
> > {{ my_tag my_filter }}
> > where c['my_tag'] = 'formatDateTime'
> > formatDateTime is the actual tag function defined in templatetags
>
> > say in both the cases  formatDateTime is registered tag/filter and has
> > been loaded
>
> > Regards,
> > ~ramyak/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with contrib.comments and signals: instance is not defined

2008-10-23 Thread Malcolm Tredinnick


On Thu, 2008-10-23 at 21:23 -0700, Brandon Taylor wrote:
> Hi everyone,
> 
> I'm using Django 1.0, and attempting to do some comment moderation
> with Akismet. When I try to wire up a pre_save signal, I'm getting an
> error saying 'instance' is not defined. Here is my code:
> 
> def moderate_comment(sender, **kwargs):
> if not instance.id:  # <-- instance is not defined

Which is correct. kwargs['instance'] may well be defined, however.

Python doesn't put kwargs keys into the local namespace, since that
would lead to no end of confusion and conflicts.

Regards,
Malcolm



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



Re: variable tag / filter

2008-10-23 Thread ramya

I wanted to write one all purpose generic template..

Now I have split that and extended multiple specific templates.. :(

Thanks,
~ramyak/


On Oct 23, 6:34 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
> To my knowledge, no, it's not possible to do that.  Even if it was,
> however, I would strongly argue against it, as it would make your
> templates unreadable--how would you know what filter/tag would be
> called without mucking through the rest of your code? Maybe there's a
> better way to get the effect you want--what are you trying to achieve?
>
> -Jeff
>
> On Oct 23, 6:59 am, ramya <[EMAIL PROTECTED]> wrote:
>
> > Is it possible to have variable tags / filters
>
> > {{ my_value | my_filter }}
> > where c['my_filter'] = 'formatDateTime'
> > formatDateTime is the actual filter function defined in templatetags
>
> > similarly
>
> > {{ my_tag my_filter }}
> > where c['my_tag'] = 'formatDateTime'
> > formatDateTime is the actual tag function defined in templatetags
>
> > say in both the cases  formatDateTime is registered tag/filter and has
> > been loaded
>
> > Regards,
> > ~ramyak/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with contrib.comments and signals: instance is not defined

2008-10-23 Thread Brandon Taylor

Hi everyone,

I'm using Django 1.0, and attempting to do some comment moderation
with Akismet. When I try to wire up a pre_save signal, I'm getting an
error saying 'instance' is not defined. Here is my code:

def moderate_comment(sender, **kwargs):
if not instance.id:  # <-- instance is not defined
entry = instance.get_content_object()
delta = datetime.datetime.now() - entry.pub_date
if delta.days > 30:
instance.is_public = False
else:
akismet_api = Akismet(key=settings.AKISMET_API_KEY,
blog_url='http://%s/' % Site.objects.get_current().domain)

if akismet_api.verify_key():
akistmet_data = {'comment_type' : 'comment',
'referrer' : '', 'user_ip' : instance.ip_address, 'user-agent' : ''}
if
akismet_api.comment_check(smart_str(instance.comment), akistmet_data,
build_data=True):
instance.is_public = False

email_body = '%s posted a new comment on the entry %s.'
mail_managers('New comment posted', email_body %
(instance.user_name, instance.get_content_object()))

models.signals.pre_save.connect(moderate_comment, sender=Comment)


Not sure what I'm doing wrong, but I would appreciate an extra set of
eyes.

TIA,
Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: variable tag / filter

2008-10-23 Thread ramya

I wanted to write one all purpose generic template..

Now I have split that and extended multiple specific templates.. :(

Thanks,
~ramyak/


On Oct 23, 6:34 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
> To my knowledge, no, it's not possible to do that.  Even if it was,
> however, I would strongly argue against it, as it would make your
> templates unreadable--how would you know what filter/tag would be
> called without mucking through the rest of your code? Maybe there's a
> better way to get the effect you want--what are you trying to achieve?
>
> -Jeff
>
> On Oct 23, 6:59 am, ramya <[EMAIL PROTECTED]> wrote:
>
> > Is it possible to have variable tags / filters
>
> > {{ my_value | my_filter }}
> > where c['my_filter'] = 'formatDateTime'
> > formatDateTime is the actual filter function defined in templatetags
>
> > similarly
>
> > {{ my_tag my_filter }}
> > where c['my_tag'] = 'formatDateTime'
> > formatDateTime is the actual tag function defined in templatetags
>
> > say in both the cases  formatDateTime is registered tag/filter and has
> > been loaded
>
> > Regards,
> > ~ramyak/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: UnicodeDecodeError when Unicode is used in view

2008-10-23 Thread Malcolm Tredinnick


On Thu, 2008-10-23 at 23:14 -0400, Chuck Bai2 wrote:
> I have a contact form which send email. It is working fine. But when I try to 
> add two Unicode to subject line:
> 
> subject = "DOMAIN.COM 留言 - %s (%s)" % (full_name,location)

The string portion of this (the "DOMAIN.COM ..." bit) is not a unicode
object. It's a byte string (a Python "str" object), so Python expects to
be able to treat everything as bytes, not unicode objects.

You need to write u"DOMAIN.COM ..." and so on.

Regards,
Malcolm



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



UnicodeDecodeError when Unicode is used in view

2008-10-23 Thread Chuck Bai2

I have a contact form which send email. It is working fine. But when I try to 
add two Unicode to subject line:

subject = "DOMAIN.COM 留言 - %s (%s)" % (full_name,location)

I got the following error message:



  UnicodeDecodeError at /contact_us/

'ascii' codec can't decode byte 0xe7 in position 11: ordinal not in range(128)


Anyone know how to resolve this?




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



Re: Different settings.py files for server and development

2008-10-23 Thread D. Woodman
Thanks Ned!

Cheers

On Thu, Oct 23, 2008 at 7:08 PM, Ned Batchelder <[EMAIL PROTECTED]>wrote:

>  And BTW, my bad.  Change the except: line to except ImportError, then the
> syntax error from the dash will be apparent in your 500 page.
>
> --Ned.
> http://nedbatchelder.com
>
>
> Ned Batchelder wrote:
>
> settings-custom isn't a valid Python file name, because a Python identifier
> can't have a dash in it.  Use an underscore.
>
> --Ned.
> http://nedbatchelder.com
>
> Dana wrote:
>
> Ned/Felix,
>
> Ok, I tried your guys solution but it does not seem to be working for
> me, so Im wondering where I goofed.
>
> Here is what ive got
>
> My settings.py and settings-custom.py file are here:
>
> config/
> settings.py
> settings-custom.py
>
> The directory containing config is on the PythonPath, so an import of:
>
> from config.settings-custom import *
>
> ... should work correct?
>
> In settings.py I have DEBUG=False and in settings-custom.py I have
> DEBUG=True, but Im getting my 500.html page, so that means it is only
> respecting the DEBUG setting in settings.py.
>
> Any ideas?
>
> Thanks
>
> On Oct 23, 5:04 pm, Ned Batchelder <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> 
> wrote:
>
>
>  In settings.py:
>
> try:
>from settings_local import *
> except:
>pass
>
> --Ned.http://nedbatchelder.com
>
>
>
> Dana wrote:
>
>
>  Hello everyone,
>
>
>  I know a form of this question has been asked before on this group but
> I can't for the life of me find the thread.
>
>
>  I am wondering how I can have a generic settings.py file that contains
> all my basic settings and then have a settings-local.py (or
> whatever...) and have that contain custom settings such as DEBUG=True,
> etc... Ideally the settings-local.py file would *only* have the custom
> settings, and nothing else, but I cannot seem to get this to work. For
> example:
>
>
>  In settings.py I would have default settings:
>
>
>  settings.py
> ---
> DEBUG = False
>
>
>  DATABASE_ENGINE = 'mysql'
>
>
>  DATABASE_NAME = 'something'
>
>
>  DATABASE_USER = 'root'
> DATABASE_PASSWORD = ''
>
>
>  MEDIA_ROOT = '/home/user/media/'
> MEDIA_URL = 'http://media.example.com/'
>
>
>  ADMIN_MEDIA_PREFIX = '/admin_media/'
>
>
>  INSTALLED_APPS = (
> 
> )
>
>
>  .. etc
>
>
>  ---
> and in settings-local.py I would override the settings:
>
>
>  # settings-local.py
> ---
> DEBUG = True
>
>
>  DATABASE_USER = 'username'
> DATABASE_PASSWORD = 'somethinghere123'
> ---
>
>
>  I would like some way to have settings-local import my settings.py
> file and then override specific settings. Anyone know how to do this
> cleanly?
>
>
>  Thanks!
>
>
>  --
> Ned Batchelder,http://nedbatchelder.com
>
>
> --
> Ned Batchelder, http://nedbatchelder.com
>
>
>
>
> --
> Ned Batchelder, http://nedbatchelder.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: ViewDoesNotExist: Even though it does

2008-10-23 Thread Dj Gilcrease

On Thu, Oct 23, 2008 at 7:20 PM, Malcolm Tredinnick
<[EMAIL PROTECTED]> wrote:
>
>
> On Wed, 2008-10-22 at 00:09 -0700, JonathanB wrote:
>> Getting a very erratic Exception:
>>
>> ViewDoesNotExist: Could not import supplier.views. Error was: cannot
>> import name Buyer

My guess is something in the file where Buyer lives actually needs
something else to be initialized before it can be imported, which is
why you only see the issue each time a new process starts, since after
that whatever it needs has been initialized

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Different settings.py files for server and development

2008-10-23 Thread Ned Batchelder
And BTW, my bad.  Change the except: line to except ImportError, then 
the syntax error from the dash will be apparent in your 500 page.

--Ned.
http://nedbatchelder.com

Ned Batchelder wrote:
> settings-custom isn't a valid Python file name, because a Python 
> identifier can't have a dash in it.  Use an underscore.
>
> --Ned.
> http://nedbatchelder.com
>
> Dana wrote:
>> Ned/Felix,
>>
>> Ok, I tried your guys solution but it does not seem to be working for
>> me, so Im wondering where I goofed.
>>
>> Here is what ive got
>>
>> My settings.py and settings-custom.py file are here:
>>
>> config/
>> settings.py
>> settings-custom.py
>>
>> The directory containing config is on the PythonPath, so an import of:
>>
>> from config.settings-custom import *
>>
>> ... should work correct?
>>
>> In settings.py I have DEBUG=False and in settings-custom.py I have
>> DEBUG=True, but Im getting my 500.html page, so that means it is only
>> respecting the DEBUG setting in settings.py.
>>
>> Any ideas?
>>
>> Thanks
>>
>> On Oct 23, 5:04 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote:
>>   
>>> In settings.py:
>>>
>>> try:
>>>from settings_local import *
>>> except:
>>>pass
>>>
>>> --Ned.http://nedbatchelder.com
>>>
>>>
>>>
>>> Dana wrote:
>>> 
 Hello everyone,
   
 I know a form of this question has been asked before on this group but
 I can't for the life of me find the thread.
   
 I am wondering how I can have a generic settings.py file that contains
 all my basic settings and then have a settings-local.py (or
 whatever...) and have that contain custom settings such as DEBUG=True,
 etc... Ideally the settings-local.py file would *only* have the custom
 settings, and nothing else, but I cannot seem to get this to work. For
 example:
   
 In settings.py I would have default settings:
   
 settings.py
 ---
 DEBUG = False
   
 DATABASE_ENGINE = 'mysql'
   
 DATABASE_NAME = 'something'
   
 DATABASE_USER = 'root'
 DATABASE_PASSWORD = ''
   
 MEDIA_ROOT = '/home/user/media/'
 MEDIA_URL = 'http://media.example.com/'
   
 ADMIN_MEDIA_PREFIX = '/admin_media/'
   
 INSTALLED_APPS = (
 
 )
   
 .. etc
   
 ---
 and in settings-local.py I would override the settings:
   
 # settings-local.py
 ---
 DEBUG = True
   
 DATABASE_USER = 'username'
 DATABASE_PASSWORD = 'somethinghere123'
 ---
   
 I would like some way to have settings-local import my settings.py
 file and then override specific settings. Anyone know how to do this
 cleanly?
   
 Thanks!
   
>>> --
>>> Ned Batchelder,http://nedbatchelder.com
>>> 
>>
>>
>>
>>   
>
> -- 
> Ned Batchelder, http://nedbatchelder.com
>   
>
> >

-- 
Ned Batchelder, http://nedbatchelder.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: Different settings.py files for server and development

2008-10-23 Thread Ned Batchelder
settings-custom isn't a valid Python file name, because a Python 
identifier can't have a dash in it.  Use an underscore.

--Ned.
http://nedbatchelder.com

Dana wrote:
> Ned/Felix,
>
> Ok, I tried your guys solution but it does not seem to be working for
> me, so Im wondering where I goofed.
>
> Here is what ive got
>
> My settings.py and settings-custom.py file are here:
>
> config/
> settings.py
> settings-custom.py
>
> The directory containing config is on the PythonPath, so an import of:
>
> from config.settings-custom import *
>
> ... should work correct?
>
> In settings.py I have DEBUG=False and in settings-custom.py I have
> DEBUG=True, but Im getting my 500.html page, so that means it is only
> respecting the DEBUG setting in settings.py.
>
> Any ideas?
>
> Thanks
>
> On Oct 23, 5:04 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote:
>   
>> In settings.py:
>>
>> try:
>>from settings_local import *
>> except:
>>pass
>>
>> --Ned.http://nedbatchelder.com
>>
>>
>>
>> Dana wrote:
>> 
>>> Hello everyone,
>>>   
>>> I know a form of this question has been asked before on this group but
>>> I can't for the life of me find the thread.
>>>   
>>> I am wondering how I can have a generic settings.py file that contains
>>> all my basic settings and then have a settings-local.py (or
>>> whatever...) and have that contain custom settings such as DEBUG=True,
>>> etc... Ideally the settings-local.py file would *only* have the custom
>>> settings, and nothing else, but I cannot seem to get this to work. For
>>> example:
>>>   
>>> In settings.py I would have default settings:
>>>   
>>> settings.py
>>> ---
>>> DEBUG = False
>>>   
>>> DATABASE_ENGINE = 'mysql'
>>>   
>>> DATABASE_NAME = 'something'
>>>   
>>> DATABASE_USER = 'root'
>>> DATABASE_PASSWORD = ''
>>>   
>>> MEDIA_ROOT = '/home/user/media/'
>>> MEDIA_URL = 'http://media.example.com/'
>>>   
>>> ADMIN_MEDIA_PREFIX = '/admin_media/'
>>>   
>>> INSTALLED_APPS = (
>>> 
>>> )
>>>   
>>> .. etc
>>>   
>>> ---
>>> and in settings-local.py I would override the settings:
>>>   
>>> # settings-local.py
>>> ---
>>> DEBUG = True
>>>   
>>> DATABASE_USER = 'username'
>>> DATABASE_PASSWORD = 'somethinghere123'
>>> ---
>>>   
>>> I would like some way to have settings-local import my settings.py
>>> file and then override specific settings. Anyone know how to do this
>>> cleanly?
>>>   
>>> Thanks!
>>>   
>> --
>> Ned Batchelder,http://nedbatchelder.com
>> 
> >
>
>
>   

-- 
Ned Batchelder, http://nedbatchelder.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: django.contrib.comments and returning to the original object

2008-10-23 Thread Brandon Taylor

Found the solution.

I can pass in: request.GET, which contains a QueryDict object
containing the 'c' variable for the comment.

Hope this helps someone!
Brandon

On Oct 23, 8:50 pm, Brandon Taylor <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I'm using 1.0 and have added contrib.comments to my project which has
> a blog. I can preview a comment just fine, but I would like to provide
> a way for the user to get back to the original blog entry once they've
> posted their comment.
>
> Out of the box, comments get redirected after being posted
> successfully to:
>
> http://localhost/comments/posted/?c=1
>
> I can get to the original object from the value of c, if only I could
> access the variable 'c' from my template tag. I'm not seeing a way to
> pass in the RequestContext so I could have access to the request
> object within my custom tag.
>
> Has anyone worked around this problem before? I could really use some
> advice.
>
> TIA,
> Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django.contrib.comments and returning to the original object

2008-10-23 Thread Brandon Taylor

Hi everyone,

I'm using 1.0 and have added contrib.comments to my project which has
a blog. I can preview a comment just fine, but I would like to provide
a way for the user to get back to the original blog entry once they've
posted their comment.

Out of the box, comments get redirected after being posted
successfully to:

http://localhost/comments/posted/?c=1

I can get to the original object from the value of c, if only I could
access the variable 'c' from my template tag. I'm not seeing a way to
pass in the RequestContext so I could have access to the request
object within my custom tag.

Has anyone worked around this problem before? I could really use some
advice.

TIA,
Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: What do you use for design interface / mockup

2008-10-23 Thread Francis

I prefer not to use software like photoshop or gimp, mainly because
I'm no graphic designer.

What I want to do is to design layout, forms and presentation. To find
the most 'user friendly' interface and to have a clear picture of my
application before writing any code. Then the graphic artist will make
it aesthetically nice.

I found fireworks from adobe, but it looks like more gear towards
designer. It's 300$ no demo.
Pencil for firefox is buggy on mac and it has a very limited set of
widgets. (but it shows much potential)
Omnigraffle looks nice (tried the demo), but it's 200$ and Mac only.

In the end, if Omnigraffle worth the price, I'll go for it.

Thank you for your suggestion,

Francis


On Oct 23, 7:24 pm, "Peter Herndon" <[EMAIL PROTECTED]> wrote:
> At the risk of being flamed, I'd say that nothing is better than OmniGraffle.
>
> That aside, both Gimp and Dia are cross-platform and very reasonable
> choices.  They may not fit the Mac gui, but they work well enough if
> cross-platform is a higher priority than best-of-breed.  You can get
> the job done with them.
>
> If cross-platform is not your highest priority, I'd pick OmniGraffle
> and Acorn, with Photoshop and such as the big guns, as required.
> Though, there's a lot to be said for wireframing in HTML, and for
> paper prototypes.
>
> ---Peter
>
> On 10/23/08, Gerard Petersen <[EMAIL PROTECTED]> wrote:
>
>
>
> > Francis,
>
> > I'm not a designer but I start my global layout on paper or in my head and
> > then it's (x)html and CSS. The first thing that comes to mind on doing this
> > electronically is photoshop (and siblings ... CS3?). And the Gimp but that
> > would not be a good choice on OSX (gui handling wise).
>
> > Regards,
>
> > Gerard.
>
> > Francis wrote:
> >> Hi,
>
> >> What do you use for design interface / mockup?
>
> >> I made some search, omnigraph seems pretty popular. But I often switch
> >> between linux and Mac and omnigraffle isn't cross platform.
>
> >> Is there any tools out there that work on Mac OS X and Linux? (or
> >> something better than omnigraffle)
>
> >> Thank you
>
> > --
> > urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl'}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 set length of db_index for CharFields?

2008-10-23 Thread Malcolm Tredinnick


On Thu, 2008-10-23 at 09:08 -0700, new_user wrote:
> In MySQL CREATE INdex there is such a parameter 'length'. Actually I
> need to make index just on first letters of the words.
> Thanks.

You'll need to do it manually or using the "initial SQL" option (see the
documentation for details on that). There's no option to do this via the
Python definition, since it's rather database-specific.

Regards,
Malcolm



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



Re: Disable i18n for certain templates

2008-10-23 Thread Malcolm Tredinnick


On Tue, 2008-10-21 at 10:07 -0700, Armandas wrote:
> Hi,
> 
> I am using internationalization on my project. Recently I found out
> that output from date filter is not in english. The point is, that I
> use this to construct pubDate for my rss, like this:
> 
> {{ post.date|date:"D, d M Y H:i:s" }} GMT
> 
> and i18n just screws things up here. Is there any proper (not a hack)
> way of disabling it in this particular template?

No, because the date filter returns the localised date. If you want to
get a non-localised date, you'll need to write your own filter that
returns that.

Regards,
Malcolm



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



Re: ViewDoesNotExist: Even though it does

2008-10-23 Thread Malcolm Tredinnick


On Wed, 2008-10-22 at 00:09 -0700, JonathanB wrote:
> Getting a very erratic Exception:
> 
> ViewDoesNotExist: Could not import supplier.views. Error was: cannot
> import name Buyer
> 
> What is stage is Buyer (model Class) does exist and the exception is
> only thrown once in a while.

I'll guess that you see this each time a new process starts on the web
server and it tries to import that view as part of processing the URL
Conf. It's one of the more confusing/annoying Django error handling
cases and "real soon now" we'll fix it (I keep poking at it and finding
more and more edge cases). Once the import has failed once, you won't
see it again for that process, since it won't try to be imported again.

You might well have more consistent luck debugging the problem using the
development server, since that's easier to stop and restart and force a
reload of everything.

Try a few experiments from the shell prompt. Try to import that view
file. Try to manually do some calls to
django.core.urlresolvers.reverse() -- which will have the effect of
importing all of your views -- and see if that triggers the problem.

If that fails, try reducing your problem code to the smallest possible
example. Comment out all the views and imports except for that one
particular view and a single URL pattern that refers to it and such that
the problem still occurs. That will help narrow down where the problem
occurs.

>  Could it be that there are too many
> ForeignKey relationships. i.e. the Buyer model is used in 3 other
> models.

There's not really any justification for that guess. Python and Django
don't just "get tired." and three of anything would be a very low
limit. :-)

Regards,
Malcolm


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



Re: Named URLs for Flatpages?

2008-10-23 Thread Malcolm Tredinnick


On Tue, 2008-10-21 at 14:14 -0700, erikcw wrote:
> Hi all,
> 
> I'm working on a project that uses flatpages pretty heavily.  I was
> wondering if there was a way to use named urls with flatpages so that
> I can use reverse() in my other views and {% url flat_privacy_policy
> %} in my templates.

No, this isn't possible with the "url" tag. Flatpages don't have
specific URL Conf entries, since they're implemented essentially as a
fallback if all other matching fails via middleware. There's also the
simple issue that the URLs for flat pages don't have a specific view
associated with them and it's the views and the URL Conf entries that
have names, so there's nothing to attach a name to with flat pages.

Even a custom templatetag to do this would still end up needing to be
passed the full URL you specified in the flatpages entry, so I'm not
sure what would be saved by doing this.

Regards,
Malcolm



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



Re: variables in forms.py?

2008-10-23 Thread Malcolm Tredinnick


On Sun, 2008-10-19 at 11:37 -0700, Jorge Romo wrote:
> Hell guys, I have this little doubt:
> 
> I want to validate a form, but it has several different options. It
> has to take a value_a and the see if it is bigger, smaller or equal to
> another value_b. The issue (or maybe not :p) is that the value_b is
> entered by the user, so it is always different, it would be perfect if
> i can call that from my views.py but i just don't know how to come
> with that.

If it's entered by the user, is it also part of the form? Because you
can do validation of form fields that depend on other form fields. See
[1] for some documentation about that.

[1]
http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other

Regards,
Malcolm


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



Re: filter OR for results...

2008-10-23 Thread Malcolm Tredinnick


On Mon, 2008-10-20 at 01:29 +0300, Erik Allik wrote:
> CollegeTeam.objects.filter(team=game.team1) |  
> CollegeTeam.objects.filter(team=game.team2)

That's certainly possible, but it's marginally more heavyweight than
doing it at the filter level (but only a tiny bit).

> But I would instead recommend:
> CollegeTeam.objects.filter(team__in=[game.team1, game.team2])

Alternatively:

from django.db.models import Q

CollegeTeam.objects.filter(Q(team=team1) | Q(team=team2))

Q-objects are documented in the database API. They exist primarily so
that you can "and" and "or" things together like this.

Most database optimisers will end up producing exactly the same query at
the lowest level when using either Erik's approach or mine. Erik's form
is probably slightly clearer in this case (where everything is of the
same type). On the other hand, the Q() approach is the only way when you
are creating disjunctions from things of different types (e.g. team name
is "team1" or home ground is "shizzle park").

Regards,
Malcolm



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



Re: Cache and upload handlers .. fun times!

2008-10-23 Thread Malcolm Tredinnick


On Sun, 2008-10-19 at 13:24 -0700, truebosko wrote:
> Hi there,
> 
> So I spent the last few hours trying to get a ProgressBar Upload
> handler working
> 
> What it does: User uploads a file, when they hit the submit button,
> javascript is called and begins polling the server (a django view) for
> progress. Progress is stored in a cache_key, very simple idea.
> 
> The Problem: The cache key is not being written to the database until
> AFTER the upload is complete. I watched the database and the key did
> not show up in it until the upload was complete. Which makes it
> totally useless.

As soon as you see something not being visible in the database to
another process until later than you expect, you have to think about
transactions and I'll wager that's almost certainly what's going on
here. Since the upload handler is writing something to the database, it
won't commit the transaction until the upload is finished, which will
mean that any other writes done by the same connection won't be visible
either.

Django's caching framework doesn't put caching writes are in separate
transactions to the rest of the view (that would require multiple
connections for some backends and be awfully complicated). The normal
use-case for caching is on the granularity of per-view and you're
wanting something finer: different points within the same view run being
visible to other processes / views.

The main stumbling block is that you've chosen to use the database cache
here and the database is also being used by the view for other things.
The solution is "don't do that". Use memcache (which is really easy to
set up). Or write your own modification of the database cache backend
that uses an entirely separate connection.

Regards,
Malcolm


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



Re: Inherited classes and generic views - curiosity.

2008-10-23 Thread Malcolm Tredinnick


On Sun, 2008-10-19 at 12:29 -0700, Scott SA wrote:
> When passing a QuerySet of objects which inherit part of their model
> from another class, generic views only seems to respond to the parent
> class:
> 
> Here's a simplified example:
> 
> class ParentClass(models.Model):
> name_last = models.CharField(max_length=64)
> name_first = models.CharField(max_length=64)
> 
> class ChildClass(ParentClass):
> likes_spam = BooleanField(default=False)
> 
> Then, in the urls.py, I pass:
> {
> "queryset": ChildClass.objects.all()
> 
> }
> 
> Without specifying the template, generic views looks for
> "parentclass_list.html", not "childclass_list.html". 

That doesn't sound right. The model name is taken from the queryset's
model attribute, which will be ChildClass, and then the template name
will be ChildClass._meta.object_name.lower(), which will be
"childclass".

Which generic view are you calling that is exhibiting this behaviour? I
can't repeat it here and reading the code for a few random generic views
show that they're all doing the same thing when it comes to constructing
the template name.

Can you construct a short, complete example of two classes and a URL
pattern that demonstrates this problem?

Regards,
Malcolm


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



Re: save_model and how to ignore any changes to an object

2008-10-23 Thread Malcolm Tredinnick


On Sun, 2008-10-19 at 10:21 -0700, Markos Gogoulos wrote:
> hi all. When I edit an object on django admin and press save, I want
> the object NOT to be saved, but instead create another object that
> contains any changes (I want to be able to review it later). So the
> original object has to be unchanged. I tried with this:

[...]
> Now when I save an item, the other object is created, but m2m changes
> are saved in my object as well. That is attributes like Charfield,
> Integer field etc are not saved in the original object, but m2m
> relationships are saved!
> 
> 
> Any ideas on why this is happening and how I can achieve the original
> object not be changed?

This is probably not really possible. Many-to-many updates aren't part
of the model's save() process, they're done externally. So you would
need to have a way for any external caller, everywhere, to know not to
use the object they have, which isn't available.

It sounds like you need to intercept the "edit" flow for admin and
create the new object initially, so that the user is editing the new
object right from the start, rather than editing the original and then
trying to hijack the final save.

Regards,
Malcolm



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



Re: QuerySet extra() duplicate table

2008-10-23 Thread Malcolm Tredinnick


On Fri, 2008-10-17 at 21:03 -0700, Rares Vernica wrote:
> Hello,
> 
> I am using QuerySet "extra()" function. For the "tables" parameter I
> need to specify the same table multiple times, so I included an alias
> for each table. Unfortunately Django quotes the table names and
> everything is messed up.
> 
> The "tables" parameter for the "extra()" is:
> 
>   tables ['FName F0', 'FName_Person Fp0', 'FName F1', 'FName_Person Fp1']
> 
> Here is how the generated query looks like:
> 
>   SELECT COUNT(DISTINCT `Person`.`id`)
>   FROM
> `Person` ,
> `FName F0` ,
> `FName_Person Fp0` ,
> `FName F1` , 
> `FName_Person Fp1` 
>   WHERE ...
> 
> If I remove the alias, Django does not realize that I give the same
> table multiple times and does not generate any aliases.
> 
> I really need the same table multiple times.
> 
> Is there a way around this?

You can't do it in one call. I've spent a long time (better part of a
year) wondering about what a reasonable API might be for this type of
thing, but I think the conclusion is that it should be done in multiple
steps, which means I need to document it and provide a public API to the
right Query methods.

The idea is that you call my_queryset.query.join() to add in the new
table and it will return the alias you can use in the select statements
when you call extra(). The call to join() will insert the tables into
the query properly and you won't need to specify them in
extra(tables=...). The docstring of Query.join() and a few experiments
should get you started there. This sort of situation is edge-case enough
(in fact using extra() is edge-case enough) that I'm reasonably
comfortable saying you have to use multiple calls to get there.

I've made a note to add something to the documentation about this.

> 
> An easy fix might be to ask Django not to quote the "tables"
> parameter. Is there a easy way to do this?

No and that's intentional at the moment,

Regards,
Malcolm


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



Re: Promote a Place to a Restaurant?

2008-10-23 Thread Malcolm Tredinnick


On Fri, 2008-10-17 at 11:47 +0200, Erik Stein wrote:
> 
> Hello --
> 
> I could not get an answer on the IRC channel and I'm also not finding  
> the right keywords for a successful search on the subject[1]:
> 
> You all know the model inheritance example with the classes Place and  
> Restaurant. Imagine I mapped every Place in my street, now one of this  
> empty places is becoming a restaurant. Is there an easy way to express  
> this in django-ORM?
> 
> I tried
> 
>   p = Place(number=32)
>   p.restaurant.create()
> 
> which gives
> 
>   DoesNotExist: Restaurant matching query does not exist.
> 
> Am I missing something or is this just not implemented? Is there a  
> workaround?

There's no concept of "promotion". Just create a new Restaurant object
with the requisite information.

This is the same as in Python: if you Bar is a subclass of Foo and you
have a Foo instance, you cannot "promote" it to a Bar instance (well,
you can poke at __class__ and initialise the missing attributes, but
that's essentially as much work as what follows); you just create a new
Bar and initialise it the necessary attributes from the Foo instance.

I personally dislike the approach in ticket #7623, as it adds API that
shouldn't really be needed. I also don't see this as a really necessary
use-case. Model inheritance is essentially a fudge to make things kind
of look like Python. If you really want variable child types and the
like, probably cleaner to model it with an explicit OneToOneField,
instead of the automatic one used with model inheritance. Then you can
set that field directly to the right key value for the parent. One day
there might be a reasonable API proposed for this, but, like I said,
#7623 isn't doing it for me at the moment.

Regards,
Malcolm



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



Re: Different settings.py files for server and development

2008-10-23 Thread Dana

Never mind, answered my own problem. I had a missing setting that was
causing a 500 error before it could access the settings-custom.py.

Your solutions worked!

Thanks!

On Oct 23, 5:18 pm, Dana <[EMAIL PROTECTED]> wrote:
> Ned/Felix,
>
> Ok, I tried your guys solution but it does not seem to be working for
> me, so Im wondering where I goofed.
>
> Here is what ive got
>
> My settings.py and settings-custom.py file are here:
>
> config/
>     settings.py
>     settings-custom.py
>
> The directory containing config is on the PythonPath, so an import of:
>
> from config.settings-custom import *
>
> ... should work correct?
>
> In settings.py I have DEBUG=False and in settings-custom.py I have
> DEBUG=True, but Im getting my 500.html page, so that means it is only
> respecting the DEBUG setting in settings.py.
>
> Any ideas?
>
> Thanks
>
> On Oct 23, 5:04 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote:
>
> > In settings.py:
>
> >     try:
> >        from settings_local import *
> >     except:
> >        pass
>
> > --Ned.http://nedbatchelder.com
>
> > Dana wrote:
> > > Hello everyone,
>
> > > I know a form of this question has been asked before on this group but
> > > I can't for the life of me find the thread.
>
> > > I am wondering how I can have a generic settings.py file that contains
> > > all my basic settings and then have a settings-local.py (or
> > > whatever...) and have that contain custom settings such as DEBUG=True,
> > > etc... Ideally the settings-local.py file would *only* have the custom
> > > settings, and nothing else, but I cannot seem to get this to work. For
> > > example:
>
> > > In settings.py I would have default settings:
>
> > > settings.py
> > > ---
> > > DEBUG = False
>
> > > DATABASE_ENGINE = 'mysql'
>
> > > DATABASE_NAME = 'something'
>
> > > DATABASE_USER = 'root'
> > > DATABASE_PASSWORD = ''
>
> > > MEDIA_ROOT = '/home/user/media/'
> > > MEDIA_URL = 'http://media.example.com/'
>
> > > ADMIN_MEDIA_PREFIX = '/admin_media/'
>
> > > INSTALLED_APPS = (
> > >     
> > > )
>
> > > .. etc
>
> > > ---
> > > and in settings-local.py I would override the settings:
>
> > > # settings-local.py
> > > ---
> > > DEBUG = True
>
> > > DATABASE_USER = 'username'
> > > DATABASE_PASSWORD = 'somethinghere123'
> > > ---
>
> > > I would like some way to have settings-local import my settings.py
> > > file and then override specific settings. Anyone know how to do this
> > > cleanly?
>
> > > Thanks!
>
> > --
> > Ned Batchelder,http://nedbatchelder.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: Different settings.py files for server and development

2008-10-23 Thread Dana

Ned/Felix,

Ok, I tried your guys solution but it does not seem to be working for
me, so Im wondering where I goofed.

Here is what ive got

My settings.py and settings-custom.py file are here:

config/
settings.py
settings-custom.py

The directory containing config is on the PythonPath, so an import of:

from config.settings-custom import *

... should work correct?

In settings.py I have DEBUG=False and in settings-custom.py I have
DEBUG=True, but Im getting my 500.html page, so that means it is only
respecting the DEBUG setting in settings.py.

Any ideas?

Thanks

On Oct 23, 5:04 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote:
> In settings.py:
>
>     try:
>        from settings_local import *
>     except:
>        pass
>
> --Ned.http://nedbatchelder.com
>
>
>
> Dana wrote:
> > Hello everyone,
>
> > I know a form of this question has been asked before on this group but
> > I can't for the life of me find the thread.
>
> > I am wondering how I can have a generic settings.py file that contains
> > all my basic settings and then have a settings-local.py (or
> > whatever...) and have that contain custom settings such as DEBUG=True,
> > etc... Ideally the settings-local.py file would *only* have the custom
> > settings, and nothing else, but I cannot seem to get this to work. For
> > example:
>
> > In settings.py I would have default settings:
>
> > settings.py
> > ---
> > DEBUG = False
>
> > DATABASE_ENGINE = 'mysql'
>
> > DATABASE_NAME = 'something'
>
> > DATABASE_USER = 'root'
> > DATABASE_PASSWORD = ''
>
> > MEDIA_ROOT = '/home/user/media/'
> > MEDIA_URL = 'http://media.example.com/'
>
> > ADMIN_MEDIA_PREFIX = '/admin_media/'
>
> > INSTALLED_APPS = (
> >     
> > )
>
> > .. etc
>
> > ---
> > and in settings-local.py I would override the settings:
>
> > # settings-local.py
> > ---
> > DEBUG = True
>
> > DATABASE_USER = 'username'
> > DATABASE_PASSWORD = 'somethinghere123'
> > ---
>
> > I would like some way to have settings-local import my settings.py
> > file and then override specific settings. Anyone know how to do this
> > cleanly?
>
> > Thanks!
>
> --
> Ned Batchelder,http://nedbatchelder.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: Different settings.py files for server and development

2008-10-23 Thread Ned Batchelder

In settings.py:

try:
   from settings_local import *
except:
   pass

--Ned.
http://nedbatchelder.com
   

Dana wrote:
> Hello everyone,
>
> I know a form of this question has been asked before on this group but
> I can't for the life of me find the thread.
>
> I am wondering how I can have a generic settings.py file that contains
> all my basic settings and then have a settings-local.py (or
> whatever...) and have that contain custom settings such as DEBUG=True,
> etc... Ideally the settings-local.py file would *only* have the custom
> settings, and nothing else, but I cannot seem to get this to work. For
> example:
>
> In settings.py I would have default settings:
>
> settings.py
> ---
> DEBUG = False
>
> DATABASE_ENGINE = 'mysql'
>
> DATABASE_NAME = 'something'
>
> DATABASE_USER = 'root'
> DATABASE_PASSWORD = ''
>
> MEDIA_ROOT = '/home/user/media/'
> MEDIA_URL = 'http://media.example.com/'
>
> ADMIN_MEDIA_PREFIX = '/admin_media/'
>
> INSTALLED_APPS = (
> 
> )
>
> .. etc
>
> ---
> and in settings-local.py I would override the settings:
>
> # settings-local.py
> ---
> DEBUG = True
>
> DATABASE_USER = 'username'
> DATABASE_PASSWORD = 'somethinghere123'
> ---
>
> I would like some way to have settings-local import my settings.py
> file and then override specific settings. Anyone know how to do this
> cleanly?
>
> Thanks!
>
> >
>
>
>   

-- 
Ned Batchelder, http://nedbatchelder.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
-~--~~~~--~~--~--~---



Date Format in Admin

2008-10-23 Thread Botolph

I would like to change the formatting of dates in the admin from -
MM-DD to DD-MM-. I have set "DATE_FORMAT" in the settings file,
but that only changes list_display and not the DateField input. In a
post from Januar 2007 Adrian wrote:

> Yes, newforms DateFields let you specify the input format(s). This has
> yet to be integrated into the Django admin, but it will be sooner
> rather than later.

Has this been integrated now? If so, where can I change it? I have
been searching for hours without finding a solution.

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



Re: What do you use for design interface / mockup

2008-10-23 Thread Peter Herndon

At the risk of being flamed, I'd say that nothing is better than OmniGraffle.

That aside, both Gimp and Dia are cross-platform and very reasonable
choices.  They may not fit the Mac gui, but they work well enough if
cross-platform is a higher priority than best-of-breed.  You can get
the job done with them.

If cross-platform is not your highest priority, I'd pick OmniGraffle
and Acorn, with Photoshop and such as the big guns, as required.
Though, there's a lot to be said for wireframing in HTML, and for
paper prototypes.

---Peter

On 10/23/08, Gerard Petersen <[EMAIL PROTECTED]> wrote:
>
> Francis,
>
> I'm not a designer but I start my global layout on paper or in my head and
> then it's (x)html and CSS. The first thing that comes to mind on doing this
> electronically is photoshop (and siblings ... CS3?). And the Gimp but that
> would not be a good choice on OSX (gui handling wise).
>
> Regards,
>
> Gerard.
>
> Francis wrote:
>> Hi,
>>
>> What do you use for design interface / mockup?
>>
>> I made some search, omnigraph seems pretty popular. But I often switch
>> between linux and Mac and omnigraffle isn't cross platform.
>>
>> Is there any tools out there that work on Mac OS X and Linux? (or
>> something better than omnigraffle)
>>
>> Thank you
>>
>>
>>
>> >
>
> --
> urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Different settings.py files for server and development

2008-10-23 Thread Dana

Sweet, I knew it was simple :)

Thanks!

On Oct 23, 3:54 pm, felix <[EMAIL PROTECTED]> wrote:
> at the very bottom of settings.py :
>
> from local_settings import *
>
> this overwrites just the imported keys/values
>
> -flx
>
> On Thu, Oct 23, 2008 at 11:55 PM, Dana <[EMAIL PROTECTED]> wrote:
>
> > Hello everyone,
>
> > I know a form of this question has been asked before on this group but
> > I can't for the life of me find the thread.
>
> > I am wondering how I can have a generic settings.py file that contains
> > all my basic settings and then have a settings-local.py (or
> > whatever...) and have that contain custom settings such as DEBUG=True,
> > etc... Ideally the settings-local.py file would *only* have the custom
> > settings, and nothing else, but I cannot seem to get this to work. For
> > example:
>
> > In settings.py I would have default settings:
>
> > settings.py
> > ---
> > DEBUG = False
>
> > DATABASE_ENGINE = 'mysql'
>
> > DATABASE_NAME = 'something'
>
> > DATABASE_USER = 'root'
> > DATABASE_PASSWORD = ''
>
> > MEDIA_ROOT = '/home/user/media/'
> > MEDIA_URL = 'http://media.example.com/'
>
> > ADMIN_MEDIA_PREFIX = '/admin_media/'
>
> > INSTALLED_APPS = (
> >    
> > )
>
> > .. etc
>
> > ---
> > and in settings-local.py I would override the settings:
>
> > # settings-local.py
> > ---
> > DEBUG = True
>
> > DATABASE_USER = 'username'
> > DATABASE_PASSWORD = 'somethinghere123'
> > ---
>
> > I would like some way to have settings-local import my settings.py
> > file and then override specific settings. Anyone know how to do this
> > cleanly?
>
> > Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Different settings.py files for server and development

2008-10-23 Thread felix
at the very bottom of settings.py :

from local_settings import *


this overwrites just the imported keys/values

-flx



On Thu, Oct 23, 2008 at 11:55 PM, Dana <[EMAIL PROTECTED]> wrote:

>
> Hello everyone,
>
> I know a form of this question has been asked before on this group but
> I can't for the life of me find the thread.
>
> I am wondering how I can have a generic settings.py file that contains
> all my basic settings and then have a settings-local.py (or
> whatever...) and have that contain custom settings such as DEBUG=True,
> etc... Ideally the settings-local.py file would *only* have the custom
> settings, and nothing else, but I cannot seem to get this to work. For
> example:
>
> In settings.py I would have default settings:
>
> settings.py
> ---
> DEBUG = False
>
> DATABASE_ENGINE = 'mysql'
>
> DATABASE_NAME = 'something'
>
> DATABASE_USER = 'root'
> DATABASE_PASSWORD = ''
>
> MEDIA_ROOT = '/home/user/media/'
> MEDIA_URL = 'http://media.example.com/'
>
> ADMIN_MEDIA_PREFIX = '/admin_media/'
>
> INSTALLED_APPS = (
>
> )
>
> .. etc
>
> ---
> and in settings-local.py I would override the settings:
>
> # settings-local.py
> ---
> DEBUG = True
>
> DATABASE_USER = 'username'
> DATABASE_PASSWORD = 'somethinghere123'
> ---
>
> I would like some way to have settings-local import my settings.py
> file and then override specific settings. Anyone know how to do this
> cleanly?
>
> 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
-~--~~~~--~~--~--~---



Different settings.py files for server and development

2008-10-23 Thread Dana

Hello everyone,

I know a form of this question has been asked before on this group but
I can't for the life of me find the thread.

I am wondering how I can have a generic settings.py file that contains
all my basic settings and then have a settings-local.py (or
whatever...) and have that contain custom settings such as DEBUG=True,
etc... Ideally the settings-local.py file would *only* have the custom
settings, and nothing else, but I cannot seem to get this to work. For
example:

In settings.py I would have default settings:

settings.py
---
DEBUG = False

DATABASE_ENGINE = 'mysql'

DATABASE_NAME = 'something'

DATABASE_USER = 'root'
DATABASE_PASSWORD = ''

MEDIA_ROOT = '/home/user/media/'
MEDIA_URL = 'http://media.example.com/'

ADMIN_MEDIA_PREFIX = '/admin_media/'

INSTALLED_APPS = (

)

.. etc

---
and in settings-local.py I would override the settings:

# settings-local.py
---
DEBUG = True

DATABASE_USER = 'username'
DATABASE_PASSWORD = 'somethinghere123'
---

I would like some way to have settings-local import my settings.py
file and then override specific settings. Anyone know how to do this
cleanly?

Thanks!

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



Limit Number Of User Sessions

2008-10-23 Thread [EMAIL PROTECTED]

Hi,

I was wondering if there is a way to limit the number of sessions a
user can have open using the authentication middleware django
provides?  In other words I would like django to end the current
session when the user logs in using another computer.  I am developing
a subscription based website and I want to prevent (or make it as
inconvenient as possible) users from sharing their log in credentials
with other people to gain access to the site.

If there isn't a way, can someone provide a short tutorial on how to
extend the authentication middleware to have this functionality?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Default values/prepopulate fields in ModelAdmin add view

2008-10-23 Thread Delta20

I want to be able to use the standard/auto-generated admin add form,
but need to put default values in the fields. Is this possible?

Basically I want to do something like this in a view:

1:  def some_view(request, ... ):
2:  ...
3:  values = { 'title': t, 'author': a }
4:  admin = new ArticleAdmin()
5.  ...
6:  return admin.add_view(request)

Notes:
  Line 4 - ArticleAdmin is a subclass of
django.contrib.admin.ModelAdmin
  Line 6 - This method in ModelAdmin displays the standard admin
change_form

Is there a way to use the "values" dictionary above to prepopulate the
corresponding fields in the model?

One way would be to create an instance of Article and then call
ModelAdmin.change_view, but I'd rather avoid that for various design
reasons.







--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: from mysite.polls.models import Poll, Choice

2008-10-23 Thread bruno desthuilliers



On 23 oct, 21:30, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 23, 2008 at 1:47 PM, bruno desthuilliers
>
> <[EMAIL PROTECTED]> wrote:
> > It's indeed a pretty bad idea to refer to the project name in import
> > statements (as well as in a couple other places too FWIW), and I
> > defnitively fail to understand why it's documented that way.
>
> It's documented that way because it means we can have a tutorial that
> doesn't immediately dump import-path configuration issues onto people
> who are brand-new to Python;


Mmm... Well, I have few experience with, say, developping on exotic
platforms like Windows, but I never had any import-path related
problem skipping the projectname in imports (directs or not...) using
the builtin dev server. And I don't see how one could use a more
"deployment-oriented" configuration (Apache or whatever) without
having to deal with import path somehow. But I'm probably not really
representative of the average Django newcomer, so I may have miss
something obvious here...

> doing things the way the tutorial does
> them, everything automatically ends up on the Python path thanks to
> manage.py.

Except when one doesn't strictly follow the tutorial and use another
name for the project - which happened very recently !-)

> This means, of course, that there is a need for followup documentation
> which explains that this isn't always the best way to develop
> real-world apps (in just the same way as the tutorial shows several
> "wrong" ways to do things like template rendering, etc., before
> showing the "right" way). Any volunteers to write it?

Isn't it what you're already doing in your talks, slides, and on your
blog ?-) FWIW, me not understanding (so far at least) why the tutorial
is written that way also comes from the contradiction between the
tutorial and your own writings.

About volunteering to write an 'advanced' tutorial, as far as I'm
concerned, I'm not sure I'm a great tutorial writer - nor even a great
writer at all. Not being a native english speaker doesn't help
neither. But I'll happily work on translating this follow-up when
it'll comes out (and hopefully will contribute some code until then -
there are a couple things in the pipe).

Oh, and while we're at it: please don't take offense of my occasional
(and very mild) criticism of some minor point of the doc or whatever.
I really think Django is by now the best available Python web
framework, and probably one of the best web frameworks around whatever
the language (ok, a bit biased here...). Almost every points that
bugged me a couple years ago (pre-magic-removal, think it was 0.91 ?)
and made me look at alternatives has been solved since then, and you
guys clearly made a pretty good job, both on the technical and the
'marketing' side, and I'm sincerly *very* grateful you did.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Setting up Django on CentOS5 with flup and fastcgi

2008-10-23 Thread [EMAIL PROTECTED]

thanks for all the suggestions...

I've managed to to kinda get it working with flup and fcgi although
i'm not quite there yet.

Here is my file structure and my fcgi file.

public file path = /home/xxx/www/projectblah/
application file path = /home/xxx/django_projects/projectblah_files/

mysite.fcgi

#!/usr/bin/python
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home/xxx/django_projects/projectblah_files/")

# Switch to the directory of your project. (Optional.)
# os.chdir("/home/xxx/www/projectblah/")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "projectblah.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")


although i keep getting this nasty error in SSH and the fastcgi file
just outputs as text when you go to the home/xxx/www/projectblah/ in
the browser.

link to traceback : http://dpaste.com/86437/

Thanks

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



Re: Following tutorial but can't get something

2008-10-23 Thread gryzzly

Thanks for the help. I've been screwed up with myself cuz I've created
SOME templates folders during making some tutorials.

Anyway, thanks for the help!

On Oct 23, 3:27 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 23, 2008 at 4:00 AM, gryzzly <[EMAIL PROTECTED]> wrote:
>
> > It is self-expalnatory, but the problem is that I do have a template
> > file. And it is there.
>
> You're saying you have a file named:
>
> /home/misha/www/djcode/templates/polls/results.html
>
> ?
>
> Are you sure you have that exact file?  If you cut-and-paste that value
> after 'cat ' in a command prompt, you see the file contents?  Or do you get:
>
> cat: /home/misha/www/djcode/templates/polls/results.html: No such file or
> directory
>
> If cat can find the file but Django can't, there's something screwy going on
> in your system.  It is far more likely that there is some subtle difference
> between the name of the file you have on your system and the name you are
> using in your code.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom include tag to parse locale into filename

2008-10-23 Thread Gerard Petersen

Hi All,

I have an include tag to a file with context help information. My app is fully 
i18n-ed, but I don't want to handle the bigger the helptext via i18n because of 
its size. I want to end up with something like this: 
myapp/customer_side.en.html.

The code snippet:


{% include "myapp/customer_side.html" %}


I'm thinking about a custom templatetag that picks up on the locale. Does 
anybody have other suggestions on how to do this?


Thanx a lot.

Regards,

Gerard.


-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: Foreign key with tons of items

2008-10-23 Thread Lars Stavholm

Fabio Natali wrote:
> Fabio Natali wrote:
> [...]
>> class Prod2(models.Model):
>> name = models.CharField(max_length=30)
>>
>> class Prod1(models.Model):
>> name = models.CharField(max_length=30)
>> belongs_to = models.ForeignKey(Prod2)
>>
>> class Prod0(models.Model):
>> name = models.CharField(max_length=30)
>> belongs_to = models.ForeignKey(Prod2)
> 
> That's obviously:
>  belongs_to = models.ForeignKey(Prod1)
> 
>> price = models.DecimalField(max_digits=10, decimal_places=2)
>> #...some more details...
>>
>> class Purchase(models.Model):
>> product = models.ForeignKey(Prod0)
>> amount = models.DecimalField(max_digits=10, decimal_places=2)
>> #...some more details...
> 
> Sorry for the typo, bye, Fabio.
> 

Have you tried filter_horizontal?
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#filter-horizontal
/L


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: from mysite.polls.models import Poll, Choice

2008-10-23 Thread James Bennett

On Thu, Oct 23, 2008 at 1:47 PM, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> It's indeed a pretty bad idea to refer to the project name in import
> statements (as well as in a couple other places too FWIW), and I
> defnitively fail to understand why it's documented that way.

It's documented that way because it means we can have a tutorial that
doesn't immediately dump import-path configuration issues onto people
who are brand-new to Python; doing things the way the tutorial does
them, everything automatically ends up on the Python path thanks to
manage.py.

This means, of course, that there is a need for followup documentation
which explains that this isn't always the best way to develop
real-world apps (in just the same way as the tutorial shows several
"wrong" ways to do things like template rendering, etc., before
showing the "right" way). Any volunteers to write it?


-- 
"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: from mysite.polls.models import Poll, Choice

2008-10-23 Thread bruno desthuilliers

On 23 oct, 11:14, tak <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am following the tutorial. One part I get confusion is the import
> statement including the project name. I am referring the last example
> of 1st tutorial.

It's indeed a pretty bad idea to refer to the project name in import
statements (as well as in a couple other places too FWIW), and I
defnitively fail to understand why it's documented that 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
-~--~~~~--~~--~--~---



Re: Python Script bugs.

2008-10-23 Thread bruno desthuilliers

On 23 oct, 19:48, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello everyone,
> I would like to know what isn't good in my script.

A couple things here and there.

But there's also something wrong with your whole post: there's nothing
Django-related in it. Python-related questions belongs to
comp.lang.python, not to a group about the web framework Django.

IOW : please post this to comp.lang.python (which you can access thru
google.groups too), and I'll answer there !-)

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



Re: Foreign Key Problem

2008-10-23 Thread bruno desthuilliers

On 23 oct, 19:53, cwurld <[EMAIL PROTECTED]> wrote:
> Hi,
(snip)
>
> When I run syncdb, the table is created (I can see it with MySQL
> Admin), but I get the following error:
>
> 
> C:\Documents and Settings\CCM\Desktop\pldev>python manage.py syncdb
> Creating table medical_xyzcontent
> Traceback (most recent call last):
(snip)
>   File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line
> 35, in defaulterrorhandler
> raise errorclass, errorvalue
> _mysql_exceptions.OperationalError: (1005, "Can't create table '.\
> \cwurld_pldev\
> \#sql-f1c_3b.frm' (errno: 150)")
> ---
>
> Here is the sql generated by the model:
>
> BEGIN;
> CREATE TABLE `content_algoxxx` (
> `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
> `name` varchar(256) NOT NULL,
> `disease_id` integer NOT NULL
> )
> ;
> ALTER TABLE `content_algoxxx` ADD CONSTRAINT
> disease_id_refs_id_5c05e27d FOREIGN
>  KEY (`disease_id`) REFERENCES `medical_medicalbranch` (`id`);
> COMMIT;
>
> I do not know if it matters, but the old table that is being
> referenced is MyISAM, while the newly created table that contains the
> reference is InnoDB.

Not a MySQL expert (IOW : you'd better check it in MySQL manual), but
I bet this the cause of your problem. IIRC, there's a simple way to
convert a MyISAM table to InnoDB:

ALTER TABLE  ENGINE=INNODB;

(NB : not tested)



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



Need help with mod python

2008-10-23 Thread R C

HELP PLEASE

I keep getting this error:


MOD_PYTHON ERROR

ProcessId:  29055
Interpreter:'mysite.com' (this has been changed by me)

ServerName: 'mysite.com'
DocumentRoot:   '/var/www/'

URI:'/admin'
Location:   '/'
Directory:  None
Filename:   '/var/www/admin'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
result = object(arg)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 222, in handler
return ModPythonHandler()(req)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 185, in __call__
self.load_middleware()

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 31, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:

  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 28, in __getattr__
self._import_settings()

  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 59, in _import_settings
self._target = Settings(settings_module)

  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 94, in __init__
raise ImportError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE,
e)

ImportError: Could not import settings 'django.ersites.settings' (Is
it on sys.path? Does it have syntax errors?): No module named
ersites.settings


In my /etc/apache2/sites-available/default  I have this:
  
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/home/er/local/django/','/var/www'] +
sys.path"


which is symbolically linked in the /etc/apache2/sites-enabled folder

I have django apps that live in:
/home/myname/local/django/mysite

my settings.py is:
/home/myname/local/django/mysite/settings.py

all of these folders and files have permissions   myname:www-data



Can anyone tell me what I'm doing wrong?

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



Foreign Key Problem

2008-10-23 Thread cwurld

Hi,

I have been using django for about a year and a half. It has been
great. My hat is off to all the developers.

I am trying to port my project to django 1.0 for 0.97. I am using
MySQL. The ported version seems to be working well.

The problem is that am trying to add a new model that contains a
foreign key to an old model. For debugging I have stripped the new
model down to bare essentials. Here it is:

class XYZContent(models.Model):
name=models.CharField(max_length=256, blank=False)
disease=models.ForeignKey(MedicalBranch)

When I run syncdb, the table is created (I can see it with MySQL
Admin), but I get the following error:


C:\Documents and Settings\CCM\Desktop\pldev>python manage.py syncdb
Creating table medical_xyzcontent
Traceback (most recent call last):
  File "manage.py", line 11, in ?
execute_manager(settings)
  File "C:\Python24\Lib\site-packages\django\core\management
\__init__.py", line
340, in execute_manager
utility.execute()
  File "C:\Python24\Lib\site-packages\django\core\management
\__init__.py", line
295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python24\Lib\site-packages\django\core\management\base.py",
line 77,
in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\Python24\Lib\site-packages\django\core\management\base.py",
line 96,
in execute
output = self.handle(*args, **options)
  File "C:\Python24\Lib\site-packages\django\core\management\base.py",
line 178,
 in handle
return self.handle_noargs(**options)
  File "C:\Python24\Lib\site-packages\django\core\management\commands
\syncdb.py"
, line 80, in handle_noargs
cursor.execute(statement)
  File "C:\Python24\Lib\site-packages\django\db\backends\util.py",
line 19, in e
xecute
return self.cursor.execute(sql, params)
  File "C:\Python24\Lib\site-packages\django\db\backends\mysql
\base.py", line 83
, in execute
return self.cursor.execute(query, args)
  File "C:\Python24\lib\site-packages\MySQLdb\cursors.py", line 163,
in execute
self.errorhandler(self, exc, value)
  File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line
35, in defau
lterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1005, "Can't create table '.\
\cwurld_pldev\
\#sql-f1c_3b.frm' (errno: 150)")
---


Here is the sql generated by the model:

BEGIN;
CREATE TABLE `content_algoxxx` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`name` varchar(256) NOT NULL,
`disease_id` integer NOT NULL
)
;
ALTER TABLE `content_algoxxx` ADD CONSTRAINT
disease_id_refs_id_5c05e27d FOREIGN
 KEY (`disease_id`) REFERENCES `medical_medicalbranch` (`id`);
COMMIT;

I do not know if it matters, but the old table that is being
referenced is MyISAM, while the newly created table that contains the
reference is InnoDB.

Thanks,
Chuck






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



Re: Django Model design: OOP or Database-centric approach?

2008-10-23 Thread dustpuppy

Thanks Kip. I appreciate the suggestions.

Kind regards,
Cormac.

On Oct 23, 4:29 pm, Kip Parker <[EMAIL PROTECTED]> wrote:
> Neither seem right to me. I'm not quite sure what the application
> does, but it seems likely that a person only belongs to one family, in
> which case you'll need a foreign key like this.
>
> class Adult(models.Model):
>     name = models.CharField(maxlength=30)
>     partner = models.CharField(maxlength=30)
>     kriskindle = models.CharField(maxlength=30)
>     email = models.EmailField()
>     family = models.ForeignKey(Family)
>
> also the Kinder and the adult classes are similar, so you might like
> to look at using inheritance, perhaps from a person class that looks
> like
>
> class Person(models.Model):
>     name = models.CharField(maxlength=30)
>     kriskindle = models.CharField(maxlength=30)
>     family = models.ForeignKey(Family)
>
> On Oct 23, 11:39 am, dustpuppy <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I'm starting off with Django and trying my first (toy) project. It's a
> > Kris Kindle application (called "Secret Santa"? by some). Not exactly
> > earth-shattering, but I want to start with something small.
>
> > I'm unsure what approach to use when designing my model.
>
> > The entities I am dealing with are Family, Adult and Kinder.
>
> > Normally for a standalone application (using Java or Python), I would
> > design a class Family, with fields/attributes representing arrays/
> > lists of objects of the classes Adult and Kinder.
> > (Apologies if my OOP terminology is mixed-up - I'm originally a C/Perl
> > programmer!)
>
> > I've started my Django design that way:
>
> > class Adult(models.Model):
> >     name = models.CharField(maxlength=30)
> >     partner = models.CharField(maxlength=30)
> >     kriskindle = models.CharField(maxlength=30)
> >     email = models.EmailField()
>
> >     def __str__(self):
> >         return self.name
>
> >     class Admin:
> >         #list_display('name', 'partner', 'email')
> >         pass
>
> > class Kinder(models.Model):
> >     name = models.CharField(maxlength=30)
> >     excluded = models.ManyToManyField(Adult)
> >     kriskindle = models.CharField(maxlength=30)
>
> >     def __str__(self):
> >         return self.name
>
> >     class Admin:
> >         #list_display('name', 'excluded')
> >         pass
>
> > class Family(models.Model):
> >     name = models.CharField(maxlength=30)
> >     children = models.ManyToManyField(Kinder)
> >     adults = models.ManyToManyField(Adult)
>
> >     def __str__(self):
> >         return self.name
>
> >     class Admin:
> >         pass
>
> > On the other hand, for any previous Web development I've done (with
> > PHP or Perl), I would have define just 2 entities, Adult and Kinder,
> > and simply included family as a string attribute of each.
>
> > class Adult(models.Model):
> >     name = models.CharField(maxlength=30)
> >     partner = models.CharField(maxlength=30)
> >     kriskindle = models.CharField(maxlength=30)
> >     email = models.EmailField()
> >     family = models.CharField(maxlength=30)
>
> >     def __str__(self):
> >         return self.name
>
> >     class Admin:
> >         #list_display('name', 'partner', 'email')
> >         pass
>
> > class Kinder(models.Model):
> >     name = models.CharField(maxlength=30)
> >     excluded = models.ManyToManyField(Adult)
> >     kriskindle = models.CharField(maxlength=30)
> >     family = models.CharField(maxlength=30)
>
> >     def __str__(self):
> >         return self.name
>
> >     class Admin:
> >         #list_display('name', 'excluded')
> >         pass
>
> > I actually think the former would be easier to program, e.g. in terms
> > of getting access to the lists of adults directly from the database,
> > instead of having to retrieve it from a Family object first.
>
> > Which of these would be the more appropriate way to do it in Django?
>
> > Thanks in advance for taking the time to respond.
>
> > Kind regards,
> > Cormac.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 Script bugs.

2008-10-23 Thread [EMAIL PROTECTED]

Hello everyone,
I would like to know what isn't good in my script.

#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
from time import strftime
import datetime
t = input(datetime.date)
global t
print t.strftime("Day %w of the week a %A . Day %d of the month (%B).
")
print t.strftime("Day %j of the year (%Y), in week %W of the year.")
raw_input()
i get error :

print t.strftime("Day %w of the week a %A . Day %d of the month
(%B). ")
AttributeError: 'tuple' object has no attribute 'strftime'

Thanks for your

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



Re: Foreign key with tons of items

2008-10-23 Thread Fabio Natali

Fabio Natali wrote:
[...]
> class Prod2(models.Model):
> name = models.CharField(max_length=30)
> 
> class Prod1(models.Model):
> name = models.CharField(max_length=30)
> belongs_to = models.ForeignKey(Prod2)
> 
> class Prod0(models.Model):
> name = models.CharField(max_length=30)
> belongs_to = models.ForeignKey(Prod2)

That's obviously:
 belongs_to = models.ForeignKey(Prod1)

> price = models.DecimalField(max_digits=10, decimal_places=2)
> #...some more details...
> 
> class Purchase(models.Model):
> product = models.ForeignKey(Prod0)
> amount = models.DecimalField(max_digits=10, decimal_places=2)
> #...some more details...

Sorry for the typo, bye, Fabio.

-- 
Fabio Natali

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



Foreign key with tons of items

2008-10-23 Thread Fabio Natali

Hi everybody.

In my admin page I have a field for a foreign key with hundreds of
items. That results in a drop down menu which is very difficult and
annoying to use.

This is my models.py:

class Prod2(models.Model):
name = models.CharField(max_length=30)

class Prod1(models.Model):
name = models.CharField(max_length=30)
belongs_to = models.ForeignKey(Prod2)

class Prod0(models.Model):
name = models.CharField(max_length=30)
belongs_to = models.ForeignKey(Prod2)
price = models.DecimalField(max_digits=10, decimal_places=2)
#...some more details...

class Purchase(models.Model):
product = models.ForeignKey(Prod0)
amount = models.DecimalField(max_digits=10, decimal_places=2)
#...some more details...

My drop-down-menu-excessive-lenght problem arises when you want to
create a new Purchase item via the admin page.

As you can see my products are organized in a hyerarchy, Prod0 being
the real products and Prod1 and Prod2 groups and super-groups of
products, respectively.

I wonder which is the best way to have a nice, friendly drop down
menu, possibly taking advantage of the product hyerarchy (with some
kind of multi level structure...).

Is there a way to customize the admin page without having to write the
whole page from scratch? Shall I have to add some Javascript?

Any tips will be really appreciated. Links to code, docs and whatever
are welcome.

All the best,

-- 
Fabio Natali

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



Re: What do you use for design interface / mockup

2008-10-23 Thread Gerard Petersen

Francis,

I'm not a designer but I start my global layout on paper or in my head and then 
it's (x)html and CSS. The first thing that comes to mind on doing this 
electronically is photoshop (and siblings ... CS3?). And the Gimp but that 
would not be a good choice on OSX (gui handling wise).

Regards,

Gerard.

Francis wrote:
> Hi,
> 
> What do you use for design interface / mockup?
> 
> I made some search, omnigraph seems pretty popular. But I often switch
> between linux and Mac and omnigraffle isn't cross platform.
> 
> Is there any tools out there that work on Mac OS X and Linux? (or
> something better than omnigraffle)
> 
> Thank you
> 
> 
> 
> > 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Permissions in template tags

2008-10-23 Thread dougeven

Something like this should work...

from django import template
import datetime
class CurrentTimeNode(template.Node):
def __init__(self, format_string):
self.format_string = format_string
def render(self, context):
# apply appropriate permissions for this tag
user = context['user']
if user.has_perm('your_package.your_permission_codename'):
return
datetime.datetime.now().strftime(self.format_string)
else:
return 'You do not have permission to see what time it
is.'


On Oct 21, 4:44 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Simple question: is it possible to access all user permissions in
> template tags just as in regular templates through the {{ perms }}
> context variable or do I need to manually pass the permissions are
> template tag params? By default the perms map does not seem to work in
> tags.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Implementing a search function for a django-powered site

2008-10-23 Thread Giles Thomas
Hi there,

I'm building a new section for our website and am having great fun doing 
it in Django!  The aim is to let people upload documents, tag them, rate 
them, etc.  Obviously one important aspect of this is searching, and I'm 
wondering how best to do that.

I've googled around to see if there was an app that people tended to 
use, and found two:

* django-search: .  This
  project is listed on Django Pluggables, and looks like the kind of
  thing I need.  However, it's not been updated since May - not
  necessarily a problem, but there is also...
* djangosearch: .  Despite
  the similar name, this is a different project.  It's not on Django
  Pluggables but it looks more live - jacob.kaplanmoss is a project
  owner (which in my Django newbie state I've taken to regarding as
  an indicator of liveness), and the last checkin was a week or so
  ago.  However, there is no documentation (at least on the trunk -
  there's a doc directory on a branch) and there's no obvious MySQL
  backend.  Despite this, I get the feeling that this is the one to
  go for.

My question for everyone is - am I right in thinking that I should be 
using djangosearch (hope I'm not starting a war with that :-)?  If so, 
should I be using the trunk, or perhaps the soc-new-backends branch?  Or 
is there yet another search app out there?  Or should I just roll my own 
(which I guess won't be too difficult)?

Thanks in advance for any help.


Regards,

Giles
-- 

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

Try out Resolver One! 

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



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



Re: Where is my Django?

2008-10-23 Thread leonel

Maicon Da Silva wrote:
> Hi every body... first sorry for my english! that's because i'm
> uruguaian(a little country between Brasil and Argentina)
>
> That is my problem:
>
> I have installed Django 0.96 from Synaptic in Ubuntu 8.04 and i don't
> find de directory 'django' in site-packages on /usr/lib/python2.5/site-
> packages or /usr/lib/python-django
>
> Some body can help me?
>
> Thanks!
>
> >
>
>
>   



dpkg -l  python-django   shows  all the package contents ..


Leonel


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

2008-10-23 Thread Carl Meyer

Hi harold,

On Oct 23, 9:27 am, dadapapa <[EMAIL PROTECTED]> wrote:
> If by "save a derived object from a parent instance" you mean that
> the method that saves the object is defined in the parent class,
> than this should not cause a problem, since type(self) will
> dynamically identify the object as being of the derived type,
> so final_type gets initialized correctly. Then again, I might have
> misunderstood your problem.

Sorry, I wasn't clear.  You may have a BaseClass instance that is
"really" a DerivedClass, and if you ever call save() from that
BaseClass instance (without casting it to a DerivedClass first), the
recipe will break.  Code is clearer:

>>> d = DerivedClass.objects.create()
>>> d.final_type

>>> d2 = BaseClass.objects.all()[0]
>>> d2.final_type

>>> d2.save()
>>> d2.final_type


The fix is just to add an "if not self.id" in the save() method, so
the "final_type" is only set once, at creation time, not on every
save:

def save(self, *args, **kwargs) :
if not self.id:
self.final_type =
ContentType.objects.get_for_model(type(self))
super(BaseClass, self).save(*args)

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

2008-10-23 Thread Niall Mccormack
Thanks for that - and yes I am in a bit of a rush!

I thought my initial question was maybe a little to convoluted as I  
just needed a lead to go on really...



On 23 Oct 2008, at 16:13, Karen Tracey wrote:

> On Thu, Oct 23, 2008 at 10:45 AM, Niall Mccormack <[EMAIL PROTECTED] 
> > wrote:
>
> ok, I'm going to simplify my question.
>
> is there any way that I can create a ForeignKey or a ManytToMany that
> can accept multiple types of data Models?
>
> Since you seem to be in a hurry, without giving your scenario a  
> whole lot of thought, I'll recommend that you search the docs for  
> "generic relations" and read up about them.
>
> Karen
>
>
> On 23 Oct 2008, at 11:34, Niall Mccormack wrote:
>
> >
> > Hi there,
> >
> > I'm learning Django at the moment and need some advice.
> >
> > I need to create sections in my website that can accept two  
> different
> > models.
> >
> > i.e. a work section can have the following data
> >   title - CharField
> >   description - TextField
> >   url link -  URLField
> >
> >   media - a mixture of ImageFields and FileFields ( for videos )
> >
> >
> > how would I setup the model for the media? where I can add in either
> > type of Field and re-order them easily?
> >
> > Any advice would be appreciated
> >
> > Cheers
> > NIall
> >
> > >
>
>
>
>
>
> >


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

2008-10-23 Thread Maicon Da Silva

Thankyou so much man! i find it!

On 23 oct, 14:20, David Reynolds <[EMAIL PROTECTED]> wrote:
> On 23 Oct 2008, at 5:17 pm, Maicon Da Silva wrote:
>
>
>
> > Hi every body... first sorry for my english! that's because i'm
> > uruguaian(a little country between Brasil and Argentina)
>
> > That is my problem:
>
> > I have installed Django 0.96 from Synaptic in Ubuntu 8.04 and i don't
> > find de directory 'django' in site-packages on /usr/lib/python2.5/
> > site-
> > packages or /usr/lib/python-django
>
> > Some body can help me?
>
> dpkg -L python-django
>
> This will give you a list of all of the files in that package and  
> where they are.
>
> --
> David Reynolds
> [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: Where is my Django?

2008-10-23 Thread David Reynolds


On 23 Oct 2008, at 5:17 pm, Maicon Da Silva wrote:

>
> Hi every body... first sorry for my english! that's because i'm
> uruguaian(a little country between Brasil and Argentina)
>
> That is my problem:
>
> I have installed Django 0.96 from Synaptic in Ubuntu 8.04 and i don't
> find de directory 'django' in site-packages on /usr/lib/python2.5/ 
> site-
> packages or /usr/lib/python-django
>
> Some body can help me?


dpkg -L python-django

This will give you a list of all of the files in that package and  
where they are.

-- 
David Reynolds
[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
-~--~~~~--~~--~--~---



Where is my Django?

2008-10-23 Thread Maicon Da Silva

Hi every body... first sorry for my english! that's because i'm
uruguaian(a little country between Brasil and Argentina)

That is my problem:

I have installed Django 0.96 from Synaptic in Ubuntu 8.04 and i don't
find de directory 'django' in site-packages on /usr/lib/python2.5/site-
packages or /usr/lib/python-django

Some body can help me?

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



How to set length of db_index for CharFields?

2008-10-23 Thread new_user

In MySQL CREATE INdex there is such a parameter 'length'. Actually I
need to make index just on first letters of the words.
Thanks.

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



Re: Exception thrown from django.test.client.Client

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

>
> By using pdb post mortem, I found out that the request.META dictionary
> doesn't actually have 'REMOTE_ADDR' in it. Settings.INTERNAL_IPS is
> '127.0.0.1'. So then get() returns None, and the error comes from
> python trying to evaluate None in '127.0.0.1'. Should the test client
> be setting this value? Is there something in my code or configuration
> that needs to change to set that?
>

I'm a little puzzled because I cannot recreate the error you see.  From your
traceback it appears like it might be resulting from having DEBUG set to
True when running the test, but even using a settings file where DEBUG is
True, I do not see that error:

>>> from django.conf import settings
>>> settings.DEBUG
True
>>> from django.test.client import Client
>>> c = Client()
>>> c.get('/')

>>>

So I am not sure why you see it.  However, the lack of a REMOTE_ADDR setting
in the test client environment has been reported in a ticket:

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

so you could probably either use the workaround mentioned there or try
running with the little patch in the ticket and see if it fixes your case.

Karen


>
> On Oct 23, 9:17 am, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
> > I found this problem while trying out the django test client:
> >
> > $ ./manage.py shell>>> from django.test.client import Client
> > >>> c = Client()
> > >>> c.get('/')
> >
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/var/lib/python-support/python2.5/django/test/client.py", line
> > 265, in get
> > return self.request(**r)
> >   File "/var/lib/python-support/python2.5/django/core/handlers/
> > base.py", line 86, in get_response
> > response = callback(request, *callback_args, **callback_kwargs)
> >   File "/path/to/website/views.py", line 12, in index
> > context_instance=RequestContext(request))
> >   File "/var/lib/python-support/python2.5/django/template/context.py",
> > line 105, in __init__
> > self.update(processor(request))
> >   File "/var/lib/python-support/python2.5/django/core/
> > context_processors.py", line 34, in debug
> > if settings.DEBUG and request.META.get('REMOTE_ADDR') in
> > settings.INTERNAL_IPS:
> > TypeError: 'in ' requires string as left operand
> >
> > This is probably a mistake in my configuration, but it may be a bug.
> > It throws the same error regardless of which path I try to get, or if
> > I use c.post instead. Can anyone figure this out?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Confused by select_related()

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

>
> Apologies for not using DPaste. I thought the snippets were small
> enough. And I thought my question was cleared than it turned out to
> be!
>

I wasn't saying what you posted would have been better at dpaste.com, what
you posted was fine.  I was saying your model definitions might work better
at dpaste.com than inline.


> To clarify (where someobject_set is a related-object queryset):
>
> someobject_set.all().query.as_sql()
> someobject_set.select_related().query.as_sql()
>
> Both show identical SQL is being generated - which indicates that
> select_related() isn't following any relationships.
>

What select_related does, exactly, is dependent on the model definitions.
It doesn't follow relations which can be null, for example.  Which is why I
asked for your model definitions.  You're also applying the select_related
to a related set, which may be coming into play (this is not code I'm
terribly familiar with), but when I try analogs to your queries on my own
models, I do get different sql reflecting select_related is having an
effect.  Which is why I asked for your model definitions.  Without seeing
your models I haven't the vaguest idea how what you are doing with your
models is different from what I am doing.

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



What do you use for design interface / mockup

2008-10-23 Thread Francis

Hi,

What do you use for design interface / mockup?

I made some search, omnigraph seems pretty popular. But I often switch
between linux and Mac and omnigraffle isn't cross platform.

Is there any tools out there that work on Mac OS X and Linux? (or
something better than omnigraffle)

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



Django 1.0: XML documents in database, view as HTML, download as RTF

2008-10-23 Thread Mirto Silvio Busico

Hi all django gurus,

There is any hint, snippet, google code related to the object?

Use case:

* publish an online magazine with content saved as XML inside the
  database
* every article is shown as a web page (so in HTML)
* there should be an download magazine function that gives a zipfile
  containing the tree structure of the magazine and the articles
  converted in rtf (or ODT)

Thanks
Mirto

-- 

_
Busico Mirto Silvio
Consulente ICT
cell. 333 4562651
email [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: Exception thrown from django.test.client.Client

2008-10-23 Thread [EMAIL PROTECTED]

By using pdb post mortem, I found out that the request.META dictionary
doesn't actually have 'REMOTE_ADDR' in it. Settings.INTERNAL_IPS is
'127.0.0.1'. So then get() returns None, and the error comes from
python trying to evaluate None in '127.0.0.1'. Should the test client
be setting this value? Is there something in my code or configuration
that needs to change to set that?

On Oct 23, 9:17 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I found this problem while trying out the django test client:
>
> $ ./manage.py shell>>> from django.test.client import Client
> >>> c = Client()
> >>> c.get('/')
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/var/lib/python-support/python2.5/django/test/client.py", line
> 265, in get
>     return self.request(**r)
>   File "/var/lib/python-support/python2.5/django/core/handlers/
> base.py", line 86, in get_response
>     response = callback(request, *callback_args, **callback_kwargs)
>   File "/path/to/website/views.py", line 12, in index
>     context_instance=RequestContext(request))
>   File "/var/lib/python-support/python2.5/django/template/context.py",
> line 105, in __init__
>     self.update(processor(request))
>   File "/var/lib/python-support/python2.5/django/core/
> context_processors.py", line 34, in debug
>     if settings.DEBUG and request.META.get('REMOTE_ADDR') in
> settings.INTERNAL_IPS:
> TypeError: 'in ' requires string as left operand
>
> This is probably a mistake in my configuration, but it may be a bug.
> It throws the same error regardless of which path I try to get, or if
> I use c.post instead. Can anyone figure this out?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Model design: OOP or Database-centric approach?

2008-10-23 Thread Kip Parker

Neither seem right to me. I'm not quite sure what the application
does, but it seems likely that a person only belongs to one family, in
which case you'll need a foreign key like this.

class Adult(models.Model):
name = models.CharField(maxlength=30)
partner = models.CharField(maxlength=30)
kriskindle = models.CharField(maxlength=30)
email = models.EmailField()
family = models.ForeignKey(Family)

also the Kinder and the adult classes are similar, so you might like
to look at using inheritance, perhaps from a person class that looks
like

class Person(models.Model):
name = models.CharField(maxlength=30)
kriskindle = models.CharField(maxlength=30)
family = models.ForeignKey(Family)

On Oct 23, 11:39 am, dustpuppy <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm starting off with Django and trying my first (toy) project. It's a
> Kris Kindle application (called "Secret Santa"? by some). Not exactly
> earth-shattering, but I want to start with something small.
>
> I'm unsure what approach to use when designing my model.
>
> The entities I am dealing with are Family, Adult and Kinder.
>
> Normally for a standalone application (using Java or Python), I would
> design a class Family, with fields/attributes representing arrays/
> lists of objects of the classes Adult and Kinder.
> (Apologies if my OOP terminology is mixed-up - I'm originally a C/Perl
> programmer!)
>
> I've started my Django design that way:
>
> class Adult(models.Model):
>     name = models.CharField(maxlength=30)
>     partner = models.CharField(maxlength=30)
>     kriskindle = models.CharField(maxlength=30)
>     email = models.EmailField()
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'partner', 'email')
>         pass
>
> class Kinder(models.Model):
>     name = models.CharField(maxlength=30)
>     excluded = models.ManyToManyField(Adult)
>     kriskindle = models.CharField(maxlength=30)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'excluded')
>         pass
>
> class Family(models.Model):
>     name = models.CharField(maxlength=30)
>     children = models.ManyToManyField(Kinder)
>     adults = models.ManyToManyField(Adult)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         pass
>
> On the other hand, for any previous Web development I've done (with
> PHP or Perl), I would have define just 2 entities, Adult and Kinder,
> and simply included family as a string attribute of each.
>
> class Adult(models.Model):
>     name = models.CharField(maxlength=30)
>     partner = models.CharField(maxlength=30)
>     kriskindle = models.CharField(maxlength=30)
>     email = models.EmailField()
>     family = models.CharField(maxlength=30)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'partner', 'email')
>         pass
>
> class Kinder(models.Model):
>     name = models.CharField(maxlength=30)
>     excluded = models.ManyToManyField(Adult)
>     kriskindle = models.CharField(maxlength=30)
>     family = models.CharField(maxlength=30)
>
>     def __str__(self):
>         return self.name
>
>     class Admin:
>         #list_display('name', 'excluded')
>         pass
>
> I actually think the former would be easier to program, e.g. in terms
> of getting access to the lists of adults directly from the database,
> instead of having to retrieve it from a Family object first.
>
> Which of these would be the more appropriate way to do it in Django?
>
> Thanks in advance for taking the time to respond.
>
> Kind regards,
> Cormac.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Confused by select_related()

2008-10-23 Thread AndyB

Apologies for not using DPaste. I thought the snippets were small
enough. And I thought my question was cleared than it turned out to
be!

To clarify (where someobject_set is a related-object queryset):

someobject_set.all().query.as_sql()
someobject_set.select_related().query.as_sql()

Both show identical SQL is being generated - which indicates that
select_related() isn't following any relationships.

One of the fields is a foreign key to another so I would have expect
the second query to result in a join.

(incidentally - the problem I am trying to solve is to sort by a field
that is in a related table but that question can wait until I can
understand the reason for the above issue)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Add more details into history

2008-10-23 Thread Low Kian Seong
Dear all,

I want to extend django's history function to show more information about
activities inside the admin interface. I want to add in the detail of what
is the original value of a field that has been changed and the value that it
has been changed into.

Can someone tell which part of django can I change to have these
functionality.

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: Confused by select_related()

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

>
> >>> p.residentialunitmix_set.all().query.as_sql()
>
> (u'SELECT `tbl_ResidentialUnitMix`.`id`,
> `tbl_ResidentialUnitMix`.`Planning-id`,
> `tbl_ResidentialUnitMix`.`quantity`,
> `tbl_ResidentialUnitMix`.`Bedrooms`, `tbl_ResidentialUnitMix`.`Type`,
> `tbl_ResidentialUnitMix`.`Tenure` FROM `tbl_ResidentialUnitMix` WHERE
> `tbl_ResidentialUnitMix`.`Planning-id` = %s '  , (82))
>
> >>> p.residentialunitmix_set.select_related().query.as_sql()
>
> (u'SELECT `tbl_ResidentialUnitMix`.`id`,
> `tbl_ResidentialUnitMix`.`Planning-id`,
> `tbl_ResidentialUnitMix`.`quantity`,
> `tbl_ResidentialUnitMix`.`Bedrooms`, `tbl_ResidentialUnitMix`.`Type`,
> `tbl_ResidentialUnitMix`.`Tenure` FROM `tbl_ResidentialUnitMix` WHERE
> `tbl_ResidentialUnitMix`.`Planning-id` = %s '  , (82))
>
> Tenure is a foreign key to another tables. How come both queries are
> identical?
>
> I am trying to sort by a field in the Tenure table and:
>
> residentialunitmix_set.select_related().order_by('tbl_lkp_ResidentialUnitMix_Tenure.sort')
>
> just gives an error. Looking at the queries explained why.
>
> (Apologies for the table names. It's a Django interface to something
> developed in Access)
>

You've rather jumped to the end problem without telling us the beginning
(model definitions).  Now it's maybe possible to puzzle out what's going on
based on the queries alone, but why make it so hard on us?  Ideally you'd
whittle it down to a minimal example that illustrates the problem you are
seeing (which by the way, you should spell out in as great a detail as is
presented to you -- "just gives an error" is about as useless a description
of a problem as "doesn't work"), but if you can't manage that at least post
the models you're actually working with.  On dpaste.com, not inline in the
post, if they are big/involved enough that the email//groups interface will
make them hard to read.

Karen

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



Re: geodjango: installation comments.

2008-10-23 Thread Justin Bronn

On Oct 18, 2:21 pm, "Jorge Vargas" <[EMAIL PROTECTED]> wrote:
> I did found some inconsistencies on the docs I'll like to point out:
> 1- the different installation docs use a methodology with little
> changes, probably due to being written by different people. it will be
> nice to unify them into a "canonical way", for 
> examplehttp://geodjango.org/docs/install.html#post-installationuses a
> template_db then copy that into testdb
> whilehttp://code.djangoproject.com/wiki/GeoDjangoInstalluses a testdb

Yes, that's ongoing.  As I'm going through the install docs I'm
removing them from the wiki -- as I've found I'm no longer able to
keep up with the changes that others add to the wiki, which in some
cases has incorrect information (the Ubuntu page, in particular which
I did not write).  Installation docs are especially difficult because
I have to write them for at least 3 different platforms which have
different concepts.  Patches are welcome.

I aim on cleaning up the installation documentation mess, hopefully by
the end of this weekend.

> Another similar example is the wiki given permission on the spacial
> tables to the "user" while the sphinx version gives them to public.

The template approach is now preferred because it only makes you go
through the spatial db creation process once, whereas repeating those
commands for each new spatial db.  The `PUBLIC` schema is specified on
the template because you don't want to have permissions set for a
specific user, as it limits the template's use to only the user you
specified.

> 2- There should be an indication on what to put in the INSTALLED_APPS,
> I was tricked to believe I had to add django.contrib.gis.admin instead
> of the normal admin.

Only `django.contrib.gis` is required (the admin models are in
`django.contrib.admin`).  This is documented in the post installation
section, but I'll try to clarify this:

http://geodjango.org/docs/install.html#add-django-contrib-gis-to-installed-apps

> 3- I had to also add GEOS_LIBRARY_PATH = '/usr/local/lib/libgeos_c.so'
> to my settings.py and it was a very obscure reference to that on the
> ubuntu installhttp://code.djangoproject.com/wiki/GeoDjangoUbuntuInstall

Because normally `/usr/local/lib` is in most system's
`LD_LIBRARY_PATH` -- when it's not, the GEOS library can't be found
and you solved by specifying manually.  Edit `/etc/ld.so.conf` and add
`/usr/local/lib` to it (make sure to run `ldconfig` as root afterwords
for changes to take effect).

> 4- there is no reference to where to add 
> thishttp://geodjango.org/docs/install.html#add-google-projection-to-spati...,
> I added it at the top of urls.py, but I don't think that's optimal for
> "real apps", specially if you are going to use non-google stuff.

You should not place your code in your `urls.py` file.  That command
only needs to be executed once per database table, e.g., just invoke
`./manage.py shell` and run the command after running `syncdb`.
Again, I'll try to clarify this.

> This are more general not really instalation stuff
> 5- Where can we get some sample data? is there a place where public
> domain shapefiles are stored?

All geospatial data created by the U.S. federal government is mandated
to be released in the public domain [1].  For example, the U.S. Census
Bureau's shapefiles are freely available for the data from the 2000
census:

http://www.census.gov/cgi-bin/geo/shapefiles/national-files

Unfortunately, most international jurisdictions do not have such
progressive policies regarding government spatial data.  EU member
governments, for example, typically retain ownership of their spatial
data and only provide it under commercial licenses which cost money.

> 6- shouldn't a small sample data be distributed with the package in
> order to test the install?

GeoDjango has a complete test suite that includes some basic data in
both WKT and shapefile form -- you may run the test suite by
specifying `TEST_RUNNER='django.contrib.gis.tests.run_gis_tests'`
[2].

> 7- the openlayers admin eat up a lot of my CPU, it's probably due to
> my old laptop (centrino 1.4 - ubuntu) is there any benchmarks on what
> a real server should be? or could that be that I'm running the python
> server instead of mod_python?

No, it's your _browser_ that's slow, not GeoDjango.  Specifically,
geometries with a large number of vertices may overwhelm the browser's
JavaScript interpreter.  Browsers with faster JavaScript
implementations (FF3, Safari) perform much better than slower ones
(FF2, IE).

> 8- shouldn't the shapefile importer (presented at the djangocon talk)
> be part of the the utils package?

`LayerMapping` has always been a part of the utils package:

http://geodjango.org/docs/layermapping.html

[1] See 17 U.S.C. § 105, available at 
http://www.law.cornell.edu/uscode/17/105.html.
[2] 
http://code.djangoproject.com/browser/django/trunk/django/contrib/gis/tests/__init__.py
--~--~-~--~~~---~--~~
You received this message 

Re: model help.

2008-10-23 Thread Niall Mccormack

ok, I'm going to simplify my question.

is there any way that I can create a ForeignKey or a ManytToMany that  
can accept multiple types of data Models?





On 23 Oct 2008, at 11:34, Niall Mccormack wrote:

>
> Hi there,
>
> I'm learning Django at the moment and need some advice.
>
> I need to create sections in my website that can accept two different
> models.
>
> i.e. a work section can have the following data
>   title - CharField
>   description - TextField
>   url link -  URLField
>   
>   media - a mixture of ImageFields and FileFields ( for videos )
>
>
> how would I setup the model for the media? where I can add in either
> type of Field and re-order them easily?
>
> Any advice would be appreciated
>
> Cheers
> NIall
>
> >


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



Confused by select_related()

2008-10-23 Thread AndyB

>>> p.residentialunitmix_set.all().query.as_sql()

(u'SELECT `tbl_ResidentialUnitMix`.`id`,
`tbl_ResidentialUnitMix`.`Planning-id`,
`tbl_ResidentialUnitMix`.`quantity`,
`tbl_ResidentialUnitMix`.`Bedrooms`, `tbl_ResidentialUnitMix`.`Type`,
`tbl_ResidentialUnitMix`.`Tenure` FROM `tbl_ResidentialUnitMix` WHERE
`tbl_ResidentialUnitMix`.`Planning-id` = %s '  , (82))

>>> p.residentialunitmix_set.select_related().query.as_sql()

(u'SELECT `tbl_ResidentialUnitMix`.`id`,
`tbl_ResidentialUnitMix`.`Planning-id`,
`tbl_ResidentialUnitMix`.`quantity`,
`tbl_ResidentialUnitMix`.`Bedrooms`, `tbl_ResidentialUnitMix`.`Type`,
`tbl_ResidentialUnitMix`.`Tenure` FROM `tbl_ResidentialUnitMix` WHERE
`tbl_ResidentialUnitMix`.`Planning-id` = %s '  , (82))

Tenure is a foreign key to another tables. How come both queries are
identical?

I am trying to sort by a field in the Tenure table and:
residentialunitmix_set.select_related().order_by('tbl_lkp_ResidentialUnitMix_Tenure.sort')

just gives an error. Looking at the queries explained why.

(Apologies for the table names. It's a Django interface to something
developed in Access)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Accidentally creating a model with "def unicode(self):" will crash django with no stack trace

2008-10-23 Thread Brian

I should be more precise. :) Here's a simplified excerpt of the
problematic code - when a Django (1.0) template tries to turn it into
text with its default unicode function, Python (2.5.1) crashes (on Mac
OS X 10.5):

  from django.db import models
  from people import Person

  class Letter(models.Model):
  to = models.ManyToManyField(Person, related_name="%
(class)s_related")
  author = models.ForeignKey(Person)
  content = models.TextField()

  def unicode(self):
  date = unicode(self.dated)
  author = self.author
  to = ", ".join([ unicode(r) for r in self.to.all()])
  return "Letter dated %s from %s to %s" % (date, author, to)

  @models.permalink
  def get_absolute_url(self):
  return ('letter_detail', [self.pk])

The fix being, of course, changing "unicode" to "__unicode__".

On Oct 22, 10:14 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 22, 2008 at 9:45 PM, Brian <[EMAIL PROTECTED]> wrote:
>
> > This might seem obvious, and I just spend a couple hours straining
> > over it, so I thought I'd share.
>
> > If you have a model, e.g.:
>
> > def MyModel(models.Model):
> >    # ...
> >    # with a unicode function likeso:
> >    def unicode(self):
> >       return 'something'
>
> > This will crash Django, without a stack trace.
>
> > Of course, the function is supposed to be "def __unicode__(self):",
> > but it'd have been awful nice to be able to figure that out without
> > rehashing the entire codebase (it seems like such an innocuous
> > addition to the model at the time haha).
>
> > Hopefully this will save someone some pain. :)
>
> It will crash when you do what?  I don't see a crash, I just see models
> reverting to being reported as "xzy object" in the Admin.
>
> 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: Problem when visit admin site for add a new item with manytomanyfield

2008-10-23 Thread Karen Tracey
On Thu, Oct 23, 2008 at 5:48 AM, IL <[EMAIL PROTECTED]> wrote:

>
> from django.db import models
>
> class Song(models.Model):
>name = models.CharField(max_length = 50, unique = True)
>lyricBy = models.CharField(max_length = 10, null = True, blank =
> True)
>coSinger = models.CharField(max_length = 10, null = True, blank =
> True)
>
>def __str__(self):
>return self.name
>
> class Album(models.Model):
>name = models.CharField(max_length = 50, unique = True)
>releaseDate = models.DateField(u'release date')
>songs = models.ManyToManyField(Song)
>
>def __str__(self):
>return self.name
>
> 
> This is my models (django 1.0)
>

If you are using Django 1.0, then your models need to have __unicode__
methods, not __str__ methods.

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: Mercurial or Git

2008-10-23 Thread Justin Bronn



On Oct 22, 2:54 pm, Rit Lim <[EMAIL PROTECTED]> wrote:
> which one is the Django community moving toward to, mercurial or git?

I would say the most popular among Django core developers is git.  I
use mercurial (with hgsvn), and Gary Wilson uses bazaar.  Personally,
I chose mercurial because I need first-class Windows support and found
git to be non-intuitive.

> if Django is to be moved...

Not going to happen anytime in the foreseeable future.  There's
nothing stopping you from using any of the aforementioned systems and
pulling changes from svn.

-Justin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Following tutorial but can't get something

2008-10-23 Thread Karen Tracey
On Thu, Oct 23, 2008 at 4:00 AM, gryzzly <[EMAIL PROTECTED]> wrote:

>
> It is self-expalnatory, but the problem is that I do have a template
> file. And it is there.
>

You're saying you have a file named:

/home/misha/www/djcode/templates/polls/results.html

?

Are you sure you have that exact file?  If you cut-and-paste that value
after 'cat ' in a command prompt, you see the file contents?  Or do you get:

cat: /home/misha/www/djcode/templates/polls/results.html: No such file or
directory

If cat can find the file but Django can't, there's something screwy going on
in your system.  It is far more likely that there is some subtle difference
between the name of the file you have on your system and the name you are
using in your code.

Karen

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



Re: How to use PythonOption DjangoPermissionName in apache authentication?

2008-10-23 Thread Eric

I've got the answer

the permission format used in DjangoPermissionName is

in my example, it's 'main.printdriver_developer'

On Oct 22, 11:56 pm, Eric <[EMAIL PROTECTED]> wrote:
> Hi everybody,
>
> I set apache authentication against django's user database. and I want
> to limit a location to a group of people of my django staff.
> I set this in apache's config file like this:
>
>         
>                   SetHandler cgi-script
>
>                   # authentication method
>                   AuthType Basic
>                   AuthName "Subversion repository"
>                   AuthUserFile /dev/null
>                   AuthBasicAuthoritative Off
>
>                   # require valid user
>                   Require valid-user
>
>                   # use django user database
>                   PythonOption DJANGO_SETTINGS_MODULE mysite.settings
>                   PythonOption DjangoPermissionName
> "printdriver_developer"
>                   PythonAuthenHandler django.contrib.auth.handlers.modpython
>         
>         ScriptAlias /viewvc /usr/lib/cgi-bin/viewvc.cgi
>
> and define model User in models.py of main app like this
>
> class User(models.Model):
>     rights = models.CharField(maxlength=100)
>
>     def __str__(self):
>         return self.rights
>
>     class Meta:
>         permissions = (
>             ("developerWorks_developer", "developerWorks developer"),
>             ("printdriver_developer", "Print Driver developer"),
>             )
>
>     class Admin:
>         pass
>
> but now only superuser can login to visit .../viewvc, why? how can I
> set DjangoPermission to allow people who have printdriver_developer
> permission to visit the page?
>
> Thanks a lot
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Suitability

2008-10-23 Thread Adam Nelson

Matt,

I feel your pain.  It's probably not best on the Django forum to say
this but:

1. Any modern framework is fine (Cake/PHP, Django/Python, Merb/Ruby,
etc...)
2. Use a framework of some sort (don't just roll with 'Java' without
some sort of web-specific framework for your needs)
3. Any real database will work (i.e. Access will not do and should not
be used for any web application ever - SQL Server is an amazing
database if you're stuck in a Windows only environment and there is
cash to throw around).

What really matters is:

1. Comfort level of the developers who will be working on the product
with whatever framework
2. Comfort level of the systems administrators and the rest of the
organization who will be supporting it after you leave

Finally:

1. Django is just a front end for Python.  Places using Python include
Nasa.  It is also a standard language in all modern UNIX systems -
which says alot about how solid it is and how it's here to stay.

-Adam

On Oct 23, 6:21 am, "Matthew Talbert" <[EMAIL PROTECTED]> wrote:
> Thanks, Dj, that is helpful.
>
> > A project I worked on over the summer used a Database that was 130
> > tables, and getting 1gb updates every 2 minutes. I was witting a new
> > web app to do calculations on the data and the company wanted to use
> > Java since thats what they knew best and had spend huge amounts of
> > money (1 mil +) to support with Sun Servers, and such. But I knew
> > python and django would be a better fit for this particular app, but
> > the boss wouldnt listen. So we had 10 Developers working on the Java
> > version (Including me) and over 3 months we got it about 85% done,
> > though it had no unit tests. During the same three months, I worked on
> > my own time after work and basically had no life for the whole time, I
> > was able to get the web app 100% complete with unit tests. That
> > convinced my boss that Django was a good fit.
>
> > The site is an internal app that I cannot give access to (And I
> > actually had to get permission to give what info I have), but I can
> > say that Django is a suitable framework for what you are looking for.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Mercurial or Git

2008-10-23 Thread Justin Lilly

Alternatively, you can find several git/bzr/hg mirrors for django
here:

http://code.djangoproject.com/wiki/DjangoBranches

So feel free to pull from those with your DVCS. As so few of us are
commiters anyway (and those who are, likely know how to hand the
exception), it should be the same as if django used these dvcs's.

 -justin

On Oct 23, 8:15 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Thu, Oct 23, 2008 at 3:54 AM, Rit Lim <[EMAIL PROTECTED]> wrote:
>
> > which one is the Django community moving toward to, mercurial or git?
> > if Django is to be moved...
>
> Several of the core developers are already using distributed version
> control systems to manage their activities. Git, for example, has very
> good SVN integration, and it is possible to work on a daily basis with
> a Git repository but make public commits to an SVN repository. I
> believe Mercurial has similar tools.
>
> However, there are no plans in place to migrate the official Django
> repository to any distributed version control system. The very nature
> of an 'official' repository dictates that there must be a single
> canonical checkout; SVN already provides this facility. The very fact
> that you are have to ask "which DVCS system should I use" also points
> to a problem - without a clear winner, any decision will inevitably
> shut out a portion of the community. For all its problems, SVN remains
> a reliable lingua franca.
>
> Please note: This is not an invitation to try and convince the core
> developers to change our mind. The core developers are well aware of
> the benefits and limitations of distributed version control, we have
> considered the options, we have made our decision for the moment, and
> we're not looking for community feedback on the decision.
>
> 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: Mercurial or Git

2008-10-23 Thread [EMAIL PROTECTED]

I would recommend Bazaar. In my opinion it has a simpler and more
intuitive command set than Git or Mercurial. It can also import code
history from Subversion, and has good integration with Trac. Bazaar is
fundamentally a distributed VCS, but has specific support for a
central repository workflow. And it's written in Python. The "shelve"
command found in bzr-tools is invaluable. Shelve is one of those
things that you didn't know you needed, but can't live without once
you discover it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: variable tag / filter

2008-10-23 Thread Jeff FW

To my knowledge, no, it's not possible to do that.  Even if it was,
however, I would strongly argue against it, as it would make your
templates unreadable--how would you know what filter/tag would be
called without mucking through the rest of your code? Maybe there's a
better way to get the effect you want--what are you trying to achieve?

-Jeff

On Oct 23, 6:59 am, ramya <[EMAIL PROTECTED]> wrote:
> Is it possible to have variable tags / filters
>
> {{ my_value | my_filter }}
> where c['my_filter'] = 'formatDateTime'
> formatDateTime is the actual filter function defined in templatetags
>
> similarly
>
> {{ my_tag my_filter }}
> where c['my_tag'] = 'formatDateTime'
> formatDateTime is the actual tag function defined in templatetags
>
> say in both the cases  formatDateTime is registered tag/filter and has
> been loaded
>
> Regards,
> ~ramyak/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Accidentally creating a model with "def unicode(self):" will crash django with no stack trace

2008-10-23 Thread Jeff FW

That's because when you define unicode(), inside the scope of that
function, the name "unicode" is now bound to the function you just
defined.  So, the line "date = unicode(self.dated)" is calling
Letter.unicode() instead of Python's builtin unicode(), and you get an
(almost) infinite recursive loop--"almost" because Python is smart
enough to die after a while (usually with: "RuntimeError: maximum
recursion depth exceeded").

-Jeff

On Oct 23, 8:54 am, Brian <[EMAIL PROTECTED]> wrote:
> I should be more precise. :) Here's a simplified excerpt of the
> problematic code - when a Django (1.0) template tries to turn it into
> text with its default unicode function, Python (2.5.1) crashes (on Mac
> OS X 10.5):
>
>   from django.db import models
>   from people import Person
>
>   class Letter(models.Model):
>       to = models.ManyToManyField(Person, related_name="%
> (class)s_related")
>       author = models.ForeignKey(Person)
>       content = models.TextField()
>
>       def unicode(self):
>           date = unicode(self.dated)
>           author = self.author
>           to = ", ".join([ unicode(r) for r in self.to.all()])
>           return "Letter dated %s from %s to %s" % (date, author, to)
>
>       @models.permalink
>       def get_absolute_url(self):
>           return ('letter_detail', [self.pk])
>
> The fix being, of course, changing "unicode" to "__unicode__".
>
> On Oct 22, 10:14 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Wed, Oct 22, 2008 at 9:45 PM, Brian <[EMAIL PROTECTED]> wrote:
>
> > > This might seem obvious, and I just spend a couple hours straining
> > > over it, so I thought I'd share.
>
> > > If you have a model, e.g.:
>
> > > def MyModel(models.Model):
> > >    # ...
> > >    # with a unicode function likeso:
> > >    def unicode(self):
> > >       return 'something'
>
> > > This will crash Django, without a stack trace.
>
> > > Of course, the function is supposed to be "def __unicode__(self):",
> > > but it'd have been awful nice to be able to figure that out without
> > > rehashing the entire codebase (it seems like such an innocuous
> > > addition to the model at the time haha).
>
> > > Hopefully this will save someone some pain. :)
>
> > It will crash when you do what?  I don't see a crash, I just see models
> > reverting to being reported as "xzy object" in the Admin.
>
> > 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: About running django 1.0 and MySQL

2008-10-23 Thread Ma Kwong Chia
Thank you!

On Thu, Oct 23, 2008 at 2:21 PM, web_geek <[EMAIL PROTECTED]> wrote:

> hi,
>
> I'm running Django-1.0-1.el5 and mysql-5.0.45-7.el5 on a Red Hat
> Enterprise Linux 5.2 box. Some how I still confuse what must be done
> to set up Django to talk to MySQL. May I ask for your advice about
> this here?
>
> Thanks.
>
> Rgrds,
> web_geek

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

2008-10-23 Thread dadapapa

On Oct 19, 10:10 pm, Carl Meyer <[EMAIL PROTECTED]> wrote:
> Just ran into this issue myself (first time using non-abstract
> inheritance).  The catch with this recipe is that you can never save a
> derived object from a parent instance, or you break the final_type
> field (it will then contain the parent class content type).

If by "save a derived object from a parent instance" you mean that
the method that saves the object is defined in the parent class,
than this should not cause a problem, since type(self) will
dynamically identify the object as being of the derived type,
so final_type gets initialized correctly. Then again, I might have
misunderstood your problem.

Cheers,

- harold -

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



Exception thrown from django.test.client.Client

2008-10-23 Thread [EMAIL PROTECTED]

I found this problem while trying out the django test client:

$ ./manage.py shell
>>> from django.test.client import Client
>>> c = Client()
>>> c.get('/')
Traceback (most recent call last):
  File "", line 1, in 
  File "/var/lib/python-support/python2.5/django/test/client.py", line
265, in get
return self.request(**r)
  File "/var/lib/python-support/python2.5/django/core/handlers/
base.py", line 86, in get_response
response = callback(request, *callback_args, **callback_kwargs)
  File "/path/to/website/views.py", line 12, in index
context_instance=RequestContext(request))
  File "/var/lib/python-support/python2.5/django/template/context.py",
line 105, in __init__
self.update(processor(request))
  File "/var/lib/python-support/python2.5/django/core/
context_processors.py", line 34, in debug
if settings.DEBUG and request.META.get('REMOTE_ADDR') in
settings.INTERNAL_IPS:
TypeError: 'in ' requires string as left operand

This is probably a mistake in my configuration, but it may be a bug.
It throws the same error regardless of which path I try to get, or if
I use c.post instead. Can anyone figure this out?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 add custom validation to inline admin forms, overriding clean(self) or clean_FIELD(self) doesn't work.

2008-10-23 Thread Karen Tracey
On Thu, Oct 23, 2008 at 5:09 AM, Jacob Rigby <[EMAIL PROTECTED]> wrote:

>
> I have a custom ModelForm with a TabularInline child form.  I can edit
> and save without problems, and simple field validation is working (if
> a required field is missing from the inline form it shows a warning).
> But when I try to add custom validation methods to the inline form (in
> the same way I would for a typical ModelForm, via clean(self) method)
> the validator never gets called...
>
> Can anyone point me in the right direction here, maybe there is
> another class or method I should be overriding?
>

I'm not entirely sure, but I think this may be covered by this ticket:

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

The specific use case identified there in the description (excluding a
field) was made to work via another fix, but it sounds like the larger
problem of admin not respecting form definitions for inline models still
exists.

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: Following tutorial but can't get something

2008-10-23 Thread gryzzly

Hey Heather,
Sure, and everything else does work. Every other view that points to
template that is in the same folder where “results” is does work.

On Oct 23, 2:04 pm, Heather <[EMAIL PROTECTED]> wrote:
> If the file is there, did you tell your settings file where to look
> for templates?
>
> On Oct 23, 4:00 am, gryzzly <[EMAIL PROTECTED]> wrote:
>
> > It is self-expalnatory, but the problem is that I do have a template
> > file. And it is there.
>
> > On Oct 23, 12:36 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > > On Wed, Oct 22, 2008 at 6:30 PM, gryzzly <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Karen, I am sorry, the previous post is irrelevant. What you have
> > > > seen is a result of changing of results view that I was doing before,
> > > > to test what is going on.  (btw, I've noticed that firefox caches an
> > > > error output, can I do something about it?) Thanks
>
> > > Yeah, I've seen that.  I haven't investigated what causes it so I don't 
> > > have
> > > any ideas for how to fix it.
>
> > > > So relevant error output looks like this:
>
> > > > [snipped]
>
> > > > Template Loader Error:
> > > > Django tried loading these templates, in this order:
> > > > Using loader django.template.loaders.filesystem.load_template_source:
> > > > /home/misha/www/djcode/templates/polls/results.html (File does not
> > > > exist)
> > > > Using loader
> > > > django.template.loaders.app_directories.load_template_source:
> > > > /usr/lib/python2.5/site-packages/django/contrib/admin/templates/polls/
> > > > results.html (File does not exist)
>
> > > > Traceback:
> > > > [snipped]
> > > > File "/usr/lib/python2.5/site-packages/django/template/loader.py" in
> > > > find_template_source
> > > >  73.     raise TemplateDoesNotExist, name
>
> > > > Exception Type: TemplateDoesNotExist at /polls/1/results/
> > > > Exception Value: polls/results.html
>
> > > This seems pretty self-explanatory?  (It even prints out details on all 
> > > the
> > > places it is looking, exactly, for the template file.)  You don't seem to
> > > have created the polls/results.html file.
>
> > > 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
-~--~~~~--~~--~--~---



Development of presentation editing module

2008-10-23 Thread Daniele Procida

I have sketched out an idea for an interface to apply presentation to
blocks in semantic HTML content. 

We need a Django module that will implement this idea, and would like to
find a developer or team of developers who can help refine the idea and
produce a module. 

The work will be done according to an agreement upon payment and
timescale. All code and documentation will be released back to the
Django development community under an appropriate licence.

In the context of this work, I represent Cardiff University, UK.

I have uploaded a brief sketch of and rationale for the idea: 



Regards,

Daniele



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Following tutorial but can't get something

2008-10-23 Thread Heather

If the file is there, did you tell your settings file where to look
for templates?

On Oct 23, 4:00 am, gryzzly <[EMAIL PROTECTED]> wrote:
> It is self-expalnatory, but the problem is that I do have a template
> file. And it is there.
>
> On Oct 23, 12:36 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Wed, Oct 22, 2008 at 6:30 PM, gryzzly <[EMAIL PROTECTED]> wrote:
>
> > > Hi Karen, I am sorry, the previous post is irrelevant. What you have
> > > seen is a result of changing of results view that I was doing before,
> > > to test what is going on.  (btw, I've noticed that firefox caches an
> > > error output, can I do something about it?) Thanks
>
> > Yeah, I've seen that.  I haven't investigated what causes it so I don't have
> > any ideas for how to fix it.
>
> > > So relevant error output looks like this:
>
> > > [snipped]
>
> > > Template Loader Error:
> > > Django tried loading these templates, in this order:
> > > Using loader django.template.loaders.filesystem.load_template_source:
> > > /home/misha/www/djcode/templates/polls/results.html (File does not
> > > exist)
> > > Using loader
> > > django.template.loaders.app_directories.load_template_source:
> > > /usr/lib/python2.5/site-packages/django/contrib/admin/templates/polls/
> > > results.html (File does not exist)
>
> > > Traceback:
> > > [snipped]
> > > File "/usr/lib/python2.5/site-packages/django/template/loader.py" in
> > > find_template_source
> > >  73.     raise TemplateDoesNotExist, name
>
> > > Exception Type: TemplateDoesNotExist at /polls/1/results/
> > > Exception Value: polls/results.html
>
> > This seems pretty self-explanatory?  (It even prints out details on all the
> > places it is looking, exactly, for the template file.)  You don't seem to
> > have created the polls/results.html file.
>
> > 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: problem with Form, but ModelForm works fine?

2008-10-23 Thread [EMAIL PROTECTED]

Sorry, I realized my own mistake a few hours later.

The problem was that I copied and pasted the fields from my Model. The
entities in my Form class were:

django.models instead of django.forms

Changing this solved the problem.

On Oct 23, 1:37 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I'n new to django, and I am having trouble with forms: I tried
> following the example on the web 
> page:http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index
>
> I setup a quick unit test, but I am unable to get the desired result
> with forms.Form. I replaced my forms.Form object with a ModelForm, and
> it works fine. Unfortunately I need to use the standard Form, because
> the form doesn't really match my model that much.
>
> I am using django1.0
>
> Example 1: with forms
>
> from django import forms
>
> class UploadImageForm(forms.Form):
>   name = models.CharField(max_length=200)
>   notes = models.CharField(max_length=200)
>   image = models.ImageField(upload_to='images')
>
> import unittest
> from django.test.client import Client
>
> class BasicTest(unittest.TestCase):
>
>   def testStuff(self):
>
> u = UploadImageForm()
>
> print ''
> print u.as_p()
> print ''
>
> I ran mange.py test
>
> Output (nothing):
> 
>
> 
>
> It is a forms.Form object. When I print out dir() I get all the other
> object data, but for some reason as_p(), as_table(), etc... don't
> produce any output.
>
> Example 2: with ModelForm
>
> from django.forms import ModelForm
>
> class UploadImageForm(ModelForm):
>
>   class Meta:
> fields = ('notes','image')
> model = ImageResource #defined elsewhere
>
> This time, when I run the unit test, I get the following output (it
> works):
>
> 
> Notes:  type="text" name="notes" maxlength="200" />
> Image:  name="image" id="id_image" />
> 
>
> Any ideas?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Mercurial or Git

2008-10-23 Thread Russell Keith-Magee

On Thu, Oct 23, 2008 at 3:54 AM, Rit Lim <[EMAIL PROTECTED]> wrote:
>
> which one is the Django community moving toward to, mercurial or git?
> if Django is to be moved...

Several of the core developers are already using distributed version
control systems to manage their activities. Git, for example, has very
good SVN integration, and it is possible to work on a daily basis with
a Git repository but make public commits to an SVN repository. I
believe Mercurial has similar tools.

However, there are no plans in place to migrate the official Django
repository to any distributed version control system. The very nature
of an 'official' repository dictates that there must be a single
canonical checkout; SVN already provides this facility. The very fact
that you are have to ask "which DVCS system should I use" also points
to a problem - without a clear winner, any decision will inevitably
shut out a portion of the community. For all its problems, SVN remains
a reliable lingua franca.

Please note: This is not an invitation to try and convince the core
developers to change our mind. The core developers are well aware of
the benefits and limitations of distributed version control, we have
considered the options, we have made our decision for the moment, and
we're not looking for community feedback on the decision.

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



problem with Form, but ModelForm works fine?

2008-10-23 Thread [EMAIL PROTECTED]

I'n new to django, and I am having trouble with forms: I tried
following the example on the web page:
http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index

I setup a quick unit test, but I am unable to get the desired result
with forms.Form. I replaced my forms.Form object with a ModelForm, and
it works fine. Unfortunately I need to use the standard Form, because
the form doesn't really match my model that much.

I am using django1.0

Example 1: with forms

from django import forms

class UploadImageForm(forms.Form):
  name = models.CharField(max_length=200)
  notes = models.CharField(max_length=200)
  image = models.ImageField(upload_to='images')

import unittest
from django.test.client import Client

class BasicTest(unittest.TestCase):

  def testStuff(self):

u = UploadImageForm()

print ''
print u.as_p()
print ''

I ran mange.py test

Output (nothing):




It is a forms.Form object. When I print out dir() I get all the other
object data, but for some reason as_p(), as_table(), etc... don't
produce any output.


Example 2: with ModelForm

from django.forms import ModelForm

class UploadImageForm(ModelForm):

  class Meta:
fields = ('notes','image')
model = ImageResource #defined elsewhere



This time, when I run the unit test, I get the following output (it
works):


Notes: 
Image: 


Any ideas?

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



Django Model design: OOP or Database-centric approach?

2008-10-23 Thread dustpuppy

Hi,

I'm starting off with Django and trying my first (toy) project. It's a
Kris Kindle application (called "Secret Santa"? by some). Not exactly
earth-shattering, but I want to start with something small.

I'm unsure what approach to use when designing my model.

The entities I am dealing with are Family, Adult and Kinder.

Normally for a standalone application (using Java or Python), I would
design a class Family, with fields/attributes representing arrays/
lists of objects of the classes Adult and Kinder.
(Apologies if my OOP terminology is mixed-up - I'm originally a C/Perl
programmer!)

I've started my Django design that way:

class Adult(models.Model):
name = models.CharField(maxlength=30)
partner = models.CharField(maxlength=30)
kriskindle = models.CharField(maxlength=30)
email = models.EmailField()

def __str__(self):
return self.name

class Admin:
#list_display('name', 'partner', 'email')
pass

class Kinder(models.Model):
name = models.CharField(maxlength=30)
excluded = models.ManyToManyField(Adult)
kriskindle = models.CharField(maxlength=30)

def __str__(self):
return self.name

class Admin:
#list_display('name', 'excluded')
pass


class Family(models.Model):
name = models.CharField(maxlength=30)
children = models.ManyToManyField(Kinder)
adults = models.ManyToManyField(Adult)

def __str__(self):
return self.name

class Admin:
pass

On the other hand, for any previous Web development I've done (with
PHP or Perl), I would have define just 2 entities, Adult and Kinder,
and simply included family as a string attribute of each.

class Adult(models.Model):
name = models.CharField(maxlength=30)
partner = models.CharField(maxlength=30)
kriskindle = models.CharField(maxlength=30)
email = models.EmailField()
family = models.CharField(maxlength=30)

def __str__(self):
return self.name

class Admin:
#list_display('name', 'partner', 'email')
pass

class Kinder(models.Model):
name = models.CharField(maxlength=30)
excluded = models.ManyToManyField(Adult)
kriskindle = models.CharField(maxlength=30)
family = models.CharField(maxlength=30)

def __str__(self):
return self.name

class Admin:
#list_display('name', 'excluded')
pass

I actually think the former would be easier to program, e.g. in terms
of getting access to the lists of adults directly from the database,
instead of having to retrieve it from a Family object first.

Which of these would be the more appropriate way to do it in Django?

Thanks in advance for taking the time to respond.

Kind regards,
Cormac.

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



Get raw data in adminform

2008-10-23 Thread Mussorgsky

In pre 1.0 I could get raw data in the admin change_form with
{{ form.data.fieldnameabc }} this does not work with 1.0 using
newforms. How would I do this now (post 1.0)?

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



from mysite.polls.models import Poll, Choice

2008-10-23 Thread tak

Hi,

I am following the tutorial. One part I get confusion is the import
statement including the project name. I am referring the last example
of 1st tutorial.

A project name is a collection of application, so should any statement
in the project not refer to it?

Does anyone have a answer to that?

Thanks,
tak

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



Problem when visit admin site for add a new item with manytomanyfield

2008-10-23 Thread IL

from django.db import models

class Song(models.Model):
name = models.CharField(max_length = 50, unique = True)
lyricBy = models.CharField(max_length = 10, null = True, blank =
True)
coSinger = models.CharField(max_length = 10, null = True, blank =
True)

def __str__(self):
return self.name

class Album(models.Model):
name = models.CharField(max_length = 50, unique = True)
releaseDate = models.DateField(u'release date')
songs = models.ManyToManyField(Song)

def __str__(self):
return self.name


This is my models (django 1.0)

I've used interactive shell add a new Album and at some songs to that
Album, It's ok.

When I mark Album.songs as comment. The admin page for add one Album
is all right.

But with the manytomany songs, I got this:


TemplateSyntaxError at /admin/xjay/album/1/

Caught an exception while rendering: 'cp932' codec can't encode
character u'\u9f99' in position 0: illegal multibyte sequence

Original Traceback (most recent call last):
  File "c:\python25\Lib\site-packages\django\template\debug.py", line
71, in render_node
result = node.render(context)
  File "c:\python25\Lib\site-packages\django\template\debug.py", line
87, in render
output = force_unicode(self.filter_expression.resolve(context))
  File "c:\python25\Lib\site-packages\django\utils\encoding.py", line
49, in force_unicode
s = unicode(s)
  File "c:\python25\Lib\site-packages\django\forms\forms.py", line
326, in __unicode__
return self.as_widget()
  File "c:\python25\Lib\site-packages\django\forms\forms.py", line
358, in as_widget
return widget.render(name, data, attrs=attrs)
  File "c:\python25\Lib\site-packages\django\contrib\admin
\widgets.py", line 224, in render
output = [self.widget.render(name, value, *args, **kwargs)]
  File "c:\python25\Lib\site-packages\django\forms\widgets.py", line
415, in render
options = self.render_options(choices, value)
  File "c:\python25\Lib\site-packages\django\forms\widgets.py", line
376, in render_options
for option_value, option_label in chain(self.choices, choices):
  File "c:\python25\Lib\site-packages\django\forms\models.py", line
569, in __iter__
yield self.choice(obj)
  File "c:\python25\Lib\site-packages\django\forms\models.py", line
582, in choice
return (key, self.field.label_from_instance(obj))
  File "c:\python25\Lib\site-packages\django\forms\models.py", line
625, in label_from_instance
return smart_unicode(obj)
  File "c:\python25\Lib\site-packages\django\utils\encoding.py", line
35, in smart_unicode
return force_unicode(s, encoding, strings_only, errors)
  File "c:\python25\Lib\site-packages\django\utils\encoding.py", line
52, in force_unicode
s = unicode(str(s), encoding, errors)
UnicodeEncodeError: 'cp932' codec can't encode character u'\u9f99' in
position 0: illegal multibyte sequence


===
Any idea?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: login_required for imported apps

2008-10-23 Thread Heather


> Authentication is actually handled by a middleware, you know ?-)
Heh, well, this is true so I guess it's not such a big deal, then.

> Ok, I already expressed MVHO on this, which is that having a clean way
> to apply a same decorator to a whole set of urls at once would be a
> good thing. Now at least you have two or three (if you count the hack
> I proposed) ways to do it - which is by all means better than none.
> Believe me or else, I sometimes had to use *way* more *evil* hacks
> (Lord forgive me...) to make some existing apps (not Django - nor even
> Python FWIW) work together.
>
Yep, that's true.  At least it *can* be done.

Thanks for the help :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: setting a 'default' filter for templates

2008-10-23 Thread Ned Batchelder

You could modify your view function (typed off the top of my head, so 
the details may be wrong):

# ...blah blah build your context...
for name, value in context.items():
   context[name] = special_function(value)
return render_to_response('template.html', context)

If you have a number of views, then a helper function:

def render_special(context):
for name, value in context.items():
   context[name] = special_function(value)
return render_to_response('template.html', context)

# then in your view:

# ..blah blah build your context...
return render_special(context)

--Ned.
http://nedbatchelder.com

Dennis Schmidt wrote:
> Hi there,
>
> I need to get every variable that will be printed out in my templates
> to be passed through a special function.
> Since I need this function globally and my variables are coming from
> various places I thought the best way to do this would be right before
> actually printing them to the template. Therefore I would create a
> custom filter. But then the 'problem' is that I would need to apply
> this filter manually {{ myVariable|myCustomFilter }} everytime which
> is kind of ugly.
>
> So I'm wondering if there is some way to tell django to use my filter
> for every output it makes for a specific template. Or maybe there is
> yet another good solution for this?
>
> I hope you can help me, thanks in advance,
>
> Dennis
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.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: Django Suitability

2008-10-23 Thread Matthew Talbert

Thanks, Dj, that is helpful.

> A project I worked on over the summer used a Database that was 130
> tables, and getting 1gb updates every 2 minutes. I was witting a new
> web app to do calculations on the data and the company wanted to use
> Java since thats what they knew best and had spend huge amounts of
> money (1 mil +) to support with Sun Servers, and such. But I knew
> python and django would be a better fit for this particular app, but
> the boss wouldnt listen. So we had 10 Developers working on the Java
> version (Including me) and over 3 months we got it about 85% done,
> though it had no unit tests. During the same three months, I worked on
> my own time after work and basically had no life for the whole time, I
> was able to get the web app 100% complete with unit tests. That
> convinced my boss that Django was a good fit.
>
> The site is an internal app that I cannot give access to (And I
> actually had to get permission to give what info I have), but I can
> say that Django is a suitable framework for what you are looking for.
>

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



variable tag / filter

2008-10-23 Thread ramya

Is it possible to have variable tags / filters

{{ my_value | my_filter }}
where c['my_filter'] = 'formatDateTime'
formatDateTime is the actual filter function defined in templatetags


similarly

{{ my_tag my_filter }}
where c['my_tag'] = 'formatDateTime'
formatDateTime is the actual tag function defined in templatetags


say in both the cases  formatDateTime is registered tag/filter and has
been loaded

Regards,
~ramyak/


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