Aaush
class Student(models.Model): FRESHMAN = 'FR' SOPHOMORE = 'SO' JUNIOR = 'JR' SENIOR = 'SR' GRADUATE = 'GR' YEAR_IN_SCHOOL_CHOICES = [ (FRESHMAN, 'Freshman'), (SOPHOMORE, 'Sophomore'), (JUNIOR, 'Junior'), (SENIOR, 'Senior'), (GRADUATE, 'Graduate'), ]
Doragonsureiyā
anyone? At least hint me out
Maybe anyone is here, yes, but they are not obliged to read everyone's message here neither to reply to everyone's message, if someone wants to reply to your message, they will do that, just don't try to draw attention to your message writing "anyone?" every 5 minutes, that will lead you to be warned for SPAM/Flood, just be patient or use Google/DuckDuckGo to research about your question instead of wasting time here waiting for people to do your work. Have a nice day 😊
Rajeev
How to perform in django i.e. if objects instances exists then perform_update else perform_create
Dexter
Update_or_create
Alex
I wanted to add a lock mechanism in my project, can someone guide me with it?
What exactly do you want to lock? Some DB actions or maybe something else?
Arsalan
I wanted to add a locking time and date filed where one cannot access a particular module.for example... I have 2 modules admin and group admin have set a time and date for a poll from 18/2/22 11am to 20/2/22 12pm and didnt want anyone to submit or access the poll after that date or time. Admin can also extend the date and time if wants.
Alex
Hello guys😉 How to create all Django apps insert a folder?(Windows 10) I wrote this command ("py manage.py startapp users apps/users") but it doesn't work(
Noor
Then you should check that does django installed globally or not
Alex
Then you should check that does django installed globally or not
I found the reason, I had to first create the "apps / users" folder and then run the command
unknown
i am looking for free vedio course of postgrasql for learning. any one has know some course like that?
Fabrício
Hi there. I published a new article on Towards Data Science; it is a Tutorial on Django, from first steps up to some more advanced topics, such as showing Plotly chart in Django web apps. Any constructive feedback about my text would be much appreciated since I'm kind of new to Django. I would also like to ask if I could post the article link here. I apologize in advance if it is not allowed, I don't mean to disturb the group normal activity in any way.
....RJ....
Can we retrieve by os module..????
....RJ....
Can we retrieve by os module..????
Please tell me is it possible
....RJ....
If yes then how
....RJ....
Help me
Dasa
I have 2 DBs. one managed by django(managed=True) and one external DB(managed=False). I need to lookup for object from both the DBs based on the need. Is there a way to know if django manages a particular self.model?
Anonymous
Hello, Is there any django way of calculating a filtered queryset integer fields without doing a for loop. Say i have a field in my model 'post_view' and I'm trying to calculate each 'post_view' in my queryset for analysis stuff..
Peet
Please post what you've done so far and we can help from there. Screenshots
Anonymous
Hello, Is there any django way of calculating a filtered queryset integer fields without doing a for loop. Say i have a field in my model 'post_view' and I'm trying to calculate each 'post_view' in my queryset for analysis stuff..
What i did was... I created a property function in the model which loop through each post model and return the sum of 'post_view' field.. What I'm trying to figure out is if there's a way i can do this efficiently without having to use a for loop.
CryptoHunt
Hello guys i have a question How can i create documentation like swagger, but for django channels(websockets)?
Maxim
neither a project selection group nor a friend finder group - you need @pythonofftopic
Vlad
Hi! I'm use DRF and I try to do POST on my drf form, from JS. I'm use function getCookie as it written in django documentation. And then I pass csrftoken and body, in my "fetch" function with method POST. But it's working on ALL devices, except IPHONE. WHY???
Alex
Hello, Is there any django way of calculating a filtered queryset integer fields without doing a for loop. Say i have a field in my model 'post_view' and I'm trying to calculate each 'post_view' in my queryset for analysis stuff..
I think you need django's aggregation capabilities https://docs.djangoproject.com/en/4.0/topics/db/aggregation/ guess in your case it will be something like Post.objects.filter(<args>).aggregate(views=Sum('post_view'))
Alex
Second question... Is there anyway i can get an index of sorted queryset object without having to iterate each of them?
Do you mean like in an array? No. It's because of how relational databases work - they return SETS. The only way is if you are sure that in a queryset you will get only specific number of records. Say we create a log record each hour, then for a day we could use indexes and etc.
Alex
What i did was... I created a property function in the model which loop through each post model and return the sum of 'post_view' field.. What I'm trying to figure out is if there's a way i can do this efficiently without having to use a for loop.
Using such properties is a common antipatter I see in many django projects written by unexperienced devs. Also it seems that you actually need Count. Here is an example from the link I provided >>> from django.db.models import Count >>> pubs = Publisher.objects.annotate(num_books=Count('book'))
Anonymous
is there any fields for telephone number in django
cj
is there any fields for telephone number in django
a CharField with a custom validator should be more than enough
 ‌‌‌‌Hamed
