by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 16:45
  • Jan 31 2019 10:02

    sliverc on pyup-update-flake8-3.6.0-to-3.7.2

    (compare)

  • Jan 31 2019 10:02
    pyup-bot commented #564
  • Jan 31 2019 10:02
    pyup-bot closed #564
  • Jan 31 2019 10:02

    sliverc on pyup-update-flake8-3.6.0-to-3.7.3

    Update flake8 from 3.6.0 to 3.7… (compare)

  • Jan 31 2019 10:02
    pyup-bot opened #566
  • Jan 31 2019 10:02

    sliverc on pyup-update-flake8-3.6.0-to-3.7.3

    (compare)

  • Jan 31 2019 02:56
    pyup-bot opened #565
  • Jan 31 2019 02:56

    sliverc on pyup-update-pytest-4.1.1-to-4.2.0

    Update pytest from 4.1.1 to 4.2… (compare)

  • Jan 31 2019 02:56

    sliverc on pyup-update-pytest-4.1.1-to-4.2.0

    (compare)

  • Jan 31 2019 02:56

    sliverc on pyup-update-flake8-3.6.0-to-3.7.1

    (compare)

  • Jan 31 2019 02:56
    pyup-bot closed #563
  • Jan 31 2019 02:56
    pyup-bot commented #563
  • Jan 31 2019 02:56
    pyup-bot opened #564
  • Jan 31 2019 02:56

    sliverc on pyup-update-flake8-3.6.0-to-3.7.2

    Update flake8 from 3.6.0 to 3.7… (compare)

  • Jan 31 2019 02:56

    sliverc on pyup-update-flake8-3.6.0-to-3.7.2

    (compare)

  • Jan 30 2019 11:02
    pyup-bot opened #563
  • Jan 30 2019 11:02

    sliverc on pyup-update-flake8-3.6.0-to-3.7.1

    Update flake8 from 3.6.0 to 3.7… (compare)

  • Jan 30 2019 11:02

    sliverc on pyup-update-flake8-3.6.0-to-3.7.1

    (compare)

  • Jan 30 2019 08:40
Bernard Parah
@b3h3rkz
@jsenecal thanks, now works
Christopher Compeau
@ccompeau
Hi room - I am stumped on an issue I'm having with APIRequestFactory. I posted a detailed explanation of the problem on Stack Overflow yesterday https://stackoverflow.com/questions/36273062/multivaluedictkeyerror-when-testing-a-get-endpoint-using-apirequestfactory . If anyone wants to take a look and offer an opinion, I'd really appreciate it.
Bernard Parah
@b3h3rkz
quick question please. I have a rest api that serves as a backend for a mobile client. Now I need to make web page for the backend. Do I need to create new views in the views.py or use angular js to consume the api. Haven't tried this before any advice will be appreciated thanks!
John Diego Domingos
@joe-diego
Hi guys
Can someone pass me some reference on how to create an api with django?
Nick Meyer
@e3b0c442
Hey guys, could use some guidance here, and I'm not finding an obvious solution. On one of my serializers I have a PrimaryKeyRelatedField back to the built-in User model. I can't add a resource_name to the model, and I need it to have a different resource name than 'users'. Any ideas on the best way to accomplish this?
Jerel Unruh
@jerel
@bierdybard I believe ResourceRelatedField is what you're looking for. It extends PrimaryKeyRelatedField. Example: https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/example/serializers.py#L41-L42
Nick Meyer
@e3b0c442
@jerel unfortunately that doesn't solve my issue, as ResourceRelatedField also doesn't allow a resource_name kwarg. I do have a view/serializer for this model (with the correct resource name set) for when it's directly accessed, would adding the view information as shown in the docs get me where I need to go? Even then, that seems a little overkill for what I'm trying to do, so if you'll accept a patch I'd like to put something together to allow a resource_name kwarg on ResourceRelatedField for these simple primary key relations.
Nick Meyer
@e3b0c442
And I now see that what I am looking for exists in the develop branch, but is not in the 2.0.0-beta.2 release. Any plans to push a new release to pypi soon?
Nick Meyer
@e3b0c442
... and I'm wrong again, because I was looking at my own fork that I apparently previously created to resolve this very issue. Kids mess with your brain... in any case, the question still stands :)
Jerel Unruh
@jerel
@bierdybard I'd be interested in a patch to solve this if it's not already possible. Glancing through the code at https://github.com/django-json-api/django-rest-framework-json-api/blob/d174b3a1ba02f0ee18c18a3065770eb4051b241c/rest_framework_json_api/relations.py#L142-L150 I expected it to pull the type off the serializer
Kerry Ritter
@KerryRitter
Hi, I am having some problems revolving around custom object permissions. Whenever I use a custom object permission on a ModelViewSet, I get 'JSON parse error - Expecting value: line 1 column 1 (char 0)'. I have no idea where to start in solving this problem, I am new to Django and Python web dev.
Kerry Ritter
@KerryRitter
Hints on debugging this would be enormously helpful. I'm using VSCode to interactively debug but i don't see what's causing my problem
Felix Ingram
@lllama
Hello all. Anyone got any tips on sideloading? I'd like to push some data to my Ember client without it having to use the include parameter.
Scott Fisk
@scottfisk
Hi @lllama That is currently in the works here: django-json-api/django-rest-framework-json-api#250. It is not supported currently though. You must use the include for sideloads.
hungphamvn
@hungphamvn
hi all. i'm new in django rest frame work and i have a problem when i get room of every customer in relationship..
class Customer(User):
    avatar = models.ImageField(_('avatar'), upload_to=upload_location, null=True)
    identity_card_number = models.CharField(_('identity card number'), max_length=20, null=True, blank=True)
    front_identity_card = models.ImageField(_('front identity card'), upload_to=upload_location, null=True)
    back_identity_card = models.ImageField(_('back identity card'), upload_to=upload_location, null=True)
    vehicle_license_number = models.CharField(_('vehicle license number'), max_length=10, null=True, blank=True)
    vehicle_license = models.ImageField(_('vehicle license'), upload_to=upload_location, null=True)
    phone_number = models.IntegerField(default='0')


