Orack
and generics.ListCreateAPIView
Orack
in views.py
pvs
How to schedule web scraper script trigger on specific time in django
Sander
How to schedule web scraper script trigger on specific time in django
Create a management command & execute it using crontab
Orack
class CreateView(generics.ListCreateAPIView): queryset = Bucketlist.objects.all() serializer_class = BucketlistSerializer def perform_create(self, serializer): serializer.save() class GroupViewSet(viewsets.ModelViewSet): queryset = StickerData.objects.all() serializer_class = StickerDataSerializer
Orack
this is confusing
Orack
can anyone link to explaination other than documentation
Shiva
How to check Django version
Faisal
How to check Django version
https://stackoverflow.com/questions/6468397/how-to-check-django-version
Anonymous
hi how can i export a data base table to csv file?
Anonymous
Hello can I use scrapy with Django
cj
hi how can i export a data base table to csv file?
just use dumpdata from manage.py 🤷‍♂️
Anonymous
How to check Django version
django-admin version
Sander
How to check Django version
python manage.py version
Anonymous
how to backup django psql db
cj
how to backup django psql db
do it at DB level 🤷‍♂️
cj
just like any other PostgreSQL DB 🤷‍♂️
Orack
class SnippetDetail(generics.RetrieveUpdateDestroyAPIView): queryset = Snippet.objects.all() serializer_class = SnippetSerializer
Orack
how does it know that im referring which number
Orack
say localhost/users/2
Orack
2 can be userid, 2 can also be a value of x=2
Omair
Hi I am trying to get Stacked In line implemented on a set of foreign keys
Omair
This is the model https://pastebin.com/CjSz41uB
Orack
and Model class has both userid and x as variables
Orack
Maybe pk=2?
pk is some variable right ?
Orack
or primary key ?
Omair
As a single tournament can have a set of (categeory, its price, event_type)
Muflone
pk is an alias for the primary Key field
Orack
then how do we put queries like
Orack
select all instances where scoreof_x=2
Orack
scoreof_x is not pk in my case
Muflone
Describe your models
Orack
https://del.dog/cudapeneno.py
Muflone
What you want to extract?
Orack
same sticker_title
Orack
or same userid
Orack
wtf
Orack
posting image banned here ;-;
Muflone
You want all StickersData with a specific sticker_title value?
Muflone
StickersData.objects.filter(sticker_title='something')
Orack
Oo
Orack
getting this
Orack
url('^stickerlists/<str:title>',CreateViewSticker.as_view() , name = "createsticker"), url pattern is this
Muflone
Hmm DRF, I don't know it enough
Omair
https://del.dog/qisusahuma.rb
You don't have to pass an extra argument 'title' in your generics class
Omair
It can be handled via request and overriding the get_queryset method
Omair
but title isnt my primary key
https://pastebin.com/wU96FXAe somewhat like this
Orack
queryset=request.query_params.get('title')
Orack
i googled this but no module named request
Rohan
Uhmmm, you pass request object in the get method of your APIView class
Omair
and using requests ?
You already defined title in your url pattern and you are using a generics class so request is not needed
Rohan
Yes, you'll be getting that as an argument when you link that class as views to your url
Orack
https://pastebin.com/wU96FXAe somewhat like this
worked 👍👍👍
Orack
what dos this mean
Orack
(?P<subject_teacher>\d+)$',
Omair
(?P<subject_teacher>\d+)$',
I guess regular expression
Muflone
(?P<subject_teacher>\d+)$',
Get a numeric argument and catch it with the name subject_teacher
Alibek
Hello, there. I have a question. I have serailizers, called BoardSerializer, TaskSerializer and JobSerializer, where the main entity is BoardSerializer. It contains (e.g. nested) TaskSerializer. In TaskSerializer there is JobSerializer . So on retrieve of BoardViewSet my context is lost. I use SerializerMethodField, where I make relational stuff with their models
Orack
how can it be modded to work with all
stickerlist/1 stickerlist/2 works but stickerlist/ doesnt
Muflone
Just use two different url map
Muflone
Pointing to the same view
Orack
and why in some cases we pass like <str:title>
Orack
(?P<subject_teacher>\d+)$',
and here using regular expression
Muflone
Not really different, in the first case you match a whole argument, in the second case you use a regex to catch an argument
Muflone
If you had complex arguments like /2-something_20190630
Muflone
It would require you to use regex
Omair
how can it be modded to work with all
You can try conditionals in your get_queryset method to return filtered query set if title has some value else return the whole queryset
Muflone
Using optional parameters within the view
Orack
Just use two different url map
doesnt wiork😂
Omair
doesnt wiork😂
Can you share the error