RES: Django-tables2
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\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 = ''' Edit upload ''' 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\d{1,2,3,4}/edit/', project_edit, name="project_edit"), url(r'projetos/?P\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 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.
Django-tables2
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 = ''' Edit upload ''' 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\d{1,2,3,4}/edit/', project_edit, name="project_edit"), url(r'projetos/?P\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 <mailto:robefe...@gmail.com> robefe...@gmail.com 11 98009942 -- 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.
Re: Noob question
Thanks guys for all replies, an especial thanks to Kurtis, I followed all your tips and my code looks very clean and objective, agree to leave the underscore from classes name! Although I really appreciate hungarian notation, without them my vars is so much objective! :) Cheers On Thu, Aug 2, 2012 at 3:34 PM, Tomas Neme <lacrymol...@gmail.com> wrote: > as Kurtis says, drop the explicit Primary Keys, and drop the hungarian > notation as well (don't declare the variable type on it's name): I > don't need to be reminded that the name of a project will be a string, > it's pretty obvious. Also, python standards talk against using > underscore in class names, so standard naming would be HeaderEnrich > instead of Header_Enrich. Underscores for field names are good. I'd > also use less abbreviations. > > also, I'd name the FK on that model just "projeto", since what you'll > get when you do `headerenrichobject.projeto` will be a Projeto object, > not it's ID > > Try to forget the underlying database, the ORM is there to abstract you > from it. > > But all these are style things, the syntax looks good, so it's all > your call, but getting used to standardized style will make your life > easier, as well as the life of people who try to help you in mailing > lists and IRC channels > > -- > "The whole of Japan is pure invention. There is no such country, there > are no such people" --Oscar Wilde > > |_|0|_| > |_|_|0| > |0|0|0| > > (\__/) > (='.'=)This is Bunny. Copy and paste bunny > (")_(") to help him gain world domination. > > -- > 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. > > -- -- Roberto Ferreira Junior +5511-98009942 robefe...@gmail.com -- 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.