Re: Getting properties of parent objects into a template

2006-08-13 Thread mediumgrade

Yes, that would be the relationship and that was actually the first
thing I tried. The template gets passed an "array" of "entry" objects.
Within the template, I loop through them printing the headline, portion
of the body, and the created date. With Author's as a foreign key, I
assumed you could do something like {{ entry.author.name }} but I get
nothing in my output when I do this. I assume that objects passed in a
template can't follow their foreign key relationships.

Sorry, I am still very new to both Django as well as Python. Forgive me
if I am not stating my problem clearly.


Ivan Sagalaev wrote:
> mediumgrade ÐÉÛÅÔ:
> > I have a simple blog app that I am working on. In this app, I have
> > ojects for  each entry as well as the author who wrote it. I wrote a
> > simple view which displays a list of all entrys made, but I want that
> > list to include the name of the author. Since the author's name is not
> > part of the entry, how do I access attributes from related objects
> > within a template?
>
> If I'm guessing correctly that relation is like this:
>
>  class Article(models.Model):
>author = models.ForeignKey(Author)
> 
> ... then {{ article.author.name }} should work.


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



Re: DateField(blank=True), null?

2006-08-13 Thread Bryan Chow

Hi Ray,

You can set null=True on your DateField to allow null values in the
database. Foe example:

thedate = models.DateField(null=True, blank=True)

Cheers,
Bryan


On 8/13/06, Rares Vernica <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a DateField with blank=True and after I complete and submit the
> form I get a Django error saying that DateField cannot be null?
>
> How can I set the DateField so that it can be empty, and eventually null
> in the DB?
>
> I don't like the idea of manually going and changing the DB schema.
>
> Thanks,
> Ray

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



Re: DateField(blank=True), null?

2006-08-13 Thread James Bennett

On 8/14/06, Rares Vernica <[EMAIL PROTECTED]> wrote:
> I have a DateField with blank=True and after I complete and submit the
> form I get a Django error saying that DateField cannot be null?

As the model documentation points out, you must also set 'null=True'
on the field to have the database accept NULL values; 'blank' is for
admin validation only, and has no effect on whether the database will
accept NULL.

The distinction is necessary to allow situations where a field can be
left blank via initial user input, but still requires that something
else fill it in before saving (for example, you might want to have a
field the user can fill in, but which will be filled with a default or
automatically-calculated value when left blank).

> I don't like the idea of manually going and changing the DB schema.

The column in the database will have been created with a NOT NULL
constraint; that constraint can only be removed by executing the
appropriate SQL statement for the database you're using.

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

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



DateField(blank=True), null?

2006-08-13 Thread Rares Vernica

Hi,

I have a DateField with blank=True and after I complete and submit the 
form I get a Django error saying that DateField cannot be null?

How can I set the DateField so that it can be empty, and eventually null 
in the DB?

I don't like the idea of manually going and changing the DB schema.

Thanks,
Ray


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



Re: Size of text field in admin

2006-08-13 Thread Bryan Chow

On 8/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Currently, in the admin interface, the size of a text field is
> defaulted at 50 for char vars and 10 for integer types.
>
> I would like to change this in the model and have it propegate through
> to the admin interface.  Is there a way to do this easily?

AFAIK this is currently not possible in admin without modifying the
Django source.

If you just want to alter the width of the text boxes in admin, you
can set the width using CSS. For example, you could place the
following code in templates/admin/base_site.html to override the width
of all text fields, as well as specify a different width for the
"title" field.

{% block extrastyle %}

input.vTextField { width: 200px; }
input#id_title { width: 100px; }

{% endblock %}

Hope this helps.

Bryan

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



Size of text field in admin

2006-08-13 Thread callwardt

Hi

Currently, in the admin interface, the size of a text field is
defaulted at 50 for char vars and 10 for integer types.

I would like to change this in the model and have it propegate through
to the admin interface.  Is there a way to do this easily?

Thanks in advanced.


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



Re: Simplifying template?

2006-08-13 Thread limodou

