Re: Search results in template

2017-12-26 Thread Malik Rumi
That appears to be it. I got content and all that on the simple template
this time.

I put values_list in there because that's the way it was done on the
postgres full text search tutorial I was using. I assumed it was needed for
rank, I never thought about it limiting me otherwise.
If I seem a little less enthused than I should be, it is only because I am
getting a little tired and hungry, and was emotionally prepared to put this
whole thing aside and had started working on something else.
But you have helped me tremendously, and I greatly appreciate it. Tomorrow
I will play with it some more... unless my mood changes after I eat  ;-)

THANK YOU

*“None of you has faith until he loves for his brother or his neighbor what
he loves for himself.”*

On Tue, Dec 26, 2017 at 9:19 PM, James Schneider 
wrote:

>
>
>
> *And the result:*
>
>
> !DOCTYPE This is the first page
>
>-
>
>('2017-10-09 Incentive, a further review', 0.151982)
>-
>
>('2017-11-14 Pulling The Trigger', 0.151982)
>-
>
>('2017-10-05 A Failure of Incentive?', 0.121585)
>-
>
>('2017-10-20 spider refactor', 0.121585) And now for something
>completely different...
>-
>
>   :
>   -
>
>   :
>   -
>
>   :
>   -
>
>   :
>   -
>
>
>
> <<>>
>
>
> So this looks like a variable problem, but I don't claim to understand
> that, either. I mentioned earlier on this thread that different variables
> gave me different results, but everyone says that can't be it.
>
>
>
> Ah. Are you still chaining .values_list() to your query in the view? That
> would explain the output above.
>
> The loop is built with the assumption that we have full objects from the
> ORM, but because we chained .value_list(), we're actually getting a list of
> tuples containing two values.
>
> Your templates are built in the same manner. Can you run the second loop
> again with .values_list() removed from the query in the view?
>
> -James
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/xSW1BjLXXSQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciWjdFDwUPT7-60Gk1OfaejZeoFAsDXZpgXjp0mQ26C
> 30g%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKd6oBzskoyggu4LBHafufPXQ1QHeuNdQiUEZbD6zRO7-fGWOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search results in template

2017-12-26 Thread James Schneider
*And the result:*


!DOCTYPE This is the first page

   -

   ('2017-10-09 Incentive, a further review', 0.151982)
   -

   ('2017-11-14 Pulling The Trigger', 0.151982)
   -

   ('2017-10-05 A Failure of Incentive?', 0.121585)
   -

   ('2017-10-20 spider refactor', 0.121585) And now for something
   completely different...
   -

  :
  -

  :
  -

  :
  -

  :
  -



<<>>


So this looks like a variable problem, but I don't claim to understand
that, either. I mentioned earlier on this thread that different variables
gave me different results, but everyone says that can't be it.



Ah. Are you still chaining .values_list() to your query in the view? That
would explain the output above.

The loop is built with the assumption that we have full objects from the
ORM, but because we chained .value_list(), we're actually getting a list of
tuples containing two values.

Your templates are built in the same manner. Can you run the second loop
again with .values_list() removed from the query in the view?

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWjdFDwUPT7-60Gk1OfaejZeoFAsDXZpgXjp0mQ26C30g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search results in template

2017-12-26 Thread Malik Rumi
*Your first suggested loop:*

This is the first page



{% for obj in QuerySet %}

{{obj}}

{% empty %}

No results

{% endfor %}

*The result:*

!DOCTYPE This is the first page

   -

   ('2017-10-09 Incentive, a further review', 0.151982)
   -

   ('2017-11-14 Pulling The Trigger', 0.151982)
   -

   ('2017-10-05 A Failure of Incentive?', 0.121585)
   -

   ('2017-10-20 spider refactor', 0.121585)


*Same template with your second loop added:*


!DOCTYPE








This is the first page




{% for obj in QuerySet %}

{{obj}}

{% empty %}

No results

{% endfor %}


And now for something completely different...




{% for obj in QuerySet %}

{{obj.title}}: {{obj.chron_date}}

{{obj.content}}

{% empty %}

No results

{% endfor %}







