Monday, December 31, 2012

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

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
> couple of times, but it doesn't help.
>
> Thanks for reply.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment