Doragonsureiyā
Hello friends, good time I have a task, can anyone help? To have a database, my sql has about 4 tables The name of each table is the name of a class in Python And for each class You have to do the crud operation I want to make such a completely object-oriented model Can anyone help?
We're not here to do your job for you. This group is to help you on specific issues you have in YOUR code, so you have to show the code you wrote by yourself and explain where and why you are stuck... as simple as that. 🤷🏻‍♂️
ARS
Hi
ARS
I am getting this error in django admin: 'str' object has no attribute 'utcoffset'
ARS
Any help would be greatly appreciated Thank you
M E H D I 1 9 0
hi i have a problem When debug is false and cant find my static any can help me?
M E H D I 1 9 0
use web server to host static files
when i run in the host and can find? or ….
Maxim
web server is the program
M E H D I 1 9 0
i do not understand
you told me i must use in the host its not problem? when debug is false
M E H D I 1 9 0
so? use web server to host static files
but when i run in the my pc and cant find why?
Maxim
but when i run in the my pc and cant find why?
because you don't use a web server
Charly
but when i run in the my pc and cant find why?
Static files are not served on with django unless is debug. You need to serve with nginx or apachhe or whatever
Naggafin
Hello everyone, I want to ask, I am making a database with a connection many to many: actors = models.ManyToManyField(Actors). But with this error: <class 'movie_app.admin.MovieAdmin'>: (admin.E109) The value of 'list_display[4]' must not be a ManyToManyField. Help please, with what this error can be connected and how to solve it?
you cannot specify an M2M field in list_display because it's unclear exactly how to always properly display such, and it also has a tendency to hit the db significantly unless you have a prefetch_related queryset. to accomplish what you are trying to do, you must do 2 things: 1. write a display function: @admin.display(description=_("Actors")) def display_actors(self, obj): return mark_safe("<br>".join([str(actor) for actor in obj.actors.all()])) 2. add this to list_display: list_display = ['display_actors', ...]
Naggafin
you will get a substantial number of redundant db hits if you do this however, which is why django does not natively support this. for every related Actor, it will be an n+1 db hit.
Naggafin
I am getting this error in django admin: 'str' object has no attribute 'utcoffset'
sounds like an issue which you need to read the python docs on. https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str you will see the interpreter is correct. according to the python std lib docs, str type objects have no attribute utcoffset. so, without more context, no one can help you other than to say the interpreter is telling you the correct error information.
Naggafin
Hello everyone! I'm getting error Origin checking failed - https://ridp.uzrd.uz does not match any trusted origins. CSRF validation failed. Request denied. this is my settings: ALLOWED_HOSTS = ['ridp.uzrd.uz'] CSRF_TRUSTED_ORIGIN = ["https://ridp.uzrd.uz" "https://*.uzrd.uz", "ridp"] CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True SESSION_EXPIRE_AT_BROWSER_CLOSE = True how can I fix it?
when I encounter weird problems like this, I'll often run a debug instance up with pdb breakpoints strategically placed to step through the code as it runs. if you can't do this from the server which that domain points to, then you'll need to run a publicly accessible debug instance via manage.py runserver 0.0.0.0:8000. this is not secure however, so definitely don't leave it up for long
Naggafin
This happen in userregistration serializer
I use django-knox for DRF user authentication and serialization. perhaps have a look at that for a solution? usually no need to re-invent the wheel on something like this
Obaida Aljarjary
STATIC_URL = 'static/' {% load static %} {% static 'logo.jpg' %} [28/Jun/2023 00:25:17] "GET /static/logo.jpg HTTP/1.1" 404 1783
Naggafin
How i can fix it?
have you read the django docs about deploying static files first?
Obaida Aljarjary
ROG 💻
Hello everyone, has anyone had a problem with the Chrome browser not logging you out once the browser or tab is closed?
ROG 💻
my settings.py configuration is:
ROG 💻
#Close Browser SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_SAVE_EVERY_REQUEST = True SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
ROG 💻
django version: 4.1.7
Naggafin
Hello everyone, has anyone had a problem with the Chrome browser not logging you out once the browser or tab is closed?
I don't know exactly how the default django implementation of session expiry at browser close works, but you could consider using a library called allauth to handle this. the login form has a switch for a "Remember me" option, which necessarily implies session logout on browser close. this is a very mature library too, having been in development since 2012 and is actively maintained now. link: https://django-allauth.readthedocs.io/en/latest/overview.html
Fernando
Hello everyone. I'm using Django forms to send info from my MySQL db to my template and get answers from template to my db. There a way to make better visualization for forms beside form.as_p, div, table, ul. I'm looking for new ways to visualize my forms. Thanks
Naggafin
Hello everyone. I'm using Django forms to send info from my MySQL db to my template and get answers from template to my db. There a way to make better visualization for forms beside form.as_p, div, table, ul. I'm looking for new ways to visualize my forms. Thanks
this is probably one of the most frustrating experiences with django and has been for some time: its lack of an innovative solution for generating stylized (and custom attributed) forms without having to create a full HTML template from scratch, even for relatively minor adjustments (like ONLY adding CSS to a particular field, everything else being the same). there are third party libraries out there like django crispy forms, but I've never found a library that has a philosophy I agree with (i.e. my issue with crispy is they seem to trend towards defining structure in Python, which is NOT a job for Python; HTML was literally designed to define the structure of a webpage, that should be being used for that purpose instead). I've created a custom form library that makes use of some of django 5.0 alpha's features and generally makes defining forms work like models, allowing one to define a Meta class and then supply attributes in dicts; i.e., to add css you would do: class MyForm(forms.Form): ... class Meta: css = {'fields': {'my_field': ['list', 'of', 'css', 'classes']}} it works generally on everything but fieldsets. but I haven't published it to github yet. I suppose I should do that, if you'd like to give it a go. otherwise, best thing I can tell you is to write an HTML template from scratch for your form and assign it to it with MyForm.template_name attribute
Fernando
Do you mean styles? Did you try with CSS?
Yes Christian, I've try. But CSS is not my real problem. I think the HTML form is the real issue. Thanks
Naggafin
this is probably one of the most frustrating experiences with django and has been for some time: its lack of an innovative solution for generating stylized (and custom attributed) forms without having to create a full HTML template from scratch, even for relatively minor adjustments (like ONLY adding CSS to a particular field, everything else being the same). there are third party libraries out there like django crispy forms, but I've never found a library that has a philosophy I agree with (i.e. my issue with crispy is they seem to trend towards defining structure in Python, which is NOT a job for Python; HTML was literally designed to define the structure of a webpage, that should be being used for that purpose instead). I've created a custom form library that makes use of some of django 5.0 alpha's features and generally makes defining forms work like models, allowing one to define a Meta class and then supply attributes in dicts; i.e., to add css you would do: class MyForm(forms.Form): ... class Meta: css = {'fields': {'my_field': ['list', 'of', 'css', 'classes']}} it works generally on everything but fieldsets. but I haven't published it to github yet. I suppose I should do that, if you'd like to give it a go. otherwise, best thing I can tell you is to write an HTML template from scratch for your form and assign it to it with MyForm.template_name attribute
I just made a repo for it if you want to try it. no docs yet. it's more experimental than anything else, but it works. https://github.com/Naggafin/django-extensible-forms
Naggafin
don't know if that would help with what you are trying to do
Fernando
Yes Christian, I've try. But CSS is not my real problem. I think the HTML form is the real issue. Thanks
Thank you for your time Naggafin. To include css attributes I used widgets in forms, seems work effectively. Nice that you created custom library, show us if possible. I'll give a try to write my html form with My forms template_name.
Naggafin
a feature of my library though allows one to define attributes for the field separator tag. right now, this is only <div>, as each field is wrapped in a <div> tag to separate from one another. you can add attributes for this through the Meta's css = {'separators': {'my_field': ['CSS', 'list']}}
Naggafin
Thanks. I will take a look
as you please :). I definitely need to come up with some rudimentary documentation. if you feel like using it, I can explain what all it can do in a PM. for the most part I did this because I got tired of having to write a custom HTML template every time I wanted basic CSS or HTML attributes defined. in any case, you say you're having an issue with HTML?
Gollamudi
https://linkode.org/#8d6yAg2DQYlLvq6tACBvk5
Gollamudi
i am unable to login with that code
Careful
i am unable to login with that code
This is a HTML code. Can you show your login view?
Gollamudi
Okay
Gollamudi
reply
@cyberZW
Hell guys any one who can tell me any free hosting platforms where I can deploy my webapp
Tatiana
Hi All) Anyone used Heroku for deploy and blaze bucket for file storage? Can’t connect to bucket also return to error of “invalid endpoint”…I’m not sure which library I need to use or which settings set up right. Please HELP HELP HELP 🌚🌚🌚
Sumit
Hi , How can I open django admin at 127.0.0.1:8000 instead of 127.0.0.1:8000/admin/ when debug = False.
Sumit
with debug= True, it is running fine, but with debug = false , django is not adding trailing / , so it is causing an error
AMIR
Hello I had a project that was working on Django 3.1 and I was connected to mqtt broker with it. Today, I had to upgrade the project version to Django 4.2, but the mqtt connection gives a timeout error Can anyone help me? Traceback (most recent call last): File "/home/HomeAmn/report/mqtt.py", line 171, in <module> client.connect("37.156.29.21", 1883, 60) File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 914, in connect TimeoutError: timed out
E
I have 1 model, and it updates on different pages, so i have 2 forms for this model, but when i enter data into fields on page4 and i need to go back to page3 to edit data and then go to page4, fields of page4 will be empty and data from model is deleted class Page3Form(forms.ModelForm): class Meta: model = Object class Page4Form(forms.ModelForm): class Meta: model = Object
Tererai Tyler
Hello Guys my cmd is not going past the django-admin start project its giving an error anyone who knows how to pass this error
(offline)REBEL WAS INNOCENT( READ BIO)
Can anyone tell me the basic of django i want to learn it
Doragonsureiyā
Can anyone tell me the basic of django i want to learn it
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
ROG 💻
Can anyone tell me the basic of django i want to learn it
look at the documentation, it is very complete
부산
TypeError at / Field 'id' expected a number but got <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x000001A1326800A0>>. how can I solve this problem?
(offline)REBEL WAS INNOCENT( READ BIO)
Tatiana
Hi All) Anyone used Heroku for deploy and blaze bucket for file storage? Can’t connect to bucket also return to error of “invalid endpoint”…I’m not sure which library I need to use or which settings set up right. Please HELP HELP HELP 🌚🌚🌚
KingFx
I have a form I want when a user fill the form that I can receive data to my email account
Shivam
Django Rest oauth toolkit provider authentication and when user login genrate access token
Shivam
I want face error grant type
Doragonsureiyā
I want face error grant type
Read this please: http://catb.org/~esr/faqs/smart-questions.html#intro
Anonymous
I have a form I want when a user fill the form that I can receive data to my email account
Bro u need to make your own class for recive the data of user in your admin panel
KingFx
Bro u need to make your own class for recive the data of user in your admin panel
I already implement an api that retrieve the data from the form But I want also to send the message to my email account
Anonymous
Ohh
Anonymous
U need to learn about generate tokens
Anonymous
And send messages to account
aditya
I want to make two separate django and connect then, example one project is for payment things and 2nd one is main project. Is there any way or idea about it
Naggafin
I want to make two separate django and connect then, example one project is for payment things and 2nd one is main project. Is there any way or idea about it
that seems like an odd way to configure things. can you go into detail about your decision for this design paradigm? if it were me, I would keep everything in one project, but have the payment system in its own module. I do this for the project I'm working on now, which expects to be able to transact in cryptocurrencies. for accomplishing this, I made a crypto module, which every app which requires crypto functionality uses. the module itself sits inside of a django app, also titled crypto, which provides models for crypto wallets and basic REST API views. perhaps a setup like that is easier? having two separate django instances running which are expected to be interfacing in unison seems like a really complicated thing to pull off. communication between them would be done via HTTP, and that would be one hell of a db setup and apache config.
부산
is there anyone who can solve the problem I am encountering? I will pay how much he/she wants if he/she can solve that problem