non-model permissions

2008-12-06 Thread mh983

What is the best way to create permissions for use in authorization if
those permissions aren't related to any specific model?  I can't seem
to find anything to tell me how to do this.  In fact, it looks like
even the database tables for permissions assume they are associated
with a model (auth_permission table has a content_type_id and the
content_type table refers to a model).

For example. I'd like to restrict certain buttons on a form or certain
links to particular users.  Also, I want to have my own page for a
superuser to see and enable/disable these permissions for any user, so
my solution needs to take that into account as well.

Should I create my own Permission model with a ForeignKey to the built-
in User model?

Any help on the best way to do this would be appreciated.  I'm just
getting started converted my application to django and I'm stuck on
this.

thanks,

mike

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



Re: Removing accents from strings

2008-12-06 Thread Karen Tracey
On Sat, Dec 6, 2008 at 9:00 PM, Dave Dash <[EMAIL PROTECTED]> wrote:

>
> Okay I think that fixes one fundamental issue... I've got a unittest,
> however that fails for a function:
>
> def normalize(tag):
>"""
>>>> normalize(u'cafe')
>u'cafe'
>>>> normalize(u'caf e')
>u'cafe'
>>>> normalize(u' cafe ')
>u'cafe'
>>>> normalize(u' café ')
>u'cafe'
>>>> normalize(u'cAFe')
>u'cafe'
>>>> normalize(u'%sss%s')
>u''
>"""
>try:
>tag = remove_diacritics(tag)
>except:
>pass
>
>tag = reTagnormalizer.sub('', tag).lower()
>return tag
>
> It fails on the ' café' and translates it to cafa instead of cafe.
> THis is only through the unittest framework (doctest) since I can run
> it from django shell and it works as intended.
>
> Is this just an issue with doctest?
>

If I cut and paste your code and take out reTagnormalizer (since you didn't
post that) and all the tests that seem to depend on what it does vs.
remove_diacritics, and just test:

   """
   >>> normalize(u'café')
   u'cafe'
   """
