Skip to content

Instantly share code, notes, and snippets.

View bismitaguha's full-sized avatar
:octocat:
Always learning

Bismita Guha bismitaguha

:octocat:
Always learning
View GitHub Profile
SOCIALACCOUNT_PROVIDERS = \
{
'facebook':
{'SCOPE': ['email', 'publish_stream'],
'AUTH_PARAMS': {'auth_type', 'reauthenticate'},
'METHOD': 'oauth2',
'LOCALE_FUNC': 'path_to_callable'}}
from crontab import CronTab
my_cron = CronTab(user='roy')
job = my_cron.new(command='python /home/roy/writeDate.py')
job.minute.every(1)
my_cron.write()
from django.contrib.gis.geoip2 import GeoIP2
g = GeoIP2()
g.country('google.com')
# {'country_code': 'US', 'country_name': 'United States'}
g.city('72.14.207.99')
# {'city': 'Mountain View',
# 'continent_code': 'NA',
# 'continent_name': 'North America',
# 'country_code': 'US',
# 'country_name': 'United States',
"listen": "test",
"script": {
"id": "b7f93d2c-9352-49fa-b97a-c9299fc0e631",
"exec": [
"if (pm.request.method === 'POST') {",
" pm.test(\"Status code\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([201, 400]);",
" }) ",
"}",
"if (pm.request.method === 'GET') {",
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication',
],
}
from django.urls import path
from rest_framework_simplejwt import TokenObtainPairView, TokenRefreshView
urlpatterns = [
# Other URLs...
path('api/token/', TokenObtainPairView, name='token_obtain_pair'),
path('api/token/refresh/', TokenRefreshView, name='token_refresh'),
]
export SENDGRID_API_KEY=xxxxxxxxxxxxxxxxxxxxxxx
from dotenv import load_dotenv
load_dotenv()
"""
Other settings here
"""
SENDGRID_API_KEY = os.getenv('SENDGRID_API_KEY')
SENDGRID_SANDBOX_MODE_IN_DEBUG = False
SENDGRID_ECHO_TO_STDOUT = True
"""
import statements
"""
class RandomView(views.APIView):
# other functions
def function(self, request, *args, **kwargs):
from django.contrib.auth.tokens import PasswordResetTokenGenerator
class TokenGenerator(PasswordResetTokenGenerator):
"""
Class for generation token for email confirmation
"""
def _make_hash_value(self, user, timestamp):