Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Dmitry Sorokin
@beeduino

Can anyone tell me how to programmatically assign a CMS page to a Product object?

@ay0000 have you found the answer?

from cms.models.pagemodel import Page  # cms page model
from shop.models.related import ProductPageModel  

# get shop_page as an instance of Page
# shop_page is a cms page related to catalog or product categories under catalog
# get product
# then you can do
ProductPageModel.objects.get_or_create(page=shop_page, product=product)

maybe the same you can do having access to productpage object manager via
product_instance.productpage_set

# try
 product_instance.productpage_set.all()
 product_instance.productpage_set.get_or_create(...)
ay0000
@ay0000
I've figured out a solution to my issue but unfortunately and SQL error has forced me to restart
And now Django-shop won't even install with the instructions on the site
Pipenv complains about dependencies
ay0000
@ay0000
This is on a fresh install in a Piping in Pycharm, copying the commands on the page verbatim.
It worked not even a week ago...
ay0000
@ay0000
If anybody knows what’s changed, let me know please.
ay0000
@ay0000
So I've managed to recover my old project...kind of. My CMS pages were wiped out though. Does anyone know how to add in the footer sitemap in the Structure view in django-CMS?
ay0000
@ay0000
Or better yet, if anyone knows how to repopulate the pages and structure behind the cookie cutter example that would be even better. initialize_shop_demo does nothing for me.
ay0000
@ay0000
Okay...so I'm kinda back and running again...I keep getting HTTP 400 Bad Request on the POST operation to /shop/api/cart though whenever I try to add one of my custom items to it. Any ideas how to diagnose what's going on?
ay0000
@ay0000
Never mind. I wiresharked my the response packet which had more info. I was specifically setting the product as inactive. The cart API doesn’t like that.
Debugging this has been the absolute worst. Granted I’m a newbie but still. Everything’s been super cryptic.
ay0000
@ay0000
So has anyone figured out what's going on with the install issues?
ay0000
@ay0000
I’m trying to move to a docker-based setup but I can’t even install the program from the cookiecutter
ay0000
@ay0000
Is this project even being maintained anymore?
ay0000
@ay0000
Does anybody know how to do validation on shipping addresses? Specifically trying to match the zip code to a certain pattern if a certain country is selected.
ay0000
@ay0000
Anybody? Bueller?
ay0000
@ay0000
@jrief Do you have any insight on this?
This should be trivial
ay0000
@ay0000
Does anybody know how to dynamically change the shipping method labels in a shipping modifier based on country/zip code? Ie if someone selects a country, then goes back and choose a different one, I’d like to update the name of the service being used (ie UPS Domestic -> UPS Int’l)
alex-eri
@alex-eri
Exception Value: Related Field got invalid lookup: slug on showing commodity with i18n
alex-eri
@alex-eri
seems fixed in master
Turmer
@Turmer
Trying to setup django-SHOP demo with cookiecutter according to Django-SHOP Tutorial , running into problems at pipenv install step, it cannot resolve dependencies:
ERROR: Could not find a version that matches django<3.1,<3.3,<4.0,>=1.6,>=1.8,>=1.8.0,>=2.0,>=2.1,>=2.2,>=3,>=3.1 (from -r /tmp/pipenv_03i74m6requirements/pipenv-ff8m1mg6-constraints.txt (line 28)).
Attemps to run pipenv install --skip-lock causes:
Installing dependencies from Pipfile... An error occurred while installing django-allauth! Will try again. An error occurred while installing django-filter! Will try again. An error occurred while installing djangoshop-paypal>=1.2! Will try again. An error occurred while installing paypalrestsdk<2! Will try again. ... ERROR: Couldn't install package: django-allauth Package installation failed....
Ubuntu 16.04, Python 3.7.10, pipenv 2021.5.29, pip 21.1.3 . Any pointers how to resolve/debug this issue would be much appreciated!
Saad A. Bazaz
@SaadBazaz

Hey there,
I've been trying to integrate a checkout system which allows both bank transfer and Stripe.

Bank Transfer: the customer "commits" that they'll buy via bank, the admin has control whether to approve the order or not (based on whether the payment comes through or not).

Stripe: Pretty straightforward! The payment is done there and then.

