我有2个查询集:发布和评论.我正在使用django-el-pagination来使用ajax渲染它们.
这是我的观点:
def profile(request, user, extra_context=None):
profile = Profile.objects.get(user__username=user)
page_template = 'profile.html'
if request.is_ajax():
user_queryset = request.GET.get('user_queryset')
print('Queryset:', user_queryset)
if user_queryset == 'user_posts':
page_template = 'user_posts.html'
elif user_queryset == 'user_comments':
page_template = 'user_comments.html'
else:
pass
print('Template:', page_template)
user_posts = Post.objects.filter(user=profile.user).order_by('-date')
user_comments = Comment.objects.filter(user=profile.user).order_by('-timestamp')
context = {'user_posts': user_posts,'user_comments': user_comments, 'page_template': page_template}
if extra_context is not None:
context.update(extra_context)
return render(request, page_template, context)
Run Code Online (Sandbox Code Playgroud)
我有一个ajax调用,找出正在使用的查询集.因此,当点击"更多评论"或"更多帖子"(在模板中)以获得更多分页对象时,我知道它来自哪个查询集.但是,当我使用上面的代码并单击'more'作为ajax分页时,它会附加整个页面,而不是相关的子模板(user_posts.html或user_comments.html).但if request.is_ajax()代码块工作正常;它会打印正确的模板以供使用,所以这不应该正在发生.
当我将该代码块更改为此时
if request.is_ajax():
page_template = 'user_posts.html'
Run Code Online (Sandbox Code Playgroud)
ajax的Post作品分页.但是,我想添加ajax分页Comment …
我试着看看其他答案,但没有帮助.我的背景是动态的,因此图像的大小会发生变化,因此我需要保持纵横比,以便看到整个图像.这是我的CSS:
.image_submit_div {
border: 1px solid #ccc;
display: inline-block;
padding: 20px 50px;
width: 55%;
height: 320px;
cursor: pointer;
background: url('something.jpg'); /* this changes */
margin: 0 0 25px;
Run Code Online (Sandbox Code Playgroud)
}
HTML
<label for="id_image" class="image_submit_div">
Run Code Online (Sandbox Code Playgroud)
目前,根据图像,有时很多都会被切断.我希望图像缩小,以便可以完全看到.任何的想法?
我想要实现SECURE_HSTS_SECONDS我的Django设置以获得额外的安全性 - 但是来自Django文档的警告让我感到害怕,所以我想要一些澄清.这是说什么:
SECURE_HSTS_SECONDS
__PRE__
它会"破坏我的网站"会发生什么?我读了HTTP Strict Transport Security documentation第一篇并没有让它更清楚.
当我执行时,pip install thumbor我收到以下错误:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 913, in <module>
ext = get_extension(sys.argv, split_extension_source=split_extension_source)
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 582, in get_extension
ext_config = ExtensionConfiguration(argv)
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 99, in __init__
self.configure()
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 316, in configure_unix
specify the SSL backend manually.''')
__main__.ConfigurationError: Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how …Run Code Online (Sandbox Code Playgroud) 使用 SwiftUI 解释 Facebook 登录的资源并不多。我不确定我的代码是否需要 a ViewController,因为 FacebookLoginManager.login()包含一个ViewController参数 - 但这并没有真正转化为 SwiftUI。
无论如何,当用户单击Button以下内容时,我试图将用户登录到 Facebook :
登录视图.swift
import Foundation
import SwiftUI
import FBSDKLoginKit
struct LoginView: View {
@EnvironmentObject var auth: UserAuth
var body: some View {
ZStack {
VStack {
Image("launcher_logo").resizable()
.scaledToFit()
.frame(height: 100)
.padding(.top, 100)
Spacer()
Button(action: {
FBLogin()
}) {
Text("Continue with Facebook")
}.foregroundColor(Color.black)
Run Code Online (Sandbox Code Playgroud)
当Button点击 时,它FBLogin在下面初始化-login()在它的中触发init():
模型:
class FBLogin: LoginManager {
let loginButton = FBLoginButton() …Run Code Online (Sandbox Code Playgroud) I'm ready to push my existing Django project (which i've been running in a local environment) to a Bitbucket repository so I can run it on a public server. At the moment I feel like there's a lot of files created in local development that needs to be added to .gitignore.
我在 github 上找到了这个.gitignore文件,但是我仍然觉得它缺少一些东西,例如它似乎没有从每个migrations文件夹中删除文件。还有很多我不知道他们做什么的东西——我知道并不是所有的东西都是需要的。任何建议表示赞赏。
我目前正在将自定义网站连接到 Firebase 托管。
Firebase 给了我以下错误:
We expected these A records
Host: my.app
Values:
151.xxx.1.xxx
151.xxx.85.xxx
We found these A records
Host: my.app
Values:
151.xxx.1.xxx
Add these A records to your domain by visiting your DNS provider or registrar.
Your site will show a security certificate warning for a few hours, until the certificate has been provisioned.
Record type Host Value
A
my.app
151.xxx.1.xxx
A
my.app
151.xxx.85.xxx
Run Code Online (Sandbox Code Playgroud)
我已经添加的第一个A记录我的谷歌域后端(151.xxx.1.xxx),但是当我尝试添加第二个(151.xxx.85.xxx)我得到这个错误:Record already in use。
我收到此错误是因为主机值完全相同(@或my.app …
我的看法是@ObservedObject:
struct HomeView: View {
@ObservedObject var station = Station()
var body: some View {
Text(self.station.status)
}
Run Code Online (Sandbox Code Playgroud)
它根据Stringfrom更新文本Station.status:
class Station: ObservableObject {
@Published var status: String = UserDefaults.standard.string(forKey: "status") ?? "OFFLINE" {
didSet {
UserDefaults.standard.set(status, forKey: "status")
}
}
Run Code Online (Sandbox Code Playgroud)
status但是,我需要更改my 中的值AppDelegate,因为这是我接收Firebase Cloud Messages的地方:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// If you are receiving a notification message while your app …Run Code Online (Sandbox Code Playgroud) 即使我明确告诉我不要,Firestore仍在从缓存中检索文档:
class MainActivity : AppCompatActivity() {
val db = FirebaseFirestore.getInstance()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val dbSettings = FirebaseFirestoreSettings.Builder().setPersistenceEnabled(false).build()
db.firestoreSettings = dbSettings
Run Code Online (Sandbox Code Playgroud)
上面是我在启动器中设置Firestore设置的活动。
在我的片段中,我执行GeoFirestore GeoQuery:
class MapFragment : Fragment() {
val instances = FirebaseFirestore.getInstance().collection("instances")
val geoFirestore = GeoFirestore(instances)
lateinit var nearbyDocs: GeoQuery
private fun searchNearby(){
nearbyDocs = geoFirestore.queryAtLocation(currentLocation, 1.0)
nearbyDocs.addGeoQueryDataEventListener(object : GeoQueryDataEventListener {
override fun onDocumentEntered(documentSnapshot: DocumentSnapshot, location: GeoPoint) {
Log.d(TAG, "onDocumentEntered: user1: ${documentSnapshot.getString("user1")?.substring(0, 3)} | docId: ${documentSnapshot.id.substring(0, 5)} | fromCache: ${documentSnapshot.metadata.isFromCache}")
Log.d(TAG, "isPersistanceEnabled2: ${db.firestoreSettings.isPersistenceEnabled}")
}
} …Run Code Online (Sandbox Code Playgroud) 我实现了一个ArrayAdapter以填充我的Spinner观点。的Spinner工作正常,但是当我单击微调器中的项目时,android并未检测到。
我所有的要求遵守微调例如在Android文档
包括实施AdapterView.OnItemSelectedListener我的活动,并覆盖它的两个方法OnItemSelectedListener和onNothingSelected,但是,没有我的Log那些方法报表打印,使他们不被调用。
我还通过将监听器设置为微调器choose_user.onItemSelectedListener = this@PlayerDetails。
这是我的活动:
class PlayerDetails : AppCompatActivity(), View.OnClickListener, TextWatcher, AdapterView.OnItemSelectedListener {
val TAG: String = "PlayerDetails"
val FirebaseTAG: String = "FirebaseDebug"
var numOfPlayers: Int = 1
var currentPlayer: Int = 1
var name: String = ""
var age: Int = 0
var genderId: Int = 0
var genderResult: String = ""
val db = FirebaseFirestore.getInstance()
var users: MutableList<String> = …Run Code Online (Sandbox Code Playgroud)