أمجد☄
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.
أمجد☄
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.
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
Muflone
Procedure to get pycharm professional version
If you maintain an open source project since minimum 3 months you can obtain a professional license for free
Anonymous
https://paste.debian.net/1090811/
أمجد☄
So you already have a workflow 😁 Create a serial code per user and do your checks You can also make a custom permission to protect your view
And how can i check if the key is in a specific model list or not ?, i have created a modelform for the userdisplay and a one for the model list and a user model for registration/login using the one that's usee for the django admin panel but how can i link them together ?, do i have to use a onetoone relationship from the user form to the modelform?, and i want a request to be sent to the admin panel so that if the key is valid the admin is the one who chooses to give the access or not to the user
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
أمجد☄
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
أمجد☄
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
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.
Ook so you have to link a key generated from your SerialCodeModel to a user to check if already exists or not
Mirco
So it's one to one
أمجد☄
Okkkay, and how can i check if its valid or not ?
Mirco
Okkkay, and how can i check if its valid or not ?
If already exists an instance of serial code related to that user and maybe you need a property to check time validity
أمجد☄
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
Am not sure what you mean 😂😅, a decorator ? 🤔
https://www.programiz.com/python-programming/property
أمجد☄
So its validtime=property(valid_from, valid_to) ?
أمجد☄
So its validtime=property(valid_from, valid_to) ?
And then add it to the ExtraAuth model
أمجد☄
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
أمجد☄
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
Hmmm i think this is solved by the lte and gte that i have given to each one of those(valid_form,valid_to) since the ExtraAuth objects can only be taken when its valid i dont think that there's a need for the property.
أمجد☄
Prove me wrong
أمجد☄
"__lte", "__gte"
"__GTE": greater then or equal to, "__LTE": less then or equal to
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
cj
Yes. It was not intentional. Sorry again
can you show your raw SQL query? maybe yes you can pass the result of your property to it
Felipe
can you show your raw SQL query? maybe yes you can pass the result of your property to it
I don't know if I can. It's from company. I'll try to write a similiar example. I need check this @property and I want to retrieve the data only if return True
cj
👍🏻
Felipe
It's something like this
Felipe
https://pastebin.com/ZQ94L7b2
cj
https://pastebin.com/ZQ94L7b2
person.is_active is the property right?, so no, you can't use it that way
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
I think in insert python code using fstring
unless you want to have a big black hole of security vulnerable to SQLi, don't to that
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
cj
Really? I've no idea
yes, never use f-string nor .format() when making SQL queries
Felipe
Good to know, thanks!
cj
Good to know, thanks!
https://realpython.com/lessons/string-formatting-template-strings/
cj
full explaining: https://realpython.com/python-string-formatting/
Felipe
string.Template doesn't have security problems?