On 8/13/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 7/31/06, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> > I would actually be okay writing the function in the view code, if we
> > had a map filter.
> >
> > {{ s.teachers|map:list_func|join:";" }}
> >
> > Then add the following to the context:
> >
> > "list_func": lambda(x): x.userinfo.informal_name()
> >
> > How hard would that be to implement, and is it potentially useful
> > enough that it'd be worth it?
>
> One problem with that is that template filters can't be objects at the
> moment -- they can only be strings. So if we were to do this (which I
> don't really have an opinion on yet), it would have to wait until the
> template system were improved to accept objects as well as strings, as
> filter arguments.
>
> Adrian
>
If we can use an alternative way to do that:

{% for t in s.teachers %}
{{ t.userinfo.informal_name }}{{ ";" if not forloop.last }}
{% endfor %}

Here I put "if" expression in template variable syntax. I don't know
whether it can be simpler.
-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

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



custom manipulator - TextField or SelectField in RadioSelectField?

2006-08-13 Thread Chris Kelly

Hey all,

I am trying to create a series of radio buttons where you can select
one radio button, and next to the selection will be a Text Field, drop
box, or maybe both, for additional information related/ needed for the
current radio selection.

like so:

Radio | Label
(o) show all rows
() Limit to [text field] rows
() Limit to [text field] percent of rows

or, either line might have a select field instead of a text field,
e.g.:
() Limit to [select field] percent of rows

is it possible to put a text field/ select field into a choices section
of a radio list? Or would this be better served by manually retrieving
form values in a post call and parsing them individually (rather than
via a manipulator)?

thanks!

-C


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



Re: Simplifying template?

2006-08-13 Thread SmileyChris

Ah, I get it now. You're right - context isn't available to filters.

My more simplistic suggestion of {{
s.teachers|loop:"userinfo.informal_name"|join:"; " }}  should still
work however.


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



Re: Django 0.95 on Dreamhost

2006-08-13 Thread Jay Parlar

On 8/13/06, Apple <[EMAIL PROTECTED]> wrote:
>
> Hi has anyone tried running Django 0.95 on Dreamhost?  I only tried to
> setup a simple project following the dreamhost's wiki.  I am getting a
> string index out of range exception on common.py:

I don't see anything obviously wrong, but I don't have much time to
look right now. I will suggest though that you use Jeff Croft's guide
(http://www2.jeffcroft.com/2006/may/11/django-dreamhost/). It's what I
used, and I have a few sites running 0.95 on Dreamhost.

We could you some more info though, such as when you get that error.
Also, your various urls.py files would help.

Oh, and it's probably not a good idea to post your SECRET_KEY to the
public :) Maybe change it before you go live.

Jay P.

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



Re: Chaining filter & exclude weirdness in many-to-many relationships

2006-08-13 Thread Malcolm Tredinnick

On Sun, 2006-08-13 at 17:14 -0700, [EMAIL PROTECTED] wrote:
> I'm trying to get a queryset of all users in two particluar groups that
> *aren't* in a third particular group.

This same conversation is going on in another thread at the moment, so
let me explain the general case: any chained filter or exclude()
commands that involve the same column in the table ('groups' in your
case) are not going to work perfectly at the moment. Same goes for
joining Q() instances involving identical columns. So try out what you
hope might work, but check the SQL carefully before using it as an
aircraft navigation system or floatation device.

It's a bug. It's on the operating table. We expect the patient to make a
full recovery in the near future.

Regards,
Malcolm



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



Re: Shell not picking up db changes

2006-08-13 Thread Malcolm Tredinnick

On Sun, 2006-08-13 at 22:05 +, cyberco wrote:
> I may have cheered to early: what if I don't use 'import as', but
> 'site.app.models import *'? If I do 'reload(models)' the Django models
> are reloaded, and doing 'reload(site.app.models)' throws an exception
> saying 'site' does not exist...

That's standard Python behaviour. Reload() only works when you have just
imported the module, not when you have imported things from the module
into your current namespace (via "...import *" or "from foo import bar")

Regards,
Malcolm



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



Re: Beginner questions on writing views

2006-08-13 Thread Malcolm Tredinnick

On Sun, 2006-08-13 at 09:13 -0700, Karen Tracey wrote:
> I'm working through the tutorial, applying its lessons to my own
> database.  So for example where it covers writing a detail view for the
> Poll model, I think really I'm going to want a detail view for each of
> the models in my database, and they're all going to be the same except
> for the name of the model and the actual stuff that gets output, which
> will be controlled by the model-specific template.
> 
> So I come up with a url mapping that looks like this:
> 
> urlpatterns = patterns('kmt.crossword.views',
> (r'^(?P\w+)/(?P\d+)/$', 'detail'),
> )
> 
> and my views.py is very simple:
> 
> from django.db.models import get_model
> from django.shortcuts import render_to_response, get_object_or_404
> 
> def detail(request, model_name, id):
> model = get_model('crossword', model_name)
> instance = get_object_or_404(model, pk=id)
> return render_to_response(model_name + '_detail.html', {'instance':
> instance})
> 
> This works nicely, but I have a few niggling questions.  First I found
> that useful get_model function not in the documentation, but by looking
> around in the Django code.  Is this something I should be using, or is
> it really only intended for Django internal use?  If it's not something
> I should be using, where should I be looking to figure out how to
> accomplish the kind of thing it does for me?

I don't see a lot of problem with using that function if you really need
to. It exists to provide the functionality you are using it for to the
Django core.

> Second, it seems a bit inelegant to hardcode my own app name
> ('crossword') here.  Seems like there should be some way for my
> kmt.crossword.views code to figure out that its own app name is
> 'crossword', but how to do that is eluding me.

With that particular view setup, you could look at the __file__
attribute (every module has one -- try printing it out to see that it's
just a standard file path, so os.path.* can be used to work on it) and
work it out from there (go to the name aboves the 'views/' component).
In general, though, this is an impossible problem based on the
information the view has available to it. Since the view is just a
Python function, it could be located anywhere at all. Multiple
directories down, or in an entirely different part of your filesystem.
So either the view module has to know its position relative to your
application directory (the case at the start of this paragraph), or you
have to pass in the application name to the view somehow. Otherwise it
simply does not have enough information.

You might think "well, my views will always be under the app directory"
and they may well be in this case. However, that's not a universal
truth. For example, as Don pointed out, generic views are useful in some
cases and they live somewhere entirely different. Sometimes you will
write an app that only consists of views and uses models from other
applications (so they present a different outlook on the data). And so
on and so forth.

Regards,
Malcolm


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



Re: Problem of render context

2006-08-13 Thread Malcolm Tredinnick

On Sun, 2006-08-13 at 17:10 +, 一首诗 wrote:
> Actually, it's not the problem of encoding, I think.

Then you need to provide a more concrete example. Show a small example
of the input string (UTF-8 encoded) and the HTTP headers and bytes you
get in the response so that we can help you diagnose it.

> For example, if s is a string, the render() method should treate {{ s
> }} in the way print() does.  But now what I see on the page is
> something like you see in a interactive python console.

[...]
These are just different representations of the same string of bytes,
though. The results of repr(s) -- the last line of output you show -- is
exactly what the code is sending back to your browser and it is the
bytes that go into the UTF-8 string. It appears that your browser (or
whatever you are using to display the bad results you showed earlier) is
not interpreting those bytes as UTF-8 stream of bytes, which is why I
suspect the client is not receiving the right encoding.

It doesn't make sense to talk about sending the string back "as print
does", since it's the same stream of bytes that repr() displays, just
processed according to the rules of converting UTF-8 bytes into glyphs
from your chosen character set(s). That is something the browser should
be doing in your case.

However, something else is going wrong if your example represents real
output, too, because \x0f isn't the first character of any printable
UTF-8 sequence. So I'm not sure that 's' really is UTF-8 in your
example.

Regards,
Malcolm


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



Re: Chain filters on ManyToManyField

2006-08-13 Thread Malcolm Tredinnick

On Sun, 2006-08-13 at 21:23 +, cyberco wrote:
> Ai, really? I'm a n00b when it comes to SQL and the SQL statement of a
> chained filter (as listed by connection.queries) is about 8 (!) lines
> of SQL abacadabra.

There's a worked example here:
http://www.pointy-stick.com/blog/2006/06/14/custom-sql-django/ . Other
ways to solve the same problem have been pointed out on this before,
too.

> Sure there is no other way to solve this issue?

Not that I know of. But I may just not know enough.

>  Will
> the bug be fixed in the next release?

It's the current high priority item I'm working on (not that particular
bug, but the meta-problem that is causing those problems). "Soon" is all
I can predict.

Regards,
Malcolm


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



Chaining filter & exclude weirdness in many-to-many relationships

2006-08-13 Thread [EMAIL PROTECTED]

I'm trying to get a queryset of all users in two particluar groups that
*aren't* in a third particular group.
Here's what I tried*:

User.objects.filter(groups__in=(author_group,
guide_group)).exclude(groups=staff_group)

This is the SQL produced:
SELECT * FROM auth_user
LEFT OUTER JOIN auth_user_groups ON auth_user.id =
auth_user_groups.user_id
WHERE auth_user_groups.group_id IN (5,3) AND NOT
auth_user_groups.group_id = 1

The "AND NOT auth_user_groups.group_id = 1" clause has no effect on the
query.
What I want is something like:
SELECT auth_user.id, auth_user.username, auth_user_groups.group_id FROM
auth_user
LEFT OUTER JOIN auth_user_groups ON auth_user.id =
auth_user_groups.user_id
WHERE auth_user_groups.group_id IN (5,3)
AND auth_user.id NOT IN (
SELECT auth_user.id FROM auth_user
LEFT OUTER JOIN auth_user_groups ON auth_user.id =
auth_user_groups.user_id
WHERE auth_user_groups.group_id = 1)

Is there a solution for me that doesn't resort to raw SQL?
Thanks in advance for helping me earn my Django queryset black belt.

* There's currently a bug in Django which causes
User.objects.filter(groups__name="staff") to fail, so my workaround is
this:
staff_group = Group.objects.get(name='staff')
User.objects.filter(groups__name=staff_group)


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



Re: Compress images on upload?

2006-08-13 Thread Jay Parlar

On 8/13/06, Bryan Chow <[EMAIL PROTECTED]> wrote:
>
> Optional parameter for JPEG quality added :)
>
> http://www.verdjn.com/wiki/PhotoField

