Re: Is there a way to limit the number of element in the template

2008-01-06 Thread Alexandre Forget
you are right ! it works now, thanks

django fresh from svn


On Jan 6, 2008 7:10 PM, Alex Koshelev <[EMAIL PROTECTED]> wrote:

>
> Note you must delete *all* spaces in filter expression
>
> part.forum.thread_set.all|slice:":5"
>
> And what is your django version?
>
> On 7 янв, 02:55, "Alexandre Forget" <[EMAIL PROTECTED]> wrote:
> > I tried with and without... no difference
> >
> > On Jan 6, 2008 6:32 PM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> > > Have you put a space between "all" and filter mark?
> >
> > > On 7 янв, 02:27, "Alexandre Forget" <[EMAIL PROTECTED]> wrote:
> > > > update: it doesn't work in the for loop.
> >
> > > > --
> > > > TemplateSyntaxError at /parts/8051/
> >
> > > > 'for' statements should use the format 'for x in y': for t in
> > > > part.forum.thread_set.all |slice: ":5"
> > > > --
> >
> > > > this is the offending line:
> > > >   {% for t in part.forum.thread_set.all |slice: ":5" %}
> >
> > > > any ideas ?
> >
> > --
> > Alexandre Forget
> > 514 523-4765
> >
> > http://embeddedcookbook.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: Is there a way to limit the number of element in the template

2008-01-06 Thread Alexandre Forget
I tried with and without... no difference

On Jan 6, 2008 6:32 PM, Alex Koshelev <[EMAIL PROTECTED]> wrote:

>
> Have you put a space between "all" and filter mark?
>
> On 7 янв, 02:27, "Alexandre Forget" <[EMAIL PROTECTED]> wrote:
> > update: it doesn't work in the for loop.
> >
> > --
> > TemplateSyntaxError at /parts/8051/
> >
> > 'for' statements should use the format 'for x in y': for t in
> > part.forum.thread_set.all |slice: ":5"
> > --
> >
> > this is the offending line:
> >   {% for t in part.forum.thread_set.all |slice: ":5" %}
> >
> > any ideas ?
> >
>


-- 
Alexandre Forget
514 523-4765

http://embeddedcookbook.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: Is there a way to limit the number of element in the template

2008-01-06 Thread Alexandre Forget
update: it doesn't work in the for loop.

--
TemplateSyntaxError at /parts/8051/

'for' statements should use the format 'for x in y': for t in
part.forum.thread_set.all |slice: ":5"
--

this is the offending line:
  {% for t in part.forum.thread_set.all |slice: ":5" %}

any ideas ?

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



Re: Is there a way to limit the number of element in the template

2008-01-06 Thread Alexandre Forget
On Jan 6, 2008 5:44 PM, Alex Koshelev <[EMAIL PROTECTED]> wrote:

>
> First of all, Part.objects.all()[:5] is still lazy. SQL query executes
> only when you try to iterate through items.
> And you can slice objects in template with "slice" filter
>
> {% for p in part.object.all|slice:":5" %}
>


Thanks, this is exactly what I was looking for.

Alexandre

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



Is there a way to limit the number of element in the template

2008-01-06 Thread Alexandre Forget
Hi,

I need to limit the number of elements I have to display on an index page.

Right now I do something like this in the template.

{% for p in part.object.all %}
...
{% endfor %}

Witch obliviously output all objects in the set.
In the view, I can do it this way:

Part.objects.all()[:5]

I would like to do this without doing the actual query in the view, am I
missing something ?

thanks

Alexandre Forget

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



shemas evolution

2007-09-22 Thread Alexandre Forget

I wonder what people are using *right now* to evolve their data ?

I'm using this:

# create a fixture with all data in the current db
python manage.py dumpdata --indent=4 > initial_data.json

# delete de database
rm db.sqlite

#  edit the model

# recreate db and reload data
manage syncdb --noinput

I know this is really rough... that's why I'm wondering if there any
better solution.


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: UnicodeEncodeError

2007-08-03 Thread Alexandre Forget

thanks the help

I am using a modified version of django-forum, replacing those __str__
with __unicode__ did the job

alex

On 8/1/07, Thomas Guettler <[EMAIL PROTECTED]> wrote:
>
> Am Mittwoch, 1. August 2007 04:23 schrieb Alexandre Forget:
> > Hi,
> >
> > I am stuck with this error, does someone know what it mean?
> > I am using django svn and sqlite.
> >
> > This error happen when I try to delete an object with the admin
> > interface but it delete fine with the shell.
> >
>
> Hi,
>
> I submitted a small patch to views/debug.py to show the characters
> before and after the wrong charachter. This helps you to find
> the place where the string comes from:
>
> http://code.djangoproject.com/attachment/ticket/5046/views_debug_unicodeerror_hint.diff
>
> Since my python code is in latin1 I get this message often.
> Be sure to use only unicode strings in your code:
>
> example:
>
> models.py
> ...
> foo=models.CharField(maxlength=6, choices=(
> ("umlaut", u"üöäßÜÖÄ"),
>
>  Thomas
>
> >
>

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



UnicodeEncodeError

2007-07-31 Thread Alexandre Forget

Hi,

I am stuck with this error, does someone know what it mean?
I am using django svn and sqlite.

This error happen when I try to delete an object with the admin
interface but it delete fine with the shell.

any help greatly appreciated

alex

Traceback (most recent call last):
File "/home/alex/project/django/myapp/django/core/handlers/base.py" in
get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/home/alex/project/django/myapp/django/contrib/admin/views/decorators.py"
in _checklogin
  55. return view_func(request, *args, **kwargs)
File "/home/alex/project/django/myapp/django/views/decorators/cache.py"
in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File "/home/alex/project/django/myapp/django/contrib/admin/views/main.py"
in delete_stage
  512. _get_deleted_objects(deleted_objects, perms_needed,
request.user, obj, opts, 1)
File "/home/alex/project/django/myapp/django/contrib/admin/views/main.py"
in _get_deleted_objects
  457. (force_unicode(capfirst(related.opts.verbose_name)),
related.opts.app_label, related.opts.object_name.lower(),
sub_obj._get_pk_val(), escape(sub_obj)), []])
File "/home/alex/project/django/myapp/django/utils/functional.py" in wrapper
  122. return func(*args, **kwargs)
File "/home/alex/project/django/myapp/django/utils/html.py" in escape
  30. return force_unicode(html).replace('&', '&').replace('<',
'<').replace('>', '>').replace('"', '"').replace("'",
''')
File "/home/alex/project/django/myapp/django/utils/encoding.py" in force_unicode
  40. s = unicode(str(s), encoding, errors)

  UnicodeEncodeError at /admin/parts/part/1/delete/
  'ascii' codec can't encode character u'\u2726' in position 15:
ordinal not in range(128)

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