ᴸᵒᵖᵉʳᵈᵃˣ
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?
Doragonsureiyā
Jayanthi
Anyone please help me in pagination
Jayanthi
Django drf
Jayanthi
bot how to post the code
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/
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
Georg
thanks
Georg
Georg
Georg
without a ModelSerializer
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})
Chocolate_girl
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
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
Farooq
Kene
Farooq
Aditya
Okay
Saeid
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
Georg
any filter operation needs a filter using
S.A
Anonymous
Is there any task?
Georg
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.
Georg
ᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠ
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
daft
daft
The form doesn't save
daft
What is your error
https://stackoverflow.com/questions/75348726/modelformset-update-multiple-instance-of-model
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)
Seyed Alireza
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
kiran
Is there any way to save the watch history in user account
Farooq
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.
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
AISHWARYA