bradleyayers/django-tables2 — pull request #185 by luzfcb (2014-02-02 01:32:48+00:00)
Title: Generate unique 'id' to table element based on...

Generate unique 'id' to table element based on child class instance counter
Generate unique 'id' attribute to

element if the 'id' attribute not defined in attrs on class Meta

I needed a simple way to uniquely identify the generated table without breaking the existing API (needs more testing)

The generated value for the "id" has the following format:

```tables.Table derived class name in lowercase + _ + tables.Table derived class current instance number```

# Example:

```python
class MyTable(tables.Table):

class Meta:
model = MyModel
```

Generated table tag is:
```html

```

If you use another instance of MyTable, the generated table tag id:
```html

```

To override generated value, simply declare the id in the Meta class

If the "id" includes "_" char, ex. "first_last", the string is split, will be utilized only the first part of the string.

```python
class MyOtherTable(tables.Table):

class Meta:
model = MyOtherModel
attrs = {'id': 'myid_last_other'}
```

Generated table tag is:
```html

```

If you use another instances of MyOtherTable, the generated table tag id:
```html

```