Hi how config fluent for get django logs file for use in elasticsearch
Max
Guys, need help. both functions are trying to change the same object. Works only the last one launched. How can i fix it? @transaction.atomic Def foo(pk): Obj=Object.objects.get(pk) Obj.foo += 1 Obj.save() @transaction.atomic Def bar(pk): Obj=Object.objects.get(pk) Obj.bar += 1 Obj.save()
ኃይሉ
hey guys have you done face recognition project with its own database recommend me.
Doragonsureiyā
hey guys have you done face recognition project with its own database recommend me.
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.
ky
How to delete all objects in project ?
Doragonsureiyā
How to delete all objects in project ?
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
ky
I try but not working
Doragonsureiyā
I try but not working
Read this please: http://catb.org/~esr/faqs/smart-questions.html#intro
ky
Because in my project some foreign key connected to another table
Alex
How to delete all objects in project ?
in a project?! In an entire project?
ky
Entire
Alex
Because in my project some foreign key connected to another table
For instance, you could connect to your database and drop it drop database <mydatabase>. Alternatively you can truncate it. Google it for your specific DB.
ky
Ok thank you
Hamza
Hello everyone, I have a question: I want to create two tables in different databases for the login page, the first one will be for all the users of our website and the second table for the other database will be for all the details about the user: is it possible to create two templates and assign each of them to the corresponding database and link them together ?
cj
https://docs.djangoproject.com/en/4.0/topics/db/multi-db/ that's all you need to know... now you can be happy
cj
just be sure to read the section: "Limitations of multiple databases" and you're all set
cj
https://docs.djangoproject.com/en/4.0/topics/db/multi-db/#cross-database-relations
Hamza
https://docs.djangoproject.com/en/4.0/topics/db/multi-db/#cross-database-relations
*However, this configuration is not officially supported by Django* this is the response of mine from django doc ..that’s why i ask for other solutions..! Do u think Using queries gonna solve the problem??
cj
Mysql
with MyISAM or InnoDB? —and why?—
cj
*However, this configuration is not officially supported by Django* this is the response of mine from django doc ..that’s why i ask for other solutions..! Do u think Using queries gonna solve the problem??
however, you have the answer there: > "you may be able to ‘fake’ cross database foreign keys" ¯\_(ツ)_/¯ it doesn't matter if it's not "officially" supported, what matters is that you may be ABLE to do that... so do that
Hamza
with MyISAM or InnoDB? —and why?—
Cuz i have a lot of tables and a lof of user gonna registered in the account like 100000 ppls and a lot of infos invoicing to much things and a need to the request from database not taking more than 100ms that’s why I’m using mysql
cj
other solution is that before saving/updating data in one DB, you manually check there's the integrity needed on the other DB so your project doesn't break
Hamza
Hamza
🙏🏻🙏🏻🙏🏻
Брат
Required fields don't show up in swagger
Брат
Serializers.py class UserSerializer(serializers.ModelSerializer): password2 = serializers.CharField(style={'input_type': 'password'}, write_only=True) class Meta: model = User fields = ['id', 'first_name', 'last_name', 'username', 'email', 'password', 'password2'] extra_kwargs = { 'password': { 'write_only': True, 'required': True } }
Брат
Views.py http://linkode.org/#LYbGAVVS1Yow0e7IkFi795
Брат
Im using drf-yasg and here is the result: https://ibb.co/PgXrWmC
Брат
Required fields don't show up in swagger
#solved https://drf-yasg.readthedocs.io/en/latest/custom_spec.html#the-swagger-auto-schema-decorator
Jean-Yves
https://www.toptal.com/developers/hastebin/laqunajexu.rb
Jean-Yves
Please, someone can help me I would like to save A Product in the Model WishList, it didn't work, I don't know if it's the right way
Брат
You just getting the object, according to your code
Jean-Yves
You are not performing any action to save it
it gave an error like this 'super' object has no attribute 'get_object'