Suraj
Need urgent help, facing issues with authentication... please
Doragonsureiyā
Suraj
Not until you explain your difficulties.
I defined everything but it's not able to authenticate user or admin in the login page. But from admin console login is happening
Doragonsureiyā
I defined everything but it's not able to authenticate user or admin in the login page. But from admin console login is happening
Please provide a full explanation including all the details that you consider relevant. Your statement is too broad and there is no clear way to answer you, you have to explain: - what you're doing - what you're expecting - what you're using - where you're running the script - what Python version you're using - what packages and their versions you're using - and the most important thing: show the code YOU wrote (read rule 5️⃣ for that) and more details, that way your chances to get help will increase
Suraj
I have created a basic authentication system using django, running in vscode, 3.10.2 Without pictures, how can I show my code
Doragonsureiyā
I have created a basic authentication system using django, running in vscode, 3.10.2 Without pictures, how can I show my code
To share code or error tracebacks, use a pasting service, like: - https://linkode.org - https://dpaste.org
Suraj
Ok, I'm trying now
Suraj
https://linkode.org/#aGFPnBkrADbI5qtf0pk5G7
Suraj
views.py
Д
Ok, I'm trying now
so your POST params are going through?
Suraj
so your POST params are going through?
Yes, going because i am not getting any error.
Д
Yes, going because i am not getting any error.
nevermind, so the `authenticate`works?
Suraj
Please suggest how to solve this issue
Д
Please suggest how to solve this issue
I don't know what your problem is buddy
Suraj
I don't know what your problem is buddy
Authentication is not happening
Д
Authentication is not happening
which function call is the problem
Д
No such errors
well figure out what function is not doing what it's supposed to
Д
how the hell am I supposed to debug that from here
Suraj
Okay
Николай
👋hi. Help pls. I need create a new field in a queryset, and I calculate this field in my custom function. I need put values from several fields of object in function, calculate and return in a new field. I can't make annotate work with my custom function 😭
Georgiy
Okay
Response pls if you find the solution. Im new to this and it is interesting
o
I have one problem any one can help me
Doragonsureiyā
I have one problem any one can help me
Please provide a full explanation including all the details that you consider relevant. Your statement is too broad and there is no clear way to answer you, you have to explain: - what you're doing - what you're expecting - what you're using - where you're running the script - what Python version you're using - what packages and their versions you're using - and the most important thing: show the code YOU wrote (read rule 5️⃣ for that) and more details, that way your chances to get help will increase
kam
How to share django-pytest database state (e.g. share created testing db objects) during the test and share between different test files? scope = 'session' autouse =True not working for other test files
Suraj
https://linkode.org/#I8M9j9WtlAh0GqQUtyM9Z4
Д
How to share django-pytest database state (e.g. share created testing db objects) during the test and share between different test files? scope = 'session' autouse =True not working for other test files
maybe create a common parent class which inherits from unittest.TestCase which has a setUp method that gets called which sets up the DB, then inherit the testcase classes for both files from that?
Suraj
My issue got resolved, it was an issue with the post method because it was in main and not in form
Suraj
I would like to thank people who responded and tried to help me
kam
maybe create a common parent class which inherits from unittest.TestCase which has a setUp method that gets called which sets up the DB, then inherit the testcase classes for both files from that?
the whole point of using pytest was to avoid using unittest) so ...)) I hoped that there would be some kind of automatic test data tear down. Interestingly, if i use setupdata fixture and then test files in the same testing file, the database state is being preserved. But as soon as I am trying to test database data from setupdata in other testing files i have empty db Using setupdata fixture at conftest is of no help either.
kam
lol I've missed something huge I guess? I've just been using pytest as a test runner but I've been inheriting my TestCases from unittest
Nothing huge, but pytest is more flexible i guess?? And it is a bit more concise. I am just starting out tbh so
Д
I mean I'm writing unittest.TestCases but then running them with pytest. I think that might be what's meant by using pytest?
kam
I mean I'm writing unittest.TestCases but then running them with pytest. I think that might be what's meant by using pytest?
no point in using TestCase, because i can share database inside one test file, which is similar to creating a class with TestCase, but I can not share data across multiple modules and submodules
Д
I just gave you a proposal on how to share the DB between multiple modules\submodules — also I'm not 100% sure if you SHOULD be doing that
Д
you want to share the setup\teardown code that - but not necessarily the DB since the DB is state and state shouldn't really be kept between tests
Ali
guys i deployed my project on python anywhere but when i tried to open it this error is shown("no such table ...") even though there is a table
Ali
what can i do?
Д
do you want me to predict what the problem is
Д
the problem is: production has different names for Tables than dev OR the migrations were never properly run
Suraj
What's the reason - both worked-please check the code in the link-
Suraj
https://linkode.org/#vPOfrxC5vl4XAW01FsmrA
Ali
protip: follow the error message
File "/home/syy/env/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 477, in execute return Database.Cursor.execute(self, query, params)
Ali
i am using sqlite
Ali
can this be the problem?
Saadi
Hello! I have a react registration and Login form. Without using django rest framework, how i can make class based views in django to register user and login. Anyone have source code on this or any good solution?
Vikash
Saadi https://learndjango.com/tutorials/django-signup-tutorial
Tao
I've been operating on a data.json file as my "database" and am now trying to import it into a real database. I *think* the best way of doing that is with the native JSONField type but am returning errors with the following code: import json from importlib import resources with resources.open_text("little_bits_of_buddha", "data.json") as json_file: data = json.load(json_file) from django.db import models class Collection(models.Model): models.JSONField(data) which returns RuntimeError: Model class __main__.Collection doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. I do have my app named main in settings.py: INSTALLED_APPS = [ "main.apps.MainConfig", What am I doing wrong?
W3
IntegrityError at /reading/add-info/ null value in column "user_id" violates not-null constraint DETAIL: Failing row contains (20, title, hello, 2022-04-07 18:03:25+00, apt, null). HELP ME PLEASE
Andrej
IntegrityError at /reading/add-info/ null value in column "user_id" violates not-null constraint DETAIL: Failing row contains (20, title, hello, 2022-04-07 18:03:25+00, apt, null). HELP ME PLEASE
You are trying to add a row. You have one NULL value defined for that insert, but your table structure tells you that for this attribute / column NULL is not allowed.
Andrej
The user_id is not set.
Joseph
Mind sharing the logic?
You do it using views plus crud operations of the database
Anonymous
Guys, can I have multiple Primary Keys and multiple Foreign Keys?
Fan / Ac
Yes
In sql a table can only have one primary key
Charly
In sql a table can only have one primary key
He never said in the same table
Georgiy
Guys, can I have multiple Primary Keys and multiple Foreign Keys?
Primary key is a thing that makes unique certain record in your table. Relational database should have 1 PK in table. Im not sure how it works in django but you can even create compositive pk, which takes some attributes (not one) in order to make a record unique
Anonymous
Guys, when doing global templates structure, is it the right way to attach the templates folder in settings.py?: DIRS = [BASE_DIR / "templates"]
Rafaela
anyone wanna code with me? too bored to code alone :(
Santosh Reddy
pikachu
hello,I have a django JSONField(django.db.models) model, that has some data like this [{'k':[1,2]},{'k':[2,3]}], how can i search 2 in data use django orm ?
Suraj
Can u share the corrected code now
It was the post method. Earlier it was in main div and i later changed to form div.
Doragonsureiyā
anyone wanna code with me? too bored to code alone :(
This is neither a job board nor a bulletin board.
EDEN
How to change db sqllite to postgres
Doragonsureiyā
How to change db sqllite to postgres
These single steps will help you a lot: Step 1️⃣: Open a browser Step 2️⃣: Write down https://google.com or https://duck.com and press Enter Step 3️⃣: In the search box, write down the same words you asked here Step 4️⃣: Read the first results
NNB
How to change db sqllite to postgres
Same place ,comment the dB sqllite, add postgress parameters (assuming you have the dB before hand) make sure the port is postgress . All this is available on Google
Andrej
Andrej, what should I do I looked through the code and did not understand what to change
You could add the user_id in that insert or you could change the column structure to allow null values for that attribute. Add the null=True attribute.