plain Python doctesting it works fine, as does 'manage.py test someapp' (if
I put the code in somapp's models.py file).

So I can't recreate the error you are reporting based on what you have
posted.  What's in reTagnormalizer?

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: keep html

2008-12-06 Thread Karen Tracey
On Sat, Dec 6, 2008 at 9:17 PM, Patricio Palma <[EMAIL PROTECTED]>wrote:

>
> Is possible to get the html code from an administration page?
>
>
> I mean, my browser is interpreting a html generated by templates and
> components of my application, some banners and pictures.
>
> Is there any way to get that code?
>

Something like View->Page Source from the browser menu? (That's what Firefox
calls it -- I'd guess most browsers have some such way to see the raw html
for a page.)  Or am I misunderstanding your question?

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



Reducing the number of my view's database queries

2008-12-06 Thread erikcw

Hi all,

I'm trying to write a model query that will return a queryset along
with the latest (and earliest) data from 2 related models.

Right now I'm doing something like this:

objects = Model1.objects.filter(user=3).select_related() #about 6,000
objects

data = {}
for o in objects:
data[o.name] = [o.field1, o.field2]
data[o.name].append(o.field3.model2_set.all().latest('created'))
#get latest row from related model2
data[o.name].append(o.model3_set.all().order_by('created')[0])
#get earliest row from related model3

The problem is that this results in a TON of database queries.  This
view is taking over a minute to process.  The select_related on the
first line doesn't seem to be helping since I'm using latest()/
order_by which generates a new query.

How can I make this more efficient?  Denormalizing the isn't an option
since model2 and model 3 are many-to-one.

Is there something I can do with extra() in the first query or some
sort of subquey I can do to eliminate the loop?

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



Re: misreporting verify_exists

2008-12-06 Thread Malcolm Tredinnick


On Sun, 2008-12-07 at 12:02 +0800, Eric Abrahamsen wrote:
[...]
> Thanks for the response, Malcolm. I wonder if I'm looking at the wrong  
> part of the code? forms.fields.URLField.clean() seems to be using a  
> full urllib2.urlopen, not just a HEAD request -- am I looking at the  
> wrong code?

Yeah, looks like you're right. *shrug* In any case, that's not your
problem. Requests to that URL go through fine, whether HEAD or GET. I
even tried it using the user agent that Django would send (unless you
reconfigured it in your settings file) and it worked.

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: misreporting verify_exists

2008-12-06 Thread Eric Abrahamsen


On Dec 7, 2008, at 11:44 AM, Malcolm Tredinnick wrote:

>
>
> On Sun, 2008-12-07 at 14:42 +1100, Malcolm Tredinnick wrote:
> [...]
>
>> So have a look at the result of something like "curl -I http://...
>> " (or
>> equivalent tool if you don't have curl around). Basically, force a  
>> HEAD
>> request and see if that returns something sensible.
>
> Ignore me. I completely missed that you'd given the link. I tried the
> HEAD request and it returned a 200 response. So that isn't it. So I  
> have
> no idea. Sorry for the noise.

Thanks for the response, Malcolm. I wonder if I'm looking at the wrong  
part of the code? forms.fields.URLField.clean() seems to be using a  
full urllib2.urlopen, not just a HEAD request -- am I looking at the  
wrong code?

Eric


>
>
> 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: misreporting verify_exists

2008-12-06 Thread Malcolm Tredinnick


On Sun, 2008-12-07 at 14:42 +1100, Malcolm Tredinnick wrote:
[...]

> So have a look at the result of something like "curl -I http://...
> " (or
> equivalent tool if you don't have curl around). Basically, force a HEAD
> request and see if that returns something sensible.

Ignore me. I completely missed that you'd given the link. I tried the
HEAD request and it returned a 200 response. So that isn't it. So I have
no idea. Sorry for the noise.

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: misreporting verify_exists

2008-12-06 Thread Malcolm Tredinnick


On Sun, 2008-12-07 at 11:32 +0800, Eric Abrahamsen wrote:
> I've got a model with a URLField, with verify_exists set to True,  
> which has suddenly started barfing "broken link" on a certain URL. I'm  
> quite sure the URL exists, and can't figure out why it can't get past  
> validation. This is the link:
> 
> http://www.rochester.edu/College/translation/threepercent/index.php?id=1482
> 
> The URLField itself is nothing special (unique=True, that's all). I  
> get the same error in development and production, though using urllib  
> on my production machine opens the URL fine, and I can open it in a  
> browser on my development machine. I started a Python interpreter and  
> manually typed in most of what goes on in  
> forms.fields.URLField.clean() (minus the User Agent stuff, don't know  
> what that is), and it opened with no problem. When the validation  
> error comes back in the Admin interface, the url hasn't been truncated  
> or altered in any way, so I don't think that's it. I've entered URLs  
> with GET parameters before...
> 
> I can't think of anything else! Has someone got a bright idea? I'm  
> running 1.1 pre-alpha SVN-9569.

Verify_exists uses an HTTP HEAD request to check the existence, since it
doesn't need the whole page. Some web browsers are misconfigured and
report 404 for URLS when a HEAD request is made, but not for the same
resource via a GET request.

So have a look at the result of something like "curl -I http://... " (or
equivalent tool if you don't have curl around). Basically, force a HEAD
request and see if that returns something sensible.

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



misreporting verify_exists

2008-12-06 Thread Eric Abrahamsen

I've got a model with a URLField, with verify_exists set to True,  
which has suddenly started barfing "broken link" on a certain URL. I'm  
quite sure the URL exists, and can't figure out why it can't get past  
validation. This is the link:

http://www.rochester.edu/College/translation/threepercent/index.php?id=1482

The URLField itself is nothing special (unique=True, that's all). I  
get the same error in development and production, though using urllib  
on my production machine opens the URL fine, and I can open it in a  
browser on my development machine. I started a Python interpreter and  
manually typed in most of what goes on in  
forms.fields.URLField.clean() (minus the User Agent stuff, don't know  
what that is), and it opened with no problem. When the validation  
error comes back in the Admin interface, the url hasn't been truncated  
or altered in any way, so I don't think that's it. I've entered URLs  
with GET parameters before...

I can't think of anything else! Has someone got a bright idea? I'm  
running 1.1 pre-alpha SVN-9569.

Thanks,
Eric

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



keep html

2008-12-06 Thread Patricio Palma

Is possible to get the html code from an administration page?


I mean, my browser is interpreting a html generated by templates and
components of my application, some banners and pictures.

Is there any way to get that 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: Removing accents from strings

2008-12-06 Thread Dave Dash

Okay I think that fixes one fundamental issue... I've got a unittest,
however that fails for a function:

def normalize(tag):
"""
>>> normalize(u'cafe')
u'cafe'
>>> normalize(u'caf e')
u'cafe'
>>> normalize(u' cafe ')
u'cafe'
>>> normalize(u' café ')
u'cafe'
>>> normalize(u'cAFe')
u'cafe'
>>> normalize(u'%sss%s')
u''
"""
try:
tag = remove_diacritics(tag)
except:
pass

tag = reTagnormalizer.sub('', tag).lower()
return tag

It fails on the ' café' and translates it to cafa instead of cafe.
THis is only through the unittest framework (doctest) since I can run
it from django shell and it works as intended.

Is this just an issue with doctest?



On Dec 6, 4:30 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sat, Dec 6, 2008 at 7:23 PM, Dave Dash <[EMAIL PROTECTED]> wrote:
>
> > I'm experiencing some strange behavior, and I think it has to do with
> > how django deals with utf strings:
>
> > When I write a test.py file:
>
> > import re, unicodedata
>
> > reCombining = re.compile(u'[\u0300-\u036f\u1dc0-\u1dff\u20d0-\u20ff
> > \ufe20-\ufe2f]',re.U)
>
> > def remove_diacritics(s):
> >    return reCombining.sub('',unicodedata.normalize('NFD',unicode
> > (s)) )
>
> > and then open the python shell, I get:
>
> > Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
> > [GCC 4.0.1 (Apple Inc. build 5484)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> from test import *
> > >>> remove_diacritics(u'café')
> > u'cafe'
>
> > as intended.
>
> > When I do the same thing with the django shell:
> > $ python manage.py shell
> > Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
> > [GCC 4.0.1 (Apple Inc. build 5484)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.
> > (InteractiveConsole)
> > >>> from test import *
> > >>> remove_diacritics(u'café')
> > u'cafA\xa9'
>
> > Which isn't quite what I expected.
>
> > My questions are:
>
> > 1. How do I properly remove accents from strings in Django
> > 2. What is django (this is using trunk) doing to strings differently
> > than python?
>
> > Even typing u'é' in the shell returns different things.
>
> That's a Python bug:http://bugs.python.org/issue1288615 (manage.py shell
> uses Python's code.interact())
>
> I believe it's fixed in 2.6.
>
> 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: Removing accents from strings

2008-12-06 Thread Karen Tracey
On Sat, Dec 6, 2008 at 7:23 PM, Dave Dash <[EMAIL PROTECTED]> wrote:

>
> I'm experiencing some strange behavior, and I think it has to do with
> how django deals with utf strings:
>
> When I write a test.py file:
>
> import re, unicodedata
>
> reCombining = re.compile(u'[\u0300-\u036f\u1dc0-\u1dff\u20d0-\u20ff
> \ufe20-\ufe2f]',re.U)
>
> def remove_diacritics(s):
>return reCombining.sub('',unicodedata.normalize('NFD',unicode
> (s)) )
>
>
> and then open the python shell, I get:
>
> Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
> [GCC 4.0.1 (Apple Inc. build 5484)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from test import *
> >>> remove_diacritics(u'café')
> u'cafe'
>
>
> as intended.
>
> When I do the same thing with the django shell:
> $ python manage.py shell
> Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
> [GCC 4.0.1 (Apple Inc. build 5484)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> from test import *
> >>> remove_diacritics(u'café')
> u'cafA\xa9'
>
>
> Which isn't quite what I expected.
>
> My questions are:
>
> 1. How do I properly remove accents from strings in Django
> 2. What is django (this is using trunk) doing to strings differently
> than python?
>
> Even typing u'é' in the shell returns different things.
>

That's a Python bug: http://bugs.python.org/issue1288615  (manage.py shell
uses Python's code.interact())

I believe it's fixed in 2.6.

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



Removing accents from strings

2008-12-06 Thread Dave Dash

I'm experiencing some strange behavior, and I think it has to do with
how django deals with utf strings:

When I write a test.py file:

import re, unicodedata

reCombining = re.compile(u'[\u0300-\u036f\u1dc0-\u1dff\u20d0-\u20ff
\ufe20-\ufe2f]',re.U)

def remove_diacritics(s):
return reCombining.sub('',unicodedata.normalize('NFD',unicode
(s)) )


and then open the python shell, I get:

Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
[GCC 4.0.1 (Apple Inc. build 5484)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from test import *
>>> remove_diacritics(u'café')
u'cafe'


as intended.

When I do the same thing with the django shell:
$ python manage.py shell
Python 2.5.2 (r252:60911, Aug 10 2008, 00:43:40)
[GCC 4.0.1 (Apple Inc. build 5484)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from test import *
>>> remove_diacritics(u'café')
u'cafA\xa9'


Which isn't quite what I expected.

My questions are:

1. How do I properly remove accents from strings in Django
2. What is django (this is using trunk) doing to strings differently
than python?

Even typing u'é' in the shell returns different things.

Cheers,

Dave

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



Re: Django configuration. I can't import django.db .

2008-12-06 Thread Marek Wawrzyczek
You're very observant. Thanks :))

2008/12/6 Karen Tracey <[EMAIL PROTECTED]>

> On Sat, Dec 6, 2008 at 11:53 AM, Marek Wawrzyczek <[EMAIL PROTECTED]>wrote:
>
>> In the tutorial (http://docs.djangoproject.com/en/dev/intro/tutorial01/)
>> I do everything what is written, and in the
>> "Activating Models" section, when I run the:
>>
>> python manage.py sql polls
>>
>> I get the following message:
>>
>> Traceback (most recent call last):
>>   File "manage.py", line 11, in 
>> execute_manager(settings)
>>   File
>> "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line
>> 340, in execute_manager
>> utility.execute()
>>   File
>> "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line
>> 295, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File "/usr/lib/python2.5/site-packages/django/core/management/base.py",
>> line 192, in run_from_argv
>> self.execute(*args, **options.__dict__)
>>   File "/usr/lib/python2.5/site-packages/django/core/management/base.py",
>> line 210, in execute
>> translation.activate('en-us')
>>   File
>> "/usr/lib/python2.5/site-packages/django/utils/translation/__init__.py",
>> line 73, in activate
>> return real_activate(language)
>>   File
>> "/usr/lib/python2.5/site-packages/django/utils/translation/__init__.py",
>> line 43, in delayed_loader
>> return g['real_%s' % caller](*args, **kwargs)
>>   File
>> "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
>> line 209, in activate
>> _active[currentThread()] = translation(language)
>>   File
>> "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
>> line 198, in translation
>> default_translation = _fetch(settings.LANGUAGE_CODE)
>>   File
>> "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
>> line 181, in _fetch
>> app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]),
>> appname[p+1:])
>> AttributeError: 'module' object has no attribute 'pools'
>>
>> What do I do wrong ?
>>
>
> You misspelled 'polls' as 'pools' in INSTALLED_APPS?
>
> Karen
>
>
> >
>


-- 
Pozdrawiam,

Marek Wawrzyczek

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



Re: Ruby on Rails vs Django

2008-12-06 Thread Low Kian Seong

I think django is closer to merb http://merbivore.com/ rather than ROR.

On Sat, Dec 6, 2008 at 10:48 PM, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
>
>
>
> On 6 déc, 10:55, "Guillermo C." <[EMAIL PROTECTED]> wrote:
>> Hi.
>>
>> - Scaffolding: I prefer it over django admin in many situations. I
>> mean, when you're doing something complex you'll need to drop out the
>> django admin and write your own code, so it's cool to have the basic
>> CRUD code and develop from that.
>
> While you surely have to write some code for custom stuff, you don't
> necessarily have to "drop out of admin" - you can just customize the
> relevant part of the admin.
> (snip)
>
>> - RoR controllers versus Django views: Django does not enclose in
>> classes the controllers neither have Routes, the mapping between urls
>> and views (plain functions taking a ``request`` object as first param).
>
> s/plain functions/callable objects/
>
> Remember that classes are callable too, and that Python let you define
> your own callable types.
>
> (snip)
> >
>



-- 
Low Kian Seong
blog: http://lowkster.blogspot.com

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



Re: Character encoding... latin1 to utf8?

2008-12-06 Thread Karen Tracey
On Sat, Dec 6, 2008 at 2:59 PM, Rob Hudson <[EMAIL PROTECTED]> wrote:

>
> Wow, thanks so much Karen, for slicing and dicing the problem like
> that.
>
> On Dec 6, 10:36 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > You could also just convert the character set used on the MySQL side:
> >
> > http://dev.mysql.com/doc/refman/5.0/en/charset-conversion.html
> >
> > Presumably since MySQL knows it really means cp1252 for stuff it calls
> > latin1, it would convert properly to utf-8 when you told it to.  You'd
> > sidestep the issues you've hit with 'latin1' meaning different things to
> > different pieces of software.
>
> The problem is, there is no cp1252 character set in MySQL as far as I
> can tell, since cp1252 == latin1 to mysql.  And setting the keyword
> argument to connect to "charset='cp1252'" threw a MySQL error.
>
> My data migration script is working now, though, when I don't specify
> 'use_unicode=True' and manually run .decode('cp1252') on the columns I
> need to.
>
>
What I meant was you could use the mysql program and commands like:

ALTER TABLE book CONVERT TO CHARACTER SET utf8;

to get MySQL to do the conversion itself.  Presumably it would convert what
it calls latin1 to utf8 correctly. (I'd first do it on a dumped/reloaded to
a test DB version before trying such a command on a production DB.)

But if you've got your migration script working, then there's no point with
experimenting to see if you could get MySQL to do it correctly itself.

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: Excel Generating Report

2008-12-06 Thread Low Kian Seong

Try this :

response['Content-Disposition']='attachment;filename=output.xls'

That worked for me.

On Sun, Dec 7, 2008 at 2:14 AM, garces.85 <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I need some urgent help.  I have a function that generates a report in
> excel, the report returns the data that i need the problem es that i
> am getting some strange characters like: Í , ó, ñ, etc...
>
> I have tried with django smart_unicode and force_unicode but nothing
> happens.
>
> Is there i way i could solve this?
>
> Here is my function:
>
> def encuesta_reporte(request):
>import csv
>from django.http import HttpResponse
>from django.template import loader, Context
>from django.utils.encoding import smart_unicode
>
>
># Query.
>school_id = School.objects.get(id = 256)
>data = School_Answer.objects.filter(school = school_id)
>
>temp =  render_to_response('my_template_name.html',
>  {'data':data,
>   'docente_id':docente_id,},
>  context_instance = RequestContext
> (request),
>  )
>
>
>response = HttpResponse(temp, mimetype='application/vnd.ms-excel')
>response['Content-Disposition'] = 'attachment;
> filename=report_school.xls'
>return response
> >
>



-- 
Low Kian Seong
blog: http://lowkster.blogspot.com

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



Re: How can I report a new user?

2008-12-06 Thread Patricio Palma
On Sat, Dec 6, 2008 at 4:59 PM, Jeff FW <[EMAIL PROTECTED]> wrote:

>
> Do you mean when a user is added via the admin interface, or when a
> user registers on the site through a view you have set up?  If it's
> through a view you've made, then just add the call to send_mail() in
> the view.  For the admin site, you'll want to look at signals:
> http://docs.djangoproject.com/en/dev/topics/signals/
>
> -Jeff
>
>
ty men, the signals are my solution, again.


-- 
Patricio Adolfo Palma Solis
Estudiante de Ingeniería en Computación
Universidad Austral de Chile
[EMAIL PROTECTED]
[EMAIL PROTECTED]
83852414

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



Re: using settings in templates

2008-12-06 Thread Jeff FW

You can pass the settings object into your context when you render
your template, or you can write a context processor that adds the
settings object to the template's context.  Take a look at the docs on
context processors, especially the section about writing your own:
http://docs.djangoproject.com/en/dev/ref/templates/api/?#id1

-Jeff

On Dec 6, 1:17 pm, barracuda <[EMAIL PROTECTED]> wrote:
> Hello,
> How can I use a configuration in settings in templates?
> For e.g , I would like to use the DATE_FORMAT configured in settings
> to format the database datetime in a template
> Here: {{db_time|date:"D d M Y" }} I want to get the format from
> settings.
>
> 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: Character encoding... latin1 to utf8?

2008-12-06 Thread Rob Hudson

Wow, thanks so much Karen, for slicing and dicing the problem like
that.

On Dec 6, 10:36 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> You could also just convert the character set used on the MySQL side:
>
> http://dev.mysql.com/doc/refman/5.0/en/charset-conversion.html
>
> Presumably since MySQL knows it really means cp1252 for stuff it calls
> latin1, it would convert properly to utf-8 when you told it to.  You'd
> sidestep the issues you've hit with 'latin1' meaning different things to
> different pieces of software.

The problem is, there is no cp1252 character set in MySQL as far as I
can tell, since cp1252 == latin1 to mysql.  And setting the keyword
argument to connect to "charset='cp1252'" threw a MySQL error.

My data migration script is working now, though, when I don't specify
'use_unicode=True' and manually run .decode('cp1252') on the columns I
need to.

Much thanks to both you and Malcolm for helping me get this cleared
up.

Thanks,
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from 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 can I report a new user?

2008-12-06 Thread Jeff FW

Do you mean when a user is added via the admin interface, or when a
user registers on the site through a view you have set up?  If it's
through a view you've made, then just add the call to send_mail() in
the view.  For the admin site, you'll want to look at signals:
http://docs.djangoproject.com/en/dev/topics/signals/

-Jeff

On Dec 6, 1:26 pm, Patricio Palma <[EMAIL PROTECTED]> wrote:
> I have a model user
>
> class User(models.Model):
>     name = models.CharField(_("name"), max_length=40)
>     paternals = models.CharField(max_length=40)
>     maternals = models.CharField(max_length=40)
>     email = models.EmailField("e-mail")
>     phone = models.IntegerField(_("phone number"))
>     rol = models.IntegerField(_("company number"))
>
> I need to know when a new user is added to the system, and send a e-
> mail report,
>
> I know how send a mail. but I don't know where or when do 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: Django configuration. I can't import django.db .

2008-12-06 Thread Karen Tracey
On Sat, Dec 6, 2008 at 11:53 AM, Marek Wawrzyczek <[EMAIL PROTECTED]>wrote:

> In the tutorial (http://docs.djangoproject.com/en/dev/intro/tutorial01/) I
> do everything what is written, and in the
> "Activating Models" section, when I run the:
>
> python manage.py sql polls
>
> I get the following message:
>
> Traceback (most recent call last):
>   File "manage.py", line 11, in 
> execute_manager(settings)
>   File
> "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line
> 340, in execute_manager
> utility.execute()
>   File
> "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line
> 295, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python2.5/site-packages/django/core/management/base.py",
> line 192, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "/usr/lib/python2.5/site-packages/django/core/management/base.py",
> line 210, in execute
> translation.activate('en-us')
>   File
> "/usr/lib/python2.5/site-packages/django/utils/translation/__init__.py",
> line 73, in activate
> return real_activate(language)
>   File
> "/usr/lib/python2.5/site-packages/django/utils/translation/__init__.py",
> line 43, in delayed_loader
> return g['real_%s' % caller](*args, **kwargs)
>   File
> "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
> line 209, in activate
> _active[currentThread()] = translation(language)
>   File
> "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
> line 198, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File
> "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
> line 181, in _fetch
> app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]),
> appname[p+1:])
> AttributeError: 'module' object has no attribute 'pools'
>
> What do I do wrong ?
>

You misspelled 'polls' as 'pools' in INSTALLED_APPS?

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: Character encoding... latin1 to utf8?

2008-12-06 Thread Karen Tracey
On Sat, Dec 6, 2008 at 1:36 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:

>
>   You can see how this works better than the latin1 code in a Python shell:
>
> >>> x = 'Bullet ->\x95<- and curly apostrophe ->\x92<- in a cp1252
> bytestring'
> >>> ulatin1 = x.decode('latin1')
> >>> ulatin1
> u'Bullet ->\x95<- and curly apostrophe ->\x92<- in a cp1252 bytestring'
> >>> print ulatin1
> Bullet ->•<- and curly apostrophe ->'<- in a cp1252 bytestring
>

Hah, this looks right in the posted version.  It looked wrong (some weird
char not a bullet,and a blank for the apostrophe) in the python shell itself
and in the version pasted into the composition window (where the two chars
turned into boxes).  I haven't the foggiest idea how they came out looking
correct when posted...

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



using settings in templates

2008-12-06 Thread barracuda

Hello,
How can I use a configuration in settings in templates?
For e.g , I would like to use the DATE_FORMAT configured in settings
to format the database datetime in a template
Here: {{db_time|date:"D d M Y" }} I want to get the format from
settings.

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 can I report a new user?

2008-12-06 Thread Patricio Palma

I have a model user

class User(models.Model):
name = models.CharField(_("name"), max_length=40)
paternals = models.CharField(max_length=40)
maternals = models.CharField(max_length=40)
email = models.EmailField("e-mail")
phone = models.IntegerField(_("phone number"))
rol = models.IntegerField(_("company number"))

I need to know when a new user is added to the system, and send a e-
mail report,


I know how send a mail. but I don't know where or when do 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: Character encoding... latin1 to utf8?

2008-12-06 Thread Karen Tracey
On Sat, Dec 6, 2008 at 11:10 AM, Rob Hudson <[EMAIL PROTECTED]> wrote:

> [snip debug info]
>
> Now instead of \x95 I get \u2022 (which is a bullet).
>
> From here I'm not sure what the best way to proceed is... do I want
> the \u2022 version instead, in which case, should I not pass in
> unicode=True and manually decode each column?


What you've got in your DB is actually cp1252 (although MySQL calls it
latin1) data.  The values assigned to 0x95 and 0x92 in cp1252 are bullet and
curly apostrophe.  What you want in your unicode strings are the \u2022 and
\u2019 versions, since these are the correct code point assignments for
bullet and curly apostrophe in unicode.  (Unicode \x95 is the message
waiting control character and \x92 is 'private use two' control character).

In case you care, why it is not working when you specify unicode=True to
MySQLdb, is, I believe, a combination two factors: first, the Python codec
MySQLdb chooses to use to decode the data coming from MySQL, and second how
that codec behaves in the face of technically invalid data.

First, MySQLdb apparently decides to use the latin1 Python codec to decode
the data coming from MySQL into a unicode string.  On the face of it this
seems like a reasonable choice, since after all MySQL reports that the data
is 'latin1'.  However if you read the MySQL docs what they call 'latin1' is
really 'cp1252': (
http://dev.mysql.com/doc/refman/5.0/en/charset-we-sets.html):

MySQL's latin1 is the same as the Windows cp1252 character set. This means
it is the same as the official ISO 8859-1 or IANA (Internet Assigned Numbers
Authority) latin1, except that IANA latin1 treats the code points between
0x80 and 0x9f as "undefined," whereas cp1252, and therefore MySQL's latin1,
assign characters for those positions. For example, 0x80 is the Euro sign.

So, MySQL allows bytes in 'latin1' strings that are technically 'not
assigned', and assumes they have their cp1252-assigned meanings.  MySQLdb
uses the Python latin1 codec for data MySQL reports to be latin1 (though
MySQLdb might have better chosen cp1252 here, I think, given MySQL clearly
documents that they really mean cp1252 when they say latin1). The Python
latin1 codec, however, does not assume 'unassigned' latin1 code points have
their cp1252-assigned values.  Rather it assumes they have their
unicode-assigned values, and passes them through unscathed and without
error.  So your cp1252 bullets turn into unicode message waiting control
characters because MySQL assumes the unassigned latin1 \x95 byte has its
cp1252-assigned meaning while Python assumes it has its unicode-assigned
meaning.

Given your data is really cp1252, you need to use the cp1252 codec to decode
it.  You can see how this works better than the latin1 code in a Python
shell:

>>> x = 'Bullet ->\x95<- and curly apostrophe ->\x92<- in a cp1252
bytestring'
>>> ulatin1 = x.decode('latin1')
>>> ulatin1
u'Bullet ->\x95<- and curly apostrophe ->\x92<- in a cp1252 bytestring'
>>> print ulatin1
Bullet ->•<- and curly apostrophe ->'<- in a cp1252 bytestring
>>> ucp1252 = x.decode('cp1252')
>>> ucp1252
u'Bullet ->\u2022<- and curly apostrophe ->\u2019<- in a cp1252 bytestring'
>>> print ucp1252
Bullet ->•<- and curly apostrophe ->'<- in a cp1252 bytestring
>>>


> I'm partly thinking that since this is a one-time operation (actually,
> it's a many one-time operation until we're ready to switch over to the
> new site), I could scan for any "\x" characters and manually replace
> them.  There are likely only a handful as in the above.  But how does
> one scan and replace these so the output is correct?
>

You could also just convert the character set used on the MySQL side:

http://dev.mysql.com/doc/refman/5.0/en/charset-conversion.html

Presumably since MySQL knows it really means cp1252 for stuff it calls
latin1, it would convert properly to utf-8 when you told it to.  You'd
sidestep the issues you've hit with 'latin1' meaning different things to
different pieces of software.

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



Excel Generating Report

2008-12-06 Thread garces.85

Hello,

I need some urgent help.  I have a function that generates a report in
excel, the report returns the data that i need the problem es that i
am getting some strange characters like: Í , ó, ñ, etc...

I have tried with django smart_unicode and force_unicode but nothing
happens.

Is there i way i could solve this?

Here is my function:

def encuesta_reporte(request):
import csv
from django.http import HttpResponse
from django.template import loader, Context
from django.utils.encoding import smart_unicode


# Query.
school_id = School.objects.get(id = 256)
data = School_Answer.objects.filter(school = school_id)

temp =  render_to_response('my_template_name.html',
  {'data':data,
   'docente_id':docente_id,},
  context_instance = RequestContext
(request),
  )


response = HttpResponse(temp, mimetype='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment;
filename=report_school.xls'
return response
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Google Friend Connect and Django

2008-12-06 Thread Eugene Lazutkin

I did: http://lazutkin.com/blog/2008/dec/4/trying-google-friend-connect/

Being a client-side technology (adding two static HTML files do not 
count) it is largely irrelevant of Django or any other server-side 
framework.

But I did you Django to style one of the static pages (the canvas) using 
Django templates.

Thanks,

Eugene

Pythoni wrote:
> Has anyone used Google Friend Connect successfully with Django?
> (I do not know where I should upload the two required files).Can
> anyone help,please?
> Thanks
> 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: transactions and locking in postgreSQL

2008-12-06 Thread msoulier

On Dec 5, 10:43 pm, Jeffrey Straszheim <[EMAIL PROTECTED]>
wrote:
> I took a quick glance at transaction.py (where the TransactionMiddleware
> class is defined), and it appears you are correct.  However, it should
> be pretty easy to roll your own transaction class that skips the
> is_dirty check.
>
> This should probably be a bug report in any case.

I'm going to have to do further investigation. I found the reason for
the blocking that I was seeing and it is my own fault.

However, I am now left wondering how this normally works.

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



models.URLField Restricting domain names

2008-12-06 Thread eldonp2

I have a models.URLField in one of my models. This is not allowing me
to save domains that end in .co.za in the field. Is there a way to
overwrite this behaviour?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django configuration. I can't import django.db .

2008-12-06 Thread Marek Wawrzyczek
In the tutorial (http://docs.djangoproject.com/en/dev/intro/tutorial01/) I
do everything what is written, and in the
"Activating Models" section, when I run the:

python manage.py sql polls

I get the following message:

Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File
"/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line
340, in execute_manager
utility.execute()
  File
"/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line
295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.5/site-packages/django/core/management/base.py",
line 192, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.5/site-packages/django/core/management/base.py",
line 210, in execute
translation.activate('en-us')
  File
"/usr/lib/python2.5/site-packages/django/utils/translation/__init__.py",
line 73, in activate
return real_activate(language)
  File
"/usr/lib/python2.5/site-packages/django/utils/translation/__init__.py",
line 43, in delayed_loader
return g['real_%s' % caller](*args, **kwargs)
  File
"/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
line 209, in activate
_active[currentThread()] = translation(language)
  File
"/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
line 198, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
  File
"/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py",
line 181, in _fetch
app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]),
appname[p+1:])
AttributeError: 'module' object has no attribute 'pools'

What do I do wrong ?

2008/12/6 Marek Wawrzyczek <[EMAIL PROTECTED]>

> On the page
> http://www.juiceanalytics.com/openjuice/django_settings_module/ I've found
> a script and after I run the script then it worked.
>
> Regards
>
> 2008/12/6 Marek Wawrzyczek <[EMAIL PROTECTED]>
>
> I've created a django application, and after that I get the same error.
>> Before I read Your post i switched to Ubuntu (and I'm still using it) to
>> check if the problem wasn't the operating system but on Ubuntu I get the
>> same error. How can I set this path, and where are stored django.db modules
>> defaultly on linux ?
>>
>> Regards,
>> Marek
>>
>> 2008/12/6 Roland van Laar <[EMAIL PROTECTED]>
>>
>>
>>> marekw2143 wrote:
>>> > Hi
>>> >
>>> > I've installed python 2.5.2 into D:\P25 folder.
>>> > Then i installed diango using python setup.py install.
>>> > After that, when i typed:
>>> >
>>> >
>>>  import django
>>> 
>>> >
>>> > everything was ok, but when i type:
>>> >
>>> >
>>>  import diango.db
>>> 
>>> >
>>> > i get the following message:
>>> >
>>> >
>>> >
>>> > Traceback (most recent call last):
>>> >   File "", line 1, in 
>>> >   File "d:\P25\Lib\site-packages\django\db\__init__.py", line 9, in
>>> > 
>>> > if not settings.DATABASE_ENGINE:
>>> >  
>>>
>>> python can't find your configuration settings.py file.
>>> You need to create a django application first.
>>> Read: http://docs.djangoproject.com/en/dev/intro/tutorial01/
>>> > What is the solution for this problem ?
>>> >
>>> >
>>> Regards,
>>>
>>> Roland van Laar
>>>
>>> >>>
>>>
>>
>>
>> --
>> Pozdrawiam,
>>
>> Marek Wawrzyczek
>>
>>
>>
>
>
> --
> Pozdrawiam,
>
> Marek Wawrzyczek
>
>
>


-- 
Pozdrawiam,

Marek Wawrzyczek

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



Re: Can't edit reverse relation in a many2many field in admin site

2008-12-06 Thread Nelson Altimari
Thank you so very much!! It worked exactly like I wanted. I had been through
the django tickets, but since this ticket has no keywords, I wasn't able to
find it... It's sad to see that this is being going on for nearly 3 years!!!

In my case, I had my tables 'syncdb'ed already, so it was not an issue for
me. But it's well worth the effort to comment out the field definition on
the second table before the 'syncdb', then remove the comment afterward.

[]s
Nelson

On Sat, Dec 6, 2008 at 4:47 AM, anode <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I'm not an expert either, but I think you can get what you want using
> a technique from here:
> http://code.djangoproject.com/ticket/897
>
> Basically you just tell your Track model it's part of a many to many
> relationship like this:
>
> class Track(models.Model):
>name = models.CharField(max_length = 50)
>records = models.ManyToManyField('Record', db_table =
> 'music_record_tracks')
>
> The only issue with this is that running sync_db with this kind of set-
> up might not work too well, as it would probably try to create the
> intermediary many-to-many table twice. I think this will only happen
> if the Track database table doesn't exist when syncdb is run, so it
> should be fine in your case, but beware if you try to set up a
> database from scratch. Just comment out the many-to-many field in the
> Track model temporarily when you set up a new database and syncdb
> should run ok.

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

2008-12-06 Thread Mahesh Vaidya

How to extend django.contrib auth and admin.

Hi,

I would like to extend "auth.user" from django.contrib auth and admin.
I would like to add one more field in user.

models.py (added Code)
from django.contrib.auth import models as auth_models

gender = (
('M', 'Male'),
('F', 'Female'),
)

class Polster(auth_models.User):
sex = models.CharField(max_length=1, choices=gender

admin..py (added code)

class PolsterAdmin(auth_admin.UserAdmin):
fieldsets = [
(None, {'fields':['sex']}),
]
admin.site.register(Polster, PolsterAdmin)


Upon hitting I expect Usefadmin is replace by my additional field; I
get this error; I suspect I need to create one more class relating to
form; Please guide me;

ImproperlyConfigured: 'PolsterAdmin.fieldsets[0][1]['fields']' refers
to field 'sex' that is missing from the form.

Thank You in Advance
-Mahesh


-- 
--Mahesh
Bangalore

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



Re: Character encoding... latin1 to utf8?

2008-12-06 Thread Rob Hudson

Thanks Malcolm,

On Dec 4, 6:12 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> Now you might well be able to have this happen automatically using the
> "unicode" option to MySQLdb -- it knows how to convert between various
> server-side encodings and Python unicode. So look at that parameter to
> the connect() call. It's fairly well done in MySQLdb (it and PostgreSQL
> were almost trivial to make work when we added Unicode support to
> Django).

I actually had that set up already.  I'm trying to look at it a little
more closely.  Here's a dpaste of a SQL call and a few columns.  Look
at the "fdescr" column output... it's showing the string is unicode
but it has some characters in it like \x95 and \x92.
http://dpaste.com/96601/

> Alternatively, if you're getting bytestrings backs, run them through a
> decode() call:
>
>         data = original_data.decode('cp1252')

I tried this at the bottom of the above dpaste just to see... I know
I'm not getting bytestrings back.  So I tried it also without the
unicode=True flag to connect and it produces different output than
above:

>>> row['fdescr'].decode('cp1252')
u'Lefty Kreh is one of the most experienced, well-prepared, and
thoughtful anglers in the world. In 101 Fly-Fishing Tips, he
shares this wealth of experience with a variety of common-sense
solutions to the problems that anglers face. Included are tips on: \u2022how to pacify a fish \u2022which hook-sharpening tools
to use and when \u2022how to take a rod apart when it\u2019s
stuck \u2022what to do when a fish runs under your boat
\u2022how to dry waders and find leaks \u2022why long hat brims
affect casting accuracy \u2022and much moreSure to
improve a fly fisher\u2019s success, comfort, and enjoyment while on
the water. A must for any angler.ABOUT THE AUTHORLefty Kreh is an internationally known and respected master in
the field of fly fishing, and the author of numerous articles and
books on the subject. He lives in Maryland.'

Now instead of \x95 I get \u2022 (which is a bullet).

>From here I'm not sure what the best way to proceed is... do I want
the \u2022 version instead, in which case, should I not pass in
unicode=True and manually decode each column?

I'm partly thinking that since this is a one-time operation (actually,
it's a many one-time operation until we're ready to switch over to the
new site), I could scan for any "\x" characters and manually replace
them.  There are likely only a handful as in the above.  But how does
one scan and replace these so the output is correct?

> Just for laughs, though, try running "file" on the csv file you generate
> and make sure it, at least, detects that it is a UTF-16 file.

It actually tells me nothing...
> file export.csv
export.csv:

Thanks,
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from 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 configuration. I can't import django.db .

2008-12-06 Thread Marek Wawrzyczek
On the page http://www.juiceanalytics.com/openjuice/django_settings_module/I've
found a script and after I run the script then it worked.

Regards

2008/12/6 Marek Wawrzyczek <[EMAIL PROTECTED]>

> I've created a django application, and after that I get the same error.
> Before I read Your post i switched to Ubuntu (and I'm still using it) to
> check if the problem wasn't the operating system but on Ubuntu I get the
> same error. How can I set this path, and where are stored django.db modules
> defaultly on linux ?
>
> Regards,
> Marek
>
> 2008/12/6 Roland van Laar <[EMAIL PROTECTED]>
>
>
>> marekw2143 wrote:
>> > Hi
>> >
>> > I've installed python 2.5.2 into D:\P25 folder.
>> > Then i installed diango using python setup.py install.
>> > After that, when i typed:
>> >
>> >
>>  import django
>> 
>> >
>> > everything was ok, but when i type:
>> >
>> >
>>  import diango.db
>> 
>> >
>> > i get the following message:
>> >
>> >
>> >
>> > Traceback (most recent call last):
>> >   File "", line 1, in 
>> >   File "d:\P25\Lib\site-packages\django\db\__init__.py", line 9, in
>> > 
>> > if not settings.DATABASE_ENGINE:
>> >  
>>
>> python can't find your configuration settings.py file.
>> You need to create a django application first.
>> Read: http://docs.djangoproject.com/en/dev/intro/tutorial01/
>> > What is the solution for this problem ?
>> >
>> >
>> Regards,
>>
>> Roland van Laar
>>
>> >>
>>
>
>
> --
> Pozdrawiam,
>
> Marek Wawrzyczek
>
>
>


-- 
Pozdrawiam,

Marek Wawrzyczek

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

2008-12-06 Thread Brett Parker

On 06 Dec 16:00, Marek Wawrzyczek wrote:
> I've created a django application, and after that I get the same error.
> Before I read Your post i switched to Ubuntu (and I'm still using it) to
> check if the problem wasn't the operating system but on Ubuntu I get the
> same error. How can I set this path, and where are stored django.db modules
> defaultly on linux ?

Are you running python directly and then importing django? It might be
better to do:
python manage.py shell

from the applcation directory.

Thanks,
-- 
Brett Parker

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

2008-12-06 Thread Marek Wawrzyczek
I've created a django application, and after that I get the same error.
Before I read Your post i switched to Ubuntu (and I'm still using it) to
check if the problem wasn't the operating system but on Ubuntu I get the
same error. How can I set this path, and where are stored django.db modules
defaultly on linux ?

Regards,
Marek

2008/12/6 Roland van Laar <[EMAIL PROTECTED]>

>
> marekw2143 wrote:
> > Hi
> >
> > I've installed python 2.5.2 into D:\P25 folder.
> > Then i installed diango using python setup.py install.
> > After that, when i typed:
> >
> >
>  import django
> 
> >
> > everything was ok, but when i type:
> >
> >
>  import diango.db
> 
> >
> > i get the following message:
> >
> >
> >
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "d:\P25\Lib\site-packages\django\db\__init__.py", line 9, in
> > 
> > if not settings.DATABASE_ENGINE:
> >  
>
> python can't find your configuration settings.py file.
> You need to create a django application first.
> Read: http://docs.djangoproject.com/en/dev/intro/tutorial01/
> > What is the solution for this problem ?
> >
> >
> Regards,
>
> Roland van Laar
>
> >
>


-- 
Pozdrawiam,

Marek Wawrzyczek

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



Re: Ruby on Rails vs Django

2008-12-06 Thread bruno desthuilliers



On 6 déc, 10:55, "Guillermo C." <[EMAIL PROTECTED]> wrote:
> Hi.
>
> - Scaffolding: I prefer it over django admin in many situations. I
> mean, when you're doing something complex you'll need to drop out the
> django admin and write your own code, so it's cool to have the basic
> CRUD code and develop from that.

While you surely have to write some code for custom stuff, you don't
necessarily have to "drop out of admin" - you can just customize the
relevant part of the admin.
(snip)

> - RoR controllers versus Django views: Django does not enclose in
> classes the controllers neither have Routes, the mapping between urls
> and views (plain functions taking a ``request`` object as first param).

s/plain functions/callable objects/

Remember that classes are callable too, and that Python let you define
your own callable types.

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



Question on Models: ImageField API

2008-12-06 Thread I.A

Hi,

I'm writing an application that recieves a file from an outside source
(not through a view though) which is written to the tmp directory and
then writing it into the db through the FileField. Obviously the file
must also be written to a path which can be retrieved later by just
calling .path from the model.
I've finally been able to make it work through the code below:

fp = '/tmp/tmpfile.jpg'
f = open(fp, 'r')
myfile = File(f)

user = User(name='username')
ti = Images(user=user)
ti.image.save(myfile.name, myfile)  # 1

My model is as follows:

class User(models.Model):
...
...

class Images(models.Model):

user   = models.ForeignKey(User)
image  = models.ImageField(upload_to="images/%Y/%m/%d",
null=True)

It took me sometime to figure # 1 out (http://scottbarnham.com/blog/
2008/08/25/dynamic-upload-paths-in-django/), and my question is, where
is the documentation that says you can do ImageField.save() and have
the data written to the db and at the same time make the file be
written to the correct path on disk?



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



Re: Ruby on Rails vs Django

2008-12-06 Thread bruno desthuilliers

On 5 déc, 23:57, yejun <[EMAIL PROTECTED]> wrote:
> On Dec 5, 2:43 pm, bruno desthuilliers <[EMAIL PROTECTED]>
> wrote:
>
> > On 5 déc, 16:16, "[EMAIL PROTECTED]"
>
> > <[EMAIL PROTECTED]> wrote:
> > > Metaphorically that Python/Djangois for a conservative engineer
> > > mindset,
>
> > ??? care to elaborate on this ???

> I think he means python is a more traditional procedure like language
> than ruby is.

"Code-blocks" set aside, I fail to see how Python is "more
traditional" or "more procedural" than Ruby.

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

2008-12-06 Thread felix

this is not the issue previously posted by somebody else.

I think I found a bug with Manager get_or_create and foreign key
fields when specifying with foreigntable__id

class ObjectPermission(models.Model):

permission = models.CharField(blank=False, max_length=20)

user = models.ForeignKey(User,blank=True,null=True)

objects = ObjectPermissionManager()

note that user may be null

class ObjectPermissionManager(models.Manager):

def set_perm(self,permission,user_id):
import pdb; pdb.set_trace()

(perm,created) = self.get_or_create
(permission=permission,user__id=user_id)


(Pdb) user_id
17L

# user_id is incorrect when using get_or_create
(Pdb) self.get_or_create(permission=permission,user_id=user_id)
*** FieldError: Cannot resolve keyword 'user_id' into field. Choices
are: id, permission, user

# using user__id
(Pdb) (op,created) = self.get_or_create
(permission=permission,user__id=user_id)
(Pdb) op


# but user_id was set to null
(Pdb) op.user_id
(Pdb) op.user

here is the crux of the issue :

# if using create, then user_id is correct
(Pdb) self.create(permission=permission,user_id=user_id)

# if using get, then user__id is correct
(Pdb) self.get(permission=permission,user__id=user_id)
*** DoesNotExist: ObjectPermission matching query does not exist.

If someone else can confirm or deny that its a bug then I'll
investigate further and maybe cure it.

thanks

-flix

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



Google Friend Connect and Django

2008-12-06 Thread Pythoni

Has anyone used Google Friend Connect successfully with Django?
(I do not know where I should upload the two required files).Can
anyone help,please?
Thanks
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: Django configuration. I can't import django.db .

2008-12-06 Thread Roland van Laar

marekw2143 wrote:
> Hi
>
> I've installed python 2.5.2 into D:\P25 folder.
> Then i installed diango using python setup.py install.
> After that, when i typed:
>
>   
 import django
 
>
> everything was ok, but when i type:
>
>   
 import diango.db
 
>
> i get the following message:
>
>
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "d:\P25\Lib\site-packages\django\db\__init__.py", line 9, in
> 
> if not settings.DATABASE_ENGINE:
>  

python can't find your configuration settings.py file.
You need to create a django application first.
Read: http://docs.djangoproject.com/en/dev/intro/tutorial01/
> What is the solution for this problem ?
>
>   
Regards,

Roland van Laar

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

2008-12-06 Thread marekw2143

Hi

I've installed python 2.5.2 into D:\P25 folder.
Then i installed diango using python setup.py install.
After that, when i typed:

>>> import django

everything was ok, but when i type:

>>> import diango.db

i get the following message:



Traceback (most recent call last):
  File "", line 1, in 
  File "d:\P25\Lib\site-packages\django\db\__init__.py", line 9, in

if not settings.DATABASE_ENGINE:
  File "d:\P25\Lib\site-packages\django\conf\__init__.py", line 28, in
__getattr
__
self._import_settings()
  File "d:\P25\Lib\site-packages\django\conf\__init__.py", line 59, in
_import_s
ettings
self._target = Settings(settings_module)
  File "d:\P25\Lib\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 'D:\P5\Lib\site-packages
\django;D:\P25\Li
b\site-packages;D:\P25;D:\P5\Lib\site-packages\django\bin;D:\P5\Lib
\site-package
s\django\bin\mysite;;D:\P5\Scripts\mysite' (Is it on sys.path? Does it
have synt
ax errors?): No module named D:\P5\Lib\site-packages\django;D:\P25\Lib
\site-pack
ages;D:\P25;D:\P5\Lib\site-packages\django\bin;D:\P5\Lib\site-packages
\django\bi
n\mysite;;D:\P5\Scripts\mysite


I also tried with Python2.6, but it didn't work too.
I searched tchrought the internet, but I didn't find any help.


What is the solution for this problem ?

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



Re: order_with_respect_to fail any workaround ?

2008-12-06 Thread Thierry Stiegler

Juste for precision I use the trunk.

On Dec 6, 9:34 am, Thierry Stiegler <[EMAIL PROTECTED]>
wrote:
> Hello,
>
> I got some errors by using the Meta options order_with_respect_to:
> 
> class Category(PublicationBase, LocalisationBase):
>     ITEM_PER_PAGE = 12
>     name = models.CharField(max_length=255)
>     pictogram = models.ImageField(upload_to="categories", blank=True)
>     old_id = models.PositiveIntegerField(blank=True)
>     parent = models.ForeignKey("Category", blank=True, null=True)
>
>     class Meta:
>         ordering = ['name']
>         order_with_respect_to = 'parent'
>
>     def __unicode__(self):
>         return self.name
> 
>
> An I got this error :
> 
> Validating models...
> Unhandled exception in thread started by  0x010ABBF0>
> Traceback (most recent call last):
>   File "C:\Python25\django-trunk\django\core\management\commands
> \runserver.py", line 48, in inner_run
>     self.validate(display_num_errors=True)
>   File "C:\Python25\django-trunk\django\core\management\base.py", line
> 249, in validate
>     num_errors = get_validation_errors(s, app)
>   File "C:\Python25\django-trunk\django\core\management
> \validation.py", line 28, in get_validation_errors
>     for (app_name, error) in get_app_errors().items():
>   File "C:\Python25\django-trunk\django\db\models\loading.py", line
> 128, in get_app_errors
>     self._populate()
>   File "C:\Python25\django-trunk\django\db\models\loading.py", line
> 57, in _populate
>     self.load_app(app_name, True)
>   File "C:\Python25\django-trunk\django\db\models\loading.py", line
> 72, in load_app
>     mod = __import__(app_name, {}, {}, ['models'])
>   File "C:\www\zebest-3000.com\trunk\zebest3000\..\apps\messages
> \models.py", line 113, in 
>     notification = get_app('notification')
>   File "C:\Python25\django-trunk\django\db\models\loading.py", line
> 111, in get_app
>     self._populate()
>   File "C:\Python25\django-trunk\django\db\models\loading.py", line
> 57, in _populate
>     self.load_app(app_name, True)
>   File "C:\Python25\django-trunk\django\db\models\loading.py", line
> 72, in load_app
>     mod = __import__(app_name, {}, {}, ['models'])
>   File "C:\www\zebest-3000.com\trunk\zebest3000\..\apps\portail
> \models.py", line 50, in 
>     class Category(PublicationBase, LocalisationBase):
>   File "C:\Python25\django-trunk\django\db\models\base.py", line 153,
> in __new__
>     new_class._prepare()
>   File "C:\Python25\django-trunk\django\db\models\base.py", line 178,
> in _prepare
>     setattr(opts.order_with_respect_to.rel.to, 'get_%s_order' %
> cls.__name__.lower(), curry(method_get_order, cls))
> AttributeError: 'str' object has no attribute 'get_category_order'
> 
>
> I found this ticket (http://code.djangoproject.com/ticket/2740), but I
> don"t want to patch django. Any Idea for a workaround ?

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



multiwidget and inlineformset

2008-12-06 Thread Petry

hi all!

I have a problem with in MultiWidget in inline forms.

I created a widget [1] to separate the phone and code, on a normal
form works fine, but when using a inlineformset use widget does not
work right


[1] http://dpaste.com/96511/


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



Re: Ruby on Rails vs Django

2008-12-06 Thread Guillermo C.

Hi.

- Scaffolding: I prefer it over django admin in many situations. I
mean, when you're doing something complex you'll need to drop out the
django admin and write your own code, so it's cool to have the basic
CRUD code and develop from that.
- Database ORM: Both orm (rail's ActiveRecord and Django's ORM follow
active record pattern (http://www. martinfowler.com/eaaCatalog/
activeRecord.html) so.. they're not too different.
- Migrations: I like the way migrations works in RoR. Django have some
projects to work out on this but they're not as mature.
- RoR controllers versus Django views: Django does not enclose in
classes the controllers neither have Routes, the mapping between urls
and views (plain functions taking a ``request`` object as first param.
and then they receive too positionally the capturing groups in the
regexps) is in files with paths and the module + function in python
which dispatch them. RoR have Routes where you map urls and
controllers, and controllers are classes. Also a huge difference is
that in RoR, to have in scope variables in templates you declare
variables as instance variables, in Django you pass them explictly in
a Context object.

The conclusion is that they're different but very close. You can enjoy
more using one or the other; but they provide with similar tools to
achieve the same goals.


On Dec 5, 1:06 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I'm new to the django world and I was just wondering how Django
> compears with  Ruby on Rails ?
>
> did anybody try Ruby on Rails so can give us a feedback ?
>
> 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
-~--~~~~--~~--~--~---



order_with_respect_to fail any workaround ?

2008-12-06 Thread Thierry Stiegler

Hello,

I got some errors by using the Meta options order_with_respect_to:

class Category(PublicationBase, LocalisationBase):
ITEM_PER_PAGE = 12
name = models.CharField(max_length=255)
pictogram = models.ImageField(upload_to="categories", blank=True)
old_id = models.PositiveIntegerField(blank=True)
parent = models.ForeignKey("Category", blank=True, null=True)

class Meta:
ordering = ['name']
order_with_respect_to = 'parent'


def __unicode__(self):
return self.name


An I got this error :

Validating models...
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "C:\Python25\django-trunk\django\core\management\commands
\runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
  File "C:\Python25\django-trunk\django\core\management\base.py", line
249, in validate
num_errors = get_validation_errors(s, app)
  File "C:\Python25\django-trunk\django\core\management
\validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "C:\Python25\django-trunk\django\db\models\loading.py", line
128, in get_app_errors
self._populate()
  File "C:\Python25\django-trunk\django\db\models\loading.py", line
57, in _populate
self.load_app(app_name, True)
  File "C:\Python25\django-trunk\django\db\models\loading.py", line
72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "C:\www\zebest-3000.com\trunk\zebest3000\..\apps\messages
\models.py", line 113, in 
notification = get_app('notification')
  File "C:\Python25\django-trunk\django\db\models\loading.py", line
111, in get_app
self._populate()
  File "C:\Python25\django-trunk\django\db\models\loading.py", line
57, in _populate
self.load_app(app_name, True)
  File "C:\Python25\django-trunk\django\db\models\loading.py", line
72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "C:\www\zebest-3000.com\trunk\zebest3000\..\apps\portail
\models.py", line 50, in 
class Category(PublicationBase, LocalisationBase):
  File "C:\Python25\django-trunk\django\db\models\base.py", line 153,
in __new__
new_class._prepare()
  File "C:\Python25\django-trunk\django\db\models\base.py", line 178,
in _prepare
setattr(opts.order_with_respect_to.rel.to, 'get_%s_order' %
cls.__name__.lower(), curry(method_get_order, cls))
AttributeError: 'str' object has no attribute 'get_category_order'


I found this ticket (http://code.djangoproject.com/ticket/2740), but I
don"t want to patch django. Any Idea for a workaround ?



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

2008-12-06 Thread redbaron

Trying to figure out how does django handle uploads with wsgi. My main
question is about handling errors, there is no .read() operations
neither in http/multiparser.py nor in uploadhandler.py wrapped in try-
except. All multipart-related infrastructure relies on checking about
InputStreamExhausted which is all about Content-Length field, so it
just trust it without any further checks. Raw posts are handled
completely without try-except checks, just environ['wsgi.input'].read
()

In case of closed connection, wrong data length any other errors what
django is going to do? Where all these cases are handled?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from 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 problem

2008-12-06 Thread Ronny Haryanto

On Sat, Dec 6, 2008 at 2:42 PM, vierda <[EMAIL PROTECTED]> wrote:
> today I try to make login page with follow example code in
> djangoproject (user authentication chapter), code as following below :
>
> def my_view(request):
>   username = request.POST['username']
>   password = request.POST['password']
>   user =  authenticate(username=username, password=password)#create
> Authentication object
>
>   if user is not None:
>  if user.is_active:
> login(request,user)
> return HttpResponse('login success')
>  else:
> return HttpResponse('disable account')
>   else:
>  return HttpResponse('invalid login')
>
> the above code always shows MultiValueDictKeyError with exception
> value "Key 'username' not found in ".

That exception will always be raised if the view is called via GET
method instead of POST.

If you're sending it via POST, then the information you provided was
not sufficient. We need to see template code that renders the form (or
the html form if you're not using templates) and probably the form as
well.

Ronny

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