Click here to Skip to main content
15,397,981 members
Home / Discussions / Article Writing
   

Article Writing

 
QuestionToo many attributes. There is a limit of 8. Pin
CodeErgoSum24-Jun-21 14:06
MemberCodeErgoSum24-Jun-21 14:06 
AnswerRe: Too many attributes. There is a limit of 8. Pin
Matthew Dennis24-Jun-21 16:01
sysadminMatthew Dennis24-Jun-21 16:01 
GeneralRe: Too many attributes. There is a limit of 8. Pin
Richard Deeming24-Jun-21 21:28
mveRichard Deeming24-Jun-21 21:28 
GeneralRe: Too many attributes. There is a limit of 8. Pin
CodeErgoSum24-Jun-21 22:05
MemberCodeErgoSum24-Jun-21 22:05 
AnswerRe: Too many attributes. There is a limit of 8. Pin
CodeErgoSum24-Jun-21 22:02
MemberCodeErgoSum24-Jun-21 22:02 
Questionarticle published that the author says is not ready to be published Pin
BillWoodruff21-Jun-21 16:11
mveBillWoodruff21-Jun-21 16:11 
AnswerRe: article published that the author says is not ready to be published Pin
Nelek22-Jun-21 0:16
protectorNelek22-Jun-21 0:16 
QuestionHow to implement live search using fetch method on my test website ? Pin
Firaki1234526-May-21 5:14
MemberFiraki1234526-May-21 5:14 
Hi so i am using python Django and using JavaScript with the help of fetch method but i am stuck can anyone please help Frown | :(

My python views File:

Python
def Data(request):
	items = Post.objects.all()

	data = []

	for qs in items:

		I = {"title":qs.title,
			 "content": qs.content,
			 "image": qs.image.url,
			}
		data.append(I)

	return JsonResponse({"data":data})



My Search_results HTML FILE:


HTML
{% extends 'blog/base.html' %}

{% load static %}

{% block content %}

<div class = 'w-100 text-center'>

<h1>Search Results</h1>


<form id = "search-form" autocomplete="off">
	{% csrf_token %}
  <input name = 'game' type="text" id = "search-input" placeholder= "Post Search..">
</form>

<div id = "results-box" class = "results-card"> 
</div> 

</div>


	


{% endblock content %}


{% block js %}


<script defer src="{% static 'blog/S1.js' %}"> </script>


{% endblock js %}




My JS FILE:


console.log('Heelowwww')


const url = window.location.href

const searchForm = document.getElementById("search-form")
const searchInput = document.getElementById("search-input")
const resultsBox = document.getElementById("results-box")


const csrf = document.getElementsByName("csrfmiddlewaretoken")[0].value




options = {method: "GET",
		   headers: {
		   	Accept: "application/json"
		   },
		   data:{
		   	'csrfmiddlewaretoken': csrf,
			// 'game':searchInput,
		   }
}





const SearchPosts = async SearchIt => {
const res = await fetch("http://localhost:8000/data/",options)
const Posts = await res.json()

S = Posts["data"]


let matches = S.filter(post =>{
const regex = new RegExp(`^${SearchIt}`, 'gi')
return post.match(regex)
})
 	console.log(matches)

}


searchInput.addEventListener('input', () => SearchPosts(searchInput.value))



I get Filter is not a fucntion/method error

i am getting back an object so how can i do this Frown | :(

sorry a beginner in javascript

AnswerRe: How to implement live search using fetch method on my test website ? Pin
Sean Ewington26-May-21 5:22
editorSean Ewington26-May-21 5:22 
QuestionSean, can I edit someone else's article while it's in draft? Pin
OriginalGriff25-May-21 8:36
mveOriginalGriff25-May-21 8:36 
AnswerRe: Sean, can I edit someone else's article while it's in draft? Pin
Sean Ewington25-May-21 8:43
editorSean Ewington25-May-21 8:43 
GeneralRe: Sean, can I edit someone else's article while it's in draft? Pin
OriginalGriff25-May-21 9:05
mveOriginalGriff25-May-21 9:05 
GeneralRe: Sean, can I edit someone else's article while it's in draft? Pin
Sean Ewington26-May-21 1:30
editorSean Ewington26-May-21 1:30 
GeneralRe: Sean, can I edit someone else's article while it's in draft? Pin
OriginalGriff26-May-21 2:02
mveOriginalGriff26-May-21 2:02 
GeneralRe: Sean, can I edit someone else's article while it's in draft? Pin
Sean Ewington26-May-21 2:15
editorSean Ewington26-May-21 2:15 
GeneralRe: Sean, can I edit someone else's article while it's in draft? Pin
OriginalGriff25-May-21 9:06
mveOriginalGriff25-May-21 9:06 
QuestionHas the monthly article competition been discontinued? Pin
Shao Voon Wong23-May-21 19:50
mvaShao Voon Wong23-May-21 19:50 
AnswerRe: Has the monthly article competition been discontinued? Pin
Sean Ewington24-May-21 5:08
editorSean Ewington24-May-21 5:08 
GeneralRe: Has the monthly article competition been discontinued? Pin
Greg Utas26-May-21 2:29
mveGreg Utas26-May-21 2:29 
QuestionTechnical blog feed not being polled? Pin
Jason Sultana6-May-21 11:33
MemberJason Sultana6-May-21 11:33 
AnswerRe: Technical blog feed not being polled? Pin
Sean Ewington7-May-21 2:27
editorSean Ewington7-May-21 2:27 
GeneralRe: Technical blog feed not being polled? Pin
Jason Sultana7-May-21 15:02
MemberJason Sultana7-May-21 15:02 
GeneralRe: Technical blog feed not being polled? Pin
Sean Ewington10-May-21 0:47
editorSean Ewington10-May-21 0:47 
QuestionWrong article sections Pin
Mircea Neacsu1-May-21 4:42
mvaMircea Neacsu1-May-21 4:42 
AnswerRe: Wrong article sections Pin
Greg Utas1-May-21 4:57
mveGreg Utas1-May-21 4:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.