SKG
did you registered your blog_tags.py as the template library? # blog_tags.py ... register = template.Library() ...
yes sir i did from django import template from ..models import Post regiser = template.Library() # print("blog_tags is being loaded") @regiser.simple_tag def total_posts(): return Post.published.count()
SKG
and loaded in the template? {% load blog_tags %}
yeah brother i did {% load blog_tags %} {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>{% block title %}{% endblock %}</title> <link rel="stylesheet" href="{% static 'css/blog.css' %}" rel="stylesheet"> </head> <body> <div id="content"> {% block content %} {% endblock %} </div> <div id="sidebar"> <h2>My blog</h2> <p> This is my blog I've written {% total_posts %} post so far. </p> </div> </body> </html>
SKG
and loaded in the template? {% load blog_tags %}
my directory structure: https://prnt.sc/_pQJGpDCt2G2
奈姆
yeah brother i did {% load blog_tags %} {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>{% block title %}{% endblock %}</title> <link rel="stylesheet" href="{% static 'css/blog.css' %}" rel="stylesheet"> </head> <body> <div id="content"> {% block content %} {% endblock %} </div> <div id="sidebar"> <h2>My blog</h2> <p> This is my blog I've written {% total_posts %} post so far. </p> </div> </body> </html>
your error is from detail page right? does it include {% load blog_tags %} as well?
奈姆
if other templates also use blog_tags, you need to include {% load blog_tags %} as well, not just the base.html. (Also, try test using incognito mode just in case...)
Akshay
Halo guys
Akshay
I need guidance on Building a Blog and Image Sharing Website
Charly
I need guidance on Building a Blog and Image Sharing Website
Better to start doing a Google search, there are plenty of tutorials for blogs
Charly
Then you can come here and ask more specific stuff
Saidnabixon
Hello everyone i have django project which i got from github but there are some issues in it.The project about To Do List website. the logout section of it isn't working. please help me guys
Saidnabixon
Hello everyone i have django project which i got from github but there are some issues in it.The project about To Do List website. the logout section of it isn't working. please help me guys
in the views.py file the "DeleteView" was imported. and also the same name was used to create class. when i change class's name the terminal shows error
mohammad
from django.utils.functional import cached_property
mohammad
Guys, has anyone used this yet? What is useful in the rest framework?
奈姆
Guys, has anyone used this yet? What is useful in the rest framework?
Have you read the official django doc for cached_property and drf doc on caching?
Алексей
Hey, guys, can i get some advanced django books? Honestly, i don't know where to seek for 'em
cj
How much does it cost btw
just around $50 https://www.feldroy.com/two-scoops-of-django
SKG
just around $50 https://www.feldroy.com/two-scoops-of-django
Please bro is it better than Django 5 by example . I downloaded it from the internet .
Abedin
Hi guys I have a login and registration page that I have already written and now I want to make it work with Django but not with a Django template I would really appreciate it if you guys could help me
cj
Please bro is it better than Django 5 by example . I downloaded it from the internet .
I'm not your bro in the book you'll learn advanced concepts you can apply in any version but the book, don't be pirate
Abedin
You have to use the Django rest framework then you build api
Im actually new to django can you help me with that
HesamGh
Im actually new to django can you help me with that
I can send you a github link of my own project which is a good and clear example for what you looking for
You
I need guidance on Building a Blog and Image Sharing Website
Go to YouTube and search for a guy called Corey Shafer, code along with him. Thank me later.
Ulug'bek
Hello everyone How necessary and correct is it to log processes within a project? If it is necessary to log, what specific situations do you recommend logging?
Kostya
Hi all. I'm developing a site for an environmental project on django. i need to create a news feed. what is the best library to use for this? Wagtail CMS Django CMS
Bardia
Hello guys, I hope you are well, I have a question, I wrote a Django file and it shows me the error page not found, I am sending my code, I hope you can help me.
Bardia
How i can send my code . There is a limit here
Qwerty
How i can send my code . There is a limit here
Using triple ` or with pastebin
شهرزاد محمد
How i can send my code . There is a limit here
5️⃣ Code sharing • Be considerate! • Try to use markdown formatting! • For many lines (5-10+) of code, use a pasting service: • dpaste.org • hastebin.com • Don't ever attach photos or videos of your screen taken with your phone camera!
Rashed
Why there is an issue with urls file in my code Resist showing template
Alex
have you defined the template dir in settings?
Alex
Share the error trace logs.
Rashed
Page not found
Alex
then that's not an issue with the template but urls mapping
Alex
mind sharing the code?
Rashed
No
Rashed
Private?
Alex
okay
Charly
Private?
Share it here so not only him can help you
Rashed
it's a zip file contains all files
Charly
it's a zip file contains all files
just share the relevant parts
Rashed
urls.py of project : from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include('lms_app.urls')), ] urls.py of the app :from django.urls import path from . import views urlpatterns = [ path('test', views.demo, name='demo'), ] views.py :from django.shortcuts import render # Create your views here. def demo(request): return render(request, 'pages/index.html')
Circuit
Put slush after test and make it like this “test/“ instead of “test”
Circuit
And make sure index.html is in templates folder like this lms_app/templates/pages/index.html
Circuit
And remember to include your app in app settings!
Nikita
Hi!Someone use neovim for Django development?I'm trying to set up my config but I can't setup configuration for jinja,if someone has ready config,can you send it to me?
Doragonsureiyā
Hi!Someone use neovim for Django development?I'm trying to set up my config but I can't setup configuration for jinja,if someone has ready config,can you send it to me?
Adding the word Django to your Off-Topic question doesn't magically turn it to a Django related question, so delete your question here and move to the @PythonOfftopic group and ask there.
Rashed
Done??
not yet!
Rashed
What url are you opening in the browser?
127.0.0.1:8000 this and with test/
Uchqun
Hi🤚 I have an interesting problem with django, celery and kafka. Can I commit a Kafka-message based on the result of a Celery task? Thanks in advance for your help.
#
Hi🤚 I have an interesting problem with django, celery and kafka. Can I commit a Kafka-message based on the result of a Celery task? Thanks in advance for your help.
Dont relay on celery task . U wont get proper control on them once the task finishes and they get invalid at certain time period or sever restars.
#
Instead u can save the result to db table then fetch that table
Uchqun
Dont relay on celery task . U wont get proper control on them once the task finishes and they get invalid at certain time period or sever restars.
Should I move the processing of messages received from Kafka to Celery or should I process them in the consumer body? Which is recommended?
𝑵𝒐-𝑩𝒐𝒅𝒚 𝑵𝒐𝒔𝒆
Hi all. which approach is better/optimized use list, retrieve, and list using filter by some fields in one API and class or separate to 2 or 3 classes and API ? Thank you for answering in advance.
𝑵𝒐-𝑩𝒐𝒅𝒚 𝑵𝒐𝒔𝒆
Your question might not be clear.
I have a API which get more than 500 000 data from database for list and retrieve methods. I need to add another list method but using filter by some fields for example filter by user through all data and returns as a result. question is should I add second list method in exists API or create new one ? Sample: - list method: logs/ - retrieve: logs/{id}/ - second list method: logs/related/{some_field}/