Search code examples
djangodjango-modelsdjango-tables2

What is the meaning of the expression A('pk') in Django Tables 2?


I'm trying to setup a LinkColumn and I've seen in the examples that a the args parameter has usually the form args=[A('pk')]. I'm wondering what is the meaning of the A().


Solution

  • From the documentation of django-tables, A is the Accessor Class.

    A string describing a path from one object to another via attribute/index accesses. For convenience, the class has an alias A to allow for more concise code.

    Relations are separated by a . character.

    So basically you are using the primary key in this example to access the objects.