class Room(BaseModel):
    house = models.ForeignKey(House, verbose_name=_('house'), on_delete=models.CASCADE)
    electricity_number = models.IntegerField(_('electricity number'))
    min_customer_number = models.PositiveIntegerField(_('min customer number'), default=1)
    max_customer_number = models.PositiveIntegerField(_('max customer number'), default=1)

class Contract(TimeStampedModel):
    customer = models.ManyToManyField(Customer, related_name='+', verbose_name=_('customer'))
    room = models.ForeignKey(Room, on_delete=models.CASCADE, verbose_name=_('room'))
    customer_number = models.PositiveIntegerField(_('customer number'), default=1)
    price = MoneyField(_('price'))
    check_in = models.DateTimeField(_('check in'))
    check_out = models.DateTimeField(_('check out'), null=True, blank=True)
    created_by = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='+', verbose_name=_('created by'),
                                   null=True)
hungphamvn
@hungphamvn
could someone help me?
AndreiHondrari
@AndreiHondrari
hi guys
Arthur
@arthur-s
Hello, can I use develop branch in production instead of master? Develop branch supports GenericRelations - it is why i want to use it.
Juan Soto
@sotojuan
Hey friends. We're using an older version of this package, before the auto prefetching was used. A team member wants to know the performance difference between 2.1.0 and before, if any. I know it depends on use cases, but I was just curious :-) Thanks.
santiavenda
@santiavenda2
Hi guys, do you know when are we going to release a new django-rest-framework-json-api version?
Cory Owens
@CoryOwens
Hey. I'm looking at this library, trying to figure out if it supports the JSON API parameter namespace recommendations (http://jsonapi.org/recommendations/), like... api/user?filter[email]=joe@example.com. It doesn't appear it does. Am I just overlooking it?
Jamie Bliss
@astronouth7303
@mblayman @jerel you in? I would love some insight into the other problems i'm seeing in #362
specifically the third item, it looks like a serializer got passed a list as its instance, and is that even ok?
(or another developer/contributor?)
Bernard Parah
@b3h3rkz
Hello everyone
please I'll be grateful if someone could take a look at this my SO question
Gauti
@gautamkumar94
from tenant_schemas_celery.app import CeleryApp
ImportError: No module named tenant_schemas_celery.app
do anyone have any clue
Falgun Swami
@swamifalgun
hi, i need some help with the django rest framework, is anyone available ?
Philip Mutua
@pmutua
Hi anyone with experience with lossless compression? have a look at this and advise https://stackoverflow.com/questions/50169019/coverting-a-filefield-into-binary-then-compresss-and-decompress-in-django-1-11
jpark3000
@jpark3000
Hello, any plans to push a new release? I'd like to be able to override "get_queryset()" on custom serializer fields.
Philip Mutua
@pmutua
Hi everyone, I would like to share data across microservices . I have a SSO service that holds user data and another services requires the user data.Which is the best approach to broadcast user data to the other service? I would appreciate if you provide helpful links.
Asif Saif Uddin
@auvipy
anyone have any review about drf-jsonapi package?
Falgun Swami
@swamifalgun
hi i need some help in buidling a rst api using djanog, anyone up fora small chat ?
Mitai
@MitaiGit
Hi everyone I'm a novice noob, sorry for my stupid question, I get json of the form [{"id":1,"name":"Windstorm"}, {"id":2,"name":"Bombasto"}, {"id":3,"name":"Magneta"}, {"id":4,"name":"Tornado"}]
how can I make it generated this way? { "data": [ { "id": "1", "name": "Windstorm" }, { "id": "2", "name": "Bombasto" }, { "id": "3", "name": "Magneta" }, { "id": "4", "name": "Tornado" } ] }
it is need for angulardart tutorial https://angulardart.dev/guide/server-communication
Amisha Shukla
@Amisha-100
Hello everyone

