Azerbaijan Python Users Group
mendeki ayarlar beledir:
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework_simplejwt.authentication.JWTAuthentication",
],
}
class UserLoginApiView(APIView):Читать полностью…
permission_classes = [AllowAny]
serializer_class = UserLoginSerializer
def post(self, request):
serializer = UserLoginSerializer(data=request.data)
if serializer.is_valid():
email = serializer.validated_data.get("email")
password = serializer.validated_data.get("password")
user_obj = get_object_or_404(
User.objects.select_related(), email__iexact=email
)
if user_obj.check_password(password):
activation_window = timedelta(hours=72) # 72
time_since_creation = timezone.now() - user_obj.created_at
if time_since_creation > activation_window:
user_obj.is_active = False
user_obj.save()
return Response(
{
"error": "Activation window expired. Account is now inactive."
},
status=status.HTTP_401_UNAUTHORIZED,
)
# Generate an access token for the authenticated user
access_token = AccessToken.for_user(user_obj)
# Serialize the user data for the response
data = UserLoginSerializer(user_obj).data
nationality_status = 1 if user_obj.profile.nationality else 0
data["nationality_status"] = nationality_status
return Response(
{
"status": status.HTTP_200_OK,
"data": data,
"token": str(access_token),
},
status=status.HTTP_200_OK,
)
else:
# Return an error response if authentication fails
message = "Email or Password is incorrect"
return Response(
{
"message": message,
"status": status.HTTP_401_UNAUTHORIZED,
},
status=status.HTTP_401_UNAUTHORIZED,
)
else:
# Return an error response if the input data is invalid
return Response(
{
"error": "Bad Request",
"status": status.HTTP_400_BAD_REQUEST,
},
status=status.HTTP_400_BAD_REQUEST,
)
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_PERMISSION_CLASSES':
'rest_framework.permissions.IsAuthenticated',
],
}
Google cloud kim istifade edib? bir api servisini istifade edirem, error verir ki, quota exhausted. OK, deyirem girib artirilmasi ucun muraciet edim, amma regionumu tapa bilmirem, duzu bilmirem hansi regiondan etmeliyem. onu men nece bile bilerem ?
Читать полностью…Əgər superuser olduğunu yoxlamağı nəzərdə tutursunuzsa request.user.is_superuser' dən istifadə edə bilərsiniz
Читать полностью…Salam.
Yoldashlar,backende django, front terefde react var. React terefde login olan superuseri djangonun oz admin paneline daxil olmasini nece saglaya bilerem? Token return eden zaman bele yontem istifade edirem amma session set olmur.
from django.contrib.auth import authenticate, loginЧитать полностью…
user = authenticate(request, email=email, password=password)
if user:
login(request, user)
https://gauge-sh.github.io/tach/strict-mode/
Читать полностью…litestar olan starlite-di bu?
men Sanic istifade edirem, async ishler ucun. Fastapi reklami ile basmamishdan qabaq var idi)
https://sanic.dev/en/
Salamlar hamiya, Movzuden kenar bir xahisim olacaqdi. Tech AI hackathonu ucun bizim komandaya ml ve ya data scientist lazimdir. Kim bizim komdaya qosulmaq isteyer? Ve ya meslehet bileceyiniz adam varsa zehmet olmasa yonelde bilersiz?
Читать полностью…User modelinde USERNAME_FIELD kimi bir atribut olmalidi djangoda
Читать полностью…Auth 2 ni deyirsiz ya hansi authentication sistemk
Читать полностью…Django-da User Telefon nömrəsi və Şifrə ilə login olursa, Username-i elə telefon nömərsinə bərabər etmək daha yaxşı olar yoxsa, ayrıca Phone number model-i yaradıb onunla auth etmək?
Читать полностью…Generative ai və produktivlik haqqında danışmışam
Читать полностью…Salamlar. Kamil Alasgarov paylaşıb. 3 vakansiya. 1 Django
https://www.facebook.com/share/BPBCH5PUYvCGjjPS/?mibextid=oFDknk
Xüsusilə "rest_framework.authentication.TokenAuthentication" aktiv olmalıdır
Читать полностью…settings.py'deki konfiqurasiyaları etmisiniz?
Читать полностью…Xeyr, lori dilde desek client drfde yazilan apiden login olanda hemcinin djangonun oz auth sistemine de auth olmus olsun.
Читать полностью…Django 5.1 release page-de baxanda mene en maraqli gelen feature qeyd etmeyibler: connection pooling pyscopg ile.
https://docs.djangoproject.com/en/dev/releases/5.1/#postgresql-connection-pools
pycopg2 ve 3 her ikisinde connection pooling varmis. Her zaman external connection pool extension (PgBouncer) istifade etmeye ehtiyaciniz olmasa da bu pyscopg-den faydalanmaq olar
https://www.psycopg.org/psycopg3/docs/advanced/pool.html
https://micro.webology.dev/2024/05/22/whats-new-in.html
Читать полностью…bilmeyenler bilsin, google Gemini ucun yarish edir. emelli udush meblegleri var
Читать полностью…Çoxdandır fikrimdə olan, Azərbaycan dilində LLM-lər və transformerlər haqqında kitaba nəhayət başlamışam. Əminəm ki, əsas prinsiplərdən başlayaraq, Böyük Dil Modellərinin dərinliklərinə qədər gedəcək bu kitab həm təcrübəli mütəxəssislər, həm də yeni başlayanlar üçün dəyərli bir qaynaq olacaq.
Bir hissəsini bitirdiyim bu kitabın yazılmasında məqsəd, bu sahədə özünü inkişaf etdirmək istəyənlərə dəstək olmaq və Azərbaycan dilində bilik bazasını genişləndirməkdir.
Ödənişsiz olan “azLLMbook”-un linki: azllmbook.nijatzeynalov.com
https://apitally.io/blog/what-makes-a-good-rest-api
Читать полностью…Ora phone_numberi yazib yoxluyun gorun alinir
Читать полностью…Jwt falandisa custom class yazmalisiz authentication classi settingsdede bilditmek lazim
Читать полностью…username-i telefon nömrəsinə bərabər etmədikdə isə auth məndən username istəyir. onu costum edib dəyişmək olur amma yenə də kodu qarmaşıqlaşdırır
Читать полностью…Salam 👋
Bugün Bakı vaxtı ilə saat 13:40 ərəfəsində PyCon Italy 2024 -da "Building a self-service kubernetes platform for python developers" mövzusunda çıxış edəcəm.
Mövzu haqqında ətraflı məlumat: https://2024.pycon.it/en/event/building-a-self-service-kubernetes-platform-for-python-developers
PyCon Italy 2024 YouTube üzərindən canlı yayımlanır. Mənim çıxışım "Tagliatelle" otağında olacaq.
Izləmək üçün: pythonitalia?si=gpfsSmDw70kpzdGu" rel="nofollow">https://youtube.com/@pythonitalia?si=gpfsSmDw70kpzdGu