Re: Variable value in template

2007-04-11 Thread Ivan Sagalaev

Kai Kuehne wrote:
> With this
> 
> Team:
> {% for team in object.squad.team_set.all  %}
>   {% appearance_count_for_team team.id %}
> 
> and
> 
> class AppearanceCountForTeamNode(template.Node):
> def __init__(self, team_id):
> print team_id
> ...
> 
> I get "team.id" printed out and not the id of the team.
> Why doesn't it get evaluated? I don't understand this.

This is because templates are first parsed into a tree (this is when you 
node is created) and only then are evaluated against a context. This 
will happen in render():


 class AppearanceCountForTeamNode(template.Node):
   def __init__(self, team_id):
 self.team_id = team_id

   def render(self, context):
 team_id = self.team_id.resolve(context)

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



Re: Testing Framework and Fixtures

2007-04-11 Thread Russell Keith-Magee

On 4/12/07, Brian Luft <[EMAIL PROTECTED]> wrote:
>
> If I remember correctly, my problem was that the JSON serializer was
> bombing out when encountering float fields.  I didn't report it
> directly because I thought I had remembered seeing others report
> similar problems.  It was probably a late night and I got around it by
> opting for XML formatting.

Ah - that problem. Forgot about that one :-)

For the record, this is ticket #3324.

The issue isn't completely the serializer - its the interaction
between floats, Decimal and the database-specific numeric types. The
biggest problem is compatibility with Python 2.3, which doesn't have a
Decimal type.

'Correct' handling for Decimals is an issue that is still under
discussion. A number of solutions have been proposed, but a final
solution hasn't been agreed upon.

> Thanks for the update Russell, nice to see the aggressive work being
> put into this very useful aspect of the framework.

Most welcome.

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



Re: Testing Framework and Fixtures

2007-04-11 Thread Brian Luft

If I remember correctly, my problem was that the JSON serializer was
bombing out when encountering float fields.  I didn't report it
directly because I thought I had remembered seeing others report
similar problems.  It was probably a late night and I got around it by
opting for XML formatting.

Thanks for the update Russell, nice to see the aggressive work being
put into this very useful aspect of the framework.

Cheers
-Brian

On Apr 11, 5:22 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 4/12/07, Merric Mercer <[EMAIL PROTECTED]> wrote:
>
>
>
> > I tried to run the dumpdata command because I'd read that this did much
> > of the work for me but I received the following error message
>
> >  >>C:\>manage.py dumpdata promotions
> > Unable to serialize database: Table_Code matching query does not exist.
> > None
>
> This sounds like your database isn't fully synchronized. Try
> recreating your database from scratch, resyncing, then dumping the
> data.
>
> > My models have several 1:1 relationships and I think I remember seeing
> > something about this causing a problem in the test framework - but I
> > can't relocate the post that mentioned this.   Does anybody know the
> > status on this?
>
> As far as I am aware, these problems have been solved. We now have a
> very extensive set of unit tests to check the full range of data
> parsing - if you find a case that is failing, let us know so we can
> fix the problem and add another test.
>
> 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 [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multilanguage folder names in urls?

2007-04-11 Thread Rohan

> Hi! Is it possible to use i18n for folder names in url patterns? For
> example "/accounts" in english would translate automatically to
> "konten" in German.

Hi, Here's my solution to what I think is the same requirement:

First of all setup urlpatterns in urls.py to map all the language
variations to the appropriate views. I found this step to be necessary
as:
a) I don't know how to rebuild urlpatterns when the language changes
b) it's probably faster to have urlpatterns static and built for all
languages.

--start code--

# 'stores_uri' is a translatable 'folder' name

for language in settings.LANGUAGES:
translation.activate(language[0])

urlpatterns += patterns('views',
(r'^(?P[a-z]{2})/'+_('stores_uri')+'/$',
'stores'),
(r'^(?P[a-z]{2})/'+_('products_uri')+'/$',
'products'),
)

--end code--

Then in the templates, I build the urls by referring to the
"stores_uri" message id, like so:

--start code--


{% trans "stores"%}

--end code--

I made a seperate message id for the URI with idea that the
translation shouldn't be changed once released (as it will cause a URI
change)



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



Re: Running django in standalone mode

2007-04-11 Thread Alex Dong

here is the 'run.sh' I've created. Hope it helps.  Now, to run a cron
job, say 'cleanup.py', you will only need to do 'run.sh cleanup.py'.

%<
#!/bin/bash

export PYTHONPATH="$PYTHONPATH:/lib/python2.4/site-package/django/:/
home/alex/projects/"
export DJANGO_SETTINGS_MODULE="looker.settings"
python $1
-->%

HTH,
Alex

On Apr 12, 8:46 am, "Alex Dong" <[EMAIL PROTECTED]> wrote:
> Thanks many. It works like a charm now.
>
> Alex
>
> On Apr 12, 12:54 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > I am assuming that "looker" is the name of your project directory.
> > When you use the statement "from looker...", python is searching
> > through its search path and looking for either modules (python files)
> > or packages (modules grouped in a directory containing an __init__.py
> > file) called "looker".  You had the right idea of appending the
> > project path to the python search path, but you went one directory too
> > deep.  Try:
> > PROJECT_PATH="~/projects"
> > That way, when python is trying to resolve "looker", it will arrive at
> > ~/projects, see a directory called "looker", happily find that it is
> > indeed a python package via the presence of __init__.py (assuming you
> > created your django project the standard way), and will then be able
> > to import the settings module from the looker package.
>
> > On Apr 11, 3:57 am, "Alex Dong" <[EMAIL PROTECTED]> wrote:
>
> > > I'm having a bunch of cron jobs which will use django model and
> > > send_mail features. I've read through this 
> > > linkhttp://groups.google.com/group/django-users/browse_thread/thread/5182...
> > > but for some unknown reason, I still can't use django's model.
>
> > > Will anyone kindly look through my code and point out where I've done
> > > wrong?
>
> > > %>--
> > > $ cat environ.py
> > > #!/usr/bin/env python
>
> > > import sys
> > > import os
> > > from local_conf import *
>
> > > DJANGO_PATH = "/lib/python2.4/site-packages/django/"
> > > PROJECT_PATH = "~/projects/looker"
> > > PROJECT_SETTING = "looker.settings"
>
> > > sys.path.append(DJANGO_PATH)
> > > sys.path.append(PROJECT_PATH)
> > > os.environ['DJANGO_SETTINGS_MODULE'] = PROJECT_SETTING
>
> > > from looker import settings
>
> > > $ environ.py
> > > Traceback (most recent call last):
> > >   File "./environ.py", line 11, in ?
> > > from looker import settings
> > > ImportError: No module named looker
> > > <%
>
> > > Plus, is it possible that we could have something like "python
> > > manage.py run environ.py" where django's 'manage.py' will take care of
> > > this stuff and execute django dependent standalone application? I
> > > could contribute the code but need some advices here.
>
> > > thanks,
> > > Alex


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



Re: Running django in standalone mode

2007-04-11 Thread Alex Dong

Thanks many. It works like a charm now.

Alex

On Apr 12, 12:54 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I am assuming that "looker" is the name of your project directory.
> When you use the statement "from looker...", python is searching
> through its search path and looking for either modules (python files)
> or packages (modules grouped in a directory containing an __init__.py
> file) called "looker".  You had the right idea of appending the
> project path to the python search path, but you went one directory too
> deep.  Try:
> PROJECT_PATH="~/projects"
> That way, when python is trying to resolve "looker", it will arrive at
> ~/projects, see a directory called "looker", happily find that it is
> indeed a python package via the presence of __init__.py (assuming you
> created your django project the standard way), and will then be able
> to import the settings module from the looker package.
>
> On Apr 11, 3:57 am, "Alex Dong" <[EMAIL PROTECTED]> wrote:
>
> > I'm having a bunch of cron jobs which will use django model and
> > send_mail features. I've read through this 
> > linkhttp://groups.google.com/group/django-users/browse_thread/thread/5182...
> > but for some unknown reason, I still can't use django's model.
>
> > Will anyone kindly look through my code and point out where I've done
> > wrong?
>
> > %>--
> > $ cat environ.py
> > #!/usr/bin/env python
>
> > import sys
> > import os
> > from local_conf import *
>
> > DJANGO_PATH = "/lib/python2.4/site-packages/django/"
> > PROJECT_PATH = "~/projects/looker"
> > PROJECT_SETTING = "looker.settings"
>
> > sys.path.append(DJANGO_PATH)
> > sys.path.append(PROJECT_PATH)
> > os.environ['DJANGO_SETTINGS_MODULE'] = PROJECT_SETTING
>
> > from looker import settings
>
> > $ environ.py
> > Traceback (most recent call last):
> >   File "./environ.py", line 11, in ?
> > from looker import settings
> > ImportError: No module named looker
> > <%
>
> > Plus, is it possible that we could have something like "python
> > manage.py run environ.py" where django's 'manage.py' will take care of
> > this stuff and execute django dependent standalone application? I
> > could contribute the code but need some advices here.
>
> > thanks,
> > Alex


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



