أمجد☄
Hello everyone, i just want to know if anyone have any resource or info on how to make a serial code verification system using django, i couldn't find any.
Mirco
أمجد☄
Serial cose of what ?
Its more like a Key verification system, in which the user is prompted to input the key after registration or after logging in if he didnt do it once registered, if the serial code is in the database and is valid the user gonna be redirected and allowed to access a specific view.
أمجد☄
Mirco
Imteyaz
https://combot.org/chat/-1001146340312
Imteyaz
https://stackoverflow.com/questions/56932517/lists-are-not-currently-supported-in-html-input-in-django-rest-api-framework
Imteyaz
This is my problem
And if anyone can fix it
Anonymous
https://paste.debian.net/1090811/
Anonymous
can someone help me with this code error
أمجد☄
Anonymous
AssertionError: 'ContactViewSet' should either include a serializer_class attribute, or override the get_serializer_class() method.
Imteyaz
MD Imteyaz:
https://combot.org/chat/-1001146340312
https://stackoverflow.com/questions/56932517/lists-are-not-currently-supported-in-html-input-in-django-rest-api-framework
This is my problem
And if anyone can fix it
أمجد☄
Imteyaz
Please anyone fix that question I requested all members this group
cj
Mirco
أمجد☄
What do you mean with model list ?
A model in which the keys are registered in through the admin panel for ex:
A model with a key, valid_to, valid_till and an active field, they all add up to produce the key which can be used to verify the userinput which is given to thr ModelForm created using Forms.py.
أمجد☄
أمجد☄
The key model is hidden, to be compared with the modelform
Mirco
أمجد☄
And what the user has to input ?
He have to input a key that is given to a specific user so that he can login and access pages that is made for these type of VIP like people.
أمجد☄
Mirco
Mirco
So it's one to one
أمجد☄
Okkkay, and how can i check if its valid or not ?
أمجد☄
Just tried to paste the code but i think the telegram link got copied too 🤦🏻♂️
أمجد☄
https://pastebin.com/L7bjTbgi
Doragonsureiyā
❎ Oleg pardoned Evil for:
Link to Telegram group or channel (1/3)
Oleg
Maybe it was @login_required
أمجد☄
أمجد☄
https://pastebin.com/L7bjTbgi
I have written this code for key verification i would be thankful if you told my anything that i need to edit or add
Игнат
I want to create a table in which there is an additional field for each field (data source), for example Table Person {first_name, source_first_name, last_name, source_ last_name}, what is the best way to do this?
Mirco
https://pastebin.com/L7bjTbgi
It's better to write a property into ExtraAuth model , for example you can write an is_valid python property that return datetime.now() between valid_start and valid_till
أمجد☄
And thats what i did
أمجد☄
https://pastebin.com/2Dh0K2LJ
Mirco
Yep but you don't have a python property to check time validity instead of doing it into views
Mirco
Do you know what property is ?
أمجد☄
Mirco
أمجد☄
So its validtime=property(valid_from, valid_to) ?
أمجد☄
أمجد☄
And then use it rather then valid_to and valid_from in the is_valid function?
أمجد☄
If not i would like to know how you would implement it.
Mirco
You should just write a method into ExtraAuth model and decorate with @property
Into this method you simply return start_date <= timezone.now() <= till_date
Now when you have an instance of ExtraAuth, you have access to this method that return True or False
أمجد☄
أمجد☄
أمجد☄
Prove me wrong
Felipe
Hey guys!
Doragonsureiyā
❎ cj pardoned Felipe for:
Link to Telegram group or channel (0/3)
cj
Hey guys!
looks like you forgot to put @property as markdown, nvm, I pasted your question the bot deleted
Felipe
Yes. It was not intentional. Sorry again
Mirco
cj
👍🏻
Игнат
Felipe
It's something like this
Felipe
https://pastebin.com/ZQ94L7b2
Felipe
company.is_on
cj
company.is_on
well... it's almost the same, in the WHERE you can't use it that way
Felipe
person.is_active is just a attribute
cj
because .is_on doesn't exists at table level in the DB
Felipe
Is there any way I can fix this?
Felipe
I think in insert python code using fstring
cj
if you really want to do that, use string.Template 🤔
cj
Is there any way I can fix this?
maybe you can make is_on an attribute, and update it with other function before running your raw SQL 🤷🏻♂️ dirty but works
Felipe
Felipe
Good to know, thanks!
cj
full explaining:
https://realpython.com/python-string-formatting/
Felipe
string.Template doesn't have security problems?
cj