Mirco
Saurabh
I am also confusing here, i tried everything but I don't know where is problem.
Saurabh
len just a example but I am not able to do anything with this queryset. It showing same error.
Alex
Saurabh
Okay.
Danilo
Hi guys, i have a def validate_email(self, value): in a serializer of type ModelSerializer and he is not called, this field it was declarated in the fields array as well, i need validate this email if is empty to raise an exception
Alex
Bernard
hi guys how to get started with Django?
Bernard
how to get Django
Dillag
Write your first shop,
so you will learn everything you need to get started
Dillag
for example now I write my vapeshop, because I know a lot about vape
Dillag
just choose a topic you are good at
Mirco
Doragonsureiyā
how to get Django
Looking for Django tutorials? you can follow these three recommended ones:
* Official documentation and tutorial
* Tutorial from MDN
* Tutorial from django-girls
Eugene
Hey,guys.
What would you say about separating HTML and static files in different apps
Eugene
?^^
Eugene
Is it a good practice to do that ?
Bernard
Daniil
Bernard
Anonymous
guys, I need a hand, I got some problem when I wanna try to POST data from Reactjs to Django API that I made. and this is the error, it's about cors
"Access to XMLHttpRequest at 'http://127.0.0.1:8000/categories' from origin 'http://localhost:3000' has been blocked by CORS policy"
and this is my setting.py
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_METHODS = [
'DELETE',
'GET',
'OPTIONS',
'PATCH',
'POST',
'PUT',
]
CORS_ALLOW_HEADERS = [
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"http-x-csrftoken",
"x-csrftoken",
"x-requested-with",
# ]
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_HTTPONLY = True
CSRF_TRUSTED_ORIGINS = ['http://127.0.0.1:3000']
it's been 2 days😭🙏🏻
Anonymous
Eugene
I meant apps
Eugene
Eugene
Not folders dude
HamidReza Fekri
hi i use postgres sql for my project i want to have another database for my models only for some spacial fields how can i have logical foreign key to mongodb
5P34R
guys, I need a hand, I got some problem when I wanna try to POST data from Reactjs to Django API that I made. and this is the error, it's about cors
"Access to XMLHttpRequest at 'http://127.0.0.1:8000/categories' from origin 'http://localhost:3000' has been blocked by CORS policy"
and this is my setting.py
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_METHODS = [
'DELETE',
'GET',
'OPTIONS',
'PATCH',
'POST',
'PUT',
]
CORS_ALLOW_HEADERS = [
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"http-x-csrftoken",
"x-csrftoken",
"x-requested-with",
# ]
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_HTTPONLY = True
CSRF_TRUSTED_ORIGINS = ['http://127.0.0.1:3000']
it's been 2 days😭🙏🏻
have u added the cores middleware ?
Anonymous
5P34R
Mirco
guys, I need a hand, I got some problem when I wanna try to POST data from Reactjs to Django API that I made. and this is the error, it's about cors
"Access to XMLHttpRequest at 'http://127.0.0.1:8000/categories' from origin 'http://localhost:3000' has been blocked by CORS policy"
and this is my setting.py
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_METHODS = [
'DELETE',
'GET',
'OPTIONS',
'PATCH',
'POST',
'PUT',
]
CORS_ALLOW_HEADERS = [
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"http-x-csrftoken",
"x-csrftoken",
"x-requested-with",
# ]
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_HTTPONLY = True
CSRF_TRUSTED_ORIGINS = ['http://127.0.0.1:3000']
it's been 2 days😭🙏🏻
Yeah the same for you
The Middleware
Mirco
guys, I need a hand, I got some problem when I wanna try to POST data from Reactjs to Django API that I made. and this is the error, it's about cors
"Access to XMLHttpRequest at 'http://127.0.0.1:8000/categories' from origin 'http://localhost:3000' has been blocked by CORS policy"
and this is my setting.py
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_METHODS = [
'DELETE',
'GET',
'OPTIONS',
'PATCH',
'POST',
'PUT',
]
CORS_ALLOW_HEADERS = [
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"http-x-csrftoken",
"x-csrftoken",
"x-requested-with",
# ]
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_HTTPONLY = True
CSRF_TRUSTED_ORIGINS = ['http://127.0.0.1:3000']
it's been 2 days😭🙏🏻
And the settings is changed
Read the repository README
The TRUSTED ORIGINS is deprecated in favour of the new one called CORS_ALLOWED_ORIGINS
Anonymous
I've defined it like this
CORS_ALLOWED_ORIGINS = ['http://127.0.0.1:3000']
but it doesnt work,
Saurabh
guys, I need a hand, I got some problem when I wanna try to POST data from Reactjs to Django API that I made. and this is the error, it's about cors
"Access to XMLHttpRequest at 'http://127.0.0.1:8000/categories' from origin 'http://localhost:3000' has been blocked by CORS policy"
and this is my setting.py
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_METHODS = [
'DELETE',
'GET',
'OPTIONS',
'PATCH',
'POST',
'PUT',
]
CORS_ALLOW_HEADERS = [
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"http-x-csrftoken",
"x-csrftoken",
"x-requested-with",
# ]
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_HTTPONLY = True
CSRF_TRUSTED_ORIGINS = ['http://127.0.0.1:3000']
it's been 2 days😭🙏🏻
Everything is fine from your side. Need to change headers from react side. I also faced same issue.
HRITIK
In my prod model if I remove constructor function it is showing no error otherwise it is showing error that init fun can't take more than 1 positional arguments
HRITIK
Plz explain
HamidReza Fekri
hi i use postgres sql for my project i want to have another database for my models only for some spacial fields how can i have logical foreign key to mongodb
HRITIK
https://dpaste.org/N4xO
HRITIK
Here is my code
In my prod model if I remove constructor function it is showing no error otherwise it is showing error that init fun can't take more than 1 positional arguments
Maxim
try to add CORS_ORIGIN_WHITELIST with same as in CORS_ALLOWED_ORIGINS value
Anonymous
same result sir, doesnt work
HamidReza Fekri
HRITIK
Plz help me
Anonymous
Margavya
Anyone here is having Django Ecommerce project with MySQL database?
HamidReza Fekri
HamidReza Fekri
Tell your problem
hi i use postgres sql for my project i want to have another database for my models only for some spacial fields how can i have logical foreign key to mongodb
Anonymous
HamidReza Fekri
yes
Anonymous
yes
But if I may ask, is that a good design philosophy?
Charly
Doragonsureiyā
hey newly I start django and i have problem can you help me ?????
Don't ask meta questions like:
"Any user of $x here?"
"Anyone used technology $y?"
"Hello, I need help on $z!"
Just ask directly! The better you are at explaining the problem, the more likely you are to get help.
Asking smart questions
HamidReza Fekri
@fishworm yes the reason that I want to do this increase speed of product filter by properties
Seth
hi guys, how could I submit a form that has your data and also several dependent foreignkey?
Anonymous
HamidReza Fekri
@fishworm thank but can you please tell me what exactly google
HamidReza Fekri
@fishworm thank you so so much🙏🙏🙏
Saurabh
HRITIK
https://dpaste.org/N4xO
In my prod model if I remove constructor function it is showing no error otherwise it is showing error that init fun can't take more than 1 positional arguments
Rushikesh
How can I remove seconds 10:20:00 from this time format in django Timefield to display as 10:20
Ihor
hi! how can i build a query like this? django orm`s
SELECT * FROM (
SELECT * FROM TABLE
) AS TMP
WHERE ROW = n
Ranken
Can filter() and aggregrate() methods be used together???.... If yes please show me a snippet
Ihor
SELECT *
FROM (
SELECT "accounts_seller"."id" as "id",
"accounts_seller"."user_id" as "user_id",
CONCAT("accounts_user"."first_name", CONCAT("accounts_user"."last_name")) AS "full_name",
"accounts_userbalance"."total_points" AS "points",
ROW_NUMBER() OVER (ORDER BY "accounts_userbalance"."total_points" DESC) AS "number"
FROM "accounts_seller"
INNER JOIN "accounts_user" ON ("accounts_seller"."user_id" = "accounts_user"."id")
LEFT OUTER JOIN "accounts_userbalance" ON ("accounts_user"."id" = "accounts_userbalance"."user_id")
) as "top"
WHERE user_id = ''
// OR
LIMIT 100
Ihor
qs = (self.model.objects
.select_related('user', 'shop_address', 'user__balance')
.annotate(full_name=Concat('user__first_name', Value(' '), 'user__last_name'),
city=F('shop_address__city__name'),
points=F('user__balance__total_points'))
.annotate(number=Window(expression=RowNumber(), order_by=F('points').desc())))
need filter or limit
Ihor
I can use raw(sql) but I want orm
Jitendra Kumar
How to make a dynamic website?
Jitendra Kumar
Using Django framework
P.
Daniel
rsrs
Seth
Hi, How could I have more than two drop down dependents?
Igor'
Hey! How can I test reverse_lazy in CreatView using TestCase?
My code:
def test_my_method(self):
client = Client()
response = client.post('/add_income')
self.assertRedirects(response, 'main_page', status_code=301)
But I get error:
AssertionError: 200 != 301 : Response didn't redirect as expected: Response code was 200 (expected 301)