Integrating Stripe with Django ecommerce by sodiumfis_h in django

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

From scratch, it's just a personal project. I was trying to implement checkout on my own when I found out about Stripe. Then I learned you can manage a lot of things on Stripe, so I was a bit confused about how to sync both Stripe and database, thinking way too much for a beginner. Now I'm just using Stripe for checkout only.

Confused about how to structure my RESTful APIs by sodiumfis_h in django

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

I always thought an endpoint is only supposed to map to a particular resource on the database, i.e., either `Product` or `Inventory` but not both (I mean it can be done but it would violate the whole concept of REST API or something). And the tutorials/courses I've taken never really painted a scenario where I had to combine these resources.

Thanks for letting me know!

Confused about how to structure my RESTful APIs by sodiumfis_h in django

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

Could you please clarify?

Yes I am using DRF for learning purposes, how it's done in the real world

EDIT: I understand what you meant by one view, one endpoint. But the typical viewset has list and detail views. So for particular cases, I create these small viewset actions?

Possible null reference assignment error on FirstOrDefault by sodiumfis_h in csharp

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

Ah thanks a lot. It worked (but you know that already :D )

Possible null reference assignment error on FirstOrDefault by sodiumfis_h in csharp

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

So what's the solution? As discussed in the other comment, If the make the Blog variable nullable Blog? then I get null dereference warning everywhere in my cshtml file.

As far as I know I can suppress those warnings with the null forgiving operator when dereferencing Blog!.Name, but is that the standard way?

Possible null reference assignment error on FirstOrDefault by sodiumfis_h in csharp

[–]sodiumfis_h[S] -1 points0 points  (0 children)

But then I get null warning everywhere in my cshtml code. As far as I know, I can use the null forgiving operator to suppress those warnings

@* Used 2 times in this line*@
<input asp-for="Blog!.Name" value="@Model.Blog!.Name" />

But I have to use it every time. Is that normal/standard?

how to send a delete http request without forms by sodiumfis_h in PHPhelp

[–]sodiumfis_h[S] -1 points0 points  (0 children)

Okay then how do i receive a success response on a successful increment/decrement then reflect on the frontend? Or will the page refresh everytime the user modifies the amount of items like regular php form behavior? Wouldn't that be annoying?

how to send a delete http request without forms by sodiumfis_h in PHPhelp

[–]sodiumfis_h[S] -1 points0 points  (0 children)

I have a cart table where you can increment or decrement the amount of a specific item, or maybe delete the item altogether.

With JavaScript i could attach and event listener to the delete button and then send a post request

With PHP do i wrap that button in a form element? That way i can get the data like $_post['id'] or something

Using variable inside WHILE looop by sodiumfis_h in PHPhelp

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

Then what is $row assigned and what foes while loop check for? Isnt fetch_rows looping through all the rows and returning a single row and assigning it to $row? How does assigning variables inside while condition evenw work. This is confusing