On Tue, Aug 25, 2009 at 4:44 PM, Benjamin  Wohlwend<[email protected]> wrote:
>
> Hi,
>
> I'm trying to generate documentation for my django project with sphinx
> [1] and autodoc[2]. It's mostly working, but I can't get sphinx to
> pick up my model field definitions (with the exception of related
> fields like m2m or ForeignKey). I asked in the IRC channel of sphinx
> (#pocoo on freenode), and they told me that it generally should work
> and that it's probably an issue with my configuration.
>
> My configuration is quite simple: I have all my apps and dependencies
> in a virtualenv and export DJANGO_SETTINGS_MODULE before running "make
> html" in the doc folder. Sphinx can import everything and doesn't
> throw any errors or warnings.
>
> So, did anybody here manage to get autodoc to recognize model fields?
> If yes, could you share how you set up your sphinx environment?
>
> Just to make sure I'm not doing something completely stupid (which,
> I'm told, does indeed happen from time to time), here's an example of
> my model
>
> http://dpaste.com/hold/85108/
>
> and my rst source:
>
> http://dpaste.com/85109/
>

It's quite easy to find out why this happens. The ForeignKey adds an
actual descriptor to the class, CharFields however do not add
top-level attributes to the class itself.

Sphinx does not that it should look into Page._meta.fields to find all
defined fields and therefore does not find most Django fields, only
the fields adding descriptors.

You might want to find out how to modify sphinx / add a new sphinx
extension which knows how Django models should be handled.


IPython session transscript:

In [1]: from feincms.module.page.models import Page

In [2]: Page.parent
Out[2]: <django.db.models.fields.related.ReverseSingleRelatedObjectDescriptor
object at 0x13720d0>

In [3]: Page._cached_url
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/mk/tmp/feincms/example/<ipython console> in <module>()

AttributeError: type object 'Page' has no attribute '_cached_url'




Matthias

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to