Giter Site home page Giter Site logo

Comments (9)

coleifer avatar coleifer commented on August 16, 2024

What version of django-relationships are you using? @paltman posted #21 which I merged but did not push to pypi. If you're using django-relationships 0.3.0 please try pulling from pypi again as I've just pushed 0.3.1

from django-relationships.

foxmask avatar foxmask commented on August 16, 2024

i check and keep you inform

from django-relationships.

foxmask avatar foxmask commented on August 16, 2024

Now, this is working great but only if I dont modify the object_list.
If I try to reduce the object list in my view with

Histo.objects.all().order_by('-date_created')[:5] 

then I have an error

AssertionError at /

Cannot filter a query once a slice has been taken.

Request Method:     GET
Request URL:    http://localhost:8000/
Django Version:     1.4.1
Exception Type:     AssertionError
Exception Value:    

Cannot filter a query once a slice has been taken.

Exception Location:     /home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages/Django-1.4.1-py2.6.egg/django/db/models/query.py in _filter_or_exclude, line 633
Python Executable:  /home/foxmask/Django-VirtualEnv/tglr/tglr/../bin/python
Python Version:     2.6.6
Python Path:    

['/home/foxmask/Django-VirtualEnv/tglr/tglr',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages/pip-1.1-py2.6.egg',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages/Django-1.4.1-py2.6.egg',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages/ipython-0.13-py2.6.egg',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages/PyMySQL-0.5-py2.6.egg',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages/django_registration-0.8-py2.6.egg',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages/django_profiles-0.2-py2.6.egg',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages/django_debug_toolbar-0.9.4-py2.6.egg',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/plat-linux2',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/lib-tk',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/lib-old',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/lib-dynload',
 '/usr/lib/python2.6',
 '/usr/lib/python2.6/plat-linux2',
 '/usr/lib/python2.6/lib-tk',
 '/usr/lib64/python2.6/lib-tk',
 '/home/foxmask/Django-VirtualEnv/tglr/lib/python2.6/site-packages']

Server time:    mar, 4 Sep 2012 18:21:27 +0200

Do I have to open another ticket ? Or it's the "normal" usage of the application ?

from django-relationships.

coleifer avatar coleifer commented on August 16, 2024

Ahh...interesting. Do you mind pasting a bit more code? What is Histo?

from django-relationships.

foxmask avatar foxmask commented on August 16, 2024

histo is a model

class Histo(models.Model):    
    text = models.TextField()
    date_created = models.DateTimeField(auto_now_add=True)
    user = models.ForeignKey(User)

from django-relationships.

coleifer avatar coleifer commented on August 16, 2024

I'm not clear how this pertains to django-relationships, could you clarify?

from django-relationships.

foxmask avatar foxmask commented on August 16, 2024

Hmm, If i dont use django-relationships I have no problem with my view where I do

Histo.objects.all().order_by('-date_created')[:5] 

Once I put this in my template

{% for histo in latest_histo_list|unblocked_content:user %}
...

I meet the error above

I hope I'm clearer.;)

from django-relationships.

coleifer avatar coleifer commented on August 16, 2024

Ahh thanks, this is what i was interested in. The problem is you're applying a limit to your query before you pass it into the templatetag, which will apply additional filters.

To solve this:

view:

Histo.objects.all().order_by('-date_created')


template:

{% for histo in latest_histo_list|unblocked_content:user|slice:":5" %}
    ...

from django-relationships.

foxmask avatar foxmask commented on August 16, 2024

perfect ! thank you

from django-relationships.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.