Giter VIP home page Giter VIP logo

blogs's Introduction

blogs's People

Contributors

adamchenwei avatar kylebuildsstuff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

blogs's Issues

"Todo.user" must be a "User" instance.

Hi there,

I've just followed through your tutorial and it was all great, but when I try to Post a new Todo object i get the error. "Todo.user" must be a "User" instance.

I'm pretty new to Django and Python so its hard to even know what info you would need. Here is the trace incase that helps:

Internal Server Error: /todos/
Traceback (most recent call last):
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/rest_framework/views.py", line 494, in dispatch
    response = self.handle_exception(exc)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/rest_framework/views.py", line 454, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/rest_framework/views.py", line 491, in dispatch
    response = handler(request, *args, **kwargs)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/rest_framework/generics.py", line 244, in post
    return self.create(request, *args, **kwargs)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/rest_framework/mixins.py", line 21, in create
    self.perform_create(serializer)
  File "/Users/jonathanbattleapc/Work/auth_api/auth_api/todos/views.py", line 14, in perform_create
    serializer.save(user=self.request.user)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/rest_framework/serializers.py", line 214, in save
    self.instance = self.create(validated_data)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/rest_framework/serializers.py", line 917, in create
    instance = ModelClass.objects.create(**validated_data)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/django/db/models/query.py", line 415, in create
    obj = self.model(**kwargs)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/django/db/models/base.py", line 477, in __init__
    _setattr(self, field.name, rel_obj)
  File "/Users/jonathanbattleapc/python-envs/auth_api--KvIaXrR/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 197, in __set__
    self.field.remote_field.model._meta.object_name,
ValueError: Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x112a1ea20>": "Todo.user" must be a "User" instance.

Cheers, Jono

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.