clouded
Frontend-framework are not developed in Python.
HAJI MASTAN
thank you my friend
HAJI MASTAN
what do you think about htmx?
clouded
what do you think about htmx?
It's also an option to go for plain Django without Django Restframework but make it behave like an SPA.
clouded
An option that is worth being considered.
HAJI MASTAN
that is great
clouded
that is great
IIRC, data isn't decoupled from views, so you'd have your views in Django but htmx would request whole templates, but still be able to replace only certain parts of the website. Of course you can use htmx also with a REST API, but that doesn't seem to be point.
clouded
Let me check.
clouded
Yeah, both works, less commonly used would be to return JSON for htmx. So, quite a nice fit for Django without Django Restframework.
HAJI MASTAN
that is great man found new things to learn
HAJI MASTAN
IIRC, data isn't decoupled from views, so you'd have your views in Django but htmx would request whole templates, but still be able to replace only certain parts of the website. Of course you can use htmx also with a REST API, but that doesn't seem to be point.
DjangoCon 2022 | From React to htmx on a real-world SaaS product: we did it, and it's awesome! check this on youtube these developers turns django react full website to django htmx, Seems like HTMX can do all the JS framework stuff.
clouded
DjangoCon 2022 | From React to htmx on a real-world SaaS product: we did it, and it's awesome! check this on youtube these developers turns django react full website to django htmx, Seems like HTMX can do all the JS framework stuff.
That's the point, but it has benefits and drawbacks that need to be considered. There's no decoupling from data, no separate API for data handling. It, as almost always, depends on what you want to do.
HAJI MASTAN
yeah you are right there is some missing but anyhow it dose the most
Ibrohim
https://dpaste.org/B4Jyz Can someone help me please, I don’t know why my function calculate_reading_duration doesn’t work
Doragonsureiyā
https://dpaste.org/B4Jyz Can someone help me please, I don’t know why my function calculate_reading_duration doesn’t work
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like: - https://dpaste.org - https://hastebin.com - https://bin.kv2.dev If you posted a wall of text, go back and delete it.
The Inspired
https://dpaste.org/B4Jyz Can someone help me please, I don’t know why my function calculate_reading_duration doesn’t work
from what I understand, the function is not being called. Try a print statement immediately after calculate_reading_duration. If it does not show up, it means you need to check it
The Inspired
It shows 1, default value
show code of that function only, with the print statement
Ibrohim
I just deleted split and it works…
DV
Not able to install...facenet-pytorch library. Showing some error " Getting requirements to build wheel did not run successfully " Pls guide me
Doragonsureiyā
Not able to install...facenet-pytorch library. Showing some error " Getting requirements to build wheel did not run successfully " Pls guide me
This is not a Django specific question, please delete your offtopic message. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
~~~
Hi Which is the best way to hide the secret keys in settings while publishing the source?
Eric
Hi Which is the best way to hide the secret keys in settings while publishing the source?
You store all secrets as evironment variables, and then use dotenv -> https://github.com/theskumar/python-dotenv/
Moussa
You can define your private variable in .env file .
But don't forget to not track it by adding the .env in your .gitignore file if you're using git
Moussa
Finally you can provide a .env-example file for instructions purposes
~
# Django AllAuth Settings settings.ACCOUNT_SIGNUP_FIELDS = ['email*','username*','password1*', 'password2*'] settings.ACCOUNT_USERNAME_REQUIRED =['email*','username*','password1*', 'password2*'] settings.ACCOUNT_EMAIL_REQUIRED = True settings.ACCOUNT_AUTHENTICATION_METHOD = {'email'} settings.ACCOUNT_EMAIL_VERIFICATION = "mandatory"
~
can anyone help me with it error"{ "non_field_errors": [ "Must include \"username\" and \"password\"." ] }"
~
what is the proper way to configure django-all-auth settings
Ibrohim
I have a backend and frontend, when frontend request, my backend reply error Access to fetch at 'http://localhost:8000/api/auth/login/' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response. api-client.ts:48
Ibrohim
I have a backend and frontend, when frontend request, my backend reply error Access to fetch at 'http://localhost:8000/api/auth/login/' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response. api-client.ts:48
I set up my corsheaders, I add it to installed apps, top in middlwares, and also: CORS_ORIGIN_ALLOW_ALL = True # Allow all origins CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_HEADERS = ['*'] # Allow all headers CSRF_COOKIE_SECURE = False # Disable CSRF cookie for development
🐾S
I tried testing my login restapi with postman and it is showing: Forbidden (403) CSRF verification failed. Request aborted. You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked by third parties. If you have configured your browser to disable cookies, please re-enable them, at least for this site, or for “same-origin” requests.
Denis
In django is there any editor for editing text. without js? Something like a ckeditor
Maxim
clouded
without js
Well, then textarea.
Denis
Why not ckeditor?
I haven't found a way to make images fixed sizes.
Denis
Well, then textarea.
There is no text formatting.
clouded
There is no text formatting.
Right, for that you need JavaScript.
HAJI MASTAN
In django is there any editor for editing text. without js? Something like a ckeditor
if no js then you have to code it ur self u can create custom editor
Denis
Ok, thanks guys
HAJI MASTAN
I'm not cool enough for that.
it is a new small chalange for u so u can learn new things by creating ur own editor
clouded
it is a new small chalange for u so u can learn new things by creating ur own editor
How do you create an editor for the web without JavaScript?
HAJI MASTAN
How do you create an editor for the web without JavaScript?
you can create basic but not advance basic mean it will somehow solve ur basic problems, for learning purpose it is good for production it will be not that helpful.
Denis
And if a user makes, for example, not the best photo sizes in his post, and I change them so that they look normal in the admin panel, is this normal practice?
Denis
And if you change the image yourself constantly to the same size, because otherwise without js I won't be able to do it
HAJI MASTAN
What functionality does "basic" include? Making fonts bold? Creating heading and links?
yeah it cover that i have created one with django html and css but if you want to go a little bit more u can make it a bit more advance with htmx
clouded
is this a big thing?
Why do you ask me? You said it's possible, I'm asking how.
Denis
What's the problem with JS?
I don't know this language. And I'm not sure that I'll learn it in at least a month. So I'm looking for other solutions, but it's better to learn it anyway..
clouded
And using JavaScript components does not require you to be an expert JavaScript developer.
clouded
But those solutions you seem to be asking for do require JavaScript.
Denis
But those solutions you seem to be asking for do require JavaScript.
Through tears and boredom I will have to learn JS 🐈
Saman
Hi, I have this model with a GenericForeignKey relation: class Attachment(SoftDeleteBaseModel, CreatorBaseModel): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) file = models.ForeignKey(File, on_delete=models.CASCADE, related_name="attachments") # Generic relation fields content_type = models.ForeignKey( ContentType, on_delete=models.PROTECT, related_name="attachments", ) object_id = models.IntegerField() content_object = GenericForeignKey("content_type", "object_id") # Extra datas order = models.PositiveIntegerField(default=0) type = models.PositiveSmallIntegerField(choices=AttachmentTypeChoices.choices) description = models.TextField(null=True, blank=True) class Meta: ordering = ("order",) What's the best practices to handle attachments of diffrence models? For example I have Request model who can have some attachments & some other models like Product, Inspectation and etc... Is that logical to implement CRUD endpoints for each model? or is that anyway to handle attachments using a single CRUD?
Suryo Adhy Chandra
Each model can have multiple attachments.
https://docs.djangoproject.com/en/5.1/topics/db/examples/ learn more about your best practice here.
Suryo Adhy Chandra
Thanks but it's just type of DB relations!
welcome. if your File models just for header, its fine. and u must define your models.FileFields here, to place your arbitrary file to upload.
иван
Hi everyone. I am combining 3 querysets using union and django sets AS col{n} for each column. Is there a way to disable this? Because of this, the 3 querysets are not being combined. Because col6 in one subquery and col6 in the other subquery have different data types. Maybe there is some way to exclude certain columns at the query level via code. I haven't found such a way