Manish
ok
Ashish
Hi
Mr. Rude
Hi
Manish
hey
Mirco
Anonymous
Anonymous
inchidi
english only please
-
Hi. Drf. I have modelserialize for django user, and when I do path request with same username, I got validation error, for unique field. How to ignore this in patrial update if username have not change?
inchidi
-
@Inchidi class UserSerializer(ModelSerializer):
class Meta:
model = User
fields = ('pk', 'username', 'first_name', 'last_name', 'middle_name',
'email', 'password')
extra_kwargs = {
'password': {
'write_only': True,
},
}
class EmployeeSerializer(ModelSerializer):
user = UserSerializer()
class Meta:
model = Employee
fields = ('user', 'birth_date', 'address', 'passport_serial',
'passport_number', 'identifing_code', 'phone_corp',
'phone_private', 'phone_ate', 'department', 'pk')
-
@Inchidi I have smthing like profile, I want to do udpate of it, but when I send same username, I have error with unique validation. I know that I need change validators of username field, but I need only to off it in patch request ( when partial = True)
Luis
I remember you can write create and update method
Luis
Please, read rest framework docs
inchidi
@Inchidi class UserSerializer(ModelSerializer):
class Meta:
model = User
fields = ('pk', 'username', 'first_name', 'last_name', 'middle_name',
'email', 'password')
extra_kwargs = {
'password': {
'write_only': True,
},
}
class EmployeeSerializer(ModelSerializer):
user = UserSerializer()
class Meta:
model = Employee
fields = ('user', 'birth_date', 'address', 'passport_serial',
'passport_number', 'identifing_code', 'phone_corp',
'phone_private', 'phone_ate', 'department', 'pk')
class UserSerializer(ModelSerializer):
username=serializers.CharField(validators=[]) # try do this
class Meta:
...
extra_kwargs = {
'password': {'write_only': True},
'username':{'validators': []} # or this
}
-
@Inchidi or this dont wotk
-
@Inchidi and first too
inchidi
then the first one
-
@Inchidi https://medium.com/django-rest-framework/dealing-with-unique-constraints-in-nested-serializers-dade33b831d9
inchidi
why it doesnt work?
-
@Inchidi coz, I need remove validators of field
inchidi
-
@Inchidi but its not what I wanted, anyway... I need just if username is same as in instance, pass it and dont try even to change
-
@Inchidi mb I will write my own validator =\ Wanted more explicit solution.
inchidi
-
I mean if partial for serializer. I make patch request within ModelViewset ( he makes partial=True for serializer). And here, I donw want to validate it...
inchidi
at this this point i guess you are using your serializer in the wrong way
-
hm, so, I just wil not send this field if it have not changed
Сергей
Hi, can i rollback last changes in sqlite3 by time?
Anonymous
https://dpaste.de/6bDA
inchidi
inchidi
Сергей
If I want rallback on 5 hours, how can I do it?
Сергей
Manish
Manish
@sdkca986 remove 1 tab space from args and return render which is after else block in line 13 and 14
Manish
@sdkca986 https://dpaste.de/o2Qs your fix
Anonymous
when i submit the form ,form.is_valid() is false so i can't save the
Anonymous
user
N S
Can someone give me a guide to deploy django project using nginx and gunicorn
Rajjix
tutorials are all out there but if you’re willing to give me access i’ll do jt for you
Anders (izzno / gooood) 🇳🇴
Anders (izzno / gooood) 🇳🇴
You might know this but i was so impressed with how easy this was today...
Anders (izzno / gooood) 🇳🇴
Build an api and populate a db in less than an hour... I wish i knew django years ago...
Rajjix
check out faker it’s great in filling up your db with data
Rajjix
It does it’s a full library made just for that you just pick what kind of data from username to phone mumbers in many different formats and makes your data look somehow real
Anders (izzno / gooood) 🇳🇴
Ill have a look thanks.
Anders (izzno / gooood) 🇳🇴
(By formats i mean i can get the data in different formats which needs to be imported in a db, xls, csf, csv .... etc
Rajjix
https://github.com/joke2k/faker
Rajjix
Anders (izzno / gooood) 🇳🇴
problem: I have to create an api for a php developer on windows and i have a few options and was wondering if you can one up me.
Option 1: Create a dockerimage and ask him to install and learn docker
Option 2: Create a Hyper-V image and ask him to run that
Option 3: Create a VirtualBox and ask him to run that
The idea is that he utilizes my api/db. Any easier suggestions for a windows dev env?
(And no, labserver, lxc is not an option)
R
Rajjix
Good man 😀
The Nginx proxy_pass worked fine, only problem my api still had to be part of my url, just now when checking my browser console, i realized CORS was the initial problem not allowing me to do GET requests, django-cors-headers solved it
Mirco
Anonymous
Hello. Started to learn Django. Need help with putting a result of linux command ls -l to django template. How can I do it ? please see the code here https://dpaste.de/9TTo
George
Anonymous
{{ cmd }} this helped but now need to convert somehow to human readable format
Anonymous
now I have <subprocess.Popen object at 0x7fed0d6b85f8> in html
George
Maybe you could stringify it
George
Str(cmd)
Anonymous
Hi, Someone have this ebook to share? 🙂
https://djangoforbeginners.com/
Rajjix
https://wsvincent.com/
Anonymous
Anonymous
like that maybe ? I tried several ways but doesn't work https://dpaste.de/83qZ
George
Anonymous
stringify is not defined
George
Vladyslav 🇺🇦🇪🇺
Anybody know, how i can send messages from telegram bot to my channel with inline buttons?
Anonymous
thanks George, I'll try to figure this out
Rajjix
Rajjix
rez = cmd.communicate()
Rajjix
George
I did once to communicate between bash scripts with the name of processes to kill for example