Re: error using XML serializer with unicode data

2007-04-11 Thread Russell Keith-Magee

On 4/12/07, Saik <[EMAIL PROTECTED]> wrote:
>
> Hi people,
>
> I'm trying to use the serialize utils at
> django.core.serializers.xml_serialize and
> django.core.serializers.json, i don't have problems using json but i
> have issues trying something like that:
>
> xml = serializers.serialize("xml", Anymodel.objects.all())

There is a known ticket for unicode related problems with the
serializer - #3878. Malcolm is currently addressing this problem as
part of the unicode stream. The best way to help out here is to
provide a specific test case that fails, and attach it to the ticket
so that your problem gets addressed.

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: Testing Framework and Fixtures

2007-04-11 Thread Russell Keith-Magee

On 4/12/07, Merric Mercer <[EMAIL PROTECTED]> wrote:
>
> I tried to run the dumpdata command because I'd read that this did much
> of the work for me but I received the following error message
>
>  >>C:\>manage.py dumpdata promotions
> Unable to serialize database: Table_Code matching query does not exist.
> None

This sounds like your database isn't fully synchronized. Try
recreating your database from scratch, resyncing, then dumping the
data.

> My models have several 1:1 relationships and I think I remember seeing
> something about this causing a problem in the test framework - but I
> can't relocate the post that mentioned this.   Does anybody know the
> status on this?

As far as I am aware, these problems have been solved. We now have a
very extensive set of unit tests to check the full range of data
parsing - if you find a case that is failing, let us know so we can
fix the problem and add another test.

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: Testing Framework and Fixtures

2007-04-11 Thread Russell Keith-Magee

On 4/12/07, Brian Luft <[EMAIL PROTECTED]> wrote:
>
> I've run into problems as well with the fixture functionality.  The
> short of it is that this is a new feature to the framework and likely
> the kinks will be worked out in the coming weeks.

Have you reported these problems? I am aware of one or two small
database backend problems. The only data related problem I am aware of
is with decoding of UTF-8 strings, which is being addressed by Malcolm
in the unicode stream.

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



Variable value in template

2007-04-11 Thread Kai Kuehne

With this

Team:
{% for team in object.squad.team_set.all  %}
{% appearance_count_for_team team.id %}

and

class AppearanceCountForTeamNode(template.Node):
def __init__(self, team_id):
print team_id
...

I get "team.id" printed out and not the id of the team.
Why doesn't it get evaluated? I don't understand this.

Greetings
Kai

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



Re: Use properties for filtering results

2007-04-11 Thread Russell Keith-Magee

On 4/11/07, Paolo Dina <[EMAIL PROTECTED]> wrote:
>
> In my model there is model method I'd like to use for filtering.
> Is it possible? I have put it in form of property, but when I use it
> with field lookup syntax I get an error.

No. In your example 'visible' isn't a field in your database. Filter
is an operation that is converted into a database query, so methods on
your Django model can't be used as part of a query.

Your best option would be to add visible as a property of the manager,
rather than the model, and define that manager operation as an alias
for the underlying database operation. See
http://www.djangoproject.com/documentation/model-api/#custom-managers
for more details, but the short version is something like:

class ContentManager(models.Manager):
def visible(self):
return self.filter(priv=False, pub_date__lt=datetime.now())

class Content(models.Model):
objects = ContentManager()
# Rest of model as before.

Then, when you want to use visible, Content.objects.visible() will
return a query set that contains all visible objects.

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: SelectMultiple widget

2007-04-11 Thread Enrico

Hi Masuran,

You're welcome. :)

That's weird!
Did you save the entire page source *with* embedded files (.css, .js,
images)?

The page source itself is the same, what makes the "magic" is the
'SelectFilter2.js' file, that manipulates the source when the page
loads, transforming SelectMultiple fields into that cool widget.

I agree with Rob, if you didn't touch the page source, you may be
missing some JS files.
If you read the comments inside the 'SelectFilter2.js' file, you'll
see that it requires some other files.

Good luck,
Enrico


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



Re: Log out problems

2007-04-11 Thread jeffhg58
James,

Thanks for the explanation. I am going to change my logout to do a redirect

Jeff

-- Original message -- 
From: "James Bennett" <[EMAIL PROTECTED]> 

