Stas
spignelon
Stas
Mr.
Hello guys. I found that in Django model admin form there are three buttons for save the form data. "Save and continue editing" and "Save and add other" for unknown reason my signals on save model method are not triggered, when I hit the button "save" in the same form, signals work though. Did you run through this problem before ?
Habib
Hi there,
I have a question
I have this user profile_template which displays username and email
And I want it included in at least 5 different templates
The template is getting data from user_profile model instance that is passed to it as context
My question is if I directly passed the user_profile object to the user_profile template and then include it in all the 5 templates will it display the data correctly or will it require all those templates to have passed the same user profile in context too
cj
Habib
So this means that each template would need to be passed the user profile separately
Habib
Ok I have one more question
{% extends 'myapp/base.html' %}
{% load static %}
{% block setting %}
<img src="{% static 'myapp/images/sample-image.jpg' %}" alt="Sample Image">
{% endblock %}
Will this work
Habib
Provided the static file exists?
George B
I'm trying to build a portfolio website but issues arise when I install requirements.txt using pip on VScode. What should I do to fix this error. It says
Charly
George B
It says " Please add the directory containing pg_config to the $PATH or specify the full execution path with the option:
python setup.py build_ext --pg-co fig / path/to/pg_config build ...
George B
Or with the pg_config in 'setup.cfg'
Habib
Charly
George B
Windows 11
Charly
Windows 11
Do you already installed postgresql?
Habib
Or does it?
Charly
Or does it?
No, what happens when you delete it?
George B
Habib
When I remove the inside tag it throws that tag not loaded or registered error
Habib
Same is the case when I remove the outside one
Charly
Habib
Habib
TemplateSyntaxError at /dashboard/
Invalid block tag on line 19: 'static', expected 'endblock'. Did you forget to register or load this tag?
Request Method: GET
Request URL: http://127.0.0.1:8000/dashboard/
Django Version: 5.0.8
Exception Type: TemplateSyntaxError
Exception Value:
Invalid block tag on line 19: 'static', expected 'endblock'. Did you forget to register or load this tag?
Exception Location: /home/habib92/testing-clone/arbzoom/backend/venv/lib/python3.10/site-packages/django/template/base.py, line 555, in invalid_block_tag
This is what I get when I remove the load static inside the {%block setting %}
cj
Habib
https://dpaste.org/XD4k6#L3,7,8
cj
cj
Habib
Yeah actually I did
Habib
But then I see the extend tag displayed as it is...with all the CSS removed
Habib
Here https://dpaste.org/EWLXS
Habib
You can find the block setting on line 1183
Charly
The error lines don't coincide
Charly
but not sure whats really happening
Charly
loading multiple times a tag is not harmful but it makes not sense for me
Habib
The Inspired
Habib
Yeah just a min ago I did
Habib
loading multiple times a tag is not harmful but it makes not sense for me
I did the same thing with a few other templates and it was working( the single tag)
And then I noticed that my vscode was
Doing something like when I was saving the template
{% load static
%}
I think the "%}" pushed to the newline was creating the confusion of tag not closed
I added a comment to put the complete tag to new line and it worked
The Inspired
The TokenTitan
Please what is the opinion on using uuid for primary key, because I am seeing from different post that there might performance issue with using especially where there are ForeignKey relation
So what is your advise
Shoyim
Hello, I have a problem with opening pictures and files.
Static conf:
BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_URL = "static/"
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Image tag:
{% load static %}
<img src="{% static 'admin/img/fvol.svg' %}" alt="header image not found">
Vivek Yadav
I have deleted all the migrations files and dbsqllite file data also , but when I run makemigrations it shows no changes detected
Vivek Yadav
Anyone can help me related to it
Maxim
The TokenTitan
also, while fetching query is it advisable to use related_name lookup something like
chapter = book.book_chapter
where book_chapter is the related_name
OR
I should first query the boon and then query the chapter of the book
book = Book.objects.get(id=1)
chapters = Chapters.objects.get(book=book)
I am talking in term of best practices and performances
Vivek Yadav
That's why I did that
The TokenTitan
Vivek Yadav
Maxim
The TokenTitan
is it on your local machine, I mean you are just developing it
And not on any server
Vivek Yadav
The TokenTitan
Maybe if you can still reclaim it from recycle bin
Vivek Yadav
Oh.
The TokenTitan
OR
You might have to drop the database also
And then start afresh
run
python manage.py makemigrations appname
for every of the app folder
Vivek Yadav
Let me do this .. then I will connect back
Vivek Yadav
The TokenTitan
but try to always fix migrations issues other than deleting it
The TokenTitan
The TokenTitan
Maxim
and this
just reassemble one new post
don't forget to delete the old ones
Vivek Yadav
Novend