Issues

Issue #660 resolved

AttributeError on TagField

Atamert Ölçgen
created an issue

I am using the following field on my model:

{{{

!python

tags = TagField(_(u"tags")) }}}

When I try to document this class with the following markup:

{{{

!restructuredtext

.. autoclass:: bdecommerce.models.myklass.MyKlass :members: }}}

I get the following exception:

{{{

!python

Traceback (most recent call last): File "/home/muhuk/code/project/lib/python2.6/site-packages/sphinx/ext/autodoc.py", line 334, in import_object obj = self.get_attr(obj, part) File "/home/muhuk/code/project/lib/python2.6/site-packages/sphinx/ext/autodoc.py", line 237, in get_attr return safe_getattr(obj, name, *defargs) File "/home/muhuk/code/project/lib/python2.6/site-packages/sphinx/util/inspect.py", line 29, in safe_getattr raise AttributeError(name) AttributeError: tags }}}

My virtualenv is:

  • Django==1.3
  • Sphinx==1.0.7
  • django-tagging==0.3.1

How can I get autodoc to publish the docstring for this attribute (field)?

Comments (6)

  1. Anonymous

    I have solved my problem adding the following code to conf.py:

    from django.core.management.commands.syncdb import Command as SyncdbCommand
    SyncdbCommand().execute(verbosity=0)
    
  2. Charl Botha

    I am seeing exactly the same behaviour and trackback, but with https://pypi.python.org/pypi/jsonfield on Django 1.6.x.

    Atamert Ölçgen Your workaround (which I have not been able to divine the mechanism of, could you elaborate on what problem it fixed?) does not work on my setup, instead yielding this traceback:

    # Sphinx version: 1.2.2
    # Python version: 2.7.6
    # Docutils version: 0.11 release
    # Jinja2 version: 2.7.3
    # Loaded extensions:
    Traceback (most recent call last):
      File "/home/cpbotha/.virtualenvs/kmxng/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 253, in main
        warningiserror, tags, verbosity, parallel)
      File "/home/cpbotha/.virtualenvs/kmxng/local/lib/python2.7/site-packages/sphinx/application.py", line 107, in __init__
        confoverrides or {}, self.tags)
      File "/home/cpbotha/.virtualenvs/kmxng/local/lib/python2.7/site-packages/sphinx/config.py", line 229, in __init__
        execfile_(filename, config)
      File "/home/cpbotha/.virtualenvs/kmxng/local/lib/python2.7/site-packages/sphinx/util/pycompat.py", line 105, in execfile_
        exec code in _globals
      File "conf.py", line 28, in <module>
        SyncdbCommand().execute(verbosity=0)
      File "/home/cpbotha/.virtualenvs/kmxng/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
        output = self.handle(*args, **options)
      File "/home/cpbotha/.virtualenvs/kmxng/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
        return self.handle_noargs(**options)
      File "/home/cpbotha/.virtualenvs/kmxng/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 56, in handle_noargs
        connection = connections[db]
      File "/home/cpbotha/.virtualenvs/kmxng/local/lib/python2.7/site-packages/django/db/utils.py", line 193, in __getitem__
        if hasattr(self._connections, alias):
    TypeError: hasattr(): attribute name must be string
    

    Any help would be greatly appreciated!

  3. Log in to comment