mohamad
hello everyone, i have database and i made models in django , and i want to edit data from the tables and delete some data too but by using postman (post،put)and form jason only ,can anyone help me by writing the founction for delete and another founction to modify in views.py by using queries?
Fedora
Hello how do i host a website on google drive
Alexandro
there are many free services to host static pages easily, github web pages for example
Fedora
Oooh i didnt know i can use github so how can i use github
Fedora
To host a web page
William
yes
Ping me
William
https://youtu.be/TmsD8QExZ84
William
yes
You can follow the above tutorial for creating API for delete and update function
mohamad
ok Thank you
4candels support
Hello everyone, I have a model with the student’s information and this model is connected to a registration form in the html interfaces. What I want is when the student registers for his information, including the email, I want him to receive a message on his welcome email, is there any help or research method that helps me
Shubham
Guys i am lillte bit confuse about django restframe work and rest Api what is the difference bet then. Pls help me.thank u
Shubham
Now clear with the help of django rest frame work u can build the rest api
.
Can we use Django for backend and firebase for chat together?
Mohamad.m
hi every body my project error CORS Error how can I fix it? and i use the all headers and alll setting but in does not work
Не выходи из комнаты.
Hi. Help me, pls https://stackoverflow.com/questions/69181590/django-channels-page-not-found
Ted
Good
Hi could someone help me use two models and display them on one page
Hunde
I am new to django,I have button in html file when button clicked i want to iterate variable in function found in view.py ,how i can do that?
Anurag
I am new to django,I have button in html file when button clicked i want to iterate variable in function found in view.py ,how i can do that?
give urls to button which is defined in urls.py ... link that url to a view in views.py and do what ever you want in that view
Sanjarbek
#help when i use this code certbot —nginx i get this error https://dpaste.org/zaFp
Azizbek Xushnazarov
Cancel saving model when using post_save?
Doragonsureiyā
Cancel saving model when using post_save?
Don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello, I need help on $z!" Just ask directly! The better you are at explaining the problem, the more likely you are to get help. Asking smart questions
Azizbek Xushnazarov
huh, this is not meta. I have explained my issue in one simple sentence.
kuzmich
Cancel saving model when using post_save?
why not to save it inside if statement?😁
kuzmich
if what_you_need: model.field = data model.save()
Azizbek Xushnazarov
if what_you_need: model.field = data model.save()
You did not get it. when I save a model it sends signal to my receiver. In the receiver function if some condition happen it should cancel the saving.
kuzmich
try to overwrite save method then
Alex
huh, this is not meta. I have explained my issue in one simple sentence.
Except you didn't. Your expression literally means that you're surprised by smt, not that you are asking for smt.
kuzmich
and it's post_save btw meaning it's already been created/updated
kuzmich
you can try pre_save and raise db validation error then
kuzmich
but I'd go with the save method
kuzmich
try to do transaction inside save method
Alex
no, it is more like stackoverflow's question title
no, it's more like "grammar is for losers"
kuzmich
it's gonna be saved only when the transaction succeeds
Hunde
give urls to button which is defined in urls.py ... link that url to a view in views.py and do what ever you want in that view
I have function in view.py and I want to call that function and iterate global variable in that function when it's clicked
Anonymous
i am facing problem with runserver command
JanelleOfficial
who can code me a FUD crypter
Azizbek Xushnazarov
You have not explained anything
[In reply to kuzmich] You did not get it. when I save a model it sends signal to my receiver. In the receiver function if some condition happen it should cancel the saving.
kuzmich
in short... you got two options 1) use pre_save and raise an error 2) use transaction in save method and rollback changes
Azizbek Xushnazarov
in short... you got two options 1) use pre_save and raise an error 2) use transaction in save method and rollback changes
I figured out a simple solution. if some_condition: instance.delete() #deletes the model. raise Exception('OMG') #cancels calling save()
kuzmich
idk man... you saved the record and deleted it
kuzmich
up to you 🙂
Azizbek Xushnazarov
idk man... you saved the record and deleted it
The reason i am using post_save is because when I do this: user = User.objects.create_user(username=_username, email=_email) i can get the email of the user by instance.email and send generated link to it. But if I use pre_save. I cant get the email of user cause it is not recorded yet. Sorry I am a beginner. Is this a good idea to do the job?
Alex
The reason i am using post_save is because when I do this: user = User.objects.create_user(username=_username, email=_email) i can get the email of the user by instance.email and send generated link to it. But if I use pre_save. I cant get the email of user cause it is not recorded yet. Sorry I am a beginner. Is this a good idea to do the job?
you can nest the user creation in a transaction: with transaction.atomic(): user = User.objects.create_user(username=_username, email=_email) # post_save is triggered here # in your signal handler if <not some precondition satisfied> raise SomeException
Alex
I don't know how but this worked. Without this, raising an exception did not cancel user creation. thanks!
Aaah, as alwasy. Two things you should learn before touching any backend framework: 1 The language 2 Databases. You cannot overestimate how important for webdevelopment they are. It's like a second OS. https://en.wikipedia.org/wiki/Database_transaction
Ted
Thanks I managed to fix it
Anonymous
Hello. I am searching for a Python&Django developer. How can I post a job ad?
Doragonsureiyā
Hello. I am searching for a Python&Django developer. How can I post a job ad?
Rule 🔟: Job-related offers are only allowed in the offtopic group. To not be considered spam, Job offers must include: • Skillset/techstack • Contact information • Brief job description • Pay figure • And can only be posted in @PythonOfftopic.
Suhaib_0.0
Hey I want to do an experimental electronic market using Django. I have a question. How can I make a variable through which I can lower all prices
Mr.
Hi guys. My django app worked ok on developement settings. now I'm getting it to the production. I configured nginx and I got a free ssl using certbot. Now when I enter the address of the admin panel, it works ok, but for my own views it returns nothing! what would be the problem?
Mr.
Returns nothing means no data?
excuse me, no. In the firefox i get: Content Encoding Error An error occurred during a connection to <MY DOMAIN>. Please contact the website owners to inform them of this problem.
Mr.
Did you set you collectstatic?
thank you very much. it was my problem. I was returning a simple httpresponse and I didn't think that I need to collectstatic.
Mr.
You could set DEBUG = True In the first steps of django production
yes . it is set to True. but it didn't show me anything
Олександр
Hello everyone, I really need help in this matter https://stackoverflow.com/questions/69178211/how-do-i-run-multiple-sites-on-the-same-server-using-docker-and-nginx?noredirect=1, who can tell?
Anonymous
how would you write a serializer in drf to validate raw json body but the body is only a list, instead of an object For example a request body like the following [ "foo", "bar" ]
Сергей
Hello, there is server nodejs with socket io, can I send on this server messages from django code, for example from model post save?
Poppu
Guys anyone know how we should convert Django model object in nested json without class or DRF I tried to find out but all the example I see to build API or class based and there are some examples but they also show only single level json I need to build a function so I can pass my custom model object and get the nested JSON.
Poppu
You can use the serialize method Django has
Did you know how we used that. Is there any example
Mirco
Did you know how we used that. Is there any example
https://docs.djangoproject.com/en/3.2/topics/serialization/#:~:text=Django's%20serialization%20framework%20provides%20a,text%2Dbased%20or%20not). Documentation man
Valter
Hello everyone, I'm struggling to find a solution on how to send a message for a dealer on my app as I wish to create a communication in between two people only as one send a message and the other can answer it, any advice are welcome. Thank you.
𝓶𝓸𝓱𝓪𝓶𝓶𝓪𝓭
Hello everybody, I have a question. If the user in django signup sent a post and the post in not valid (based on django signup laws (for exmple password must not be just numeric and ...)) What should I do to give an error for not is valid post?🌹
Poppu
https://imgur.com/a/l82p1Qk And one more thing why this error occurred whenever I can this function most specific this line of code I tried to convert my firebase timestamp in Django readable DateTime object this is the only solution which I found on stack overflow and it's work but also give some warning