Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Estoy tratando de enviar una solicitud de publicación con una clave de autorización como parámetro y sigo recibiendo un error: "Programa.usuario" debe ser una instancia de "Usuario"

El error que sigo recibiendo es: ValueError: Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x102704820>": "Program.user" must be a "User" instance.

Estoy usando Redux y haciendo la solicitud de publicación usando una acción llamada createProgram que se ve así

 export const createProgram = () => async (dispatch, getState) => { try{ dispatch({ type: PROGRAM_CREATE_REQUEST}) const { userLogin: { userInfo }, } = getState() const config = { header: { 'Content-type': 'application/json', Authorization: `Bearer ${userInfo.token}` } } const { data } = await axios.post( `/api/programs/program-create/`, {}, config ) dispatch({ type: PROGRAM_CREATE_SUCCESS, payload: data, }) } catch (error) { dispatch({ type: PROGRAM_CREATE_FAIL, payload: error.response && error.response.data.detail ? error.response.data.detail : error.message }) } }

Estoy usando Dango para el backend y la vista y el modelo createProgram se ven así:

 @api_view(['POST']) def createProgram(request): user = request.user program = Program.objects.create( user = user, name = 'Empty Name' ) serializer = ProgramSerializer(program, many=False) return Response(serializer.data)

 class Program(models.Model): user = models.ForeignKey(User, on_delete=CASCADE, null=False) name = models.CharField(max_length=200) dateCreated = models.DateTimeField(auto_now_add=True) # lastWorkout = models.DateTimeField(auto_now_add=False) #I have to fix this def __str__(self): return str(self.name) + ' - ' + str(self.user.first_name)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!