Beautiful, now it's worth my time ;-)

Seriously, thanks a lot.
Jay P.

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



Re: Compress images on upload?

2006-08-13 Thread Bryan Chow

Optional parameter for JPEG quality added :)

http://www.verdjn.com/wiki/PhotoField


On 8/12/06, Bryan Chow <[EMAIL PROTECTED]> wrote:
> Hi Jay,
>
> Here's a custom field that automatically resizes the uploaded image
> using PIL. You should be able to modify save_file() to adjust the JPEG
> compression level on pil_obj.save()
>
> In fact we might add this as an optional parameter in the next version.
>
> http://www.verdjn.com/wiki/PhotoField
>
> Bryan

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



Re: Simplifying template?

2006-08-13 Thread Todd O'Bryan


On Aug 13, 2006, at 6:01 PM, SmileyChris wrote:

>
>
> Adrian Holovaty wrote:
>> On 7/31/06, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
>>> I would actually be okay writing the function in the view code,  
>>> if we
>>> had a map filter.
>>>
>>> {{ s.teachers|map:list_func|join:";" }}
>>>
>>> Then add the following to the context:
>>>
>>> "list_func": lambda(x): x.userinfo.informal_name()
>>>
>>> How hard would that be to implement, and is it potentially useful
>>> enough that it'd be worth it?
>>
>> One problem with that is that template filters can't be objects at  
>> the
>> moment -- they can only be strings.
>
> I like Tod's solution and I don't see the problem, maybe I'm missing
> something:
>
> We have a function being passed to context -- I don't see why that
> would be a problem since the context can contain objects.
>
> And we have a template filter named |map which takes a list, does
> something to it, and returns a list -- just like |slice does now.

The problem Adrian mentions is that slice takes a string (such as  
"1:7" or ":2"), whereas map would have to take an argument and look  
it up in the context. I'm not even sure if the context is available  
when the filter argument would have to be resolved.

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



Re: Shell not picking up db changes

2006-08-13 Thread cyberco

I may have cheered to early: what if I don't use 'import as', but
'site.app.models import *'? If I do 'reload(models)' the Django models
are reloaded, and doing 'reload(site.app.models)' throws an exception
saying 'site' does not exist...


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



Re: Simplifying template?

2006-08-13 Thread SmileyChris