> 
> On 4/11/07, jeffhg58 wrote: 
> > The only problem I am having is when I log out and either hit the back 
> > button or go to my home 
> > page from the browser it does not give me the login prompt window. 
> 
> This is kind of tricky and exposes a pseudo-bug in Django. 
> 
> What's happening is this: 
> 
> 1. At the time the request starts, you're logged in, and so the 
> AuthenticationMiddleware sets 'request.user' so that it returns your 
> User object, which in turn returns True on an 'is_authenticated()' 
> check. 
> 2. At the time that you hit the 'login_required' decorator, you 
> haven't yet hit the view code which logs you out, so you pass that 
> check and don't get redirected to a login form. 
> 3. When the 'logout' view logs you out, it doesn't reset 
> 'request.user', so any template rendering which uses an 
> 'is_authenticated()' check will get confused (this is the bug). 
> 4. When the response comes back to your browser, it includes cookie 
> headers which make the logout persist. 
> 
> So if you use the 'logout' view and return a template directly from 
> it, the template may "think" you're logged in even though you're not 
> (you can't actually do anything which requires authentication, it's 
> just that 'request.user' wasn't updated before the template rendered). 
> If you instead have 'logout' redirect to another URL, you'll see 
> everything working intuitively, because that involves a new request 
> which starts out with 'request.user' as an AnonymousUser. 
> 
> Hitting the back button probably causes the behavior you're seeing 
> because some browsers don't actually hit the server on a "back" and 
> instead reload the page from cache, which means you'll see the same 
> thing you saw when you were logged in previously. 
> 
> The confusing aspects of this can be handled by having Django reset 
> 'request.user' on authentication changes (it also doesn't do so on 
> login, which can be somewhat counterintuitive when using things like 
> the registered comments model), so I'll file a ticket for that. 
> 
> -- 
> "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
-~--~~~~--~~--~--~---



Matthew 24 and EndTime Disasters!!!

2007-04-11 Thread micen

Matthew 24 and EndTime Disasters!!!

http://video.google.com/videoplay?docid=303204416536528381


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



Re: Log out problems

2007-04-11 Thread James Bennett

On 4/11/07, jeffhg58 <[EMAIL PROTECTED]> wrote:
> The only problem I am having is when I log out and either hit the back
> button or go to my home
> page from the browser it does not give me the login prompt window.

This is kind of tricky and exposes a pseudo-bug in Django.

What's happening is this:

1. At the time the request starts, you're logged in, and so the
AuthenticationMiddleware sets 'request.user' so that it returns your
User object, which in turn returns True on an 'is_authenticated()'
check.
2. At the time that you hit the 'login_required' decorator, you
haven't yet hit the view code which logs you out, so you pass that
check and don't get redirected to a login form.
3. When the 'logout' view logs you out, it doesn't reset
'request.user', so any template rendering which uses an
'is_authenticated()' check will get confused (this is the bug).
4. When the response comes back to your browser, it includes cookie
headers which make the logout persist.

So if you use the 'logout' view and return a template directly from
it, the template may "think" you're logged in even though you're not
(you can't actually do anything which requires authentication, it's
just that 'request.user' wasn't updated before the template rendered).
If you instead have 'logout' redirect to another URL, you'll see
everything working intuitively, because that involves a new request
which starts out with 'request.user' as an AnonymousUser.

Hitting the back button probably causes the behavior you're seeing
because some browsers don't actually hit the server on a "back" and
instead reload the page from cache, which means you'll see the same
thing you saw when you were logged in previously.

The confusing aspects of this can be handled by having Django reset
'request.user' on authentication changes (it also doesn't do so on
login, which can be somewhat counterintuitive when using things like
the registered comments model), so I'll file a ticket for that.

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



Programmer Career

2007-04-11 Thread Mike

Find Your Programming Job Vacancy and resources here -->
http://www.jobbankdata.com/job-programming.htm


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

2007-04-11 Thread Jesse Lovelace

Or:

from django.http import HttpResponseNotAllowed

return HttpResponseNotAllowed()

On 4/9/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 4/9/07, johnny <[EMAIL PROTECTED]> wrote:
> > At a particular url, my view is looking for XML document to be sent
> > over http, by post.  If a request come in without post, I want to
> > raise an error "405 Method Not Allowed".  How do I do this?
>
> response = HttpResponse('some output here')
> response.status_code = 405
> return response
>
> --
> "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
-~--~~~~--~~--~--~---



error using XML serializer with unicode data

2007-04-11 Thread Saik

Hi people,

I'm trying to use the serialize utils at
django.core.serializers.xml_serialize and
django.core.serializers.json, i don't have problems using json but i
have issues trying something like that:

xml = serializers.serialize("xml", Anymodel.objects.all())

If the model data contains unicode characters (example:
Anymodel.name='Ñ'). The error is the following:

---
exceptions.UnicodeDecodeErrorTraceback (most
recent call last)

/usr/local/lib/python2.4/site-packages/django/core/serializers/
__init__.py in serialize(format, queryset, **options)
 65 """
 66 s = get_serializer(format)()
---> 67 s.serialize(queryset, **options)
 68 return s.getvalue()
 69

/usr/local/lib/python2.4/site-packages/django/core/serializers/base.py
in serialize(self, queryset, **options)
 38 if field.rel is None:
 39 if self.selected_fields is None or
field.attname in self.selected_fields:
---> 40 self.handle_field(obj, field)
 41 else:
 42 if self.selected_fields is None or
field.attname[:-3] in self.selected_fields:

/usr/local/lib/python2.4/site-packages/django/core/serializers/
xml_serializer.py in handle_field(self, obj, field)
 70 value = self.get_string_value(obj, field)
 71 self.xml.characters(str(value))
---> 72 else:
 73 self.xml.addQuickElement("None")
 74

/usr/lib/python2.4/site-packages/_xmlplus/sax/saxutils.py in
characters(self, content)
307
308 def characters(self, content):
--> 309 writetext(self._out, content)
310
311 def ignorableWhitespace(self, content):

/usr/lib/python2.4/site-packages/_xmlplus/sax/saxutils.py in
writetext(stream, text, entities)
186 def writetext(stream, text, entities={}):
187 stream.errors = "xmlcharrefreplace"
--> 188 stream.write(escape(text, entities))
189 stream.errors = "strict"
190 else:

/usr/lib/python2.4/codecs.py in write(self, object)
176 """ Writes the object's contents encoded to
self.stream.
177 """
--> 178 data, consumed = self.encode(object, self.errors)
179 self.stream.write(data)
180

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
54: ordinal not in range(128)
--
I'm using version from svn (rev. 4997) and the default charset, utf-8.

I couldn't find any post about that...

Any idea? I'm a real noob in unicode things. Anyone with the same
problem?

Thx a lot in advance,
Saik


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



Log out problems

2007-04-11 Thread jeffhg58

I am having a problem when I log out from my site.

Here is the scenario I am using the @login_required for logging into
my site.
Then I have the link to log out very similar to the admin pages.
The only problem I am having is when I log out and either hit the back
button or go to my home
page from the browser it does not give me the login prompt window.
But, when I hit the home button link on the logout page, I get the
login window.

Here is a snippet of my logout function:

def logout_view(request, template_name='registration/
logged_out.html'):
logout(request)
 return render_to_response(template_name, {'title': _('Logged
out')}, context_instance=template.RequestContext(request))

Thanks,
Jeff


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



Re: Simple python question

2007-04-11 Thread mrstone


> What I'm doing is to load a model from a template.
> I have in a template something like this:
> {% block menu %}
> {% block rss %}
>
> I want to load "menu" and "rss", but I think that is too much work for
> now, I have no idea how to implement it and I probably won't do it.
> Thank you very much for your help.


Have you looked at template tags?
Check this tutorial: 
http://www.djangoproject.com/documentation/templates_python/
-Sten


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



Re: Custom SQL - MySQL Dictcursor

2007-04-11 Thread Jacob Kaplan-Moss

Check out the ``django.db.backend.dictfetch*`` functions. For example:

from django.db import connection, backend

c = connection.cursor()
c.execute(SQL)
rows = backend.dictfetchall(c)

Jacob

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



Re: Custom SQL - MySQL Dictcursor

2007-04-11 Thread shwag


I looked at a lot of different ways of doing this, and it looks like
the django.db cursor needs to be hacked to support MySQLdb's
DicCursor. That seems overkill since its easy to just import MySQLdb
yourself, and the prebuild django.db libraries are mostly just for the
Models. Your other option is to use your own method to create the
dictionary.

def query(cursor, sql):
cursor.execute(sql)
columns = range(len(cursor.description))
while True:
result = cursor.fetchone()
if not result:
raise StopIteration
row = {}
for column in columns:
row[cursor.description[column][0]] = result[column]
yield row




On Feb 11, 4:25 am, Dirk Eschler <[EMAIL PROTECTED]> wrote:
> On Freitag, 9. Februar 2007, Dirk Eschler wrote:
>
> > Hello,
>
> > is there a way to get a dictcursor from Django when using custom MySQL?
>
> > >from django.db import connection
>
> > cursor = connection.cursor()
> > cursor.execute("SELECT [...]")
> > cursor.fetchall()
>
> > The above fetchall returns a tuple, while i need a dict, like it is built
> > with MySQLdb.cursors.DictCursor(db).
>
> In case it's not possible: can i reuse Django's connection object somehow, or
> do i have to handle the connection myself?
>
> Is there any Django/MySQLdb example maybe?
>
> Best Regards,
> Dirk Eschler
>
> --
> Dirk Eschler http://www.krusader.org


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



Re: Dynamic Model Fields

2007-04-11 Thread Olivier Guilyardi

Tim Chase wrote:
>> Actually the labs where just an example: one laboratory will
>> have one installation of the application, and the dynamic
>> fields will only apply within the scope of this installation.
>> There's no such thing as consistency accross labs.
> 
> It still sounds like the above scheme would do the trick...one 
> code-base could work for any of the installations.

Well, not really. Think of an installation as a "site" in Django, I'm currently
working on the "application". Administrators are expected to add/remove dynamic
fields within the scope of a given site. In other words, it's some sort of
site-specific configuration.

>> Or does your "ManyToMany(Values)" field helps for
>> optimization? May I expect any help from manipulators,
>> managers, query sets (all of these are still a bit obscure to
>> me) ?
> 
> ManyToMany neither helps nor hinders performance...it states a 
> fact about your model.  For performance, you may want to try 
> using the Model.objects.select_related() call.  This pulls in the 
> items related to your search, so you can do things like
> 
>MediaItem.objects.filter(author='Smith').select_related()
> 
> This should help reduce the number of hits on the DB by telling 
> Django to pull them all back in one pass.

Thank you (and to Gulopine) for pointing this out.

> This scheme does have one small complicating factor wherein if 
> you want MediaItems with property1='foo' and property2='bar', you 
> have to jump through some hoops.  Some dark-art SQL-foo can solve 
> the problem, but it's not a pretty scene.  As long as you only 
> limit it one property, Django's good:
> 
>items = MediaItem.objects.select_related().filter(
>  property__category__name='MyProp'
>  ).filter(property__value='MyValue')

Okay

> (adjusting for your model).  Asking for multiple properties is 
> akin to asking
> 
>SELECT * FROM tblFoo WHERE x=1 AND x=2
> 
> and returns no rows (because there's no way to have x be both 
> values...unless you have

I see

>> SELECT Owner FROM tblCat WHERE state='alive' AND state='dead'
> 
>Owner
>
>Schroedinger
> 
> ...a little feeble SQL/metaphysics humor there)

Apparently we're not going to deal with cats ;)

> However, if you know which piece of your cross-cutting will have 
> the smaller results, you can do things like the above and then 
> filter the resulting items based on whether they have properties 
> 2..N such as
> 
>new_items = []
>for item in items:
>  for property in item.property:
>if (property.value=='MyValue2' and
>property.category.name=='MyName2'):
>  new_items.append(item)
> 
> It's not ideal for high volumes of data or high volumes of 
> traffic, but should be sufficient for most small uses.

Okay, I got the point.

Now, there's another problem with the above method: it doesn't play nice with
Django's auto-admin interface and generic views. Additionally, that makes 4
models for what is conceptually one thing : a media item.

What about a radically different idea: a command line tool that would "modify"
the models and SQL tables in one go. Say something like:

$ telemeta-admin addfield musicians charfield

This would retain all of the power/simplicity of Django admin interface. I'm not
sure how this could be generalized to get included into Django's manage.py, but
a such command line tool would be rather feasible within the scope of telemeta.

However, I don't like the idea of modifying the python models code with this
tool. I'd prefer the models to be customized by loading some external fields
definitions, say from an XML file.

I'm still a python newbie, but it seems to me that there could be a way to
modify the model definition before Django knows about it:

=== start of models.py ===

class MediaItem(models.Model):
"Describe an audio/video item with metadata"
title = models.CharField(maxlength=250)
author = models.CharField(maxlength=250)

# Parse some external XML file defining the dynamic fields and then add them
# to the class definition with something similar to:
MediaItem.foobar = models.CharField(maxlength=250)

=== end of models.py ===

I tried it: when I load the model withing the python shell, the class does have
a foobar attribute. However, when I run python manage.py sql, the foobar field
is gone...

Any idea?

--
  Olivier - http://www.samalyse.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
-~--~~~~--~~--~--~---



Fwd: Face Shapes - hair style

2007-04-11 Thread Kooooool forwords
 Face Shapes - hair
style

 There are seven basic types of facial shapes. They are:

1. Oval,
2. Long,
3. Rectangular,
4. Pear,
5. Diamond
6. Square, and
7. Heart


*Oval*
The oval face is 1.5 times longer that it is wide and its forehead is
slightly wider than the jaw. Considered the most ideal and versatile facial
shape by hair experts, many haircuts and styles suit an oval face. However,
the best styles to go for are the ones that have layers at the height of you
best features such as cheekbones, lips or chin. Short layers at the top of
the head should be avoided as they make the face look longer, while ladies
with an oval face and thick and curly hair should avoid blunt cut as it
looks like a pyramid.

*Rectangular*
Long and narrow facial shape with a square chin and hairline is known as
Rectangular facial shape. Hair cut for rectangular face should add width to
its sides, play down on its length by adding a fringe on the forehead and a
style that has a side part to soften the squareness of the face. Extremely
long or short haircuts make the face look longer while chin-length bobs and
haircuts add width to the face. Another way to add the width is to add the
curls & waves in your hair. However, short layers lend volume to the top
further elongating the face then balancing it.


*Pear*
This facial shape has a narrow forehead and wide jawline with a round chin.
Attempt is to add width to the forehead and the temples while taking the
attention away from the roundness of the jaw. You hair should appear wide
and full at the top and temples and could be wear brushed away from the face
and up toward the ears. Down from the ears, the hair should fall along the
chin to soften it and narrow down the jaw line. Chin length hair is best.
Decrease the hair volume from the top, the sides and around the ears. Curls
around the temples will soften the face.

*Diamond*
Widest at the forehead but narrow at the forehead and chin, hair styles for
a diamond face needs to add width to the forehead and soften or disguise the
cheekbones to give an illusion of the oval face. Add more fringe and volume
to the forehead and the chin while smooth hair compliment the cheekbones
better. A low side parting and a sweep of hair brushed across the forehead
add width to the face and make it look shorter. Asymmetric haircuts look
good too along with adding to the hair volume with curly or wavy styles.
Read MOre 
...
More areticles :

  Latest

   - herbal 
beauty
   - frugal 
beauty
   - facial and skin
care
   - eyebrow 
waxing
   - essential 
Oils
   - beautiful 
eyebrows
   - beach beauty
   - tips on hand
care
   - Nail Polish &
makeup
   - Mascara 4 
eyes


Some Wallpapers 4 u

[image: TROPICAL BEACH , COCOA BEACH , BEACH PICTURE]

[image:
TROPICAL BEACH , COCOA BEACH , BEACH PICTURE]

[image:
TROPICAL BEACH , COCOA BEACH , BEACH PICTURE]

*An Empty Hammock, Kauai, Hawaii - 1600x1200 - ID*
1600 X 1198
0 KB *Anaura Bay, Gisborne, New Zealand - 1600x1200 - *
1600 X 1200
0 KB *Balboa Pier, California - 1600x1200 - ID 27253*
1600 X 1200
0 KB  [image: TROPICAL BEACH , COCOA BEACH , BEACH PICTURE]

[image:
TROPICAL BEACH , COCOA BEACH , BEACH PICTURE]

[image:
TROPICAL BEACH , COCOA BEACH , BEACH PICTURE]

*Bandon, Oregon - 1600x1200 - ID 32511*
1600 X 1200
0 KB *Boardman State Park, near Brookings-Harbor, Oreg*
1600 X 1200
0 KB *Boathouse at Dawn, Fiji - 1600x1200 - ID 27249*
1600 X 1200
0 KB  [image: TROPICA

Database error misreported(?)

2007-04-11 Thread Tim Holloway

I got brought to a dead halt just by populating a single database
column. The error message is short on context and the stack trace
seems to be at odds with it.

Changing values in the database caused a previously-functional page
display to fail. Exception reported was "Caught an exception while
rendering: hour must be in 0..23", no database row or column
indicated. Nor, for that matter any way of backtracking the message to
which of several formatting tags on the page might have triggered it.
However, the database values changed were simple integers, not dates
or times, and they are not  referenced on the web page in question.

Stack trace indicates a failure in the database backend - on the SQL
request, NOT in the formatting process. It appears that there may be
some sort of SQL error, but the original exception message is being
supplanted by a format-level exception message. The generated SQL as
displayed in the trace looks OK, and manual queries work with no
error.

I don't know what to try next.

   Tim


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



Re: Testing Framework and Fixtures

2007-04-11 Thread Brian Luft

I've run into problems as well with the fixture functionality.  The
short of it is that this is a new feature to the framework and likely
the kinks will be worked out in the coming weeks.

In the meantime you might check out one of these as a workable
temporary solution:
http://www.djangosnippets.org/snippets/167/
http://www.djangosnippets.org/snippets/14/

I can't vouch for them personally other than to say that they both
look to be fairly well thought out.

On Apr 11, 9:28 am, Merric Mercer <[EMAIL PROTECTED]> wrote:
> Being a relative newbie I don't really understand how to create a
> fixture for the testing framework.  Could someone provide an example of
> the format of a
> fixture ?
>
> I tried to run the dumpdata command because I'd read that this did much
> of the work for me but I received the following error message
>
>  >>C:\>manage.py dumpdata promotions
> Unable to serialize database: Table_Code matching query does not exist.
> None
>
> My models have several 1:1 relationships and I think I remember seeing
> something about this causing a problem in the test framework - but I
> can't relocate the post that mentioned this.   Does anybody know the
> status on this?
>
> MerMer


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

2007-04-11 Thread Tim Chase

> Actually the labs where just an example: one laboratory will
> have one installation of the application, and the dynamic
> fields will only apply within the scope of this installation.
> There's no such thing as consistency accross labs.

It still sounds like the above scheme would do the trick...one 
code-base could work for any of the installations.

> Well, that's what I almost did... with support for
> enumerations (some fields must only accept predetermined
> values):
> 
[snipped]
> 
> However, watching the MySQL verbose log, I realized that
> retrieving properties as well as their definitions (and
> enumeration values) to properly display an detail view or
> edition form execute a _lot_ of SQL queries, when this could
> be achieved with one or two joins... I'm afraid it won't
> scale.
> 
> Or does your "ManyToMany(Values)" field helps for
> optimization? May I expect any help from manipulators,
> managers, query sets (all of these are still a bit obscure to
> me) ?

ManyToMany neither helps nor hinders performance...it states a 
fact about your model.  For performance, you may want to try 
using the Model.objects.select_related() call.  This pulls in the 
items related to your search, so you can do things like

   MediaItem.objects.filter(author='Smith').select_related()

This should help reduce the number of hits on the DB by telling 
Django to pull them all back in one pass.

This scheme does have one small complicating factor wherein if 
you want MediaItems with property1='foo' and property2='bar', you 
have to jump through some hoops.  Some dark-art SQL-foo can solve 
the problem, but it's not a pretty scene.  As long as you only 
limit it one property, Django's good:

   items = MediaItem.objects.select_related().filter(
 property__category__name='MyProp'
 ).filter(property__value='MyValue')

(adjusting for your model).  Asking for multiple properties is 
akin to asking

   SELECT * FROM tblFoo WHERE x=1 AND x=2

and returns no rows (because there's no way to have x be both 
values...unless you have

   > SELECT Owner FROM tblCat WHERE state='alive' AND state='dead'

   Owner
   
   Schroedinger

...a little feeble SQL/metaphysics humor there)

However, if you know which piece of your cross-cutting will have 
the smaller results, you can do things like the above and then 
filter the resulting items based on whether they have properties 
2..N such as

   new_items = []
   for item in items:
 for property in item.property:
   if (property.value=='MyValue2' and
   property.category.name=='MyName2'):
 new_items.append(item)

It's not ideal for high volumes of data or high volumes of 
traffic, but should be sufficient for most small uses.

-tkc





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

2007-04-11 Thread Gulopine

On Apr 11, 1:36 pm, Olivier Guilyardi <[EMAIL PROTECTED]> wrote:
> However, watching the MySQL verbose log, I realized that retrieving properties
> as well as their definitions (and enumeration values) to properly display an
> detail view or edition form execute a _lot_ of SQL queries, when this could be
> achieved with one or two joins... I'm afraid it won't scale.

You might look into select_related() to get the properties in one
query, since you know you'll need them every time you access a
category.

http://www.djangoproject.com/documentation/db-api/#select-related

-Gul


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



Re: SelectMultiple widget

2007-04-11 Thread oggie rob

Try using firebug (extension for Firefox). You can see how it is
instantiated in the admin site and where things are going wrong.
I suspect you either are missing the "vSelectMultipleField" (is that
right?) class, the multiple="multiple" attribute, or have not got all
of the JS included. As for why it worked in one place and not another
- if they are the exact same environment, that is hard to explain :)
But again, use Firebug.

 -rob

On Apr 11, 5:05 am, "masuran" <[EMAIL PROTECTED]> wrote:
> Hello Enrico,
>
> First of all thank you for your help :)
> But unfortunately that didn't solve my problem.
>
> Next I tried to copy the entire source of an admin generated form that
> had the two list boxes and modify it. But even without modifying it I
> didn't get the two listboxes. Very very very strange. Two pages with
> the exact same source and only the one generated by the admin part has
> the two listboxes.
>
> I'm getting pretty confused :)
>
> On 10 apr, 21:11, "Enrico" <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > There is a 'YOUR_ADMIN_MEDIA/js/SelectFilter2.js' file, I think this
> > is the file that does the "magic".
>
> > Maybe you can use it as a base for applying the widget on your site.
>
> > Best regards,
> > Enrico


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

2007-04-11 Thread Olivier Guilyardi

Tim Chase wrote:
>> I'm in the process of turning telemeta [1] into a django
>> application, and need dynamic model fields: we want to allow
>> site administrators to easily add/remove "fields" to our main
>> data structure, the MediaItem, which represents an audio/video
>> resource.
> 
> Our current app does something like this...our basic solution was 
> something like one of the two following ideas (depending on 
> whether particular categories should be consistent across labs, 
> such as "media" meaning the same thing in Lab1 and Lab2)

Actually the labs where just an example: one laboratory will have one
installation of the application, and the dynamic fields will only apply within
the scope of this installation. There's no such thing as consistency accross 
labs.

> or the more simple "every lab has its own bag of categories that 
> don't relate to anybody else" (this is how we settled on it 
> because our clients rarely have much in common for these 
> category/value pairs):
> 
> 
>class Lab(Model):
>   pass
>class Category(Model):
>   lab = ForeignKey(Lab)
>   name = CharField(maxlength=40)
>class Value(Model):
>   category = ForeignKey(Category)
>   value = CharField(maxlength=40)
>class MediaItem(Model):
>   lab = ForeignKey(Lab)
>   values = ManyToMany(Values)

Well, that's what I almost did... with support for enumerations (some fields
must only accept predetermined values):

class MediaItem(models.Model):
"Describe an audio/video item with metadata"
title = models.CharField(maxlength=250)
author = models.CharField(maxlength=250)

def get_dynamic_properties(self):
"Retrieve dynamic properties associated with a given media item"
[...]

class MediaItemPropertyDefinition(models.Model):
"Define a media item dynamic property"
TYPE_CHOICES = (('text', 'Text'), ('enumeration', 'Enumeration'))
name = models.CharField(maxlength=64)
type = models.CharField(maxlength=64, choices = TYPE_CHOICES)

class MediaItemPropertyEnumerationItem(models.Model):
"Define a possible value for media item dynamic enumeration properties"
definition = models.ForeignKey(MediaItemPropertyDefinition, core=True)
name = models.CharField(maxlength=250)

class MediaItemProperty(models.Model):
"Associate a value to a media item dynamic property"
definition = models.ForeignKey(MediaItemPropertyDefinition, core=True)
media_item = models.ForeignKey(MediaItem)
value = models.CharField(maxlength=250)
enum_item = models.ForeignKey(MediaItemPropertyEnumerationItem, null=True)

However, watching the MySQL verbose log, I realized that retrieving properties
as well as their definitions (and enumeration values) to properly display an
detail view or edition form execute a _lot_ of SQL queries, when this could be
achieved with one or two joins... I'm afraid it won't scale.

Or does your "ManyToMany(Values)" field helps for optimization?
May I expect any help from manipulators, managers, query sets (all of these are
still a bit obscure to me) ?

Regards,

--
  Olivier - http://www.samalyse.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: Global model/view best practice help

2007-04-11 Thread Dave

Thanks Sam, that was enough for me to start playing around with.

Perfect. :)

On Apr 11, 3:44 pm, "Sam" <[EMAIL PROTECTED]> wrote:
> Like Todd said,
>
> 1. Write a function :
>
> def my_template_vars(request)
> return {'var1': 'test', 'var2': 'test2'}
>
> 2. Edit your settings.py
> TEMPLATE_CONTEXT_PROCESSORS = (
> ...
> 'project.app.file.my_template_vars',
> )
>
> 3. Inside your views, load your templates with a RequestContext object
> if you are using functions like render_to_response.
>
> def my_view(request):
> ...
> return render_to_response(template_name,
>
> context_instance=RequestContext(request))
>
> 4. Inside your template, you can now access {{ var1 }} all the time
>
> On 11 avr, 15:37, "Dave" <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > I was looking at middleware - so, thanks Todd for the pointer in the
> > right direction. I can't seem to find anything much in docs or on the
> > web about TEMPLATE_CONTEXT_PROCESSORS in Django. Anyone got any links?
>
> > 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: NewForms Question..

2007-04-11 Thread brad

You are exactly right. Thanks for your time and 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: Running django in standalone mode

2007-04-11 Thread [EMAIL PROTECTED]

I am assuming that "looker" is the name of your project directory.
When you use the statement "from looker...", python is searching
through its search path and looking for either modules (python files)
or packages (modules grouped in a directory containing an __init__.py
file) called "looker".  You had the right idea of appending the
project path to the python search path, but you went one directory too
deep.  Try:
PROJECT_PATH="~/projects"
That way, when python is trying to resolve "looker", it will arrive at
~/projects, see a directory called "looker", happily find that it is
indeed a python package via the presence of __init__.py (assuming you
created your django project the standard way), and will then be able
to import the settings module from the looker package.


On Apr 11, 3:57 am, "Alex Dong" <[EMAIL PROTECTED]> wrote:
> I'm having a bunch of cron jobs which will use django model and
> send_mail features. I've read through this 
> linkhttp://groups.google.com/group/django-users/browse_thread/thread/5182...
> but for some unknown reason, I still can't use django's model.
>
> Will anyone kindly look through my code and point out where I've done
> wrong?
>
> %>--
> $ cat environ.py
> #!/usr/bin/env python
>
> import sys
> import os
> from local_conf import *
>
> DJANGO_PATH = "/lib/python2.4/site-packages/django/"
> PROJECT_PATH = "~/projects/looker"
> PROJECT_SETTING = "looker.settings"
>
> sys.path.append(DJANGO_PATH)
> sys.path.append(PROJECT_PATH)
> os.environ['DJANGO_SETTINGS_MODULE'] = PROJECT_SETTING
>
> from looker import settings
>
> $ environ.py
> Traceback (most recent call last):
>   File "./environ.py", line 11, in ?
> from looker import settings
> ImportError: No module named looker
> <%
>
> Plus, is it possible that we could have something like "python
> manage.py run environ.py" where django's 'manage.py' will take care of
> this stuff and execute django dependent standalone application? I
> could contribute the code but need some advices here.
>
> thanks,
> Alex


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



About static/dynamic urlconf, multiple hosts, urlpatterns, and RegexURLResolver

2007-04-11 Thread Alejo

Hi.

Got a question for you about an idea on making urlconfs more
sophisticated and dynamic.

First some background:

We are (re) developing a rather complex collection of sites. We have a
live Zope system currently, with a lot of extensions to it's code, it
works but it reached it's architectural limits.

We like Django architecture. The problem we face now is it's kind of
static url  to view matching system. Current site is dynamically
edited, up to folders and domains. Our content is rather large and the
site is quite busy. We can't afford restart the application for new
url paths as this will be a burden on our deployment procedure
(development environments, qa environments, production environments.)

Also we in principle we wouldn't like a single generic view for every
path and then do all our own way like many do. And anyway currenttly
it doesn't deal with multiple hosts/domains.

The idea:

We've been thinking on extending/changing the conf.url code and the
resolver code to support some method call to resolve a full url (not
just the path, but the host and domain too.)

This could be achieved using an "urlpatterns object" (instead of a
list  as currently returned by pattern()). It might end up needing to
move the regex matching at the urlconf level.

So the RegexURLResolver.resolve() code should move the iteration to
the "urlpatterns object" itself.

This could open the door for dynamically configured urls including
host, dynamically loads of views.

It's a crude idea, and definetly not something final. But would love
to listen what Django experts would think about it.

Thanks!

Alejo


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



Re: gettext & UnicodeDecodeError

2007-04-11 Thread Michael Radziej

On Wed, Apr 11, Sandro Dentella wrote:

> 
> Hi all,
> 
>   I'm having problems understanding an error that raises with gettext and an
>   accented letter. Italian translation of 'priority' is 'priorità', the text
>   to be translated is:
> 
> subject = _("Priority changed in ticket #%(id)s %(title)s") % (
>{'id':instance.id, 'title':instance.title})
> 
>   that *works nicely* when run in this way:
> 
> 
> # coding: latin-1
> import os, sys
> os.environ['DJANGO_SETTINGS_MODULE'] = 'jobs.settings'
> from django.utils.translation import gettext as _
> 
> subject = _("Priority changed in ticket #%(id)s %(title)s") % (
>   {'id': 11, 'title': 'abc'})
> 
>   but raises an error when run within a function in a callback connected
>   with a signal:
> 
> Traceback (most recent call last):
>  [...]
>   UnicodeDecodeError at /ticket/ticket/edit/21/
>   'ascii' codec can't decode byte 0xc3 in position 7: ordinal not in
>   range(128)
> 
> 
>my understnding of the problem is clearly partial here. I don't
>understand what changes when the function in run within django.
> 
>Any hint?

is perhaps one of the format parameters (to the '%' operator) a unicode
string, such as 
   _("...") % {'id': 11, 'title': u'abc'}
 ^^^

In that case, python tries to convert the format string to unicode, but
it uses ASCII as default encoding ...

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

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



Testing Framework and Fixtures

2007-04-11 Thread Merric Mercer

Being a relative newbie I don't really understand how to create a 
fixture for the testing framework.  Could someone provide an example of  
the format of a
fixture ?

I tried to run the dumpdata command because I'd read that this did much 
of the work for me but I received the following error message

 >>C:\>manage.py dumpdata promotions
Unable to serialize database: Table_Code matching query does not exist.
None

My models have several 1:1 relationships and I think I remember seeing 
something about this causing a problem in the test framework - but I 
can't relocate the post that mentioned this.   Does anybody know the 
status on this?

MerMer


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



gettext & UnicodeDecodeError

2007-04-11 Thread Sandro Dentella

Hi all,

  I'm having problems understanding an error that raises with gettext and an
  accented letter. Italian translation of 'priority' is 'priorità', the text
  to be translated is:

subject = _("Priority changed in ticket #%(id)s %(title)s") % (
   {'id':instance.id, 'title':instance.title})

  that *works nicely* when run in this way:


# coding: latin-1
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'jobs.settings'
from django.utils.translation import gettext as _

subject = _("Priority changed in ticket #%(id)s %(title)s") % (
{'id': 11, 'title': 'abc'})

  but raises an error when run within a function in a callback connected
  with a signal:

Traceback (most recent call last):
File "/home/sandro/src/django/jungle/apps/ticket/views.py" in update
  40. return generic.update_object(request, model, ext="_update", **kw)
File "/home/sandro/src/django/jungle/views/mgeneric.py" in update_object
  62. return create_update.update_object(request, model, **kw)
File "/home/sandro/src/django/jungle/views/create_update.py" in update_object
  146. object = form.save()
File "/misc/src/django/trunk/django/newforms/models.py" in save
  65. return save_instance(self, instance, commit)
File "/misc/src/django/trunk/django/newforms/models.py" in save_instance
  53. instance.save()
File "/misc/src/django/trunk/django/db/models/base.py" in save
  250. dispatcher.send(signal=signals.post_save, sender=self.__class__, 
instance=self)
File "/misc/src/django/trunk/django/dispatch/dispatcher.py" in send
  358. sender=sender,
File "/home/sandro/src/django/jungle/apps/ticket/jsignals.py" in mail_on_change
  78. subject = _("Priority changed in ticket #%(id)s %(title)s") % (

  UnicodeDecodeError at /ticket/ticket/edit/21/
  'ascii' codec can't decode byte 0xc3 in position 7: ordinal not in
  range(128)


   my understnding of the problem is clearly partial here. I don't
   understand what changes when the function in run within django.

   Any hint?

   thanks in advance
   sandro
   *:-)


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



Re: Contact Form App

2007-04-11 Thread Chris Moffitt

>
> Is there a newform contact form snippet to use in a django website to
> add the possibility to send email messages from a webpage to an email
> address, without spam?

Here's what we're using in Satchmo -
http://www.satchmoproject.com/trac/browser/satchmo/trunk/satchmo/shop/views/contact.py

-Chris

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



Re: Dynamic Model Fields

2007-04-11 Thread Tim Chase

> I'm in the process of turning telemeta [1] into a django
> application, and need dynamic model fields: we want to allow
> site administrators to easily add/remove "fields" to our main
> data structure, the MediaItem, which represents an audio/video
> resource.
> 
> Example: for a given research laboratory the MediaItem may
> need to have a "musicians" field, but for another laboratory
> it can be "filmmaker", etc... And there may be dozens of these
> dynamic fields, which could be added/removed at any time.
> 
> We believe the process of hard-coding those fields into the
> models is a developer task and too heavy for the
> administrators we target, especially because of the need to
> manually modify the SQL tables.


Our current app does something like this...our basic solution was 
something like one of the two following ideas (depending on 
whether particular categories should be consistent across labs, 
such as "media" meaning the same thing in Lab1 and Lab2)

   class Lab(Model):
pass
   class Category(Model):
name = CharField(maxlength=40)
   class LabCategory(Model):
lab = ForeignKey(Lab)
category = ForeignKey(Category)
   class Values(Model):
category = ForeignKey(LabCategory)
value = CharField(maxlength=40)
   class MediaItem(Model):
lab = ForeignKey(Lab)
values = ManyToMany(Values)

or the more simple "every lab has its own bag of categories that 
don't relate to anybody else" (this is how we settled on it 
because our clients rarely have much in common for these 
category/value pairs):


   class Lab(Model):
pass
   class Category(Model):
lab = ForeignKey(Lab)
name = CharField(maxlength=40)
   class Value(Model):
category = ForeignKey(Category)
value = CharField(maxlength=40)
   class MediaItem(Model):
lab = ForeignKey(Lab)
values = ManyToMany(Values)

Thus, you can use something like (possibly bogus code, but the 
idea applies)

   for item in MediaItem.objects.all():
s = '%s: %s' % (item.lab, item)
print s
print '='*len(s)
for v in item.values:
print '\t', v.category.name, '=', v.value

It does require checking to ensure that a MediaItem has all the 
Category values filled out for the given Lab (otherwise, it's 
possible for a Lab to have 3 Category fields, but the user only 
populates 2 of them), but that's an exercise to the reader (a 
non-trivial task when you add new categories, what goes into the 
category value for all existing data).

This doesn't involve any SQL monkeying once the system is in 
production, but it still allows each Lab to have an arbitrary 
list of its own Category/Values.

If you have archive data, you may also want to add an "active" 
flag to both the Category and Value models so that you can retire 
either, but still have the data in the system.  Your 
checks-for-all-categories should then take the Category's active 
flag into consideration.

My $0.02 from my own feable experiences...

-tkc




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



Dynamic Model Fields

2007-04-11 Thread Olivier Guilyardi

Hi,

I'm in the process of turning telemeta [1] into a django application, and need
dynamic model fields: we want to allow site administrators to easily add/remove
"fields" to our main data structure, the MediaItem, which represents an
audio/video resource.

Example: for a given research laboratory the MediaItem may need to have a
"musicians" field, but for another laboratory it can be "filmmaker", etc... And
there may be dozens of these dynamic fields, which could be added/removed at any
time.

We believe the process of hard-coding those fields into the models is a
developer task and too heavy for the administrators we target, especially
because of the need to manually modify the SQL tables.

Any ideas?

Regards,

[1] http://svn.parisson.org/telemeta

--
  Olivier - http://www.samalyse.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: Global model/view best practice help

2007-04-11 Thread Sam

Like Todd said,

1. Write a function :

def my_template_vars(request)
return {'var1': 'test', 'var2': 'test2'}

2. Edit your settings.py
TEMPLATE_CONTEXT_PROCESSORS = (
...
'project.app.file.my_template_vars',
)

3. Inside your views, load your templates with a RequestContext object
if you are using functions like render_to_response.

def my_view(request):
...
return render_to_response(template_name,
 
context_instance=RequestContext(request))

4. Inside your template, you can now access {{ var1 }} all the time




On 11 avr, 15:37, "Dave" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I was looking at middleware - so, thanks Todd for the pointer in the
> right direction. I can't seem to find anything much in docs or on the
> web about TEMPLATE_CONTEXT_PROCESSORS in Django. Anyone got any links?
>
> 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
-~--~~~~--~~--~--~---



Use properties for filtering results

2007-04-11 Thread Paolo Dina

In my model there is model method I'd like to use for filtering.
Is it possible? I have put it in form of property, but when I use it
with field lookup syntax I get an error.

This is a minimal sample model that should explain what I mean:

class Category(models.Model):
name = models.CharField(maxlength=16)

class Content(models.Model):
title = models.CharField(maxlength=32)
category = models.ForeignKey(Category)
pub_date = models.DateTimeField()
priv = BooleanField(default=True)

def _visible(self):
return (self.priv == False and self.pub_date < datetime.now())
visible = property(_visible)

>>> c = Content.objects.get(pk=1)
>>> c.visible
False
>>> Category.objects.filter(visible=False)
Traceback (most recent call last):
...
TypeError: Cannot resolve keyword 'visible' into field

Filtering in this way would come handy in a custom template tag, where
I'd like to ask things in this way:
Category.objects.get_categories(user), where get_categories is a
Category's custom manager method that returns different results
depending on user's authentication status.

def get_categories(self, user=None):
c_qs = Category.objects.all()

if hasattr(user, 'is_staff') and user.is_staff:
res = [(c, c.content_set.count()) for c in c_qs]
else:
res = [(c, c.content_set.filter(visible=True).count()) for c
in c_qs]
return res

Any suggestion?

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: Detect ajax request

2007-04-11 Thread Ryan Kanno

Ahh... that's what I was missing.

Thanks, Nathan (as I'm also using jQuery). :)

On Apr 10, 6:23 pm, "Nathaniel Whiteinge" <[EMAIL PROTECTED]> wrote:
> I've been happily using limodou's suggestion with the jQuery framework
> for a few weeks, hopefully whatever framework you're using also sends
> the X-Requested-With header--it just feels cleaner.
>
> if request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest':
> # do stuff...
>
> - whiteinge
>
> On Apr 10, 8:56 am, Tim Chase <[EMAIL PROTECTED]> wrote:
>
> > > Is there a standard way to detect if a request was an ajax one?  I
> > > know I could append a key to the ajax request like in Mr. Bennett's
> > > post here:
>
> > >http://www.b-list.org/weblog/2006/07/31/django-tips-simple-ajax-examp...
>
> > > iehttp://website.com/some/request/?xhrandin my view, dump out json
> > > accordingly, etc, but I was wondering if there was a standard way
> > > without attaching a key (perhaps looking at a request header).
>
> > One of the beauties of the web is that a request is a request is
> > a request.  Information can be transmitted in the URL, in
> > cookies, or in HTTP-authentication.  One might also be able to
> > tweak the other HTTP headers.  My interpretation of the web
> > philosophy says that you want to refer to the resource:
>
> >http://example.com/path/to/resource
>
> > If you want to alter the format, you can either make it a
> > pseudo-resource:
>
> >http://example.com/path/to/resource/json
>
> > or pass it as a parameter:
>
> >http://example.com/path/to/resource?format=json
>
> > I tend to prefer the latter, because it's clearly the same
> > resource, just changed-up a bit in the formatting dimension
> > (plain-text, HTML, XML, JSON, YAML, CSV, tab-delimited, etc).  I
> > do similarly for sorting options:
>
> >http://example.com/path/to/resource?order=fieldname
>
> > Just my $0.02
>
> > -tkc


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



Re: Global model/view best practice help

2007-04-11 Thread Dave

Hi all,

I was looking at middleware - so, thanks Todd for the pointer in the
right direction. I can't seem to find anything much in docs or on the
web about TEMPLATE_CONTEXT_PROCESSORS in Django. Anyone got any links?

Cheers,
Dave

On Apr 10, 11:47 pm, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote:
> On Tue, 2007-04-10 at 22:21 +, Dave wrote:
> > I could add to the Context object in each view, but that's a lot of
> > repeat code (urgh). Also, if I were to take that route, I'd need the
> > Model to be available between multiple apps within a project and I've
> > not seen how to do that.
>
> You want a TEMPLATE_CONTEXT_PROCESSOR. Write a function that takes a
> request and returns a dictionary with the name you want for your
> included model. Then add that function to TEMPLATE_CONTEXT_PROCESSORS in
> your settings.py file. Voila.
>
> Todd


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

2007-04-11 Thread asrenzo

Hi,

I'm wrtting a small web site with a limited number of apps and tables.
Almost all my models can easely be managed throught the automatic
django admin interface.

I changed some minors points of the some change_form by subclassing
the original ones and adding extra content in some usable blocks.

I'm still stucked with one of my model class which implements a basic
tree of data.

The default list view will present a list of entries sorted
accordingly to the sorting attr defined in the Meta class but this is
a "flat" list of records.

I would like to be able to :

- Present each list view with respect to the ordering attr but also
limited to a certain subset of the records (that is to say only one
level at a time).

- Move the add button on each row to be able to add a child to the
node

- Add an edit button on each row

- Change the default link on each row to only present the list of
children

This sounds almost to specific to be able to do it with minor changes
(block replacement and so on) in a custom admin view.

I'm sure there's an elegant way to do this. I'm also sure that I'm not
the first one trying to manage trees from within Django's admin
site :

So do you have any pointers or solutions ?

Regards,

Laurent


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

2007-04-11 Thread va:patrick.kranzlmueller

hi,

it means that somewhere on your server there is a directory for file- 
uploads - just point to that directory.

e.g., our media-structure looks like this:
within the media-directory (=settings.MEDIA_ROOT) we have some sub- 
directories:
/admin/
/site/
/tinymce/
/uploads/

we want our editors to only upload to the UPLOADS-directory. that´s  
why we set FB_ROOT to "+ uploads/" ...

for playing around with the file-browser, just use this:
FB_ROOT = settings.MEDIA_ROOT
FB_URL = settings.MEDIA_URL

patrick

Am 11.04.2007 um 14:00 schrieb zehi:

>
> Hi,
>
> I can't figure out step 5:
>
> Change /filebrowser/views.py. Replace the paths:
>
> FB_ROOT = settings.MEDIA_ROOT + "uploads/"
> FB_URL = settings.MEDIA_URL + "uploads/"
>
> Does it mean to just delete or change?
>
> If to change, then how?
>
> Thanks
>
> On Mar 14, 1:18 am, "patrick k." <[EMAIL PROTECTED]> wrote:
>> if you can´t see the mentioned screenshot, your urls are probably
>> configured wrong.
>>
>> be sure to follow the installation guide EXACTLY - I´ve done that
>> with all of my projects and I don´t have any problems.
>> check the settings file (esp. MEDIA_ROOT and MEDIA_URL).
>>
>> patrick.
>>
>> Am 13.03.2007 um 19:01 schrieb Mary:
>>
>>
>>
>>> No i can't see this pictures and directories
>>> but when i copy and past the url before the admin url [sorry i read
>>> this note in the steps and i think i missed it the first time]i was
>>> able to add directories
>>
>>> But i still can't see the
>>> http://trac.dedhost-sil-076.sil.at/trac/filebrowser/chrome/site/
>>> fb_2.jpg
>>
>>> I wondering why?
>>
>>> On Mar 13, 6:35 pm, "patrick k." <[EMAIL PROTECTED]> wrote:
 before you click on "make directory", do you see the directory-
 listing like this:http://trac.dedhost-sil-076.sil.at/trac/
 filebrowser/chrome/site/fb_2.jpg
>>
 did you follow step 6?
 it seems that the urls aren´t configured.
>>
 patrick
>>
 Am 13.03.2007 um 17:14 schrieb Mary:
>>
> I would like to use Django file browser
> i did the steps 1-8 that is on the link
> http://trac.dedhost-sil-076.sil.at/trac/filebrowser/
> wiki#DjangoFileBrowser
> and when i open my admin interface i found the filebrowse but  
> when i
> click on
> Adddirectory it gave me an error
>>
>  App 'filebrowser', model 'mkdir', not found
>>
> Does anyone have an idea why is this happened to me ?
>>
> Thank you in advance ;
> Mary Adel
>
>
> >


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



Contact Form App

2007-04-11 Thread Alessandro Ronchi

Is there a newform contact form snippet to use in a django website to
add the possibility to send email messages from a webpage to an email
address, without spam?

Thanks in advance.

-- 
Alessandro Ronchi
Skype: aronchi - Wengo: aleronchi
http://www.alessandroronchi.net - Il mio sito personale
http://www.soasi.com - Sviluppo Software e Sistemi Open Source

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



Re: SelectMultiple widget

2007-04-11 Thread masuran

Hello Enrico,

First of all thank you for your help :)
But unfortunately that didn't solve my problem.

Next I tried to copy the entire source of an admin generated form that
had the two list boxes and modify it. But even without modifying it I
didn't get the two listboxes. Very very very strange. Two pages with
the exact same source and only the one generated by the admin part has
the two listboxes.

I'm getting pretty confused :)

On 10 apr, 21:11, "Enrico" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> There is a 'YOUR_ADMIN_MEDIA/js/SelectFilter2.js' file, I think this
> is the file that does the "magic".
>
> Maybe you can use it as a base for applying the widget on your site.
>
> Best regards,
> Enrico


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

2007-04-11 Thread zehi

Hi,

I can't figure out step 5:

Change /filebrowser/views.py. Replace the paths:

FB_ROOT = settings.MEDIA_ROOT + "uploads/"
FB_URL = settings.MEDIA_URL + "uploads/"

Does it mean to just delete or change?

If to change, then how?

Thanks

On Mar 14, 1:18 am, "patrick k." <[EMAIL PROTECTED]> wrote:
> if you can´t see the mentioned screenshot, your urls are probably
> configured wrong.
>
> be sure to follow the installation guide EXACTLY - I´ve done that
> with all of my projects and I don´t have any problems.
> check the settings file (esp. MEDIA_ROOT and MEDIA_URL).
>
> patrick.
>
> Am 13.03.2007 um 19:01 schrieb Mary:
>
>
>
> > No i can't see this pictures and directories
> > but when i copy and past the url before the admin url [sorry i read
> > this note in the steps and i think i missed it the first time]i was
> > able to add directories
>
> > But i still can't see the
> >http://trac.dedhost-sil-076.sil.at/trac/filebrowser/chrome/site/
> > fb_2.jpg
>
> > I wondering why?
>
> > On Mar 13, 6:35 pm, "patrick k." <[EMAIL PROTECTED]> wrote:
> >> before you click on "make directory", do you see the directory-
> >> listing like this:http://trac.dedhost-sil-076.sil.at/trac/
> >>filebrowser/chrome/site/fb_2.jpg
>
> >> did you follow step 6?
> >> it seems that the urls aren´t configured.
>
> >> patrick
>
> >> Am 13.03.2007 um 17:14 schrieb Mary:
>
> >>> I would like to use Django file browser
> >>> i did the steps 1-8 that is on the link
> >>>http://trac.dedhost-sil-076.sil.at/trac/filebrowser/
> >>> wiki#DjangoFileBrowser
> >>> and when i open my admin interface i found the filebrowse but when i
> >>> click on
> >>> Adddirectory it gave me an error
>
> >>>  App 'filebrowser', model 'mkdir', not found
>
> >>> Does anyone have an idea why is this happened to me ?
>
> >>> Thank you in advance ;
> >>> Mary Adel


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



Running django in standalone mode

2007-04-11 Thread Alex Dong

I'm having a bunch of cron jobs which will use django model and
send_mail features. I've read through this link
http://groups.google.com/group/django-users/browse_thread/thread/51827a2a40e5262e/bb66770dfff75cfe
but for some unknown reason, I still can't use django's model.

Will anyone kindly look through my code and point out where I've done
wrong?

%>--
$ cat environ.py
#!/usr/bin/env python

import sys
import os
from local_conf import *

DJANGO_PATH = "/lib/python2.4/site-packages/django/"
PROJECT_PATH = "~/projects/looker"
PROJECT_SETTING = "looker.settings"

sys.path.append(DJANGO_PATH)
sys.path.append(PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = PROJECT_SETTING

from looker import settings

$ environ.py
Traceback (most recent call last):
  File "./environ.py", line 11, in ?
from looker import settings
ImportError: No module named looker
<%

Plus, is it possible that we could have something like "python
manage.py run environ.py" where django's 'manage.py' will take care of
this stuff and execute django dependent standalone application? I
could contribute the code but need some advices here.

thanks,
Alex


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



SelectDateWidget unicode problem

2007-04-11 Thread Robert

When trying to use a SelectDateWidget from forms.extras.widgets.py I'm
getting the
following error:


Traceback (most recent call last):
File "c:\Python24\Lib\site-packages\django\template\__init__.py" in
render_node
  723. result = node.render(context)
File "c:\Python24\Lib\site-packages\django\template\__init__.py" in
render
  778. return self.encode_output(output)
File "c:\Python24\Lib\site-packages\django\template\__init__.py" in
encode_output
  757. return str(output)
File "c:\Python24\Lib\site-packages\django\utils\encoding.py" in
__str__
  31. return self.__unicode__().encode(settings.DEFAULT_CHARSET)
File "c:\Python24\Lib\site-packages\django\newforms\forms.py" in
__unicode__
  74. return self.as_table()
File "c:\Python24\Lib\site-packages\django\newforms\forms.py" in
as_table
  145. return self._html_output(u'%(label)s%(errors)s%
(field)s%(help_text)s', u'%s',
'', u'%s', False)
File "c:\Python24\Lib\site-packages\django\newforms\forms.py" in
_html_output
  130. output.append(normal_row % {'errors': bf_errors, 'label':
label, 'field': unicode(bf), 'help_text': help_text})
File "c:\Python24\Lib\site-packages\django\newforms\forms.py" in
__unicode__
  228. value = self.as_widget(self.field.widget)
File "c:\Python24\Lib\site-packages\django\newforms\forms.py" in
as_widget
  253. return widget.render(self.html_name, data, attrs=attrs)
File "c:\Python24\Lib\site-packages\django\newforms\extras\widgets.py"
in render
  42. select_html =
Select(choices=month_choices).render(self.month_field % name,
month_val)
File "c:\Python24\Lib\site-packages\django\newforms\widgets.py" in
render
  171. output.append(u'%s' %
(escape(option_value), selected_html,
escape(smart_unicode(option_label

  UnicodeDecodeError at /prod/add/
  'ascii' codec can't decode byte 0xc5 in position 6: ordinal not in
range(128)

Tried with both Django 0.96 & SVN (as of today April 11th).
DEFAULT_CHARSET='utf-8'

Thanks,

Robert


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



Re: sort values in a drop down SOLVED

2007-04-11 Thread Benedict Verheyen

Benedict Verheyen schreef:


> class ScoreAddManipulator(Score.AddManipulator):
> default = {}
> 
> def __init__(self):
> # Construct the fields and set the values in default
> Score.AddManipulator.__init__(self)
> ScoreAddManipulator.default["patient"]=[(patient.id,
> patient.name) for patient in Patient.objects.all()])
>   ...
> d = datetime.datetime.now()
> s = d.strftime("%d/%m/%Y")
> ScoreAddManipulator.default["c_date"]=s

With a few cups of coffee, it all goes better, doesn't it ? :)

I added this line to the add manipulator:

self.fields[0] = forms.SelectField(field_name="patient",
is_required=True, choices = patient_choices() )

Where patient_choices is a function:
def patient_choices():
patient_choices = [('','-')]
for patient in Patient.objects.all_sort_on_room():
room_nr = "-"
if ( patient.room ): room_nr = patient.room.number
to_add = (patient.id, patient.name + ' (' + room_nr + ')')
patient_choices.append(to_add)
return patient_choices

I do the same for the ChangeManipulator but i also have to set the id
to reflect the correct selection.

self.fields[0] = forms.SelectField(field_name="patient",
is_required=True, choices = patient_choices() )
self.default["patient"] = self.default["patient_id"]

This solved the issue for me.

Regards,
Benedict


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



Re: Integrating third parties script within django

2007-04-11 Thread [EMAIL PROTECTED]



On 11 avr, 07:33, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> If you are integrating a 3rd party library or script into a django (or
> ANY python) project, it needs to be available on the python
> interpreter's path.  It sounds like you are getting hung up on the
> mechanics of python's package/module rules.  I would suggest
> familiarizing yourself withhttp://docs.python.org/tut/node8.html-
> particularly the section titled "The Module Search Path".   In my
> opinion the documentation leaves out a few key points so I would also
> recommend reading section 4.1 
> here:http://docs.python.org/inst/search-path.html
>
> Put Django aside for a second, you should be able to fire up a python
> interpreter and type>> import 
>
> if you have set it up correctly the module will import successfully,
> if not you will receive an error.
>
> Hope that helps.

At least it makes sense for me for things I was not aware of. I
thought according to the wiki page that Django could make some
"introspection" to load any file present in the project in an easy
way.

I'm not fan of modifying the python path, so as flickr.py do not comme
with an installation process, I will put it somewhere in the python
path.

It's mentionned that python look in current directory but also in
python path. What should be the "current directory" for a django
project ? the app directory ? the root project's directory ?

I'll try these the evening, thanks for the answer !
Nicolas


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



Template context lost in parent template

2007-04-11 Thread Wolfram Kriesing

I have the standard setup, base.html and mytpl.html.
I have written a tag, that stores data into the context (inside the
render() method), now I try to read out this data in the base.html,
but they are not there.
Is the scope a different one?
Or is the execution order not mytpl.html and then base.html?

-- 
cu

Wolfram

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



Re: Simple python question

2007-04-11 Thread Grupo Django

Thank you!
What I'm doing is to load a model from a template.
I have in a template something like this:
{% block menu %}
{% block rss %}

I want to load "menu" and "rss", but I think that is too much work for
now, I have no idea how to implement it and I probably won't do it.
Thank you very much for your help.




On 11 abr, 00:07, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote:
> On Tue, 2007-04-10 at 18:03 -0500, Jeremy Dunck wrote:
> > On 4/10/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> > ...
> > > The key is that he wanted to use the string name of the class, not the
> > > class itself. Assuming that Foo is available (i.e., is local to the code
> > > you're running or has been imported), this should work:
>
> > > o = locals()['Foo']()
>
> > Oh.  In that case, you also want to make sure the string is trust-worthy.
>
> > I hope you're not creating a class instance from a request parameter. :)
>
> What he said! (I'm inclined to be so trusting...)


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