*And the result:*


!DOCTYPE This is the first page

   -

   ('2017-10-09 Incentive, a further review', 0.151982)
   -

   ('2017-11-14 Pulling The Trigger', 0.151982)
   -

   ('2017-10-05 A Failure of Incentive?', 0.121585)
   -

   ('2017-10-20 spider refactor', 0.121585) And now for something
   completely different...
   -

  :
  -

  :
  -

  :
  -

  :
  -



<<>>


So this looks like a variable problem, but I don't claim to understand
that, either. I mentioned earlier on this thread that different variables
gave me different results, but everyone says that can't be it.

*“None of you has faith until he loves for his brother or his neighbor what
he loves for himself.”*

On Tue, Dec 26, 2017 at 8:34 PM, Malik Rumi  wrote:

> Here is the Entry model:
>
> class Entry(models.Model):
> title = models.CharField(max_length=100, blank=False, null=False)
> slug = models.SlugField(max_length=100)
> content = models.TextField()
> posted_date = models.DateTimeField(auto_now=True)
> chron_date = models.DateField(auto_now=False, auto_now_add=False,
> blank=True)
> clock = models.TimeField(auto_now=False, auto_now_add=False,
> blank=True)
>
> ALIGN = "Align"
> CULTURE = "Culture"
> EXPENSE = "Expense"
> INCOME = "Income"
> HUMAN_RELATIONSHIPS = "Human Relationships"
> CATEGORY_CHOICES = (
> (ALIGN, "Align"),
> (CULTURE, "Culture"),
> (EXPENSE, "Expense"),
> (INCOME, "Income"),
> (HUMAN_RELATIONSHIPS, "Human Relationships"),
> )
> category = models.CharField(max_length=25, choices=CATEGORY_CHOICES,
> default=INCOME)
> tags = models.ManyToManyField(Tag)
> search_vector = SearchVectorField(blank=True, null=True)
>
> class Meta:
> verbose_name = "Diary Entry"
> verbose_name_plural = "Diary Entries"
> ordering = ["-chron_date", "clock"]
> indexes = [
> GinIndex(fields=['search_vector'])
> ]
>
> def __str__(self):
> return self.title
>
> def get_absolute_url(self):
> return reverse('detail', kwargs={"slug": self.slug})
>
>
> You already have the template in my original post to start this thread.
>
> *“None of you has faith until he loves for his brother or his neighbor
> what he loves for himself.”*
>
> On Tue, Dec 26, 2017 at 2:26 PM, James Schneider 
> wrote:
>
>>
>>
>>
>> The template context says I have a queryset
>>
>>
>> I see it there. Can you post up the model for Entry?
>>
>>
>>
>>
>> And so does the selection
>>
>>
>> Yes. It appears that you will have 4 results in your queryset.
>>
>>
>>
>> I put print statements in the view:
>>
>> ##
>> Quit the server with CONTROL-C.
>> This is the value of query:  SearchQuery(eaa)
>> This is the value of QuerySet:  > further review', 0.151982), ('2017-11-14  Pulling The Trigger', 0.151982),
>> ('2017-10-05 A Failure of Incentive?', 0.121585), ('2017-10-20 spider
>> refactor', 0.121585)]>
>> [26/Dec/2017 18:57:31] "GET /serp/?q=eaa HTTP/1.1" 200 66580
>>
>> ##
>>
>>
>> At this point, the view doesn't appear to be the problem. We need to
>> start tracking things down in the template code.
>>
>>
>>
>>
>> Note this is all done through my simple html search form, defined in the
>> template. My Django Form, SearchBox(), does absolutely nothing, as if it
>> isn't connected to anything. I don't understand what the problem there is,
>> I can't show that this is related or not. I do know I'd rather have the
>> functionality than a pretty form.
>>
>>
>> No reason you can't have both, but let's work on the result display issue
>> first.
>>
>> An ordinary ListView of all objects works normally, as does my
>> DetailView. I have tried several times to re-write views.serp as a cbv with
>> get_context_data, but either context or request or Searchbox() end up being
>> undefined, or an ImportError.
>>
>>
>> Are you overriding get_context_data() correctly? It doesn't sound like it.
>>
>>
>> Finally, a screenshot of my search page, with four spaces for the 4
>> entries that correctly correspond to the query 'eaa'. They just aren't
>> there.
>>
>>
>> This is where the problem is, I think.
>>
>> You should set up a simple loop in your 

Re: Search results in template

2017-12-26 Thread Malik Rumi
Here is the Entry model:

class Entry(models.Model):
title = models.CharField(max_length=100, blank=False, null=False)
slug = models.SlugField(max_length=100)
content = models.TextField()
posted_date = models.DateTimeField(auto_now=True)
chron_date = models.DateField(auto_now=False, auto_now_add=False,
blank=True)
clock = models.TimeField(auto_now=False, auto_now_add=False, blank=True)

ALIGN = "Align"
CULTURE = "Culture"
EXPENSE = "Expense"
INCOME = "Income"
HUMAN_RELATIONSHIPS = "Human Relationships"
CATEGORY_CHOICES = (
(ALIGN, "Align"),
(CULTURE, "Culture"),
(EXPENSE, "Expense"),
(INCOME, "Income"),
(HUMAN_RELATIONSHIPS, "Human Relationships"),
)
category = models.CharField(max_length=25, choices=CATEGORY_CHOICES,
default=INCOME)
tags = models.ManyToManyField(Tag)
search_vector = SearchVectorField(blank=True, null=True)

class Meta:
verbose_name = "Diary Entry"
verbose_name_plural = "Diary Entries"
ordering = ["-chron_date", "clock"]
indexes = [
GinIndex(fields=['search_vector'])
]

def __str__(self):
return self.title

def get_absolute_url(self):
return reverse('detail', kwargs={"slug": self.slug})


You already have the template in my original post to start this thread.

*“None of you has faith until he loves for his brother or his neighbor what
he loves for himself.”*

On Tue, Dec 26, 2017 at 2:26 PM, James Schneider 
wrote:

>
>
>
> The template context says I have a queryset
>
>
> I see it there. Can you post up the model for Entry?
>
>
>
>
> And so does the selection
>
>
> Yes. It appears that you will have 4 results in your queryset.
>
>
>
> I put print statements in the view:
>
> ##
> Quit the server with CONTROL-C.
> This is the value of query:  SearchQuery(eaa)
> This is the value of QuerySet:   further review', 0.151982), ('2017-11-14  Pulling The Trigger', 0.151982),
> ('2017-10-05 A Failure of Incentive?', 0.121585), ('2017-10-20 spider
> refactor', 0.121585)]>
> [26/Dec/2017 18:57:31] "GET /serp/?q=eaa HTTP/1.1" 200 66580
>
> ##
>
>
> At this point, the view doesn't appear to be the problem. We need to start
> tracking things down in the template code.
>
>
>
>
> Note this is all done through my simple html search form, defined in the
> template. My Django Form, SearchBox(), does absolutely nothing, as if it
> isn't connected to anything. I don't understand what the problem there is,
> I can't show that this is related or not. I do know I'd rather have the
> functionality than a pretty form.
>
>
> No reason you can't have both, but let's work on the result display issue
> first.
>
> An ordinary ListView of all objects works normally, as does my DetailView.
> I have tried several times to re-write views.serp as a cbv with
> get_context_data, but either context or request or Searchbox() end up being
> undefined, or an ImportError.
>
>
> Are you overriding get_context_data() correctly? It doesn't sound like it.
>
>
> Finally, a screenshot of my search page, with four spaces for the 4
> entries that correctly correspond to the query 'eaa'. They just aren't
> there.
>
>
> This is where the problem is, I think.
>
> You should set up a simple loop in your template:
>
> 
> {% for obj in QuerySet %}
> {{obj}}
> {% empty %}
> No results
> {% endfor %}
>
> If that works, you should go deeper per your Entry model:
>
>
> 
> {% for obj in QuerySet %}
> {{obj.name}}: {{obj.weight}}
> {% empty %}
> No results
> {% endfor %}
>
> I'm using name and weight as an attribute of Entry, but you should use
> something that matches your model definition. I think the issue is that you
> are not referring to your model correctly within the search results within
> the template.
>
> -James
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/xSW1BjLXXSQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciWvgD7-RnqWJvpKrpYvd2SB2TGwOW2bj4UOcK
> btMJVR%3Dg%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to d

Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Sajid Samsad
Could you kindly suggest me some autocomplete library which I can use for 
my Django Project? My deadline is coming fast and furiously and I have 
already spent too much time on this autocomplete library `Select2`. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aedbaee1-737e-46c1-a6c8-7563d007376d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search results in template

2017-12-26 Thread James Schneider
The template context says I have a queryset


I see it there. Can you post up the model for Entry?




And so does the selection


Yes. It appears that you will have 4 results in your queryset.



I put print statements in the view:

##
Quit the server with CONTROL-C.
This is the value of query:  SearchQuery(eaa)
This is the value of QuerySet:  
[26/Dec/2017 18:57:31] "GET /serp/?q=eaa HTTP/1.1" 200 66580

##


At this point, the view doesn't appear to be the problem. We need to start
tracking things down in the template code.




Note this is all done through my simple html search form, defined in the
template. My Django Form, SearchBox(), does absolutely nothing, as if it
isn't connected to anything. I don't understand what the problem there is,
I can't show that this is related or not. I do know I'd rather have the
functionality than a pretty form.


No reason you can't have both, but let's work on the result display issue
first.

An ordinary ListView of all objects works normally, as does my DetailView.
I have tried several times to re-write views.serp as a cbv with
get_context_data, but either context or request or Searchbox() end up being
undefined, or an ImportError.


Are you overriding get_context_data() correctly? It doesn't sound like it.


Finally, a screenshot of my search page, with four spaces for the 4 entries
that correctly correspond to the query 'eaa'. They just aren't there.


This is where the problem is, I think.

You should set up a simple loop in your template:


{% for obj in QuerySet %}
{{obj}}
{% empty %}
No results
{% endfor %}

If that works, you should go deeper per your Entry model:



{% for obj in QuerySet %}
{{obj.name}}: {{obj.weight}}
{% empty %}
No results
{% endfor %}

I'm using name and weight as an attribute of Entry, but you should use
something that matches your model definition. I think the issue is that you
are not referring to your model correctly within the search results within
the template.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWvgD7-RnqWJvpKrpYvd2SB2TGwOW2bj4UOcKbtMJVR%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Jason
looks like something you should go to the select2 github issue tracker for, 
since this is not a django issue.  

In the meantime, try using the unminified version of select2, would be a 
more relevant stack trace for you to look through the errors without the 
transformed names.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a09559e2-ca16-435f-b0c8-b60ad12f393d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search results in template

2017-12-26 Thread Malik Rumi
PyCharm had my project running in a separate process. Don't worry about
that. I don't think it's a huge issue


I have the right view


The template context says I have a queryset


The explanation seems right.


And so does the selection

I put print statements in the view:

##
Quit the server with CONTROL-C.
This is the value of query:  SearchQuery(eaa)
This is the value of QuerySet:  
[26/Dec/2017 18:57:31] "GET /serp/?q=eaa HTTP/1.1" 200 66580

##

Note this is all done through my simple html search form, defined in the
template. My Django Form, SearchBox(), does absolutely nothing, as if it
isn't connected to anything. I don't understand what the problem there is,
I can't show that this is related or not. I do know I'd rather have the
functionality than a pretty form.

An ordinary ListView of all objects works normally, as does my DetailView.
I have tried several times to re-write views.serp as a cbv with
get_context_data, but either context or request or Searchbox() end up being
undefined, or an ImportError.

Finally, a screenshot of my search page, with four spaces for the 4 entries
that correctly correspond to the query 'eaa'. They just aren't there.






😪



*“None of you has faith until he loves for his brother or his neighbor what
he loves for himself.”*

On Sun, Dec 24, 2017 at 2:44 AM, James Schneider 
wrote:

>
>
> On Dec 23, 2017 5:36 PM, "Malik Rumi"  wrote:
>
> FIRST, James, let me say how much I *greatly* appreciate you hanging in
> there and trying to help me.
>
>
> No worries.
>
> 2nd, as to your two points about the html:
>a. This template, serp_list.html, is identical to ktab_list.html,
> except that serp_list has the title 'SEARCH' at the top and some
> bolierplate text about this being the search results page. Other than that
> they are identical, including the template for loop.
>serp_list is supposed to be called by localhost/serp/, which points
> to views.serp, which is an FBV.
>ktab_list is a vanilla implementation of ListView, called by
> localhost/index/, and it shows all Entry objects as you would expect.
>The header you see is the blog post header, ie, this is where the
> title and the get absoulte url to the detail page is supposed to go. On
> /index/ that works like it should. On serp, well, that's why I am here.
>   b. Your second point is probably well taken, that the for loop should
> completely wrap the article, and that might explain why the author and
> comments part of the last three posts were not the same font as the first
> post. I have changed that in the html, but it has not changed the result.
>
>
> Hooray, at least I've gotten something right. ;-
>
>
> 3rd, just because things weren't complicated enough, now I am getting
> inconsistent results. Whereas before I got views.serp called, a db query
> with 4 results, on the right template, now I am getting a value error
> ('returns None' - how's that for a news flash?). The only difference is
> that I downloaded the free version of pycharm to see if their visual
> debugger would help me. So calling the page through pycharm, instead of the
> regular terminal, is the only difference, and I don't think that should
> make a difference. But either way, I still have no result on my page - and
> oh yea, pycharm says the same thing my print statements did - that the
> query was there and pulled up the expected objects. They just won't show up
> on the template.
>
>
> Confused. You mentioned PyCharm affected the results but then indicated
> the same results?
>
>
> 4th, I don't know how relevant this is, but the form which created the
> search box has the form action = '/serp/', but despite that, if I use the
> search box in /index/, I stay on /index/ and just get the query attached to
> the end of that url, rather than /serp/ plus the query. I have to manually
> type in /serp/ to get  views.serp called. When it stays on  /index/ plus
> the query, the result shown are just Entry.objects.all(), as you would
> expect on a ListView. Any thoughts on that? Is it related? Why isn't my
> form action working? THANKS!
>
>
>
>
> A few (possibly dumb) questions:
>
> Have you verified that the serp.html page is the one actually being
> rendered? DDT can verify this.
>
> Have you confirmed the context being provided to the template actually
> contains the variables and query results you are expecting? DDT can also
> verify this.
>
> Can you do something simple like {{ object_list }} in your template just
> to see if anything is printed? When doing quick troubleshooting I like to
> do this:
>
> |{{ object_list }}|
>
> That way if I see || in the template (and source), I know the variable is
> empty.
>
> Do you have any non-standard middleware or template context processors
> enabled?
>
> Are your forms set to use a method of GET or POST? Sounds like GET but
> just want to verify.
>
> When you are on /index/ and you search, does the runserver console show a
> hit against /serp/ (per the form a

Re: How to parse json and display it in CBV.

2017-12-26 Thread tango ward
Thanks for the idea Andréas. You're always helping me.

On Wed, Dec 27, 2017 at 2:29 AM, Andréas Kühne 
wrote:

> All you need is to send the image (the url to the image) that should be
> shown to the template, and then display it on the template. It shouldn't be
> too hard as long as you understand how to send context data to the template.
>
> See here :
> https://docs.djangoproject.com/en/2.0/topics/class-based-
> views/generic-display/#adding-extra-context
>
> Regards,
>
> Andréas
>
> 2017-12-26 19:07 GMT+01:00 tango ward :
>
>> Hi Andréas,
>>
>> Thanks for the help.
>>
>> Also, I am not sure if the correct term is parse but I also want to
>> display the images of heroes of DOTA 2 from OpenDOTA API. I saw a video on
>> youtube on how to do it however its in Swift. Not sure if I can do it using
>> CBV in django.
>>
>> On Wed, Dec 27, 2017 at 1:56 AM, Andréas Kühne <
>> andreas.ku...@hypercode.se> wrote:
>>
>>> Hi,
>>>
>>> If you want to parse json in django - or in python for that matter - all
>>> you have to do is to use the json module.
>>>
>>> import json
>>>
>>> object = json.loads(insert_string_here)
>>>
>>> insert_string_here is the string that you want to parse - and object is
>>> the parsed json.
>>>
>>> Look here for more information: http://docs.pytho
>>> n-guide.org/en/latest/scenarios/json/
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>> 2017-12-26 18:29 GMT+01:00 tango ward :
>>>

 Hi,

 I need suggestions on this.

 I want to use the OpenDOTA API for my pet project. As a beginner, I
 don't know where to start working on this. I have found the OpenDOTA API
 https://api.opendota.com/api/heroes which I am planning to use but I
 am confuse as to how to parse the json into my CBVs. I read this article
 https://godjango.com/blog/working-with-json-and-django/ but it doesn't
 show how to work with json in CBV.

 What I would like to achieve is to display all heroes from the OpenDOTA
 api link into my template.

 Can anyone shed some light on where should I start?


 Regards,
 Jarvis

 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users+unsubscr...@googlegroups.com.
 To post to this group, send email to django-users@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit https://groups.google.com/d/ms
 gid/django-users/CAA6wQL%2BFW8ZGjgCxX2MKNr9e8mmR6xvsmZwSTufT
 eEFB54tjrA%40mail.gmail.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/CAK4qSCc%3DD43bpYNUXj3NmAqk2kR_fNnNBvTocVWT
>>> r44ioVT_mQ%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAA6wQLJPZmUcG28g%3Dxw%3DWODVHzT06ir1SfQRsn
>> TWUGBV8uBgJQ%40mail.gmail.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAK4qSCe5iKY3p_%2BjaRykG5ov4GjFBJb

Re: How to parse json and display it in CBV.

2017-12-26 Thread Andréas Kühne
All you need is to send the image (the url to the image) that should be
shown to the template, and then display it on the template. It shouldn't be
too hard as long as you understand how to send context data to the template.

See here :
https://docs.djangoproject.com/en/2.0/topics/class-based-views/generic-display/#adding-extra-context

Regards,

Andréas

2017-12-26 19:07 GMT+01:00 tango ward :

> Hi Andréas,
>
> Thanks for the help.
>
> Also, I am not sure if the correct term is parse but I also want to
> display the images of heroes of DOTA 2 from OpenDOTA API. I saw a video on
> youtube on how to do it however its in Swift. Not sure if I can do it using
> CBV in django.
>
> On Wed, Dec 27, 2017 at 1:56 AM, Andréas Kühne  > wrote:
>
>> Hi,
>>
>> If you want to parse json in django - or in python for that matter - all
>> you have to do is to use the json module.
>>
>> import json
>>
>> object = json.loads(insert_string_here)
>>
>> insert_string_here is the string that you want to parse - and object is
>> the parsed json.
>>
>> Look here for more information: http://docs.pytho
>> n-guide.org/en/latest/scenarios/json/
>>
>> Regards,
>>
>> Andréas
>>
>> 2017-12-26 18:29 GMT+01:00 tango ward :
>>
>>>
>>> Hi,
>>>
>>> I need suggestions on this.
>>>
>>> I want to use the OpenDOTA API for my pet project. As a beginner, I
>>> don't know where to start working on this. I have found the OpenDOTA API
>>> https://api.opendota.com/api/heroes which I am planning to use but I am
>>> confuse as to how to parse the json into my CBVs. I read this article
>>> https://godjango.com/blog/working-with-json-and-django/ but it doesn't
>>> show how to work with json in CBV.
>>>
>>> What I would like to achieve is to display all heroes from the OpenDOTA
>>> api link into my template.
>>>
>>> Can anyone shed some light on where should I start?
>>>
>>>
>>> Regards,
>>> Jarvis
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/CAA6wQL%2BFW8ZGjgCxX2MKNr9e8mmR6xvsmZwSTufT
>>> eEFB54tjrA%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAK4qSCc%3DD43bpYNUXj3NmAqk2kR_fNnNBvTocVWT
>> r44ioVT_mQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAA6wQLJPZmUcG28g%3Dxw%3DWODVHzT06ir1SfQRsnTWUGBV8uBg
> JQ%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCe5iKY3p_%2BjaRykG5ov4GjFBJbFaYmYLN7R0aet7hjbcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to parse json and display it in CBV.

2017-12-26 Thread tango ward
Hi Andréas,

Thanks for the help.

Also, I am not sure if the correct term is parse but I also want to display
the images of heroes of DOTA 2 from OpenDOTA API. I saw a video on youtube
on how to do it however its in Swift. Not sure if I can do it using CBV in
django.

On Wed, Dec 27, 2017 at 1:56 AM, Andréas Kühne 
wrote:

> Hi,
>
> If you want to parse json in django - or in python for that matter - all
> you have to do is to use the json module.
>
> import json
>
> object = json.loads(insert_string_here)
>
> insert_string_here is the string that you want to parse - and object is
> the parsed json.
>
> Look here for more information: http://docs.python-guide.org/en/latest/
> scenarios/json/
>
> Regards,
>
> Andréas
>
> 2017-12-26 18:29 GMT+01:00 tango ward :
>
>>
>> Hi,
>>
>> I need suggestions on this.
>>
>> I want to use the OpenDOTA API for my pet project. As a beginner, I don't
>> know where to start working on this. I have found the OpenDOTA API
>> https://api.opendota.com/api/heroes which I am planning to use but I am
>> confuse as to how to parse the json into my CBVs. I read this article
>> https://godjango.com/blog/working-with-json-and-django/ but it doesn't
>> show how to work with json in CBV.
>>
>> What I would like to achieve is to display all heroes from the OpenDOTA
>> api link into my template.
>>
>> Can anyone shed some light on where should I start?
>>
>>
>> Regards,
>> Jarvis
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAA6wQL%2BFW8ZGjgCxX2MKNr9e8mmR6xvsmZwSTufT
>> eEFB54tjrA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAK4qSCc%3DD43bpYNUXj3NmAqk2kR_
> fNnNBvTocVWTr44ioVT_mQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA6wQLJPZmUcG28g%3Dxw%3DWODVHzT06ir1SfQRsnTWUGBV8uBgJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to parse json and display it in CBV.

2017-12-26 Thread Andréas Kühne
Hi,

If you want to parse json in django - or in python for that matter - all
you have to do is to use the json module.

import json

object = json.loads(insert_string_here)

insert_string_here is the string that you want to parse - and object is the
parsed json.

Look here for more information:
http://docs.python-guide.org/en/latest/scenarios/json/

Regards,

Andréas

2017-12-26 18:29 GMT+01:00 tango ward :

>
> Hi,
>
> I need suggestions on this.
>
> I want to use the OpenDOTA API for my pet project. As a beginner, I don't
> know where to start working on this. I have found the OpenDOTA API
> https://api.opendota.com/api/heroes which I am planning to use but I am
> confuse as to how to parse the json into my CBVs. I read this article
> https://godjango.com/blog/working-with-json-and-django/ but it doesn't
> show how to work with json in CBV.
>
> What I would like to achieve is to display all heroes from the OpenDOTA
> api link into my template.
>
> Can anyone shed some light on where should I start?
>
>
> Regards,
> Jarvis
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAA6wQL%2BFW8ZGjgCxX2MKNr9e8mmR6xvsmZw
> STufTeEFB54tjrA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCc%3DD43bpYNUXj3NmAqk2kR_fNnNBvTocVWTr44ioVT_mQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Sajid Samsad

>
> I actually didn't understand your question. 
>
>  

> I have posted the codes above. 
>
>  

> Could you kindly take a look if it's anything with the code?your question.
>
>
I actually didn't understand your question. I have posted the codes above. 
Could you kindly take a look if it's to anything with the codes?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/83df68d9-2d16-4f9f-a74a-bd37f4b14259%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to parse json and display it in CBV.

2017-12-26 Thread tango ward
Hi,

I need suggestions on this.

I want to use the OpenDOTA API for my pet project. As a beginner, I don't
know where to start working on this. I have found the OpenDOTA API
https://api.opendota.com/api/heroes which I am planning to use but I am
confuse as to how to parse the json into my CBVs. I read this article
https://godjango.com/blog/working-with-json-and-django/ but it doesn't show
how to work with json in CBV.

What I would like to achieve is to display all heroes from the OpenDOTA api
link into my template.

Can anyone shed some light on where should I start?


Regards,
Jarvis

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA6wQL%2BFW8ZGjgCxX2MKNr9e8mmR6xvsmZwSTufTeEFB54tjrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Jason
As you can see at https://select2.org/data-sources/ajax#jquery-ajax-options, 
ajax parameters are passed to a jquery method.  So do you have a 

RE: How to store multiple object reference in one field?

2017-12-26 Thread Matthew Pava
Use a many-to-many field instead.
https://docs.djangoproject.com/en/2.0/topics/db/models/#many-to-many-relationships


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Hasanul Islam
Sent: Tuesday, December 26, 2017 9:52 AM
To: Django users
Subject: How to store multiple object reference in one field?

Suppose, I have a model
class Project(models.Model):
name = models.CharField(max_length=50)
Another model,
   class Manager(models.Model)
 name = models.CharField(max_length = 50)
 projects = ArrayField( models.Foreignkey(Project, 
on_delete=models.PROTECT) )

Here, projects field would be an array of Project object. But it is PostgreSQL 
specific. How can I implement this so that it will be useful for every database?
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1f3a4691-fb23-4a42-9387-ea67562635c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7ca4ccae24404cea8643dccc6c42fef3%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


How to store multiple object reference in one field?

2017-12-26 Thread Hasanul Islam
Suppose, I have a model 
class Project(models.Model):
name = models.CharField(max_length=50)
Another model,
   class Manager(models.Model)
 name = models.CharField(max_length = 50)
 projects = ArrayField( models.Foreignkey(Project, 
on_delete=models.PROTECT) )

Here,* projects field would be an array of Project object*. But it is 
PostgreSQL specific. How can I implement this so that it will be useful for 
every database?   

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1f3a4691-fb23-4a42-9387-ea67562635c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Sajid Samsad

>
> Well when I write something in the search options, I got this error:
>
>

But I didn't write the js. It is from select2.
And if the request is not hit then what should I write?
The request for the API is localhost:8000/api.alife-marine/search/products
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb08e04b-03ef-4a0d-8be5-a49dd1265a63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Jason
That;s not quite what I mean 


See above, there's a XHR (ajax) request going to reddit and you can see the 
headers of the request/response as well as the data sent back.  What do you 
see of this when you call your search api?

Because it seems to me your request isn't being hit in the server from the 
client code





On Monday, December 25, 2017 at 8:28:37 PM UTC-5, Sajid Samsad wrote:
>
> To @Jason
>>
>> 1) Yeah. I used the url from the browser and it worked. Actually the 
> whole url is
> localhost:8000//api.alif-marine.com/search/products?q=product_name
> As
> ?q=whatever I type 
> is supposed to be added by javascript so when I am manually doing this 
> from my browser, I am using the above url.
>
> 2) Well I used `//` but didn't work
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/695127be-15d3-4224-a561-37719385850d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] BlogEngine 0.8.2 release

2017-12-26 Thread Etienne Robillard

Hi all,

I'm excited to announce the public release of BlogEngine2, a ZODB 
powered blogging microframework on top of Django. :P


BlogEngine2 is a full-featured API to develop a functional blog site in 
Python and django-hotsauce.


Download:

https://www.isotopesoftware.ca/pub/blogengine2/blogengine2-0.8.2.tar.gz

https://pypi.python.org/pypi/blogengine2/0.8.2

Changes:

- Bugfixes release - Updated to django-hotsauce 0.8.2

For more info, please see the wiki: 
https://www.isotopesoftware.ca/wiki/BlogEngine


Cheers,

Etienne


--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ded3df04-e08e-ebb3-0f7b-28c136a62090%40yandex.com.
For more options, visit https://groups.google.com/d/optout.