Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8407233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:18:21+00:00 2026-06-09T23:18:21+00:00

I made a lookup channel, using django-ajax-select, for an field on Model Areas, to

  • 0

I made a lookup channel, using django-ajax-select, for an field on Model Areas, to use on my ModelForm to select fields when I create or edit a UserProfile.

class FormRegisterProfile(forms.ModelForm):

class Meta: 
    model = UserProfile
    exclude = ('user')

interests  = make_ajax_field(UserProfile,'interests','areas2',help_text=True)
expertise  = make_ajax_field(UserProfile,'expertise','areas2',help_text=True)    

What happens is, when i’m logged with an user that’s do not have admin permission I get this line on server

[16/Aug/2012 14:56:12] "GET /profile/ajax_lookup/areas2?term=g HTTP/1.1" 403 22

my url.py

(r'^admin/lookups/', include(ajax_select_urls)),
(r'^profile/', include(ajax_select_urls)),
url(r'^profile/edit/$', 'mycu.views.EditUserProfile', {}, 'register.html'),
url(r'^admin/', include(admin.site.urls)),

my lookup channel:

AJAX_LOOKUP_CHANNELS = {
'areas'  : {'model':'mycu.areas', 'search_field':'type'},
'areas2' : ('mycu.lookups', 'AreasLookup'),

my lookups.py

class AreasLookup(LookupChannel):

    model = Areas

    def get_query(self,q,request):
        return Areas.objects.filter(Q(type__icontains=q)).order_by('type')

    def get_result(self,obj):
        u""" result is the simple text that is the completion of what the person typed """
        return obj.type

    def format_match(self,obj):
        """ (HTML) formatted item for display in the dropdown """
        return self.format_item_display(obj)

    def format_item_display(self,obj):
        """ (HTML) formatted item for displaying item in the selected deck area """
        return u"%s" % (escape(obj.type))

without the ‘make_ajax_fields’ lines on ModelForm, I can easily access the model areas.

what I’m not figured out is:

what’s the relationship between admin/lookups

thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:18:23+00:00Added an answer on June 9, 2026 at 11:18 pm

    The default permissions for django-ajax-selects require the user to be staff (user.is_staff) . See the README note on changing this default in your LookupChannel https://github.com/crucialfelix/django-ajax-selects#check_authselfrequest

    check_auth(self,request):

    To ensure that nobody can get your data via json simply by knowing the
    URL. The default is to limit it to request.user.is_staff and raise a
    PermissionDenied exception. By default this is an error with a 401
    response, but your middleware may intercept and choose to do other
    things.

    Public facing forms should write a custom LookupChannel to implement
    as needed. Also you could choose to return HttpResponseForbidden(“who
    are you?”) instead of raising PermissionDenied

    This incorrectly states that it will return a 401 status code when in fact Django will handle the PermissionDenied with a 403 response like you are seeing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using (or trying to use) a lookup table to represent a column
I'm using django-ajax-selects , which is a freely available django app providing jquery autocomplete
Made a custom obj called Item with some string fields and one float. .h
Edit: Maybe I made the question more complex than it should. My questions is
While trying to call an EJB made using NETbeans (using jdk1.7) from a client
Has anyone ever made a sharepoint lookup column that allows fill inn choices and
I've created a plugin to create new records when a field changes on another
I made that one column id GridView is lookup from stored procedure. Stored procedure
A recent talk about unordered_map in C++ made me realize that I should use
I've made a game using the Canvas element and with 300+ images being drawn

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.