Adrian Holovaty wrote:
> On 7/31/06, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> > I would actually be okay writing the function in the view code, if we
> > had a map filter.
> >
> > {{ s.teachers|map:list_func|join:";" }}
> >
> > Then add the following to the context:
> >
> > "list_func": lambda(x): x.userinfo.informal_name()
> >
> > How hard would that be to implement, and is it potentially useful
> > enough that it'd be worth it?
>
> One problem with that is that template filters can't be objects at the
> moment -- they can only be strings.

I like Tod's solution and I don't see the problem, maybe I'm missing
something:

We have a function being passed to context -- I don't see why that
would be a problem since the context can contain objects.

And we have a template filter named |map which takes a list, does
something to it, and returns a list -- just like |slice does now.


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



Re: Shell not picking up db changes

2006-08-13 Thread cyberco

Ah! Thanks for the tip! I totally forgot about Python's reload method
because my mind was on a 'db-track' all the time.


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



Django 0.95 on Dreamhost

2006-08-13 Thread Apple

Hi has anyone tried running Django 0.95 on Dreamhost?  I only tried to
setup a simple project following the dreamhost's wiki.  I am getting a
string index out of range exception on common.py:

--   error messages --

Re: Shell not picking up db changes

2006-08-13 Thread Pedro Lima

Module reload works as expected

>>> import uatki.blogdata.models as m
>>> e = m.Blog.objects.get(id=1)
>>> e.test()
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'Blog' object has no attribute 'test'

[ changed the model to have a test method ]

>>> reload(m)

>>> e = m.Blog.objects.get(id=1)
>>> e.test()
'test ok'


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



Re: what features do you like to see in a rss reader

2006-08-13 Thread [EMAIL PROTECTED]

René Pijlman wrote:
> Self-learning relevance ranking of individual posts. Bayesian, or
> otherwise. Information overload is problem #1 for weblogs/rss.
>

I agree - it would be very nice to have something like that, but I am
not sure if a was thinking about tnat kind of features :)

Anyway, if somebody will start working on that I would suggest to
examine nice tool for AI called Orange (written in Python)

http://www.ailab.si/orange/

IMHO it would be quite simple to implement textmining or some Bayesian
procedures using that.


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



Re: Chain filters on ManyToManyField

2006-08-13 Thread cyberco

Ai, really? I'm a n00b when it comes to SQL and the SQL statement of a
chained filter (as listed by connection.queries) is about 8 (!) lines
of SQL abacadabra. Sure there is no other way to solve this issue? Will
the bug be fixed in the next release?


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



Re: Getting properties of parent objects into a template

2006-08-13 Thread Ivan Sagalaev

mediumgrade ÐÉÛÅÔ:
> I have a simple blog app that I am working on. In this app, I have
> ojects for  each entry as well as the author who wrote it. I wrote a
> simple view which displays a list of all entrys made, but I want that
> list to include the name of the author. Since the author's name is not
> part of the entry, how do I access attributes from related objects
> within a template?

If I'm guessing correctly that relation is like this:

 class Article(models.Model):
   author = models.ForeignKey(Author)

... then {{ article.author.name }} should work.

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



Re: Getting properties of parent objects into a template

2006-08-13 Thread Bryan Chow

Hi David,

Not sure what you mean by "parent object". If author is a ForeignKey
in your blog_entry model, and author has a field called full_name,
then you should be able to use {{ blog_entry.author.full_name }}.

Otherwise, you could just place author in the context that's passed to
your templates.

blog_entry = ... # get blog entry
author = ... # get author
t = loader.get_template('blog/detail.html')
c = Context({
'blog_entry': blog_entry,
'author': author,
})
return HttpResponse(t.render(c))

Hope this helps.

Bryan


On 8/13/06, mediumgrade <[EMAIL PROTECTED]> wrote:
> I have a simple blog app that I am working on. In this app, I have
> ojects for  each entry as well as the author who wrote it. I wrote a
> simple view which displays a list of all entrys made, but I want that
> list to include the name of the author. Since the author's name is not
> part of the entry, how do I access attributes from related objects
> within a template?

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



edit_inline behavior

2006-08-13 Thread John

Howdy --

edit_inline seems to be doing something funky when I use it through
update_object generic view.  I've got a model that looks something like
this:

class StationEvent(models.Model):
date = models.DateTimeField()
description = models.CharField(maxlength = 150)
class Admin:
pass

class StationEventParticipant(models.Model):
event = models.ForeignKey(StationEvent,edit_inline=models.TABULAR)
participant = models.ForeignKey(Member, core=True)

The relevant part of the template is:
{% for p in form.stationeventparticipant %}


Participant: 


{{ p.participant }}


{% for e in p.errors %} {{ e }} {% endfor %}


{% endfor %}

At first glance it appears to be working -- the update_oject view for
StationEvent lists its fields and a field for a participant.  But when
it's actually saved, what happens is that for each participant listed,
it will create a new StationEventParticipant object whether or not it
already existed.  So every time I come back after saving the list of
participants doubles!

All of this machinery works fine in the django dupplied admin
interface, so I'm guessing it's something I'm doing wrong.  Any help
would be awesome!  Apologies if this is a common issue, but a search
through the mailing list doesn't indicate anyone has had this problem.

-- John


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



Shell not picking up db changes

2006-08-13 Thread cyberco

Using the ipython started from manage.py I noticed that changes to the
db are not automatically picked up (added values for instance). I have
to restart the shell to pick  them up, which also means I have to
reimport everything and I loose my shell history.

Is there a way to pick up the changes without restarting the shell?


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



Getting properties of parent objects into a template

