Naggafin
Hello. Can react-admin receive JsonResponse from django from views.py without DRF? I installed django-cors-headers but still got error in console CORS request did not succeed
anything you can do in drf you can do with django's generic View class or view functions. drf simply makes making a REST API with django much, much easier. I wouldn't at all recommend making any REST API endpoints that aren't handled by drf unless it's for the absolute most basic functionality
Naggafin
Is there is a way to make real time apps or apis with something work naturaly on windows without ( wsl ) most package i saw are using redis or something similar which doesnt work on windows
do you mean you need a message broker engine? because that's what redis is. also very tangent suggestion, but if you can, I would highly recommend switching the targeted production environment for your django app to utilize some variant of Linux instead, since that is what 99% of the servers actually running anything of importance on the internet are using. there's a good reason it's industry standard now, even if it began more so for the fact that Linux is free to use. but if it's absolutely unavoidable that you must use a Windows Server environment, well, have you tried Cygwin?
Ravi
where can i learn Django rest framework ORM with advance way
Naggafin
where can i learn Django rest framework ORM with advance way
the official tutorial docs for drf aren't so great, unfortunately. I learned mostly by experience and trial and error. your best bet is to actually learn by doing. take a project you've already created in the past, and give yourself a practice assignment of making basic CRUD API endpoints using drf, which would act like the django admin control pages, but serve as a REST API version of it for your app
Amnas
Hey, my Django WebSocket is running properly on the Django localhost, but it's not working on the live server. I'm not sure why it's not working. When I connect using the live server, it shows a 1011 Server Error: Internal server error while operating. ?
Shanu
DJanog
Shanu
DJANOG movie
Krushna
Is there any library to receive e-mails into the django website via mailgun? I've tried django-anymail and received inbound mail from the mailgun route. I want whole email functionality like inbox, sent items, spam, trash integrated into django project database. Any suggestion is highly appreciated.
Doragonsureiyā
DJANOG movie
What are you talking about?
Naggafin
Is there any library to receive e-mails into the django website via mailgun? I've tried django-anymail and received inbound mail from the mailgun route. I want whole email functionality like inbox, sent items, spam, trash integrated into django project database. Any suggestion is highly appreciated.
seems complicated. never thought to try anything like that. I don't know of any libraries, but maybe helpful, maybe not: I see two approaches to this. 1. you could keep email data entirely within the db django has control over and manage that way, essentially having django act as its own email server. no idea how well that would work in practice since django was meant for HTTP and not SMTP 2. you could have some sort of non-django related python library which is able to retrieve data from the system mailbox like actual SMTP server applications such as exim and postman can do, then use that as an email interface while keeping django as running a user presentable web app for email
Naggafin
of course, if you're pulling data from a third party source, the most you should be doing with that data is caching it. I guess, if it were me, I'd probably have some caching backend like redis cache email data pulled from the third party source you're using and then having that as presented to the user as opposed to storage anything at all in the database, since without being the original source of that information, it makes not so much sense to store it
Ammar
Put maybe this is a bad way to learn Or what do you think
Naggafin
Put maybe this is a bad way to learn Or what do you think
I ditched Windows in 2016 completely so I can't say entirely. my honest opinion, which lacks a lot of nuance, is developing on a non-Linux system is just not such a great idea to begin with because there exists exponentially more support for things on Linux if you're a dev. I've encountered many libraries over the users the that explicitly state they either don't support Windows or getting them to run on Windows would require a bunch of complicated things. but that's just my opinion. take it with a grain of salt. I've heard good things about Cygwin though. if I were you, I'd install Cygwin (which is basically a Linux sandbox for Windows), learn a little bit of the basics, and you can follow this tut for redis: https://gist.github.com/cromat/a86511f72e1282c496ba156fb6eb2352
Naggafin
this of course differs from the official documentation. I don't know which way is better. the only reason I bring up Cygwin is because I've heard it recommended a lot. I've neither used Cygwin nor WSL myself since I don't use Windows
Naggafin
I use Ubuntu because it's relatively easy to use in comparison to other distros and it's free. whatever you choose, be prepared to get comfortable using a terminal interface. a lot of things you do in Linux require that of you
مريم خالد
I want to learn about cache in django any recommendations
Doragonsureiyā
Naggafin
yw
Naggafin
yw
Ravi
How to create django pipeline. How it is useful
Naggafin
How to create django pipeline. How it is useful
too vague. can you be more specific?
Diwakar_jii
Hello guys I am facing an issue related to audio Blob handling from django backend can anybody help me with that
Diwakar_jii
I am only getting 1kb audio
Diwakar_jii
What you want tell me
Doragonsureiyā
What you want tell me
Read this please: http://catb.org/~esr/faqs/smart-questions.html#intro
Diwakar_jii
audio_blob = request.FILES['audio_blob'] aud_name = 'audio/'+name path=os.path.join(settings.MEDIA_ROOT, f'{aud_name}.wav') with open(path,'wb') as wav_file: wav_file.write(audio_blob.read()) wav_file.close() this me my code
Asukhan
Hey there! been reading the documentation, but still can not completely understand what is **kwargs in Django CBV. Like, is it the list, that contains the attributes of the class we created and then we pass them in get_context_data etc?
Asukhan
*args and **kwargs are standard python concepts, not specific to Django. any additional argument to the method/constructor will be passed into kwargs
by additional you mean the attributes we'll write in a method or the ones we already defined as a an attributes of class before? p.s sorry if i am being stupid!
Muflone
arguments passed to the method/constructor call, not attributes
Muflone
consult the python documentation for *args and **kwargs
levels
Im trying to deploy simple Django project in aws In my project there are 5 urls include django admin dashboard But at the end I can't login as admin or register any user It claims  csrf token During production everything works fine Database i use is SQLite Please can anyone help me with this issue?
Vipul
I created a login API in django I have connected it to postgres It works fine when I define the field values in my views.py and return it What I want to do is create field values directly using SQL query in postgres and it should run But it's not running when I'm doing it like this Can anyone help?
1man
Psycopg2- binary error
Doragonsureiyā
Psycopg2- binary error
Read this please: http://catb.org/~esr/faqs/smart-questions.html#intro
1man
https://nekobin.com/kaqitopaza
Maxim
https://nekobin.com/kaqitopaza
https://www.psycopg.org/docs/install.html Build prerequisites section
دانایی
My friends, I have a problem. I uploaded my files, I specified the media url and media root in the media settings, but when I click on the image link of Apple, it gives me a 404 error. Does anyone know how to fix it?
Kairat
My friends, I have a problem. I uploaded my files, I specified the media url and media root in the media settings, but when I click on the image link of Apple, it gives me a 404 error. Does anyone know how to fix it?
from django.conf import settings from django.conf.urls.static import static urlpatterns = [ # ... the rest of your URLconf goes here ... ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
دانایی
You have to collect static
I did this once, do I need to use the collctstatic command again?
Kairat
and you gotta fix thing in setting.py also
Shijin
Why u restrict photos in here. If u remove that. That will help me. Because I have lots of error. But I can't share pics here
Kairat
Read errors and google it step by step
Kairat
Or copy and paste your errors here
Doragonsureiyā
Why u restrict photos in here. If u remove that. That will help me. Because I have lots of error. But I can't share pics here
Rule 5️⃣: Never post walls of text or screen photos. Use paste bins like https://linkode.org, https://nekobin.com (or your favorite one)
カカロット
select column where ....=.... and ....=.... how this statement written in django
 
Mahdi
Hey guys, hope u all doing great. Quick question, I have a model that has a file field and i'm trying to save a file that i have downloaded from internet to it. This is what the download and save to model function looks like : def down(url,nerf_id): response = requests.get(url) with open("model.glb", "wb") as downloaded_file: downloaded_file.write(response.content) export = ExportTest.objects.create(nerf_id = nerf_id, low_glb = downloaded_file) downloaded_file.close() The downloading part is working properly, but when it comes to save the file to model i get this error : AttributeError at /down/27 'int' object has no attribute '_committed' Request Method: GET Request URL: http://127.0.0.1:8000/down/27 Django Version: 4.2.3 Exception Type: AttributeError Exception Value: 'int' object has no attribute '_committed' Exception Location: /home/mahdi/Django Projects/env/lib/python3.10/site-packages/django/db/models/fields/files.py, line 315, in pre_save How can i resolve this? Thanks.
Ravi
How to create meme generator in Django or any readyment project for learning
Ravi
Yes, run and check how it work and what logic are me used
Oraz
Dear friends and distinguished Devs, As an entry level of Django, I'd like to ask your confirmation and advice about my project. So I've to reproduce a website made with PHP, a simple website that represents a number of vacation apartments for rent, without possiblity to interact with the website, because the reservation side is run by another third-party portal. So I have to remake the website, making an admin for uploading apartments details and photos etc... The question is: do I have to create one model for all these details ? (apartment_name, description, area, max_persons, address.) Only this approach comes to my mind for now, as there's no other activities to assign. I might add blog section, so I could add another model I think. What do you think? Which approach is appropriate in my case and if someone suggests something more interesting or maybe more appropriate to this project aspects. Thank you in advance!!! Highly appreciate any feedback
E
HELP Hello, i have a task (read below) but don't understand what websocket have to do. I made this: views.py set_cookie for new user and save it to db.json, react-admin show this data from json. as I understood, the websocket should monitor when the user connects and disconnects and it should delete his data from db.json. But in websocket I can't get cookie, so i couldn't delete this user from db.json. TASK: Solution consists of 3 components, which are connected with each other: 1. Simple website with several pages, theme/style is up to you. End-user gets its own id number, which is stored in cookie. For each web page visiting, information of {end_user_id, web_page_url} is sent to a server (second component). 2. Server gets the information from the first component and sent this information to the third component. 3. Admin website, which gets the information from the Server {end_user_id, web_page_url} and list this information grouped by end_user_id. It is up to you how to present the information. My consumers.py class MyAsyncWebsocketConsumer(AsyncWebsocketConsumer): async def connect(self): await self.accept() async def receive(self, text_data=None, bytes_data=None): pass async def disconnect(self, close_code): pass My views.py def index(request): response = render(request, 'app/index.html') response.set_cookie('user_id', '5') # not real, just for testing return response
E
sorry, above is not all task: + 1. Communication between second and third component is done via websocket. 2. Admin website is build using React Admin library
Denilson
Good afternoon, I'm trying to use try/except to test the data, but I'm having some difficulty. It always shows the following errors: If the user already has registered data: The DadosPaciente could not be changed because the data didn't validate. If the user does not have registered data: The DadosPaciente could not be created because the data didn't validate. Someone already have this problem? I already tried if form.is_valid(): form.save() But, doesn't word https://gist.github.com/DenilsonRBatista/d81bc55fc2a2278fe20a6448d6e5f048
Denilson
I don't understand
I have 2 model’s, PacienteCreate and DadosPacienteCreate. First, I create the paciente and after I alocate the DadosPaciente. So, I want to use the same button to create DadosPaciente or edit DadosPaciente. For this, I’m trying using “try/exception”
Джонни
ModuleNotFoundError
Doragonsureiyā
ModuleNotFoundError
Impossible to help without details.
Fan / Ac
Hi, when there is collisions in migrations do you try to fix it using python manage.py makemigraions --merge ?? or is there a better way(without manual renaming of migrations file) ?? https://www.algotech.solutions/blog/python/django-migrations-and-how-to-manage-conflicts/ https://adamj.eu/tech/2020/12/10/introducing-django-linear-migrations/