Elements don't render in my table

51 views
Skip to first unread message

Matheus Bon

unread,
Sep 28, 2022, 5:56:09 PM9/28/22
to Django users
Hello friends!

I've been trying to find my error for a while as to why my database items are not being printed in the table I created, I've looked at all my files and nothing!

Where is my mistake?

Thanks.

Here is the code:

Views.py


Urls.py


Table


Note: I am rendering my table in the 'paginas' app and their data is in the 'registrations' app


Thank you again!



Boris Pérez

unread,
Sep 29, 2022, 9:15:44 AM9/29/22
to django...@googlegroups.com
Oi Matheus!!! Uma pregunta, as despesas estao guardadas na base de dados??? 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/99f2b47a-e3a0-47fd-9534-dbb5a8ab491bn%40googlegroups.com.

Walter Randazzo

unread,
Sep 29, 2022, 9:27:36 AM9/29/22
to django...@googlegroups.com
HI Bro,

Are you sure that u r writing the name of the fields ( models fields ) in the template same as you defined in the models.py?

Regards,



Derek

unread,
Sep 29, 2022, 9:29:40 AM9/29/22
to Django users
I find a quick way to check what data is actually going to the template is to print the whole object; so in your case probably {{ despesas }}

Its sometime the case that there is no actual data (so not really a problem with the template design).

If that does not work, try passing in a constant value to check the pipeline and rendering is working e.g. in the view : {'despesas': despesa_list, 'test': 'example' }

and then in the template  you access that constant via {{ test }}

HTH

Matheus Bon

unread,
Sep 29, 2022, 9:49:28 AM9/29/22
to Django users
Olá, Boris!

Meu banco de dados está povoado, o problema é que não aparace na tabela. Isso ocorreu quando eu mudei o diretório da pasta gastos.html, pois antes estava funcionando perfeitamente. Antes era assim:

templates ---> paginas ---> listas ---> gastos.html ( Fica assim: "paginas/listas/gastos.html" )

Agora é:

templates ---> paginas ---> gastos.html ( Fica assim: "paginas/gastos.html" )

Foi depois dessa mudança que fiz de diretório que iniciaram os erros e o estranho, creio eu que coloquei tudo da forma certa para o jeito que é agora.

Matheus Bon

unread,
Sep 29, 2022, 9:59:23 AM9/29/22
to Django users
Hi Bro!

From what I've seen here, all models are correct, otherwise my IDE would already accuse an error... at least I think :V

Matheus Bon

unread,
Sep 29, 2022, 10:07:37 AM9/29/22
to Django users
Hi Derek!

I did what you recommended: In my view I put {'expenses': expense_list, 'test': 'example'}

I went in my HTML (gastos.html) I changed the tag to {% for test in test %} I created a new td and inside I put {{ test }} and it didn't work

I don't know if this has anything to do with it but to make this table I'm using DataTable

Another factor that I explained to Boris was:

  This happened when I changed the directory of the expenses.html folder, because before it was working perfectly. Before it was like this:

templates ---> paginas ---> listas ---> gastos.html ( It looks like this: "paginass/listas/gastos.html" )

Now is:

templates ---> paginas ---> gastos.html ( It looks like this: "paginas/gastos.html" )

It was after this change that I made the directory that the errors started and the strange thing, I believe that I put everything in the right way for the way it is now.

Matheus Bon

unread,
Sep 29, 2022, 10:10:25 AM9/29/22
to Django users
I have two pages that use tables, one of them I use DataTables and I don't. Both are not showing data.

The first table is in estoque.html and the second is in gastos.html

Justice Asare

unread,
Sep 29, 2022, 11:09:43 AM9/29/22
to django...@googlegroups.com
 python3 manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/kali/.local/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/home/kali/.local/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 115, in inner_run
    autoreload.raise_last_exception()
  File "/home/kali/.local/lib/python3.10/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/home/kali/.local/lib/python3.10/site-packages/django/core/management/__init__.py", line 381, in execute
    autoreload.check_errors(django.setup)()
  File "/home/kali/.local/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/home/kali/.local/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/kali/.local/lib/python3.10/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/home/kali/.local/lib/python3.10/site-packages/django/apps/config.py", line 223, in create
    import_module(entry)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'crispy_forms'
                

peteru mimo

unread,
Sep 29, 2022, 11:11:01 AM9/29/22
to django...@googlegroups.com
check your path and change (/<str:despesa>/) to  (/<int:despesa>/) 

Matheus Bon

unread,
Sep 29, 2022, 4:40:41 PM9/29/22
to Django users
Hi Nanaba and Peter!

Peter, I did what you told me and it doesn't work

And Nanaba I didn't understand what you meant, sorry

subin

unread,
Oct 2, 2022, 4:19:19 PM10/2/22
to django...@googlegroups.com

subin

unread,
Oct 2, 2022, 4:24:21 PM10/2/22
to django...@googlegroups.com
Hi ! Thanks for making an appointment with us. We’re located at . We look forward to seeing you then!

subin

unread,
Oct 2, 2022, 4:25:42 PM10/2/22
to django...@googlegroups.com
Best regards.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

subin

unread,
Oct 2, 2022, 4:26:24 PM10/2/22
to django...@googlegroups.com
Ready for your next order of [product name]? Order now so you don’t run out!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

subin

unread,
Oct 2, 2022, 4:27:54 PM10/2/22
to django...@googlegroups.com
Thanks for opting into text alerts for your recent order. We’ll send you a message once your order has shipped!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

subin

unread,
Oct 2, 2022, 4:28:36 PM10/2/22
to django...@googlegroups.com

subin

unread,
Oct 2, 2022, 4:37:36 PM10/2/22
to django...@googlegroups.com
Please let me know if that is okay.

On Thu, Sep 29, 2022 at 2:26 PM Walter Randazzo <wwran...@gmail.com> wrote:

subin

unread,
Oct 2, 2022, 4:38:31 PM10/2/22
to django...@googlegroups.com
Thank you for contacting our 24/7 Customer Support Desk. A member of our team will respond to you within two hours. Thank you for your patience!

subin

unread,
Oct 2, 2022, 4:44:54 PM10/2/22
to django...@googlegroups.com
Please let me know if that is okay.

Reply all
Reply to author
Forward
0 new messages