Hi Matt,

 

            When I use linkcolum instead of a template tag, my collum cell
does not display nothing!

 

Muito Obrigado,

--

Roberto Ferreira Junior

robefe...@gmail.com

11 98009942

 

De: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Em
nome de MattDale
Enviada em: sexta-feira, 24 de agosto de 2012 09:15
Para: django-users@googlegroups.com
Assunto: Re: Django-tables2

 

Here's an example of one of my tables.

 

class NeedsTable(tables.Table):

    needQuantity = tables.Column()

    prod_id = tables.Column()

    description = tables.LinkColumn('needsdetail', args=[A('pk')])

    department = tables.Column()

    order = tables.Column()

    priority = tables.Column(accessor='order.event.priority')

    show = tables.Column(accessor='order.event.name')

    preppedQuantity = tables.Column()

    prepdate = tables.Column()

    

    class Meta:

        order_by = 'priority'

        attrs = {'class': 'general_table'}

 

URLS.py - 

url(r'^qcarea/needs/detail/(?P<pk>\d+)/$', 'needs.views.needsdetail',
name='needsdetail') 

 

LinkColumn uses reverse() to get its view and you use the Accessor(A) to
pass the pk to the args of the reverse call.  This means that you must name
your URL in your urls.py.  

 

In your example, I can't quite figure out what you are attempting with the
TemplateColumn.  To me it seems like you need to create two link columns.  

Good Luck

 


On Thursday, August 23, 2012 1:28:01 PM UTC-4, Robert wrote:

Hi All,

 

            I would like to ask something, I´m trying to render a table
using Django-tables2 and that table has a link column that I want to link
with another page, I cant figure out how can I link my model, and pass my PK
to url.py.  Here’s My code:

 

############ 

## Models.py:  ##

############

 

class Projetos(models.Model):

 

    #FIELDS

    nome_projeto = models.CharField("Projeto", max_length=150, null='true',)

    desc_oferta = models.CharField("Descrição da oferta", max_length=500,
null='true',) #aumentar

    integrador = models.CharField("Integrador", max_length=150,
null='true',)

    contend_provider = models.CharField("Contend Provider", max_length=150,
null='true',)

    marca_servico = models.CharField("Marca do Serviço", max_length=150,
null='true',)

    valor_retry = models.IntegerField("Valor de retry", null='true',)

    la =  models.IntegerField("Large account", null='true',)

    lanc_comercial = models.DateField("Lançamento comercial", null='true')

    term_projeto = models.DateField("Término do projeto", null='true')

    data_acordo = models.DateField("Data de Acordo", null='true')

    data_revisao = models.DateField("Data de Revisão", null='true')

    ura_id =  models.IntegerField("URA ID", null='true')

    ura_desc = models.CharField("Descição URA",max_length=150, null='true')

 

############

## tables.py  ##

############

 

TEMPLATE = '''

 

   <a href="{% url project_docs  %}" >Edit</a>

 

   <a href="{% url project_edit  %}" >&nbsp upload</a>

 

'''

 

 

class ProjetosMain(tables.Table):

 

        pdb.set_trace()

        nome_projeto = tables.Column(verbose_name='Projeto',orderable=False)

        integrador =
tables.Column(verbose_name='Integrador',orderable=False)

        contend_provider = tables.Column(verbose_name='CP',orderable=False)

        status = tables.Column(verbose_name='Status',orderable=False)

        term_projeto =
tables.Column(verbose_name='Vigencia',orderable=False)

 

        Acoes = tables.TemplateColumn(TEMPLATE)

 

        class Meta:

            attrs = {'class': 'bordered'}

#########

##  url.py ##

#########

 

urlpatterns = patterns('',

 

    # Main Page portal

    (r'^$', portal_main_page),

 

    # Home Page

    (r'home/$', portal_main_page),

 

    # Project Page

    url(r'projetos/$', projetos_main_page),

    url(r'projetos/?P<project_id>\d{1,2,3,4}/edit/', project_edit,
name="project_edit"),

    url(r'projetos/?P<project_id>\d{1,2,3,4}/docs/', project_docs,
name="project_docs"),

 

    # Upload File

    (r'^uploadfile/$', uploadfile),

    (r'^uploadsuccess/$', uploadsuccess),

 

)

 

 

Best Regards / Muito Obrigado,

--

Roberto Ferreira Junior

robefe...@gmail.com <javascript:> 

11 98009942

 

-- 
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/vm2VIX0jZOAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

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

Reply via email to