I'm having a tough time finding any help towards how to implement a basic checkout system, even. I want to use it as a REST API (because the frontend is independent).

Any resources?

I used cookiecutter to setup a basic project and it worked great. Just the checkout system isn't implemented as far as I can see. And I can't find even a simple implementation for RESTful checkout I can follow.

Trying to setup django-SHOP demo with cookiecutter according to Django-SHOP Tutorial , running into problems at pipenv install step, it cannot resolve dependencies:
ERROR: Could not find a version that matches django<3.1,<3.3,<4.0,>=1.6,>=1.8,>=1.8.0,>=2.0,>=2.1,>=2.2,>=3,>=3.1 (from -r /tmp/pipenv_03i74m6requirements/pipenv-ff8m1mg6-constraints.txt (line 28)).
Attemps to run pipenv install --skip-lock causes:
Installing dependencies from Pipfile... An error occurred while installing django-allauth! Will try again. An error occurred while installing django-filter! Will try again. An error occurred while installing djangoshop-paypal>=1.2! Will try again. An error occurred while installing paypalrestsdk<2! Will try again. ... ERROR: Couldn't install package: django-allauth Package installation failed....
Ubuntu 16.04, Python 3.7.10, pipenv 2021.5.29, pip 21.1.3 . Any pointers how to resolve/debug this issue would be much appreciated!

Faced this too, as referred in this issue: awesto/cookiecutter-django-shop#43

The solution was pointed out awesto/cookiecutter-django-shop#41. Worked great for me.

