[Django] #29010: Which models is using search_fields to get_search_results

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29010: Which models is using search_fields to get_search_results

Django
#29010: Which models is using search_fields to get_search_results
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  MakdosBilisim                      |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  2.0
  layer (models, ORM)                |       Keywords:  ForeignKey,
               Severity:  Normal     |  get_search_results, search_fields
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I have A,B,C models. A and B models are using C model's ForeignKey for
 autocomplete.

 How can i find which model is querying?

--
Ticket URL: <https://code.djangoproject.com/ticket/29010>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/056.c01a816d832e94d548a02c61ff55f131%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29010: Which models is querying search_fields to autocomplete? (was: Which models is using search_fields to get_search_results)

Django
#29010: Which models is querying search_fields to autocomplete?
-------------------------------------+-------------------------------------
     Reporter:  Makdos Bili┼čim       |                    Owner:  nobody
  Teknolojileri                      |
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  ForeignKey,          |             Triage Stage:
  get_search_results, search_fields  |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/29010#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.a8410656d981ff1d808e14133438426c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29010: Which models is querying search_fields to autocomplete?

Django
In reply to this post by Django
#29010: Which models is querying search_fields to autocomplete?
-------------------------------------+-------------------------------------
     Reporter:  Muslu Y.             |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  ForeignKey,          |             Triage Stage:
  get_search_results, search_fields  |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 I don't understand your question, and this isn't the place to ask usage
 questions. Please see TicketClosingReasons/UseSupportChannels.

--
Ticket URL: <https://code.djangoproject.com/ticket/29010#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.b0b6dc142e7f9d8d2a499aeeec89e2f2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29010: Which models is querying search_fields to autocomplete?

Django
In reply to this post by Django
#29010: Which models is querying search_fields to autocomplete?
-------------------------------------+-------------------------------------
     Reporter:  Muslu Y.             |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  ForeignKey,          |             Triage Stage:
  get_search_results, search_fields  |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Muslu Y.):

 * status:  closed => new
 * resolution:  invalid =>


Comment:

 I think Autocomplete is not enough right now.

 **models.py**

 {{{
 class A(models.Model):
     a_name = models.CharField(max_length=100)

 class B(models.Model):
     b_name   =   models.ManyToManyField(A)

 class C(models.Model):
     c_name   =   models.ManyToManyField(A)
 }}}


 **admin.py**

 {{{
 class AAdmin(admin.ModelAdmin):
     search_fields       =   ['a_name']

     def get_search_results(self, request, queryset, search_term):
         queryset, use_distinct  =   super().get_search_results(request,
 queryset, search_term)

         ## how can i learn which models (B or C) querying for a_name?
         ## because i want to separately filter for every model


 class BAdmin(admin.ModelAdmin):
     autocomplete_fields    =   ['b_name']

 class CAdmin(admin.ModelAdmin):
     autocomplete_fields    =   ['c_name']
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29010#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.b35a396b821c1d45194624da328462d2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29010: Allow customizing the autocomplete search results based on the querying model (was: Which models is querying search_fields to autocomplete?)

Django
In reply to this post by Django
#29010: Allow customizing the autocomplete search results based on the querying
model
-------------------------------------+-------------------------------------
     Reporter:  Muslu Y.             |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  contrib.admin        |                  Version:  2.0
     Severity:  Normal               |               Resolution:
     Keywords:  ForeignKey,          |             Triage Stage:
  get_search_results, search_fields  |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * cc: Johannes Hoppe (added)
 * component:  Database layer (models, ORM) => contrib.admin


Comment:

 I see. I guess it might be possible to add a hint of the model where the
 query is coming from in a GET parameter. That would be untrusted though.

--
Ticket URL: <https://code.djangoproject.com/ticket/29010#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.966b6b9fa679464f5ca5a02b35212fe8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29010: Allow customizing the autocomplete search results based on the querying model

Django
In reply to this post by Django
#29010: Allow customizing the autocomplete search results based on the querying
model
-------------------------------------+-------------------------------------
     Reporter:  Muslu Y.             |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  contrib.admin        |                  Version:  2.0
     Severity:  Normal               |               Resolution:
     Keywords:  ForeignKey,          |             Triage Stage:  Accepted
  get_search_results, search_fields  |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * stage:  Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29010#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.db54a8ae3cc4b9aca4b1198ebab11aa8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29010: Allow customizing the autocomplete search results based on the querying model

Django
In reply to this post by Django
#29010: Allow customizing the autocomplete search results based on the querying
model
-------------------------------------+-------------------------------------
     Reporter:  Muslu Y.             |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  contrib.admin        |                  Version:  2.0
     Severity:  Normal               |               Resolution:
     Keywords:  ForeignKey,          |             Triage Stage:
  get_search_results, search_fields  |  Someday/Maybe
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Johannes Hoppe):

 * stage:  Accepted => Someday/Maybe


Comment:

 Hi there,

 currently you don't explicitly know who is calling this method, since it's
 all called from the same view. Both Widgets call the same view as the view
 is on AAdmin.
 So this is conceptually not supported. That doesn't mean it doesn't work.
 You can always check https://en.wikipedia.org/wiki/HTTP_referer

 To add a bit more context here, we did have an intermediate solution that
 would have made this easier. A view per widget. We ultimately dropped that
 approach to decrease complexity. A decision I still support.

 My suggestion would be use an external library like `django-select2` or
 `django-autocomplete` if you want to implement more sophisticated logic.
 Please also keep in mind, the admin is not recommend to be used for
 sofistikated user interfaces.

 Anyhow, at the moment I would strongly advice against adding a "hint" to
 the request. Since it's not safe against request forging and can lead to
 unintended security issues.

--
Ticket URL: <https://code.djangoproject.com/ticket/29010#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.382b4a7074c58830131c7d00e5943d66%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.