Cesar
you should first order by, and then slice it. There is no much logic in ordering (or filter) after slicing
Shrey
Why do you add an id field if all models already have one?
Instead of the default object value, its easier to identify entries from ID Just thats why !!
Cesar
Instead of the default object value, its easier to identify entries from ID Just thats why !!
Wait, what? entries are identified with a default ID field. By default, Django gives each model the following field: id = models.AutoField(primary_key=True) This is an auto-incrementing primary key.
Cesar
Instead of the default object value, its easier to identify entries from ID Just thats why !!
what i think you mean is that you want to change the string representation of that model... 🧐 in that case you should override the str(self) method
Shrey
Wait, what? entries are identified with a default ID field. By default, Django gives each model the following field: id = models.AutoField(primary_key=True) This is an auto-incrementing primary key.
This thing is not working for me, that was the reason I wanted to try the above approach !! AutoField is not creating any id in any of my models.....
Mohamad
How to return to the current url? return HttpResponseRedirect(request.path)
Shrey
You could try return redirect("viewname")
|-|●$€!|/|
Hello , Why I cant use slug in Get_absolute_url ?
|-|●$€!|/|
Hello , Why I cant use slug in Get_absolute_url ?
If I use pk/id reverse function works , but I get no reverse match error if I use slug
Ravi
add current user to model please help me
Ravi
from django.db import models from django.contrib.auth.models import User from django.conf import settings # Create your models here. class Book(models.Model): name = models.CharField(max_length=200) created_by = models.ForeignKey(User,null=True,on_delete=models.SET_NULL,editable=False) def _str__(self): return self.name
Dheekshith
Hi Can anybody give a clue about how to deploy a django application Like on which platform and what package should I choose
Dheekshith
I tried using pythonanywhere I did all the config but site didn’t load. It would be helpful even sharing tutorials which worked for you Thanks in advance
.
I tried using pythonanywhere I did all the config but site didn’t load. It would be helpful even sharing tutorials which worked for you Thanks in advance
You can give us a clue on how to help by being more descriptive. Didn’t load how? Was there an error? What error was displayed? Does it only display pythonanywhere’s default app page?
Amnas
CSRF verification failed. Request aborted.
Amnas
Origin checking failed - http://35.72.2.239 does not match any trusted origins.
.
hello guys , how can i create the parent and its chiledren in one form i know that i need to use inline formset to create many chileds in one time ,buy how can i crate the parent and relate it to them if i did not make before
whoami
hi all. i have a confluent-kafka producer, and i wanna see the result of this produce, how can i do it, can anyone give me good tutorial about it?
Dheekshith
Something went wrong: ( Something went wrong while trying to load this website; please try again later. If it is your site, you should check your logs to determine what the problem is.
S
How to send email with attachement?
S
Using django
Doragonsureiyā
How to send email with attachement?
These single steps will help you a lot: Step 1️⃣: Open a browser Step 2️⃣: Write down https://google.com or https://duck.com and press Enter Step 3️⃣: In the search box, write down the same words you asked here Step 4️⃣: Read the first results
S
Ok thank you
Vishnu
Anyone have project model using django
Krunal
I am using swagger to documentation of my drf api. Some of my api use query parameters. swagger is not giving input for such situations. can someone please help me how cam i get that in swagger?
Tура
hello is there any alternative for social share in django, because there is not instagram
Tура
also no posibility to share photos
Doragonsureiyā
also no posibility to share photos
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like: - https://dpaste.org - https://linkode.org - https://hastebin.com - https://bin.kv2.dev If you posted a wall of text, go back and delete it.
Tура
!paste
I mean in 'social share' app
Mirco
I mean in 'social share' app
If it doesn't exist, built your own
Mirco
how
Google it, search, study how it works
Georg
hello.. How to make a query SELECT ... FROM (SELECT ...) forcibly ?
Georg
I mean, what I should use to separate internal "select" from external ? Subquery isn't useful for this...
Charly
hello.. How to make a query SELECT ... FROM (SELECT ...) forcibly ?
What exactly you want to do? I mean forget the SQL because you are suing an ORM on django, so what's your desired outcome?
Georg
I want something like this: Separator(MyModel.objects.filter(...).annotate(...)).filter(.<by fields created in annotate>.).exclude(.<by fields created in annotate>.)
Georg
in objectives I want to filter my queryset by new annotated fields (like status, some summas, etc)
Georg
if I do it in standard in simple flat select - it does not work as it should.. It filters first and then calculates balance-on-row. But I need vice versa
Sudhanshu
I have one issue...from frontend date is coming in string '01/12/2022' in dd-mm-yyyy format but django save it into mm-dd-yyyy format 12/01/2022
Bandar
Using the dateutil library: import dateutil.parser date_string = '01/12/2022' date_parsed = dateutil.parser.parse(date_string) # datetime.datetime object YourModel.objects.create(date=date_parsed) Or using the datetime library: import datetime date_string = '01/12/2022' date_parsed = datetime.datetime.strptime(date_string, '%d/%m/%Y') # datetime.datetime object YourModel.objects.create(date=date_parsed)
Bandar
I have a question does using multiple files for html file increase the speed ?
Bandar
like instead of one file for file.css I do 2 files
S
How to implement celery on sending emails
Doragonsureiyā
I have a question does using multiple files for html file increase the speed ?
Your question is not related to Django. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
Gumi
I'm using multi threading in django, I tried to stop my development server with Ctrl + C but it doesn't worked for me, it only happens whenever I use multi threading, any suggestions please?
💻
Hello , i want to know if there is a way to restrict django views if another another view which contains a form isnt completed ?
Doragonsureiyā
Hello , i want to know if there is a way to restrict django views if another another view which contains a form isnt completed ?
To get an answer to your question, it is worth to formulate it more clearly, perhaps add more details, perhaps add explanations.
💻
Hello , i want to know if there is a way to restrict django views if another another view which contains a form isnt completed ?
So, I have some views in django, but I have extended user model using one to one field. Now I want to restrict views until user model extended isnt completed.
Osiris *
How to implement celery on sending emails
Why implementing celery when you have async views
Osiris *
task scheduling ?
For scheduling purpose, implement crontab with celery - see celery service in documentation
Sergey
Hi guys! For some reason, m2m_changed signal does not come to me, maybe, because I connected 11 fields to the handler. I have connected 11 fields because these fied are have same structure connection with exact one model :) Anybody can help?
Ivan
hello everyone, does anyone know how to make a page on django admin where you can aggregate model objects? for example, I have an expense model, and I want to group expenses by text and calculate how much money is spent in total or can anyone tell me how to make such reports? I tried Django Slick Reporting, but it didn't seem so flexible to me for such a task
Omadbek
Has anyone tried linking the yml file in Django
Doragonsureiyā
Has anyone tried linking the yml file in Django
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
Pradhipta
Hello everyone 👋 Anyone want to share how you usually manage your migration files when working with your team in django? I often do merge migrations because I often run into conflicts with other feature branches, or usually feature branches depend on someone else if there is a migration. is this efficient way? let me know ehat do you think. Thanks!
Smile
Hello how can i automatically call a function (with business logic) every time the model is updated? I dont want do it every time in my template.
Bekk1 👨‍💻
which free hosting can i use to deploy my project
Bekk1 👨‍💻
???
navid
pythonanywhere
Bekk1 👨‍💻
thank you broo ✊✊✊
Bekk1 👨‍💻
before i used heroku but now i did not understand they changed paymend systems and removed free dynoses
Mahdi hosseini
Hello everyone, I have a very busy mind when I start coding and sometimes I don't know where to start. This way I lose huge time Do someone have any practical idea to solve this problem?
Doragonsureiyā
Hello everyone, I have a very busy mind when I start coding and sometimes I don't know where to start. This way I lose huge time Do someone have any practical idea to solve this problem?
Your question is not related to Django. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
.
hello guys , how can i create the parent and its chiledren in one form i know that i need to use inline formset to create many children in one time ,buy how can i crate the parent and relate it to the new children if i did not make it before , which means its id is not Existing