2006-08-13 Thread mediumgrade

I have a simple blog app that I am working on. In this app, I have
ojects for  each entry as well as the author who wrote it. I wrote a
simple view which displays a list of all entrys made, but I want that
list to include the name of the author. Since the author's name is not
part of the entry, how do I access attributes from related objects
within a template?


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



cache anonymous error with request.user ?

2006-08-13 Thread dummy

Hi,

has anybody seen the following traceback:

Traceback (most recent call last):

  File 
"/usr/local/lib/python2.4/site-packages/django/core/servers/basehttp.py", line 
272, in run
self.result = application(self.environ, self.start_response)

  File 
"/usr/local/lib/python2.4/site-packages/django/core/servers/basehttp.py", line 
611, in __call__
return self.application(environ, start_response)

  File "/usr/local/lib/python2.4/site-packages/django/core/handlers/wsgi.py", 
line 148, in __call__
response = self.get_response(request.path, request)

  File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py", 
line 59, in get_response
response = middleware_method(request)

  File "/usr/local/lib/python2.4/site-packages/django/middleware/cache.py", 
line 48, in process_request
if self.cache_anonymous_only and request.user.is_authenticated():

AttributeError: 'WSGIRequest' object has no attribute 'user'


This are my Cache-settings:


CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
CACHE_MIDDLEWARE_SECONDS = 600
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True