Turmer
@Turmer
Thanks for suggestions, I made it through using same comments awesto/cookiecutter-django-shop#43 and awesto/cookiecutter-django-shop#41, I mentioned it here and here. Struggling with cookiecutter containerized shop behind NGiNX (selection 4): the shop containers are working, but letsencypt-companion seems to be getting invalid certificate, so most browsers do not show pages. Cannot yet comment on REST API resources you mentioned - not that far yet.
Saad A. Bazaz
@SaadBazaz
No problem, hopefully the experienced community can guide me (a noob)
Turmer
@Turmer
This forum seems to be pretty inactive. If you find some suitable resources for checkout, please do share.
ay0000
@ay0000
I think the whole project is pretty much dead tbh. May be best to find something more established.
Turmer
@Turmer
It certainly looks that way. The last release is dated Feb. 28, 2021, hopefully this was not the last kick. What would be the alernative, Saleor?
Saad A. Bazaz
@SaadBazaz
Hey @jrief , any update?
Saad A. Bazaz
@SaadBazaz
Screen Shot 2021-09-03 at 8.47.31 PM.png
1 reply
I get this when I click the Proceed to Checkout button on the cart page. I'd just like to see a basic checkout sample so I can make a REST API for it.
image.png
Button in question^
Saad A. Bazaz
@SaadBazaz
Anyone? :(
ay0000
@ay0000
At this point I think I’m gonna work on a front end then dockerize a micro service to integrate with Shopify.
I know next to nothing about front end development though.
Saad A. Bazaz
@SaadBazaz

So If figured out what the problem was. I had to go into Editor mode on the Django-SHOP UI, go to Cart page and double-click the Checkout button. In there are options of where you want to redirect the button's link. I set it to "checkout" and now it works.

Seems like they prefer keeping this up to the developer.

But then I spent a few days screwing up my brain because I could not find any documentation on how the Checkout API works. (I want to use Django-SHOP as a backend, while React is on the frontend).

There is no documentation on it in the official docs, nor is it described very well on Swagger.

I resorted to some old school tricks; since I have access to the server, I can just print out any request's headers and data. I walked through the checkout process, and kept checking the data and which APIs were being hit. I've written out a super crude API of what is required for checkout.

I know it's a very hacky way but that's how I found out. The best part is that Stripe and Bank Transfer are working great, but I can't find out:

  • how to add a different payment modifier without completely breaking things,
  • how to customize the fields,
  • how to checkout for a guest user (I'm assuming some kind of Session token would be being used, but how do I get it in the first place??)

I guess I get what I get.

Saad A. Bazaz
@SaadBazaz

Here is what I gathered:

How to Place an Order in Django-SHOP

  1. First put something in the cart! Use PUT /shop/api/cart... to put an item in the cart. The request data is:

    {
    "product": <the product id, e.g. 42>,
    "quantity": <how much you want, e.g. 1>
    }
  2. Now enter some details so the checkout process can be completed! This method will keep the server synced with all the details needed for checkout. Remember: You can partially fill details e.g. if you've made separate pages with separate data, you can call this API whenever the user wants to go to the next page so to "upload" the data entered so far. (this will also help you in error catching). Fill in the details using PUT /shop/api/checkout/uploadThe request data is:

    {
     "shipping_address": {
         "siblings_summary": [],
         "plugin_id": "632",
         "plugin_order": "2",
         "active_priority": "add",
         "name": "Saad Bazaz",
         "address1": "24",
         "address2": "Street 3, Sector F, DHA-II",
         "zip_code": "44000",
         "city": "Islamabad",
         "country": "PK"
     },
     "billing_address": {
         "use_primary_address": True,
         "siblings_summary": [],
         "plugin_id": "633",
         "plugin_order": "3",
         "active_priority": "add"
     }
         "shipping_method": {
                 "plugin_id": "640", 
                 "plugin_order": "5", 
                 "shipping_modifier": "self-collection"
         },
    
         "payment_method": {
                 "payment_modifier": "stripe-payment",           
                 "plugin_id": "639", 
                 "plugin_order": "4", 
                 "payment_data": {
                   "token_id": "tok_1JVyfuIUofFe97bGuuEwosvC"
                 }
         }, 
         "payment": {
                 "card": {
                   "name": "John Doe", 
                   "number": "4242 4242 4242 4242", 
                   "exp_month": "07", 
                   "exp_year": "2030", 
                   "cvc": "123"
         }
    }
  3. Now you just have to call POST ​/shop​/api​/checkout​/purchase​/No request data is needed. Although remember that your header should contain __stripe_mid ... and __stripe_sidHere is an example of a typical header which is coming from the default website:

    {'Content-Length': '2', 'Content-Type': 'application/json', 'Host': 'localhost:8080', 'Connection': 'keep-alive', 'Accept': 'application/json', 'X-Csrftoken': 'dfb5doAWKzN6HcZ67g5oxqefQsCjjEATUyjDTPV1r2xuPeXvp0M8POgn744Aq1aM', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36', 'Origin': 'http://localhost:8080', 'Referer': 'http://localhost:8080/en/swagger/', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.9', 'Cookie': 'django_language=en; csrftoken=mMDwKaEjS0H7jX2fhgk7gUTqvi3lO6r035L4qBZoztrvrZ0Ez01RyiVyMUvCVt1T; sessionid=dintzztd6dnqwelm8azip2xsdh8yyvwx; __stripe_sid=<STRIPE S ID>; __stripe_mid=<STRIPE M ID>'}

NOTE: The above is an example of Stripe Payment.

Turmer
@Turmer
Thanks for sharing this information, I am sure a bunch of folks will find it useful.
Turmer
@Turmer
BTW, do you plan for the server to authenticate the client and encode/decode the information flow between the two?
2 replies
Saad A. Bazaz
@SaadBazaz

Hey y'all, how to create a Customer (+ its User) in Django-SHOP? I want to create an authentication middleware.

Note: I successfully created a User using User.objects.create (**serializer.validated_data ), but turns out it was not creating an associated Customer.
So I created a Customer in the next line using Customer.objects.create(user=user).

Is that the right way?

Saad A. Bazaz
@SaadBazaz
Hey friends, how do I view my own orders via the REST API?
1 reply
Saad A. Bazaz
@SaadBazaz
Hey all,
How to add more fields to default Customer, such as imageURL?
1 reply
Saad A. Bazaz
@SaadBazaz

Solved the above, but brings me to another question: How to add a customized Customer model to the Admin? Currently I had to do the same: Copy everything from the default implementation of CustomerAdmin (https://github.com/awesto/django-shop/blob/master/shop/admin/customer.py) into myshop/admin.py, but when I try to save something it gives me:

.
.
.
AttributeError: type object 'CustomerProxy' has no attribute 'birth_date'

Note: I have overrided the default Customer model and added birth_date.

Saad A. Bazaz
@SaadBazaz
Hello all, Any idea how to get Django-SHOP working with Django 3.1+?
Saad A. Bazaz
@SaadBazaz
@jrief