8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

$ python -m django startproject mysite . 未找到命令“python”,您的意思是它不起作用

Marek Langer 3月前

51 0

django-admin.py startproject mysite .refreshcommand 未找到$ python -m django startproject mysite .命令“python”未找到,您的意思是:来自 deb python3command“python”的命令“python3”

django-admin.py startproject mysite .refreshcommand 未找到

$ python -m django startproject mysite .未找到命令“python”,您的意思是:来自 deb python3 的命令“python3”来自 deb python-is-python3 的命令“python”

帖子版权声明 1、本帖标题:$ python -m django startproject mysite . 未找到命令“python”,您的意思是它不起作用
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由Marek Langer在本站《django》版块原创发布, 转载请注明出处!
最新回复 (0)
  • 崩溃报告异常类型:SIGSEGVException 代码:SEGV_MAPERR 位于 0x8000000000000010 崩溃线程:0`XfinityHome.XhomeAPIPanel.panelOfflineStatus.getter:XfinityHome.PanelOfflineStatusSt...

    崩溃报告

    异常类型:SIGSEGV

    异常代码:SEGV_MAPERR 位于 0x8000000000000010

    崩溃线程:0

    `XfinityHome.XhomeAPIPanel.panelOfflineStatus.getter: XfinityHome.PanelOfflineStatus

    堆栈跟踪主线程 - 崩溃XfinityHomeXfinityHome.XhomeAPIPanel.panelOfflineStatus.getter:XfinityHome.PanelOfflineStatus:0

    XfinityHome函数签名专业化静态 XfinityHome.SectionTileController.offlineModeActive.getter : Swift.Bool :0

    XfinityHome函数签名专业化XfinityHome.BBOfflineWithCellularTileController.shouldDisplayInControllerWrapper(XfinityHome.SectionTileController) -> Swift.Bool :0

    CoreFoundation__CFRunLoopRunCoreFoundationCFRunLoopRunSpecificGraphicsServicesGSEventRunModalUIKitCore-[UIApplication _run]UIKitCoreUIApplicationMainXfinityHomemain AppDelegate.swift:30libdyld.dylibstart`CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE: A, action: (A) -> RxSwift.Disposable) -> RxSwift.Disposable MainScheduler.swift:72RxSwiftreabstraction thunk helper 从 @escaping @callee_guaranteed () -> () 到 @escaping @callee_unowned @convention(block) () -> () :0libdispatch.dylib_dispatch_call_block_and_releaselibdispatch.dylib_dispatch_client_calloutlibdispatch.dylib_dispatch_main_queue_callback_4CF$VARIANT$armv81CoreFoundation)) -> (@out RxSwift.Disposable) :0RxSwiftpartial 将转发器应用于闭包 #1 () -> () 在 RxSwift.MainScheduler.scheduleInternal(277A93ABA8477198C125F3F26B2D4B62),RxSwift.Event)->(@out RxSwift.Disposable)到@escaping @callee_guaranteed(@in_guaranteed(RxSwift。(ObserveOnSerialDispatchQueueSink inXfinityHomeprotocol 见证 XfinityHome.SectionTileContentProvider.shouldDisplayInController(XfinityHome.SectionTileController) -> Swift.Bool 符合 XfinityHome.BBOfflineWithCellularTileController : XfinityHome.SectionTileContentProvider in XfinityHome :0XfinityHomeXfinityHome.SectionTileController.(updateVisibleTiles in _E0A1AF71D8779E1E1D506C5AC683426E)() -> () SectionTileController.swift:352XfinityHomeXfinityHome.SectionTileController.(performTileReload in _E0A1AF71D8779E1E1D506C5AC683426E)() -> () SectionTileController.swift:379XfinityHomepartial 应用转发器进行闭包 #1 () -> () 在 XfinityHome.SectionTileController.viewDidLoad() 中 -> () SectionTileController.swift:206XfinityHomereabstraction thunk helper 从 @escaping @callee_guaranteed () -> () 到 @escaping @callee_guaranteed (@in_guaranteed ()) -> () :0RxSwiftclosure #1 (RxSwift.Event 277A93ABA8477198C125F3F26B2D4B62), RxSwift.Event<A.RxSwift.ObserverType.E>)) -> (@out RxSwift.Disposable) :0RxSwiftpartial apply forwarder for closure #1 () -> () in RxSwift.MainScheduler.scheduleInternal( ) -> () 在 (RxSwift 中的扩展) 中:RxSwift.ObservableType.subscribe(onNext: (AE) -> ()?, onError: (Swift.Error) -> ()?, onCompleted: () -> ()?, onDisposed: () -> ()?) -> RxSwift.Disposable :0RxSwiftRxSwift.AnonymousObserver.onCore(RxSwift.Event) -> () AnonymousObserver.swift:24RxSwiftRxSwift.ObserverBase.on(RxSwift.Event) -> () ObserverBase.swift:18RxSwiftprotocol 见证 RxSwift.ObserverType.on(RxSwift.Event ) -> () 符合 RxSwift.ObserverBase : RxSwift.ObserverType 在 RxSwift 中 :0RxSwiftclosure #1 ((sink: RxSwift.(ObserveOnSerialDispatchQueueSink 在 _277A93ABA8477198C125F3F26B2D4B62 中),事件: RxSwift.Event ))-> RxSwift.Disposable 在 RxSwift 中。(ObserveOnSerialDispatchQueueSink 在 _277A93ABA8477198C125F3F26B2D4B62).init(scheduler:RxSwift.SerialDispatchQueueScheduler,observer:A,cancel:RxSwift.Cancelable)-> RxSwift。(ObserveOnSerialDispatchQueueSink 在 _277A93ABA8477198C125F3F26B2D4B62)ObserveOn.swift:184RxSwiftpartial 应用转发器以重新抽象 thunk 助手来自@escaping @callee_guaranteed(@guaranteed RxSwift。(ObserveOnSerialDispatchQueueSink 在_277A93ABA8477198C125F3F26B2D4B62),@in_guaranteed RxSwift.Event

    该问题无法在本地或通过僵尸网络重现

  • 这是我的代码,主要基于 Stripe 的基本模板代码:import UIKitimport StripePaymentSheetclass CheckoutViewController: UIViewController { private static let back...

    这是我的代码,它主要基于 Stripe 的基本模板代码:

    import UIKit
    import StripePaymentSheet
    
    class CheckoutViewController: UIViewController {
    
        private static let backendURL = URL(string: "https://sundealit.com/stripetest")!
    
        private var paymentIntentClientSecret: String?
    
        private lazy var payButton: UIButton = {
            let button = UIButton(type: .custom)
            button.setTitle("Pay now", for: .normal)
            button.backgroundColor = .systemIndigo
            button.layer.cornerRadius = 5
            button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
            button.addTarget(self, action: #selector(pay), for: .touchUpInside)
            button.translatesAutoresizingMaskIntoConstraints = false
            button.isEnabled = false
            return button
        }()
    
        override func viewDidLoad() {
            super.viewDidLoad()
            view.backgroundColor = .systemBackground
            view.addSubview(payButton)
    
            NSLayoutConstraint.activate([
                payButton.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 16),
                payButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16),
                payButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16)
            ])
    
            self.fetchPaymentIntent()
        }
    
        func fetchPaymentIntent() {
            let url = Self.backendURL.appendingPathComponent("/create-payment-intent")
    
            let shoppingCartContent: [String: Any] = [
                "items": [
                    ["id": "xl-shirt"]
                ]
            ]
    
            var request = URLRequest(url: url)
            request.httpMethod = "POST"
            request.setValue("application/json", forHTTPHeaderField: "Content-Type")
            request.httpBody = try? JSONSerialization.data(withJSONObject: shoppingCartContent)
    
            let task = URLSession.shared.dataTask(with: request, completionHandler: { [weak self] (data, response, error) in
                guard
                    let response = response as? HTTPURLResponse,
                    response.statusCode == 200,
                    let data = data,
                    let json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String : Any],
                    let clientSecret = json["clientSecret"] as? String,
                    let publishableKey = json["publishableKey"] as? String
                else {
                    let message = error?.localizedDescription ?? "Failed to decode response from server."
                    self?.displayAlert(title: "Error loading page", message: message)
                    return
                }
    
                print("Created PaymentIntent")
                print(clientSecret)
                print(publishableKey)
                self?.paymentIntentClientSecret = clientSecret
                StripeAPI.defaultPublishableKey = publishableKey
                DispatchQueue.main.async {
                    self?.payButton.isEnabled = true
                }
            })
    
            task.resume()
        }
    
        func displayAlert(title: String, message: String? = nil) {
            DispatchQueue.main.async {
                let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
                alertController.addAction(UIAlertAction(title: "OK", style: .default))
                self.present(alertController, animated: true)
            }
        }
    
        @objc
        func pay() {
            guard let paymentIntentClientSecret = self.paymentIntentClientSecret else {
                return
            }
    
            var configuration = PaymentSheet.Configuration()
            configuration.merchantDisplayName = "Example, Inc."
    
            let paymentSheet = PaymentSheet(
                paymentIntentClientSecret: paymentIntentClientSecret,
                configuration: configuration)
    
            paymentSheet.present(from: self) { [weak self] (paymentResult) in
                switch paymentResult {
                case .completed:
                    self?.displayAlert(title: "Payment complete!")
                case .canceled:
                    print("Payment canceled!")
                case .failed(let error):
                    self?.displayAlert(title: "Payment failed", message: error.localizedDescription)
                }
            }
        }
    
    }
    

    但是,在这个基本模板中,用户无法输入送货地址,所以即使他们已经付了钱,我也不知道将产品运送到哪里。

    我查看了 Stripe 的文档,据说它教我如何在 Swift 中将送货地址字段添加到我的移动应用程序中: https://docs.stripe.com/elements/address-element/collect-addresses

    但是,步骤 4 最令人困惑,我应该在代码的哪里插入步骤 4 中的代码,才能获得与该页面顶部图像中显示的相同效果?

    简而言之,我也需要以某种方式收集用户的送货地址。谢谢!

  • 此处使用 AddressElement 需要使用 您—— UINavigationController 将在 CheckoutViewController 中设置一个按钮,按下该按钮时会触发 UINavigationController 以将用户导航到 AddressElement。这就是所引用文档的第 4 步中显示的内容。

  • 哦!这意味着地址不是从付款表中收集的?地址元素更像是一个单独的“小部件”,我可以在里面收集客人的地址?但是我该如何将收集到的送货地址输入到付款表中呢?

  • 该运输信息不会出现在付款表中。您可以收集它并将其单独存储在您自己的数据库中,或者您可以调用您的服务器并更新 PaymentIntent 的运输信息 (docs.stripe.com/api/payment_intents/…),以供 PaymentSheet 使用的 PaymentIntent 使用。

  • 我可以隐藏最后一行的底部分隔符,但无法根据我的集合视图单元格中的 SwiftUI 视图正确缩进。如何像其他单元格一样正确缩进它...

    我可以隐藏 底部分隔符 ,但无法根据集合视图单元格中的 SwiftUI 视图正确缩进。如何像其他单元格一样正确缩进它,而不是从边到边?

    我知道您可以在列表配置中手动设置缩进,但是有没有更好的自动方法?

    class ViewController: UIViewController {
        var collectionView: UICollectionView!
        var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
        private var headerRegistration: UICollectionView.SupplementaryRegistration<UICollectionViewCell>!
    
        var items: [Item] = [
            Item(title: "Item 1"),
            Item(title: "Item 2"),
            Item(title: "Item 3"),
            Item(title: "Item 4"),
            Item(title: "Item 5")
        ]
        
        override func viewDidLoad() {
            super.viewDidLoad()
                    
            registerHeader()
            collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: createLayout())
            collectionView.translatesAutoresizingMaskIntoConstraints = false
            view.addSubview(collectionView)
            
            NSLayoutConstraint.activate([
                collectionView.topAnchor.constraint(equalTo: view.topAnchor),
                collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
                collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
                collectionView.bottomAnchor.constraint(equalTo: addButton.topAnchor)
            ])
            
            collectionView.register(UICollectionViewListCell.self, forCellWithReuseIdentifier: "cell")
            
            configureDataSource()
            applySnapshot()
        }
        
        func registerHeader() {
            headerRegistration = .init(elementKind: UICollectionView.elementKindSectionHeader) {
                (header, elementKind, indexPath) in
    
                header.contentConfiguration = UIHostingConfiguration {
                    Button {
                        
                    } label: {
                        Text("Header")
                            .frame(width: 100, height: 50)
                            .contentShape(.rect)
                            .buttonStyle(.bordered)
                    }
                }
            }
        }
    
        func createLayout() -> UICollectionViewLayout {
            var listConfiguration = UICollectionLayoutListConfiguration(appearance: .grouped)
            listConfiguration.headerMode = .supplementary
    
            listConfiguration.itemSeparatorHandler = { [unowned self] (indexPath, sectionSeparatorConfiguration) in
                var configuration = sectionSeparatorConfiguration
                if indexPath.row == 0 {
                    configuration.topSeparatorVisibility = .hidden
                } else if indexPath.row == items.count - 1 {
                    //Correctly the last row separator here?
                    configuration.bottomSeparatorVisibility = .hidden
                }
                
                return configuration
            }
    
            let layout = UICollectionViewCompositionalLayout.list(using: listConfiguration)
            return layout
        }
    
        func configureDataSource() {
            dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { (collectionView, indexPath, item) -> UICollectionViewCell? in
                let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! UICollectionViewListCell
                cell.contentConfiguration = UIHostingConfiguration {
                    HStack {
                        Image(systemName: "house")
                            .resizable()
                            .foregroundStyle(.gray)
                            .scaledToFit()
                            .padding()
                            .frame(width: 50, height: 50)
                            .background(.quaternary)
                            .cornerRadius(5)
                            .padding(.trailing, 5)
    
                        VStack(alignment: .leading) {
                            Text("Item name")
                                .lineLimit(1)
                            Text("Item subtitle")
                                .font(.subheadline)
                                .foregroundColor(.secondary)
                                .lineLimit(1)
                        }
                    }
                }
                .margins(.all, 5)
                
                return cell
            }
                    
            dataSource.supplementaryViewProvider = { [unowned self] collectionView, elementKind, indexPath in
                return collectionView.dequeueConfiguredReusableSupplementary(using: headerRegistration, for: indexPath)
            }
        }
    
        func applySnapshot(animatingDifferences: Bool = true) {
            var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
            snapshot.appendSections([.main])
            snapshot.appendItems(items)
            dataSource.apply(snapshot, animatingDifferences: animatingDifferences)
        }
    }
    
  • 抱歉,看了您的链接 docs.stripe.com/api/payment_intents/update 后,我还是有点困惑。您能写下代码并向我说明如何将数据(字典格式)添加到 PaymentIntent 吗?

  • 由于我根据您的评论修改了我的代码,我想为了保持一致性,我写一篇新文章,而不是直接从上面修改代码,否则您对我的问题的回答将不一致

  • 我想用 UIAlertController 创建一个弹出菜单,其中包含自定义操作项,用户可以定义字体大小、背景颜色、对齐方式和图标位置(前导/尾随)等样式...

    我想用 UIAlertController 创建一个弹出菜单,其中包含自定义操作项,用户可以定义字体大小、背景颜色、对齐方式和图标位置(前导/尾随)等样式,如何更改图标位置,使图标位于标题后面?

    在此处输入图片描述

    我使用以下扩展来设置颜色和对齐方式,但不知道如何设置字体大小和图标位置,请帮我找到解决方案。

    extension UIAlertAction {
        var titleTextColor: UIColor? {
            get { return self.value(forKey: "titleTextColor") as? UIColor }
            set { self.setValue(newValue, forKey: "titleTextColor") }
        }
        
        var titleAlignment: Int? {
            get { return self.value(forKey: "titleTextAlignment") as? Int }
            set { self.setValue(newValue, forKey: "titleTextAlignment") }
        }
    }
    
  • UIAlertAction 不支持更改图像的位置。我建议编写自己的警报控制器,而不是使用内置的控制器。

    也就是说, 可以 所有 的图像移动 到右侧,因为图像始终出现在最前面。

    let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert)
    let action1 = UIAlertAction(title: "Action 1", style: .default) { _ in }
    action1.setValue(UIImage(...), forKey: "image")
    alert.addAction(action1)
    // assuming this is in a UIViewController subclass
    present(alert, animated: true)
    if #available(iOS 17.0, *) {
        alert.traitOverrides.layoutDirection = .rightToLeft
    } else {
        setOverrideTraitCollection(.init(layoutDirection: .rightToLeft), forChild: alert)
    }
    
  • 嗨@Sweeper,该类永远不会像下面的代码那样继承 UIViewController,public class Popover:NSObject,UIPopoverPresentationControllerDelegate {...因此存在关于在范围内找不到 setOverrideTraitCollection 的错误。弹出菜单由函数 controller.present(...) 显示,控制器是一个页面(UIViewController),我可以通过运行粗体 controller.setOverrideTraitCollection(...) 来解决错误吗?

  • 引用 13

    我正在我的应用程序 (Django) 中集成支付网关 API。我编写了一个 PaymentGateway 类,它提供了所有与支付相关的实用程序的所有方法。__init__ 初始化 pa...

    我正在我的应用程序 (Django) 中集成支付网关 API。我编写了一个类 PaymentGateway ,它提供了所有与支付相关的实用程序的所有方法。它 __init__ 初始化支付网关客户端, self.client 以便它可用于所有方法。但是,我需要帮助来决定如何使用它。

    当我需要时,我是否可以在程序中实例化并使用支付网关对象?或者我应该在整个应用程序中维护它的单个实例?

    需要帮助来了解什么是优点和缺点或任何其他建议,以便我可以做出这个决定。

    我当前的代码现在如下所示:

    class PaymentGateway:
        def __init__(self):
            self.client = PG(api_key="api_key")
    
        def create_intent(self, user):
            return self.client.intents.create(customer_id=user.email)
    
        def get_user_id(email):
            return self.client.users.retrieve(customer_id=email)
    
    class MyView(GenericAPIView):
        def get(self, request):
            pg_instance = PaymentGateway()
            intent = pg_instance.create(request.user)
            return Response({"user_id": get_user_id(request.user), "intent": intent})
    
    
    # Somewhere in utils.py
    def get_user_id(user):
        pg = PaymentGateway()
        return pg.get_user_id(user.email)
    
    
返回
作者最近主题: