.
i add session auth and its works
No, you are not using tokenauth
.
Install Postman
.
It is not "log in" action in REST
.
You deliver token and should place it in every request that has IsAuthenticated permission
Izzati
Install Postman
okay i'll try
.
Or you can use curl
.
For test
inchidi
or with python import requests headers= {'Authentication': 'Token <your token here>'} response = requests.get('http://url.to/your/api', headers=headers)
Luis
Hi! How can I create a seed for some tables that not change using insert command?
Just create empty migrations file and edit it this way: https://docs.djangoproject.com/en/2.1/ref/migration-operations/#runpython
Izzati
Install Postman
i install postman and the output is
Izzati
{ "token": "f7014ad4bb7a6c68b44be6c3f7bcb87a81a428e9" }
.
wait a minute
cj
please use English in this group, thanks.
Dmitriy
oh sorry
Hokage
I am getting Type Error: can't compare datetime.datetime to datetime.date and I am using timezone.now() - datetime.timedelta(days=1) . Any ideas?
Hokage
https://pastebin.com/k2aGrF9m
Mirco
https://pastebin.com/k2aGrF9m
Remove the timestamp()
Hokage
Remove the timestamp()
Its not working without it as well.
cj
I tried and that worked for me the way it is🤔
cj
https://i.imgur.com/J9YZQoT.png
cj
lol
cj
I see what's the problem
cj
self.pub_date is a DateField, whereas a Date value while the other value is a DateTime value
Mirco
Its not working without it as well.
You have a DateField and you're trying to compare it with a datetime
Mirco
Lol 🤣
cj
lol 🤣🤣🤣
cj
stop stealing my words, you 🤣
Mirco
🤣🤣🤣
Hokage
Well so what do I do??
Anonymous
cj
Well so what do I do??
cast the DateTime to a Date only value
cj
or use a DateTime field
Hokage
Thanks for the help.
Hokage
I changed to DateTimeField and now I am getting a different error @iFlare3G @c0x6A
Hokage
'>=' not supported between instances of NoneType and datetime.datetime
Hokage
The code is still same except I changed the field of pub_date to Datetime
cj
that's why you're getting NoneType
Hokage
So what do I do?
cj
So what do I do?
you need to fill data to your DB first
cj
save data to your models
Ghorz
Plagiarism alert
Python is plagiarism itself, import this, import that. It's all copycat
888
How to deploy Django app to web server?
inchidi
https://docs.djangoproject.com/en/2.0/howto/deployment/
Anonymous
help
Anonymous
https://www.reddit.com/r/djangolearning/comments/atq2km/i_can_not_save_an_object_related_to_the_user/
Luis
'>=' not supported between instances of NoneType and datetime.datetime
First check your filtering condition. It's not returning rows from your DB. Then: >= is not supported Use myField__gte=datetimeObjHere
ʚɞÇherry Łoveʚɞ
Are there any way to extend a model from a django external library ?
ʚɞÇherry Łoveʚɞ
third-party package i mean.
inchidi
third-party package i mean.
which package which model?
ʚɞÇherry Łoveʚɞ
which package which model?
any package as a django-app and must be run migrate command to use.
inchidi
but basically only if the model have Meta().abstract=True
inchidi
ok. I see.
cmiiw (you can just try it), if its not abstract model and you extends it, it will work, but you'll have 2 table. the one from package and your custom
Rajesh
How will be the kivy for barcode scanning app
Le Createur
Hi suppose i have this model class Student(models.Model): name = models.CharField(max_length=20) joined = models.DateTimeField() user = models.OneToOneField(User) mentor = models.ForeignKey(Professor, models.DO_NOTHING) courses = models.ManyToManeField(Course) how to determine the correct class field of each Field ?? like knowing that Student.name is a models.CharField. All solutions are welcome but i prefer the solution where i don't instanciate the model. for a field that is a relation like OneToOne, ForeignKey and ManyToMany how to know the referenced Model ??
Le Createur
Study better databases theory
it is supposed to be a help here ? i don't want to query the database for the schema and all. it is time consuming. how Django does it? i read ModefForm because it is something like that i want to achieve but i don't understand the code well. surely i need to read other part of the framework to understand
Le Createur
First study how databases work , how to define entities and relationships Then study Django ORM
man i know how to handle database manually defining entities and relationships. please read well my problem. let me emphase it you I don't want to query the database for the schema because for a model field the sgbd could save it in differents column types
Mirco
Yep, you can know a class using __class___
Guillermo
@jefcolbi for foreign keys and many to many, the attrib related_model of the fields has the info you want
Anonymous
Goodyear Morning, I have a site deployed Andrés tried todo add a form with ckeditor.all workshop Gine, butcher as longitud as I try yo add an image they server complaints that i AM kot allowed yo write ir tras un that área (Nginx static folder). Once i Fix the path it sa ys that therevid a soudpicous filete path outside Django static folder. Have anyone experienced this issue.
Anonymous
Damned spell correction.
Anonymous
Excuse me.