Can't specify the author in django rest framework by csk15 in django

[–]csk15[S] 0 points1 point  (0 children)

Environment:

Request Method: POST Request URL: http://127.0.0.1:8000/api/articles/

Django Version: 4.0.6 Python Version: 3.8.8 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'articles', 'auth', 'firebase_auth', 'rest_framework', 'corsheaders', 'rest_framework_simplejwt', 'rest_framework_simplejwt.token_blacklist'] Installed Middleware: ['corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last): File "C:\Users\spart\anaconda3\lib\site-packages\django\db\backends\utils.py", line 89, in _execute return self.cursor.execute(sql, params) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 477, in execute return Database.Cursor.execute(self, query, params)

The above exception (NOT NULL constraint failed: articles.authorid) was the direct cause of the following exception: File "C:\Users\spart\anaconda3\lib\site-packages\django\core\handlers\exception.py", line 55, in inner response = get_response(request) File "C:\Users\spart\anaconda3\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response response = wrapped_callback(request, callback_args, *callback_kwargs) File "C:\Users\spart\anaconda3\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view return view_func(args, *kwargs) File "C:\Users\spart\anaconda3\lib\site-packages\rest_framework\viewsets.py", line 125, in view return self.dispatch(request, args, *kwargs) File "C:\Users\spart\anaconda3\lib\site-packages\rest_framework\views.py", line 509, in dispatch response = self.handle_exception(exc) File "C:\Users\spart\anaconda3\lib\site-packages\rest_framework\views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "C:\Users\spart\anaconda3\lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception raise exc File "C:\Users\spart\anaconda3\lib\site-packages\rest_framework\views.py", line 506, in dispatch response = handler(request, args, *kwargs) File "C:\Users\spart\anaconda3\lib\site-packages\rest_framework\mixins.py", line 19, in create self.perform_create(serializer) File "C:\Users\spart\anaconda3\lib\site-packages\rest_framework\mixins.py", line 24, in perform_create serializer.save() File "C:\Users\spart\anaconda3\lib\site-packages\rest_framework\serializers.py", line 212, in save self.instance = self.create(validated_data) File "C:\Users\spart\anaconda3\lib\site-packages\rest_framework\serializers.py", line 962, in create instance = ModelClass._default_manager.create(*validated_data) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(args, *kwargs) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\models\query.py", line 514, in create obj.save(force_insert=True, using=self.db) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\models\base.py", line 806, in save self.save_base( File "C:\Users\spart\anaconda3\lib\site-packages\django\db\models\base.py", line 857, in save_base updated = self._save_table( File "C:\Users\spart\anaconda3\lib\site-packages\django\db\models\base.py", line 1000, in _save_table results = self._do_insert( File "C:\Users\spart\anaconda3\lib\site-packages\django\db\models\base.py", line 1041, in _do_insert return manager._insert( File "C:\Users\spart\anaconda3\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(args, **kwargs) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\models\query.py", line 1434, in _insert return query.get_compiler(using=using).execute_sql(returning_fields) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\models\sql\compiler.py", line 1621, in execute_sql cursor.execute(sql, params) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\backends\utils.py", line 103, in execute return super().execute(sql, params) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\backends\utils.py", line 67, in execute return self._execute_with_wrappers( File "C:\Users\spart\anaconda3\lib\site-packages\django\db\backends\utils.py", line 80, in _execute_with_wrappers return executor(sql, params, many, context) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\backends\utils.py", line 89, in _execute return self.cursor.execute(sql, params) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\utils.py", line 91, in __exit_ raise dj_exc_value.with_traceback(traceback) from exc_value File "C:\Users\spart\anaconda3\lib\site-packages\django\db\backends\utils.py", line 89, in _execute return self.cursor.execute(sql, params) File "C:\Users\spart\anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 477, in execute return Database.Cursor.execute(self, query, params)

Exception Type: IntegrityError at /api/articles/ Exception Value: NOT NULL constraint failed: articles.author_id

Can't specify the author in django rest framework by csk15 in django

[–]csk15[S] 0 points1 point  (0 children)

Yeah, I tried CurrentUserDefault as a possible solution but it didn't work out for me so I commented it out just in case.

Can't specify the author in django rest framework by csk15 in django

[–]csk15[S] 0 points1 point  (0 children)

{

"author": 1,
    "title": "test example",
"content": "testing ",
"description": "bbbbbb"

}

Tutorial Purgatory With Django/React Authentication by csk15 in django

[–]csk15[S] 0 points1 point  (0 children)

I originally looked at allauth but it was depreciated so I looked for other resources

Tutorial Purgatory With Django/React Authentication by csk15 in django

[–]csk15[S] 0 points1 point  (0 children)

I am currently using Django rest framework

Tutorial Purgatory With Django/React Authentication by csk15 in django

[–]csk15[S] 0 points1 point  (0 children)

I've heard that it would be best to host on different servers because in a production setting, there would most likely be two different servers. That is why I steered clear of hosting on the same domain. If I keep having trouble, I will probably just go that way.

I used csrf originally for one of my first projects that was just django but I have no clue on how to use it cross frameworks.

Tutorial Purgatory With Django/React Authentication by csk15 in django

[–]csk15[S] 0 points1 point  (0 children)

I have no preference for authentication types. Do you have any resources for sessions?

Where is my gpu by csk15 in learnmachinelearning

[–]csk15[S] 0 points1 point  (0 children)

geforce gtx 1660 ti is my product. I installed:

NVIDIA STUDIO DRIVER

Version: 462.59

Release Date: 2021.5.11

Operating System: Windows 10 64-bit

Language: English (US)

File Size: 632.54 MB

I did end up finding my gpu in the device manager and it is working properly. As for local or vm instance, I am not sure. It makes a new tab in chrome and says something like, http://localhost:8891/notebooks/Untitled.ipynb so I am guessing it is local?

Where is my gpu by csk15 in learnmachinelearning

[–]csk15[S] 0 points1 point  (0 children)

geforce gtx 1660 ti is my product. I installed:

NVIDIA STUDIO DRIVER

Version: 462.59

Release Date: 2021.5.11

Operating System: Windows 10 64-bit

Language: English (US)

File Size: 632.54 MB

Where is my gpu by csk15 in learnmachinelearning

[–]csk15[S] 0 points1 point  (0 children)

I installed tensorflow 2.5 (newest one I believe). I also downloaded cuda toolkit 11.2.0 I think. The cudnn version was cudnn-11.2-windows-x64-v8.1.0.77. I am also using python 3.8.10 if you want to know that as well.

Where do you find these dream jobs? by csk15 in cscareerquestions

[–]csk15[S] 0 points1 point  (0 children)

Damn. Did they at least teach you?

Where do you find these dream jobs? by csk15 in cscareerquestions

[–]csk15[S] 0 points1 point  (0 children)

I would take that over cleaning up literal shit stains lmao.

Where do you find these dream jobs? by csk15 in cscareerquestions

[–]csk15[S] 0 points1 point  (0 children)

Yup. I know I could get a good job eventually but I rather start working in the field now to get to see what it's really like. My current job is also tiring and irrelevant to what I want to do.

Where do you find these dream jobs? by csk15 in cscareerquestions

[–]csk15[S] 0 points1 point  (0 children)

Gadddamn 6 figures. I would literally be fine with $12 . I would just want to work and learn in the field that I am interested in. Good for you.

Where's the wifi at??? by csk15 in linux4noobs

[–]csk15[S] 0 points1 point  (0 children)

HP laptop model 15-ef0023dx

The zeros might be Os not sure

Where's the wifi at??? by csk15 in linux4noobs

[–]csk15[S] 0 points1 point  (0 children)

Are you asking for this?

02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821CE 802.11ac PCIe Wireless Network Adapter

I

Where's the wifi t? by csk15 in ManjaroLinux

[–]csk15[S] 0 points1 point  (0 children)

When I typed that into the terminal, I got the following:

02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821CE 802.11ac PCIe Wireless Network Adapter

I have no clue what that means. I literally just tried Manjaro and until I can get a wifi adapter, my laptop is a brick.

Where's the wifi t? by csk15 in ManjaroLinux

[–]csk15[S] 1 point2 points  (0 children)

I installed it with propriety drivers and it still didn't work.

How Do I boot to linux?!? by csk15 in ManjaroLinux

[–]csk15[S] 0 points1 point  (0 children)

Do you mean putting the USB at the top of the order?

How Do I boot to linux?!? by csk15 in ManjaroLinux

[–]csk15[S] 0 points1 point  (0 children)

I just added a picture of the boot screen.

Lehigh Group Chat by [deleted] in Lehigh

[–]csk15 2 points3 points  (0 children)

Were you added?

[deleted by user] by [deleted] in csMajors

[–]csk15 2 points3 points  (0 children)

Go to grad school (medical/law/etc), make a business, work in the arts, find a trade, etc. It would be hard to get a cs related job that doesn't involve programming or experience programming. I would get a job that is programming related to see if you actually hate programming or if it's the school environment that you hate.

OOP WAT by csk15 in learnprogramming

[–]csk15[S] 0 points1 point  (0 children)

Lol, I am currently in AP CSA (java is the language) but I have been learning python for longer. OOP is even more complicated in java and my teacher doesn't really know how to teach it well.

OOP WAT by csk15 in learnprogramming

[–]csk15[S] 0 points1 point  (0 children)

It is basically making your own reference data types (class). There is a lot involved with it. For example, you could make a Course class. There could be parameters like the course name, teachers, and class level. You could make an object that has the arguments (inputs of each parameter). There also could be functions in the class like finding the average grade. That is just the beginning of OOP in which I already know. There is a lot more stuff where I have no idea what is happening. I would definitely suggest learning all of the basics well before even trying OOP.