The method all() in overrided models.Manager doesn't works as expected

7 views
Skip to first unread message

Shuge Lee

unread,
Dec 30, 2012, 9:52:12 PM12/30/12
to django...@googlegroups.com

I'm writing a simple CMS, it stores page file data on local file system instead of SQL server.

I do overrides the model Page's Manager, but it not works as expected, problems

  • PageManager.all(it calls PageQuerySet?) doesn't works
  • I can create Page object in Admin, but can't view it or delete it

Source code is here https://github.com/shuge/mcms/blob/master/pages/models.py

I have read Django Manager docs a couple of times, but it doesn't help.

Thanks for reply.

akaariai

unread,
Dec 31, 2012, 7:02:13 AM12/31/12
to Django users
Interesting approach :)

Some pointers:
- The Page object has an automatic primary key. You should probably
change the path to be the primary key.
- .all() should not return a list of objects, instead it should
return a QuerySet which returns a list of objects when iterated.

You might be better of using just a regular FileField. Store the
objects in the DB, remove the path field and store the content in a
FileField. That is the way this is supposed to be done in Django. You
can likely make your approach work but it wont be easy.

- Anssi

On 31 joulu, 04:52, Shuge Lee <shuge....@gmail.com> wrote:
> I'm writing a simple CMS, it stores page file data on local file system
> instead of SQL server.
>
> I do overrides the model Page's Manager, but it not works as expected,
> problems
>
>    - PageManager.all(it calls PageQuerySet?) doesn't works
>    - I can create Page object in Admin, but can't view it or delete it
>
> Source code is herehttps://github.com/shuge/mcms/blob/master/pages/models.py
>
> I have read Django Manager docs<https://docs.djangoproject.com/en/1.4/topics/db/managers/> a
Reply all
Reply to author
Forward
0 new messages