Giter Club home page Giter Club logo

blog-api-with-django-rest-framework's People

Contributors

codingforentrepreneurs avatar

Stargazers

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

Watchers

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

blog-api-with-django-rest-framework's Issues

How do I fix "ImportError: No module named genric.base"

Hi, I was following up on your tutorial Django + AngularJS for a Powerful Web Application where I get to edit /src/blog/urls.py I tried to import from django.views.genric.base import TemplateView. When I cd 'd to src folder and run python manage.py runserver I got the following error:
ImportError: No module named genric.base

Tags feature should available for post model

First of all, appreciate this project. This is very helpful. As I know tags feature is essential for a blog system. Admin should be able to control (add/edit/delete) tags and client user should be able to filter blogs via tags or searching.

Base case for creating new posts on a clean DB has not been handled.

models.py in posts app.

replace the exiting upload_location function with this code snippet. I have already ported my db to Postgres, hence I ain't making a pull request.

def upload_location(instance, filename):
     #filebase, extension = filename.split(".")
     #return "%s/%s.%s" %(instance.id, instance.id, extension)
     PostModel = instance.__class__
     last = PostModel.objects.order_by("id").last()
     new_id = 1 if last == None else (last.id+1)

    """
    instance.__class__ gets the model Post. We must use this method because the model is defined below.
    Then create a queryset ordered by the "id"s of each object, 
    Then we get the last object in the queryset with `.last()`
    Which will give us the most recently created Model instance
    We add 1 to it, so we get what should be the same id as the the post we are creating.
    """
    return "%s/%s" %(new_id, filename)

Is the login function incomplete?

Hi, i am an audience from Youtube.When i was learning this course, i found some questions.

  • Blog-API-with-Django-Rest-Framework/src/accounts/api/views.py function:post
    I think it's needed check_password here.
  • How can i sign out if it's needed.
    So i think the login function is not complete.Is it necessary to update self.request.user.So the user logged in can log out.

Thanks for the courses, i learned a lot from it.
Waiting for your replay.

IsAuthenticated Permission is not working

When creating a post and there's no user logged in, the result shows "Authentication credentials were not provided", something like that.
When I'm trying to create a post and there's no user logged in, it doesn't show the message above. It still proceed in creating.

What do I need to do?

This the code the I used.

from rest_framework.generics import (
CreateAPIView,
DestroyAPIView,
ListAPIView,
UpdateAPIView,
RetrieveAPIView,
RetrieveUpdateAPIView
)

from rest_framework.permissions import (
AllowAny,
IsAuthenticated,
IsAdminUser,
IsAuthenticatedOrReadOnly,

)

from posts.models import Post

from .permissions import IsOwnerOrReadOnly

from .serializers import (
PostCreateUpdateSerializer,
PostDetailSerializer,
PostListSerializer
)

class PostCreateAPIView(CreateAPIView):
queryset = Post.objects.all()
serializer_class = PostCreateUpdateSerializer
permission_classes = [IsAuthenticated]

def perform_create(self, serializer):
    serializer.save(user=self.request.user)

class PostDetailAPIView(RetrieveAPIView):
queryset = Post.objects.all()
serializer_class = PostDetailSerializer
lookup_field = 'slug'
#lookup_url_kwarg = "abc"

class PostUpdateAPIView(RetrieveUpdateAPIView):
queryset = Post.objects.all()
serializer_class = PostCreateUpdateSerializer
lookup_field = 'slug'
permission_classes = [IsAuthenticatedOrReadOnly, IsOwnerOrReadOnly]
#lookup_url_kwarg = "abc"
def perform_update(self, serializer):
serializer.save(user=self.request.user)
#email send_email

class PostDeleteAPIView(DestroyAPIView):
queryset = Post.objects.all()
serializer_class = PostDetailSerializer
lookup_field = 'slug'
#lookup_url_kwarg = "abc"

class PostListAPIView(ListAPIView):
queryset = Post.objects.all()
serializer_class = PostListSerializer

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.