ᴸᵒᵖᵉʳᵈᵃˣ
Hello, my web server project works with Selenium Is it possible to run this project on the server? Do Selenium and Django both run on the server?
Jayanthi
Anyone please help me in pagination
Jayanthi
Django drf
Jayanthi
bot how to post the code
Maxim
bot how to post the code
don't ask bot find out from the rules
rtg
I am testing this package ( DJANGO-PRIVATE-CHAT ) but when writing in the chat, the sent text is not displayed. It's like nothing happens.
rtg
https://djangopackages.org/packages/p/django-private-chat/
Maxim
I am testing this package ( DJANGO-PRIVATE-CHAT ) but when writing in the chat, the sent text is not displayed. It's like nothing happens.
(Deprecated - Please check out https://github.com/Bearle/django_private_chat2) Django one-to-one Websocket-based Asyncio-handled chat, developed by Bearle team
rtg
ok! 🤦🏼‍♂️ I am sorry
rtg
and thank you Maxim!
Georg
hello, howto skip check instance existance in ModelSerializer ?
Adorilson
hello, howto skip check instance existance in ModelSerializer ?
In Django Rest Framework (DRF), you can skip the instance existence check in a ModelSerializer by using the create or update method of the serializer and manually handling the instance creation or update process. Here's an example of how to skip the check in the create method: class MySerializer(serializers.ModelSerializer): class Meta: model = MyModel fields = '__all__' def create(self, validated_data): return MyModel.objects.create(**validated_data) And here's an example of how to skip the check in the update method: class MySerializer(serializers.ModelSerializer): class Meta: model = MyModel fields = '__all__' def update(self, instance, validated_data): instance.__dict__.update(validated_data) instance.save() return instance Note that, by skipping the instance existence check, it is important to be cautious about data consistency and security. You may want to add additional validation and/or authentication to make sure that the data being created or updated is valid and can only be accessed by authorized users.
Georg
not exactly what I seek
Georg
I mean how can I skip it in is_valid method ?
Adorilson
I mean how can I skip it in is_valid method ?
In Django Rest Framework (DRF), you can skip the instance existence check in the is_valid method of a ModelSerializer by using the partial=True argument when instantiating the serializer. Here's an example: class MySerializer(serializers.ModelSerializer): class Meta: model = MyModel fields = '__all__' serializer = MySerializer(data=request.data, partial=True) if serializer.is_valid(): # data is valid and can be saved serializer.save() else: # data is not valid, handle the error return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) By setting partial=True, DRF will only validate fields that are included in the incoming data and will allow for updating existing instances with partial data. Note that, by skipping the instance existence check, it is important to be cautious about data consistency and security. You may want to add additional validation and/or authentication to make sure that the data being updated is valid and can only be accessed by authorized users.
Georg
thanks
Georg
without a ModelSerializer
Binary
I done it with a simple Serializer
Re write everything now urself and u loosed ur consistentcy
Binary
like consistent error messages
Georg
nothing understood
Артём
Hello I want to makemigrations, but terminal shows this error. I tried to google the solution, but still can’t fix it. What’s wrong here? ‘AttributeError: module “django.db.models.signals” has no attribute “post_syncdb”’
Adorilson
Hello I want to makemigrations, but terminal shows this error. I tried to google the solution, but still can’t fix it. What’s wrong here? ‘AttributeError: module “django.db.models.signals” has no attribute “post_syncdb”’
This error message is indicating that you are trying to use the post_syncdb signal from django.db.models.signals, but it is no longer available in Django. The post_syncdb signal was used in older versions of Django to perform actions after the database schema was created. However, it has been deprecated and is no longer available in recent versions of Django. Instead of using the post_syncdb signal, you should use the post_migrate signal, which performs actions after each migration is applied. To use this signal, create a function that listens for the signal and perform the actions you need. Then, connect this function to the signal using the receiver decorator. Here's an example: from django.db.models.signals import post_migrate from django.dispatch import receiver @receiver(post_migrate) def perform_post_migrate_actions(sender, **kwargs): # Perform actions here
Adorilson
Thank you! But what am I supposed to do if it’s not my project? Maybe there are other options to make the migration?
In this case, you should try to identify the source of the error. Here are some steps that might help: 1. Check the Django version used in the project, as the post_syncdb signal has been deprecated since Django 1.9. 2. Look through the project's code and identify any references to post_syncdb signal. If there are any, you may have to update the code to use a different signal. 3. If the error persists, it may be a bug in one of the installed packages. You can try to update the packages to the latest version or raise an issue on the package's repository. If you are unable to resolve the error, you may consider reaching out to the project maintainers.
daft
I am trying to update multiple instance of a model using modelformset_factory to render out my form In template but it does not work Here is my views def approve(request,pk): user = User.objects.get(id=pk) requests = PendingRequest.objects.filter(member=user) RequestFormset = modelformset_factory(PendingRequest, form=Approve ,extra=0) if request.method == "POST": formset = RequestFormset(request.POST, queryset=requests) if formset.is_valid(): for form in formset: form.save() else: formset = RequestFormset(queryset=requests) return render(request, "books/approve.html",{"formset":formset, "users":requests})
kiran
Our user instance save how many videos we have played and we are playing this video like Netfix
kiran
Is there any way to save this
muhammad
hey guys, I wanna ask..is it possible to implement realtime data for django admin panel?
Farooq
Yes
.
hey guys, I wanna ask..is it possible to implement realtime data for django admin panel?
Yes, consider adding custom template and/or custom js media to your admin page that contains what you need to get realtime data
Saeid
Hey friends, I have a question. I have a datepicker in django and I have too many pdf file reports which were publiched in different days. How can I connect Datepicker days in django to these pdf files. for example if they click on feb 2 automatically the program opens my pdf file which was pubished on feb 2.
Aditya
Hello can I use django for back-end and react js together? If yes how is that possible?
Shrenika
Anyone know How to write unittests for fortify wrapper functions
Aditya
Yes you can install cross package into react
Okay. So we will have a django project, django app and within the django app we will have react js?
Aditya
Okay
Tushant
Datetime filed default value
Saeid
Datetime filed default value
If you are guiding me, Could you do me a favor and explain it more. I am not professional in Django. appritiate in advance.
Georg
hello. I'm using router in DRF, why can't I add a couple of actions with same url_path but different methods ?
S.A
Hi which method need to be used to filter out data from many to many mapped table .
Georg
any filter operation needs a filter using
Anonymous
Is there any task?
Georg
Filter.
then use filter
S.A
Yeah I tried object. Filters it's not working
S.A
Tablename.objects.filter( Id=id)
Georg
then tell us what are you doing, what are you expecting, what is happening
S.A
Need to create an api . But it's mapped in many to many method . Have to do both get and post for tht tables.
S.A
Need data from two different tables in a single api which is mapped to a table using its id.
ᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠ
Hello! Is it possible to receive a signal from two models at the same time? Like this: @receiver(signal=post_save, sender=[Poll, Answers])
ᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠ
This construction does not work for me, although both are saved at the same time. Because Answers are tied to Poll
enansi
This construction does not work for me, although both are saved at the same time. Because Answers are tied to Poll
If both are saved at the same time, then does it matter? You could use either Model as the trigger for the signal.
daft
The form doesn't save
daft
What is your error
https://stackoverflow.com/questions/75348726/modelformset-update-multiple-instance-of-model
ᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠ
If both are saved at the same time, then does it matter? You could use either Model as the trigger for the signal.
Thanks, I already found the solution. It's just that the number of related models is dynamic, so you can't find everything at once. They are saved exclusively by one transaction, and not simultaneously. But I have already decided, I will repeat
Seyed Alireza
Hello How can i create a model multiple choice in model.py Django ?
Eslam
class ModelName(models.Model): CHOICES = [ ('beg', 'Beginner'), ('intr', 'Intermediate'), ('adv', 'Advanced'), ] field = models.CharField(choices=CHOICES, default='beg', max_length=250)
Eslam
default='Here name the options',
Alex
Hey guys. I'm migrating from my old ubuntu laptop to Mac. Just cloned my Django project and installed it on Mac. Here is one problem with macOS. Django-debug-toolbar doesn't work. I have the next error in my Traceback: AttributeError: 'str' object has no attribute 'items'. If I pip uninstall Django-debug-toolbar everything works as expected.
Alex
Hey I'm new here i know python But i don't know how to start django Can anyone help me . From where i should start And which course i should choose
My advice - buy this book: https://www.packtpub.com/product/django-4-by-example-fourth-edition/9781801813051
kiran
Is there any way to save the watch history in user account
kiran
How?
AISHWARYA
Can anybody suggest me the road map to learn django Any resources or any YouTube channels that can help to learn it from the basics.
Doragonsureiyā
Can anybody suggest me the road map to learn django Any resources or any YouTube channels that can help to learn it from the basics.
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
Charly
How?
Create a model to store a History Item and add an foreign key to the user, then in each watch event create s new History Item
Venkat
Can anybody suggest me the road map to learn django Any resources or any YouTube channels that can help to learn it from the basics.
Documentation is faar better than any other to learn django.. To start with follow the tutorial in documentation and do an app by following the steps over there.. That's its your django journey started..