MIDDLEWARE_CLASSES = (
'django.middleware.cache.CacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)

With CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False the error goes away.

Regards,
Dirk

-- 


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

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



Re: models that reference each other through foreign key

2006-08-13 Thread Bryan Murdock
On 8/12/06, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
>
> On 12-Aug-06, at 3:45 PM, Maciej Bliziñski wrote:
>
> >> committee = models.ForeignKey( 'Committee' )
> >
> > You shouldn't use the string argument (I mean, I never do that). And
> > what if one person is in two committees?
>
> since the class 'Committee' is not yet defined, it wont work without
> the ''

Exactly.  I found a relevant example here:

http://www.djangoproject.com/documentation/models/mutually_referential/

However, this doesn't still gives the same error in the admin.  I have
filed a ticket for this bug:

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

Bryan
>
> --
>
> regards
> kg
> http://lawgon.livejournal.com
> http://nrcfosshelpline.in/web/
>
>
>
> >
>

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



Re: Beginner questions on writing views

2006-08-13 Thread Karen Tracey

At 12:54 PM 8/13/2006, you wrote:
>You might want to look at generic views. When you write "my views.py
>is very simple", that's a cue that a generic view is a good idea.

Ah, there it is right in the next section of the tutorial -- in fact 
from a quick glance they seem to use the exact same naming convention 
for templates that I came up with.  I just hadn't gotten that far yet 
because in the tutorial doing something with a form came first and I 
didn't want to get involved with forms before trying to get some 
basic views working.  Thanks for the pointer!

Karen


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



Re: Case sensitivity with different database backends

2006-08-13 Thread Don Arbow

On Aug 13, 2006, at 9:57 AM, Jon Atkinson wrote:
> I've noticed that my application changes case sensitivity in queries
> depending on whether it is using MySQL or sqlite as the database
> backend
>
> ...
> If there a recommended way to deal with this? I want to avoid forcing
> a certain scheme on the users (i.e., they can type the name in all
> lowercase, uppercase or mixed, it doesn't matter).


By default, MySQL searches are case insensitive. So if you want all  
queries, regardless of backend, to search case insensitively, use this:

user = User.objects.get(username__iexact=person)

Don



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



Re: Problem of render context

2006-08-13 Thread 一首诗

Actually, it's not the problem of encoding, I think.

For example, if s is a string, the render() method should treate {{ s
}} in the way print() does.  But now what I see on the page is
something like you see in a interactive python console.

>>> print s
XXX   #Some text
>>> s
'\x0f\xde' #this is what I see.


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



Case sensitivity with different database backends

2006-08-13 Thread Jon Atkinson

Hi,

I've noticed that my application changes case sensitivity in queries
depending on whether it is using MySQL or sqlite as the database
backend

The simplest test case is as follows:

My database contains a user record, in which the username is = "jon"

My urls.py is simply as follows:

(r'^/?(?P\w+)/$', 'abnew.planetx.views.user'),

My corresponding view code to retrieve this user is like this:

def user(request, person):
# Let the logger know where we are.
logging.info("Rendering person " + person)
user = User.objects.get(username=person)


Now, if I point my browser at localhost:8000/jon, or
localhost:8000/Jon when using MySQL, the query works correctly.
However, when using sqlite the second query will not work (as the
first character is upper case, and hence different from what is in the
database).

If there a recommended way to deal with this? I want to avoid forcing
a certain scheme on the users (i.e., they can type the name in all
lowercase, uppercase or mixed, it doesn't matter).

Thanks,

--Jon

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



Re: Beginner questions on writing views

2006-08-13 Thread Don Arbow

On Aug 13, 2006, at 9:13 AM, Karen Tracey wrote:
>
> I'm working through the tutorial, applying its lessons to my own
> database.  So for example where it covers writing a detail view for  
> the
> Poll model, I think really I'm going to want a detail view for each of
> the models in my database, and they're all going to be the same except
> for the name of the model and the actual stuff that gets output, which
> will be controlled by the model-specific template.
>
> So I come up with a url mapping that looks like this:
>
> urlpatterns = patterns('kmt.crossword.views',
> (r'^(?P\w+)/(?P\d+)/$', 'detail'),
> )
>
> and my views.py is very simple:



You might want to look at generic views. When you write "my views.py  
is very simple", that's a cue that a generic view is a good idea.  
With a generic view, you can code most of the info in the urls.py  
file and eliminate the views.py altogether. When I first came across  
generic views, I passed over them thinking I wanted to control all of  
my views. Then after coding numerous "simple" views, you start to  
wish that there was an easier way - generic views are the answer to  
repetitive coding.  There are generic views for many mundane tasks.

As for the get_model thing, I don't have a good idea as to how to  
deal with that. I am usually not too concerned with decoupling my  
templates from my views, so hard coding them is not really a burden.

Don


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



Beginner questions on writing views

2006-08-13 Thread Karen Tracey

I'm working through the tutorial, applying its lessons to my own
database.  So for example where it covers writing a detail view for the
Poll model, I think really I'm going to want a detail view for each of
the models in my database, and they're all going to be the same except
for the name of the model and the actual stuff that gets output, which
will be controlled by the model-specific template.

So I come up with a url mapping that looks like this:

urlpatterns = patterns('kmt.crossword.views',
(r'^(?P\w+)/(?P\d+)/$', 'detail'),
)

and my views.py is very simple:

from django.db.models import get_model
from django.shortcuts import render_to_response, get_object_or_404

def detail(request, model_name, id):
model = get_model('crossword', model_name)
instance = get_object_or_404(model, pk=id)
return render_to_response(model_name + '_detail.html', {'instance':
instance})

This works nicely, but I have a few niggling questions.  First I found
that useful get_model function not in the documentation, but by looking
around in the Django code.  Is this something I should be using, or is
it really only intended for Django internal use?  If it's not something
I should be using, where should I be looking to figure out how to
accomplish the kind of thing it does for me?

Second, it seems a bit inelegant to hardcode my own app name
('crossword') here.  Seems like there should be some way for my
kmt.crossword.views code to figure out that its own app name is
'crossword', but how to do that is eluding me.  I'm not quite sure I'm
going to stick with that name so I'd like to minimize the places I have
it hard-coded.

(Finally I know I am ignoring some error cases at the momemt, like if a
url with a non-existant model name comes in.  I know I have to deal
with that but right now I'm concentrating on the model names that do
exist.)

Thanks for any feedback -- I'm a complete Python and Django novice so
welcome any and all suggestions as to how I should be approaching this
in the proper manner.

Karen


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



Re: Django Blog software

2006-08-13 Thread Pedro Lima

For a more complete blog application I suggest checking limodou's
woodlog

http://www.djangocn.org/help/#does-woodlog-is-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
-~--~~~~--~~--~--~---



Re: Django not working with FCGI

2006-08-13 Thread cypher543

It's an odd error. I requested that my host install it for me, and they
did. So the error went a way, but it comes back later. Then it goes
away again. Just refresh the page to get the IndexError.


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



Re: Django Blog software

2006-08-13 Thread [EMAIL PROTECTED]

Say it's GPL :)
I've used "metrohacker" template which can be found on oswd.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
-~--~~~~--~~--~--~---



Re: Re: Re: Django Blog software

2006-08-13 Thread Jon Atkinson

Thank you both for the replies.

Riklaunim: Have you chosen a license for miniblog? Is it okay for me
to make some changes and re-release it?

--Jon

> On 13/08/06, David Larlet <[EMAIL PROTECTED]> wrote:
> >
> > 2006/8/13, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> > >
> > > Hi,
> > >
> > > I've been playing with Django for a few weeks, and I've been looking
> > > for some blog software which I can use for my blog and also play with
> > > extending to help me learn a little more about Django. I searched the
> > > Django wiki, and does as many Google queries as I can think of, but I
> > > can't find anything but references to people homebrewing their own
> > > blogging system.
> > >
> > > I realise that writing a blogging system in Django wouldn't take much
> > > work, but I was just wondering if there was anything already out there.
> > > Any ideas?
> > >
> >
> > You can check the Ross one:
> > http://www.rossp.org/blog/2006/jun/08/django-blog-redux/
> > or directly browse the source code of the djangoproject site:
> > http://code.djangoproject.com/browser/djangoproject.com. Both are
> > interesting to learn Django. If there is no generic blog app it's
> > because Django is not oriented end-user but developer and every
> > developer needs his unique blog ;-). BTW, it's really easy to make
> > your own.
> >
> > Regards,
> > David
> >
> > > >
> >
>

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



Re: session management

2006-08-13 Thread Jan Claeys

Op do, 10-08-2006 te 09:15 +, schreef uselpa:
> Unless you check that the IP from which the request is coming is the
> same IP from which the initial request came. 

Which breaks if the user is using a pool of proxy servers...


-- 
Jan Claeys


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



Re: Chain filters on ManyToManyField

2006-08-13 Thread Malcolm Tredinnick

On Sun, 2006-08-13 at 12:31 +, cyberco wrote:
> Having:
> ___
> 
> class Pizza(models.Model):
> name = models.TextField()
> toppings = models.ManyToManyField(Topping)
> 
> class Topping(models.Model):
> name = models.TextField()
> ___
> 
> ...and for instance having toppings 'tomato' and 'cheese', how do I
> select all pizza's with BOTH toppings? I would say by using a filter
> chain, such as:
> 
> ___
> 
> Pizza.objects.filter(topping=topping_tomato).filter(topping=topping_cheese)
> 
> (where topping_tomato and topping_cheese are topping instances.
> ___
> 
> ...but although each individual filter returns a result the chain
> returns an empty list.

This is a known bug. We're working on it. For now, you have to write
some custom SQL.

Regards,
Malcolm



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



Re: Problem of render context

2006-08-13 Thread Malcolm Tredinnick

On Sun, 2006-08-13 at 12:33 +, 一首诗 wrote:
> When use something like this in a template
> 
>  {{ message }} X
> 
> and render it in this way:
> 
> c = Context({'message':s}) # s is an string encoded in utf-8
> Response(template.render(c))
> 
> What I got is:
> 
>  '\x??\x??..\x??\x??' 
> 
> What's the problem??

I would guess that the character encoding on the HTTP response is not
set to UTF-8. Have a look at the HTTP headers that are being returned.
The template substition (the render() call) should substitute in the
UTF-8 string without complaint.

Regards,
Malcolm



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



Re: Compress images on upload?

2006-08-13 Thread Nebojša Đorđević

On 12 Aug 2006, at 06:58, Jay Parlar wrote:


And just to note, I tried doing compression with PIL in my model's
save() method. The problem is that files aren't written to disk until
*after* the save() method is complete.



You can look at http://trac.studioquattro.biz/djangoutils/wiki/ 
Thumbnail.


---
Nebojša Đorđević - nesh
Studio Quattro - Niš - Serbia
http://studioquattro.biz/ |  http://trac.studioquattro.biz/djangoutils/
Registered Linux User 282159 [http://counter.li.org]

What is the sound of one backpack EMP weapon discharging? -- Joe  
Thompson

"Clickety-click" -- Charles Cazabon




PGP.sig
Description: This is a digitally signed message part


Problem of render context

2006-08-13 Thread 一首诗

When use something like this in a template

 {{ message }} X

and render it in this way:

c = Context({'message':s}) # s is an string encoded in utf-8
Response(template.render(c))

What I got is:

 '\x??\x??..\x??\x??' 

What's the problem??


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



Chain filters on ManyToManyField

2006-08-13 Thread cyberco

Having:
___

class Pizza(models.Model):
name = models.TextField()
toppings = models.ManyToManyField(Topping)

class Topping(models.Model):
name = models.TextField()
___

...and for instance having toppings 'tomato' and 'cheese', how do I
select all pizza's with BOTH toppings? I would say by using a filter
chain, such as:

___

Pizza.objects.filter(topping=topping_tomato).filter(topping=topping_cheese)

(where topping_tomato and topping_cheese are topping instances.
___

...but although each individual filter returns a result the chain
returns an empty list.


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



Re: Django Blog software

2006-08-13 Thread David Larlet

2006/8/13, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> Hi,
>
> I've been playing with Django for a few weeks, and I've been looking
> for some blog software which I can use for my blog and also play with
> extending to help me learn a little more about Django. I searched the
> Django wiki, and does as many Google queries as I can think of, but I
> can't find anything but references to people homebrewing their own
> blogging system.
>
> I realise that writing a blogging system in Django wouldn't take much
> work, but I was just wondering if there was anything already out there.
> Any ideas?
>

You can check the Ross one:
http://www.rossp.org/blog/2006/jun/08/django-blog-redux/
or directly browse the source code of the djangoproject site:
http://code.djangoproject.com/browser/djangoproject.com. Both are
interesting to learn Django. If there is no generic blog app it's
because Django is not oriented end-user but developer and every
developer needs his unique blog ;-). BTW, it's really easy to make
your own.

Regards,
David

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



Re: django + lighttpd on FreeBSD, possible CACHE_BACKEND problem?

2006-08-13 Thread Wiktor Grębla

Wiktor Grębla napisał(a):
> I was wondering, is there any way to  set a cookie valid for the 
> current session only, without setting global  
> SESSION_EXPIRE_AT_BROWSER_CLOSE?
I should RTFM more (BTW, thanks for the great documentation):
#v+
from django.contrib.sessions.models import Session

response = HttpResponseRedirect('/main/')
if not request.COOKIES.has_key('nuqkie'):
skey = Session.objects.get_new_session_key()
response.set_cookie('nuqkie', skey, max_age=None)
return response   # we need session id
   # and it shows 
after reloading

ecname = request.COOKIES['nuqkie'] + '_entries'
icname = request.COOKIES['nuqkie'] + '_images'
#v-
No need to set SESSION_EXPIRE_AT_BROWSER_CLOSE.

Everyday I like Django more. I only need to stop replying to my own 
e-mails :).

Cheers,
W.

-- 
Talkers are no good doers.
http://greblus.go.pl


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



Re: Django Blog software

2006-08-13 Thread [EMAIL PROTECTED]

there is on the mailing list my "miniblog"
http://groups.google.com/group/django-users/browse_thread/thread/d8ae2e3dc533e214/75d2281e490f1d83?lnk=gst&q=miniblog&rnum=1#75d2281e490f1d83

It isn't feature compleate but it has news + comments ;)


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



Re: Frameworks, Documentation and the Joy of Django

2006-08-13 Thread David Larlet

2006/8/13, jws <[EMAIL PROTECTED]>:
>
[snip]
>
> Given the recent security problems with Rails, it's clear that the RoR
> community is not infallible. Why have they then received so much praise
> and admiration? It's not the technology, it's the narrative.

37signals is the best Buzz2.0 company you know :-).

>
> The Rails community hit this one out of the park with their
> screencasts. When evaluating frameworks, you want to get a feel for how
> it works in broad terms. This is not the same as 'well-documented'.
> Documentation tells you how product features work, a narrative tells
> you how use the product. A tutorial should never tell me to refer to
> the documentation of another project. Zope is well-documented, but try
> explaining it to someone who's never used it before. Likewise, A wiki
> is great for reference material, but it's no replacement for a
> step-by-step walkthrough of actually doing work in the product. The
> point is not that you can create a blog or wiki in 15 minutes,
>
> It's that you can understand _how_ to_ in 15 minutes!

Just a  testimony, I have to learn symfony php framework (django rox
but my boss no...) recently and I'm really surprised by the quality of
the documentation. Have a look at:
http://www.symfony-project.com/content/documentation.html

It's really clear: you have tutorials on the top and documentation at
the bottom. I think it's interesting to have two kind of tutorials for
Django too:
* a quick one for a first overview.
* a second one for a real site, everybody knows that a real site can't
be done in 15 minutes!

For the moment, polls app is great but not as fast as "create a blog
in 5 minutes" (and with generic views it's possible to do that). In
this case, the user doesn't understand exactly what happens but he is
really impressed and want to know more about this wonderful framework.
Next step is the real site one which explain exactly what happens and
Django mechanisms. This one can be detailed and follow a kind of time
line to reflect the "reality" of the tutorial.

Just my 0.2cts
David

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



Re: what features do you like to see in a rss reader

2006-08-13 Thread Ian Holsman
On 13/08/2006, at 7:38 PM, René Pijlman wrote:a wrote: i m developing a feedreader/web desktop using djangoi m looking for feature suggesstions Self-learning relevance ranking of individual posts. Bayesian, or otherwise. Information overload is problem #1 for weblogs/rss.i've started doing something similar to what you suggested a while backon http://vc-chat.com. nothing as sophisticated as bayes (yet), just popularityand 1-5 ratings.http://vc-chat.com/aggy/popular/andhttp://vc-chat.com/aggy/rating/d/7/for example.bayes is on the list of things to do, but until the reader base multiplies by 10x I don'tthink it will be worth it, and the rating is hard as it requires people to re-vist the site *after* they have left, which most won't.the popularity code is open source and available here: http://svn.zyons.python-hosting.com/trunk/zilbo/common/counter/regardsIan-- Renéhttp://www.applinet.nl  --Ian Holsman[EMAIL PROTECTED]http://med-chatter.com/ it's about the medicine 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django users" group.  To post to this group, send email to django-users@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



Django Blog software

2006-08-13 Thread [EMAIL PROTECTED]

Hi,

I've been playing with Django for a few weeks, and I've been looking
for some blog software which I can use for my blog and also play with
extending to help me learn a little more about Django. I searched the
Django wiki, and does as many Google queries as I can think of, but I
can't find anything but references to people homebrewing their own
blogging system.

I realise that writing a blogging system in Django wouldn't take much
work, but I was just wondering if there was anything already out there.
Any ideas?

--Jon


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



Re: what features do you like to see in a rss reader

2006-08-13 Thread René Pijlman

a wrote:
> i m developing a feedreader/web desktop using django
> 
> i m looking for feature suggesstions

Self-learning relevance ranking of individual posts. Bayesian, or 
otherwise. Information overload is problem #1 for weblogs/rss.

-- 
René
http://www.applinet.nl

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



Re: rewriting urls

2006-08-13 Thread Malcolm Tredinnick

On Sun, 2006-08-13 at 05:59 +, a wrote:
> http://localhost/todo
> 
> i want to rewrite this automatically as
> 
> http://localhost/todo/
> 
> is there a easy way to do this

See
http://www.djangoproject.com/documentation/middleware/#django-middleware-common-commonmiddleware

Regards,
Malcolm



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



Re: rewriting urls

2006-08-13 Thread Matt McDonald

And in a more generic sense the APPEND_SLASH setting of the  
CommonMiddleware may be what you are looking for.

http://www.djangoproject.com/documentation/middleware/#django- 
middleware-common-commonmiddleware

On 13/08/2006, at 5:17 PM, Ivan Sagalaev wrote:

>
> a wrote:
>> http://localhost/todo
>>
>> i want to rewrite this automatically as
>>
>> http://localhost/todo/
>>
>> is there a easy way to do this
>
> Yep.
>
> http://www.djangoproject.com/documentation/generic_views/#django- 
> views-generic-simple-redirect-to
>
> >


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



what features do you like to see in a rss reader

2006-08-13 Thread a

dear django users
i m developing a feedreader/web desktop using django

i m looking for feature suggesstions

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



suggestions for rss reader

2006-08-13 Thread a

keep a list of read and unread items

hi guys
i m building an rss reader and i want you suggestions for datastructure
for keeping read and unread list for each use
i m assuming it will be very sparse
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
-~--~~~~--~~--~--~---



Re: How to make delete() more clever?

2006-08-13 Thread 一首诗

First I should thank  Ivan  for your help.  But I think Malcolm figured
out what I really want.

Maybe django should catch Exception when calling a model's save /
delete method.


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



Re: rewriting urls

2006-08-13 Thread Ivan Sagalaev

a wrote:
> http://localhost/todo
> 
> i want to rewrite this automatically as
> 
> http://localhost/todo/
> 
> is there a easy way to do this

Yep.

http://www.djangoproject.com/documentation/generic_views/#django-views-generic-simple-redirect-to

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



Re: Converting characteres non-ASCII in the templates

2006-08-13 Thread Ivan Sagalaev

GinTon wrote:
> To convert the names to lower or UPPER case in the templates is used {{
> foo.name|lower }} and {{ foo.name|upper }}
> 
> But is possible convert characters non-ASCII? Is there any of use
> foo.name.decode('utf-8').upper()  in the templates?

There is a patch fixing string filters to do this sort of thing properly 
in ticket http://code.djangoproject.com/ticket/924 (use the latest which 
I just have updated to the current trunk: 
http://code.djangoproject.com/attachment/ticket/924/924.5.diff)



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