from django.db import models

class Sport(models.Model):
name = models.CharField(max_length=30)

def __str__(self):
    return self.name

class Player(models.Model):
first_name = models.TextField(max_length=30)
last_name = models.TextField(max_length=30)
age = models.IntegerField(default=30)

def __str__(self):
    return f"{self.first_name} {self.last_name}"

class Team(models.Model):
name = models.CharField(max_length=100)
sport = models.ForeignKey(Sport, on_delete=models.CASCADE, related_name="teams")

# players = models.ManyToManyField(
#     Player, through="TeamPlayerAssociation", related_name="teams"
# )

def __str__(self):
    return self.name

class TeamPlayerAssociation(models.Model):
team= models.ForeignKey(Team, on_delete=models.CASCADE, related_name="associations")
player = models.ForeignKey(Player, on_delete=models.CASCADE, related_name="associations")
is_captain = models.BooleanField(default=False)
salary = models.IntegerField(default=100)

def __str__(self):
    return f"Team {self.team.name} : Player {self.player.first_name}"
This is my model

from django.shortcuts import render
from django.http import HttpResponse
from django.shortcuts import get_object_or_404 #if object does not exist!

from rest_framework.views import APIView #Normal views can return an API data
from rest_framework.response import Response #To get response mainly in terms of code
from rest_framework import generics, status, viewsets, filters
from rest_framework.decorators import action

from .models import Sport, Team, Player, TeamPlayerAssociation
from .serializers import SportSerializer, TeamSerializer, PlayerSerializer, TeamPlayerAassociationSerializer

Create your views here.

class TeamList(viewsets.ModelViewSet):

queryset = Team.objects.all()
serializer_class = TeamSerializer
filter_backends = (filters.SearchFilter,)

@action(detail=True, methods=["get"])
def players(self, request, *args, **kwargs):
    team = self.get_object()
    players = team.players
    serializer = PlayerSerializer(players, many=True)
    return Response(serializer.data)

def get(self, request):
    team = Team.objects.all()  
    serializer = TeamSerializer(team, many=True)    
    return Response(serializer.data)

def post(self, request, *args, **kwargs):
    return self.create(request, *args, **kwargs)

class PlayerList(viewsets.ModelViewSet):

queryset = Player.objects.all()
serializer_class = PlayerSerializer
This is my view
I had implemented Team and Player api
Now, I want when team is passed, all of its members must be visible!
And a Player is given then its Team name'
How to proceed with that??
Gaurav Pandey
@gauravpandey1998
Screenshot from 2020-04-03 09-37-17.png
Screenshot from 2020-04-03 09-37-17.png