Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django - temporarily storing figures
I have a database with population data. I want to create a page that shows a figure of this data (with for example matplotlib). How and where would I store the figures which I create with matplotlib? Example data: year | people 2010 | 100 2011 | 110 2012 | 110 2013 | 114 2014 | 124 2015 | 154 2016 | 143 2017 | 112 In my view I already have collected the variable, year and people. I would normally do something like this: plt.plot(year, people) plt.savefig('figure.svg') The question is where/how would I store this and present it to the user? Should I store this in a media directory? I do not want to store the file forever cause then diskspace would quickly fill up with graphs which are only used once. -
Django Bower - ImportError
I am currently making a django application that requires me to add Bower and django-schedule library. When i try to make migrations, I get this error: Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line utility.execute() File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 347, in execute django.setup() File "C:\Python34\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Python34\lib\site-packages\django\apps\registry.py", line 89, in populate app_config = AppConfig.create(entry) File "C:\Python34\lib\site-packages\django\apps\config.py", line 90, in create module = import_module(entry) File "C:\Python34\lib\importlib\__init__.py", line 109, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 2254, in _gcd_import File "<frozen importlib._bootstrap>", line 2237, in _find_and_load File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked ImportError: No module named 'djangobower' my settings.py consists of: INSTALLED_APPS = [ 'patients.apps.PatientsConfig', 'accounts.apps.AccountsConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'djangobower', 'schedule', ] BOWER_COMPONENTS_ROOT = 'Project root/components/' BOWER_INSTALLED_APPS = ( 'jquery', 'jquery-ui', 'bootstrap', 'fullcalendar' ) i am using pycharm as my IDE and in bower apps, it shows jquery-ui and fullcalendar as unresolved, even though I have installed them. Any help is appreciated. -
Django-, display and filter particular fields from a foreign key in a model form
I am using a model form, and the field is a foreign key, to another the model, the foreign key model contains a choice field(status) which i want filter based on user group,such that if a user belongs to a group, for example if the user in a group DEVELOPER, the status choices available will be 'Weekly Task' and 'Daily Task' models.py class ScrumyGoals(models.Model): user_name=models.ForeignKey('ScrumyUser', on_delete= models.CASCADE, null= True) status_id = models.ForeignKey('GoalStatus', on_delete=models.CASCADE,null=True) goal_type = models.CharField(choices=GOAL_TYPE, max_length=64, default='DT') def __str__(self): return '{},{}'.format(self.user_name,self.status_id) class GoalStatus(models.Model): GOALS_TYPE= (('DT','Daily Task'), ('WT','Weekly Task'), ('V','Verified'), ('D','Done'), ) title = models.CharField(max_length=254, null=True) task_id=models.IntegerField(default=1,null=False) description =models.CharField(max_length=254) verified_by=models.ForeignKey('ScrumyUser', on_delete= models.CASCADE, null=True) status=models.CharField(choices=GOALS_TYPE, max_length=2, default='DT') forms.py class ChangeTaskForm(forms.ModelForm): class Meta: model = ScrumyGoals fields = ['status_id'] def __init__(self, *args, **kwargs): user = kwargs.pop('user', None) super(ChangeTaskForm, self).__init__(*args, **kwargs) if user.groups.filter(name ='DEVELOPER').exists(): self.fields['status'].choices = (('WT','Weekly Task'), ('DT','Daily Task'),) views.py def changetask(request): if request.method == 'POST': form = ChangeTaskForm(request.POST, user=request.user) if form.is_valid(): return HttpResponseRedirect('/index/') else: form = ChangeTaskForm(user=request.user) return render(request, 'oderascrumy/changetask.html', {'form': form}) The form only currently shows the status_id , it doesn't show the choices (ie "status") so in essence what i want is this if the logged in user is in group say "DEVELOPER", The user can only change the … -
NodeJS lacks ORM?
I have looked and worked with couple of back-end frameworks like django, RoR, Spring Boot. All of them come with a built in ORM. But NodeJS is popular as others, lacks an inbuilt ORM. What could be the reason behind the lack of built-in ORM? -
How to debug ajax view in production?
I have this view which only responses on AJAX requests: def ajax_product_details_like_prods(request, product_id): like_prods = None product = get_object_or_404(Product, product_id=product_id) # Haystack if product != None: like_prods = SearchQuerySet().more_like_this(product)[:15] html = render_to_string('ajax/product_details.html', {"most_visited": like_prods}) return HttpResponse(html) This code works on local dev server, but it throws 500 error in dev-tools console when I try to access page with that AJAX on my production server. More details: 1) This view uses Haystack+Whoosh connection: HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', 'PATH': os.path.join(BASE_DIR, 'whoosh_index') }, } And this seems to be ok - when I run manage.py shell and print settings.HAYSTACK_CONNECTIONS - i see a right path. 2) There are all needed indexes in whoosh_index folder. They are generated on my local machine and then uploaded to prod. But I think that might work cuz I tested to copy indexes and they worked on local. How can I check on what stage this AJAX view fails? -
How to download excel file
I am working with the GUI where there is a button. On button click, an ajax call happens which returns a JSON to the backend in Django's view.py. On the basis of the JSON, I am creating an excel file and the path of this file is returned to the place where ajax call happened. I want that file to download on the click of the same button. i.e, is it possible to do all these operations (from ajax call to download the excel file) with one click of that button? -
Django - getting the original class name in abstact method
What I am trying to do is best described by the following example: class MyAbstractClass(models.Model): abstract_field = IntegerField() class Meta: abstract = True def abstract_method(self): # THE ISSUE LIES IN THE LINE BELOW ParentClass.objects.filter(..).update(....) return self class InheritedClass(MyAbstractClass): # Field def my_view(request): obj = InheritedClass.objects.get(id=1) obj.save() return obj So basically, the question is, is there any way in the abstract_method to tell Django to address the calling class (that is, InheritedClass)? -
Django - This is field is required error
I am new to Django and trying to save some data from the form to the model i.e. from a html template to a view.My submit code is: def submitNewIdea(request): #get the context from the request context = RequestContext(request) print(context) #A HTTP POST? if request.method == 'POST': form = submitNewIdeaForm(request.POST) # Have we been provided with a valid form? if form.is_valid(): # Save the new Idea to the Idea model print(request.POST.get("IdeaCategory")) print(request.POST.get("IdeaSubCategory")) i = Idea( idea_heading = form["idea_heading"].value() ,idea_description = form["idea_description"].value() ,idea_created_by = form["idea_created_by"].value() ,idea_votes = form["idea_votes"].value() ,idea_category = request.POST.get("IdeaCategory") #value from dropdown ,idea_sub_category = request.POST.get("IdeaSubCategory") #value from dropdown ) i.save() # get the just saved id print(Idea.objects.get(pk = i.id)) iu = IdeaUpvotes(idea_id = Idea.objects.get(pk = i.id) ,upvoted_by = form["upvoted_by"].value() ,upvoted_date = timezone.now() ) iu.save() form.save(commit = True) # Now call the index() view. # The user will be shown the homepage. return index(request) else: # The supplied form contained errors - just print them to the terminal. print (form.errors) else: # If the request was not a POST, display the form to enter details. form = submitNewIdeaForm() # Bad form (or form details), no form supplied... # Render the form with error messages (if any). return render(request,'Ideas/Index.html',{'form' :form}) I … -
Simple Delete form django
I need to make a very simple form where you can chose by name field from a dropdown, hit submit and the object with that name from the database should get deleted. The code below works but i cannot figure out how to pass all the Categories model Objects to be selectable. Example: if the database has 2 objects: id = 1, name = Fruits, id = 2, name = Bats, I need a dropdown to choose bats and delete it. Right now, if i remove the widgets = { 'name' : forms.Select, } line from Forms.py i can write Bats and it will delete it. Code: Model.py class Categories(models.Model): id = models.AutoField(primary_key = True) name = models.CharField (max_length = 50) Forms.py class DeleteCategoryForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(DeleteCategoryForm,self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'POST' self.helper.add_input(Submit('submit', 'Submit', css_class='btn-success')) class Meta: model = Categories fields = ['name'] ##Pass Categories.objects.all() here somehow to this Select field widgets = { 'name' : forms.Select, } Views.py if request.method == "POST": form = DeleteCategoryForm(request.POST) if form.is_valid(): to_delete_name = form.cleaned_data['name'] to_delete_object = Categories.objects.get(name = to_delete_name) to_delete_object.delete() -
How can I implement keystroke live update from a database?
I am developing a web app with a "search functionality", in the search functionality, I would like the app to display the database matches with every keystroke in the search field by the user. The picture below shows what I am trying to achieve. I am developing with Python Django. thanking you in advance. -
how to make a url pattern for a query string django
After the form is submitted a get request with parameters will be created, I was struggling with the regex in the urls.py I want to know the pattern for this Get request /create-usecase/?usecase_name=test&category=1&sub_category=msameh&csrfmiddlewaretoken=m4UIwr0qsWuAwVJq7OCLt6KY8EnFrlFDNGJcTUicY2rUylMgFMzILElZaPDbNLtr and how to get these values in the view function -
Django Cart Model with products - implementing quantity of items
I've got a Cart, Product and a Entry model. What I'm trying to do is giving users the option to put more then one item in the cart and displaying the quantity in the checkout. I can get the chosen quantity over quantity_input= request.POST.get('quantity-field') and create a new Entry object within the cart_update() Entry.objects.create(cart=cart_obj, product=product_obj, quantity=quantity_form) which knows what cart and product it belongs to. But then I hit a wall in outputting it over the view since I'm only having a cart_obj as context not knowing how to also render the entry object in addition. Also outputting cart.count in my home.html will always return 0, even tho the @receiver(post_save, sender=Entry) def update_cart(sender, instance, **kwargs): should update that after every added item? Cart Model: class Cart(models.Model): user = models.ForeignKey(User, null=True, blank=True) products = models.ManyToManyField(Product, blank=True) subtotal = models.DecimalField(default=0.00, decimal_places=2, max_digits=100) total = models.DecimalField(default=0.00, decimal_places=2, max_digits=100) count = models.PositiveIntegerField(default=0) objects = CartManager() class CartManager(models.Manager): def new_or_get(self, request): cart_id = request.session.get("cart_id", None) qs = self.get_queryset().filter(id=cart_id) if qs.count() == 1: new_obj = False cart_obj = qs.first() if request.user.is_authenticated() and cart_obj.user is None: cart_obj.user = request.user cart_obj.save() else: cart_obj = Cart.objects.new_cart(user=request.user) new_obj = True request.session['cart_id'] = cart_obj.id return cart_obj, new_obj Entry Model class Entry(models.Model): … -
Django DB Log Issue
I have placed the log handler for django.db.backends and each call it querying 3 times as per log.It should be call only one times >>> Person.objects.all() oscar_demo_api.Person.objects *****verbose***********DEBUG 2018-05-16 09:53:24,646 utils 1 140058399721216 (0.001) SELECT "oscar_demo_api_person"."id", "oscar_demo_api_person"."timestamp", "oscar_demo_api_person"."created_at", "oscar_demo_api_person"."active", "oscar_demo_api_person"."create_date", "oscar_demo_api_person"."write_date", "oscar_demo_api_person"."first_name", "oscar_demo_api_person"."last_name", "oscar_demo_api_person"."role" FROM "oscar_demo_api_person" WHERE "oscar_demo_api_person"."active" = 1 LIMIT 21; args=(True,) (0.001) SELECT "oscar_demo_api_person"."id", "oscar_demo_api_person"."timestamp", "oscar_demo_api_person"."created_at", "oscar_demo_api_person"."active", "oscar_demo_api_person"."create_date", "oscar_demo_api_person"."write_date", "oscar_demo_api_person"."first_name", "oscar_demo_api_person"."last_name", "oscar_demo_api_person"."role" FROM "oscar_demo_api_person" WHERE "oscar_demo_api_person"."active" = 1 LIMIT 21; args=(True,) (0.001) SELECT "oscar_demo_api_person"."id", "oscar_demo_api_person"."timestamp", "oscar_demo_api_person"."created_at", "oscar_demo_api_person"."active", "oscar_demo_api_person"."create_date", "oscar_demo_api_person"."write_date", "oscar_demo_api_person"."first_name", "oscar_demo_api_person"."last_name", "oscar_demo_api_person"."role" FROM "oscar_demo_api_person" WHERE "oscar_demo_api_person"."active" = 1 LIMIT 21; args=(True,) (0.001) SELECT "oscar_demo_api_person"."id", "oscar_demo_api_person"."timestamp", "oscar_demo_api_person"."created_at", "oscar_demo_api_person"."active", "oscar_demo_api_person"."create_date", "oscar_demo_api_person"."write_date", "oscar_demo_api_person"."first_name", "oscar_demo_api_person"."last_name", "oscar_demo_api_person"."role" FROM "oscar_demo_api_person" WHERE "oscar_demo_api_person"."active" = 1 LIMIT 21; args=(True,) <QuerySet []> Above here SELECT statement is called 3 times why ?? please guide. Here is my log config: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '*****verbose***********%(levelname)s %(asctime)s %(module)s ' '%(process)d %(thread)d %(message)s' }, 'simple': { 'format': '=====simple===========%(levelname)s %(asctime)s %(module)s %(message)s' }, }, 'handlers': { 'console_sys': { 'class': 'logging.StreamHandler', 'stream': sys.stdout, }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose' }, 'file': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'filename': os.path.join(BASE_DIR, 'log_file.txt'), 'formatter': 'verbose' }, }, 'loggers': { 'django.db.backends': { 'level': 'DEBUG', # 'level': … -
Rest FrameWork 3.7 with django 2.0, Post method does not working in API documention?
view.py class AreaViewSet(viewsets.ModelViewSet): """ create: Create a new area instance. """ serializer_class = AreaSerializer parser_classes = (FormParser, MultiPartParser,FileUploadParser) queryset = User.objects.all() permission_classes = [AllowAny, ] filter_backends = (DjangoFilterBackend,) filter_fields = ('first_name',) def create(self, request): data = self.request.data with transaction.atomic(): name = data['name'] address = data['address'] email = json.loads(data['email']) phone = json.loads(data['phone']) zipcode = data['zipcode'] area = Area.objects.create(name=name,address=address, zipcode=zipcode) for i in email: Email.objects.create(email=i['email'], area = area) for i in phone: Phone.objects.create(phone=i['phone'], area=area) return Response({'status': {'code': status.HTTP_200_OK, 'error': None, 'message':' Area has been added.' }, 'data': None}) serializer.py class AreaSerializer(serializers.ModelSerializer): email = EmailSerializer(many=True) phone = PhoneSerializer(many=True) class Meta: model = Area fields = '__all__' i am using http://www.django-rest-framework.org/topics/documenting-your-api/ There is no file upload in image field in default docs. In email and phone field it is accepting as list but i want these accept list as string ? When all data is filled up, when i send request it does not response from server.. it is always showing waiting request ? image upload and file upload in not working in ui of docs ? Please help to solve these problems. -
Django Slug raising error NoReverse Match
I am working on a django project(Django v2.0) which has users from different groups, this group is set up within the user profile. I would like to make the website more personal and have the user's group at the start of the website's url (added in through a slug), after they login. Ideally once they login they would then be redirected to the right page with that slug at the beginning of the url. Within the login page I access the user's group, this group is called and will from now on be referred to as troop, to minimise confusion with Django groups. Here's my login class post view where I retrieve this: def post(self, request): def normal_user(user): return user.groups.filter(name='Normal_User').exists() username = request.POST['username'] password = request.POST['password'] user = authenticate(request, username=username, password=password) if user is not None: login(request, user) if normal_user(user): redirecting_url = 'accounts:home' elif user.is_superuser: redirecting_url = 'admin:index' slug = user.userprofile.troop return redirect(redirecting_url, slug=slug) else: form = AuthenticationForm() error = True args = {'form': form, 'error': error} return render(request, self.template_name, args) In this case I am trying to access the url "account" which I have called "home" and is in my app "accounts". My home function in views.py in the … -
Django Deployed on apache returns: The view didn't return an HttpResponse object. It returned None instead
I have a problem when I deployed django on Apache. I have a view : @csrf_exempt def login(request,id=-1): if request.method == 'POST': if 'HTTP_AUTHORIZATION' in request.META: auth_header = request.META['HTTP_AUTHORIZATION'] encoded_credentials = auth_header.split(' ')[1] decoded_credentials = base64.b64decode(encoded_credentials).decode("utf-8")\ .split(':') username = decoded_credentials[0] password = decoded_credentials[1] if username is '' or password is '': return JsonResponse({'Please enter username & password': 1}) info = Personel.validation(username,password) if info == -1: return JsonResponse({' page_not_found': 404}) if info == 0: return JsonResponse({' permission_denied': 403}) if info == 1: personpass = Personel.objects.filter(username=username,password=password) dd=Personel.serializer.__get__(personpass[0]) data2 = json.dumps(list(personpass[0].serializer)) data2 = json.dumps(dd) return JsonResponse(data2,status=200, safe=False) I call it using this url http://127.0.0.1:8000/views/login on my development host (127.0.0.1:8000) when I call it and provide a user/password by http authorization it works fine. Yesterday I deployed my site on server. it is windows and I am using Apache, When I call the above route it returns this error The view didn't return an HttpResponse object. It returned None instead Nothing is changed. My server is deployed fine and django admin page works fine. I can not find the reason why this happens -
Django: Where to clean values from URL?
I want to write a class based view, and I want to clean a part of the URL: The URL looks like this: r'^some-date/(?P<date>\d\d\d\d-\d\d-\d\d)/view' Which method should I use to "clean" the string (for example "2018-12-31") to the python datetime object? -
Django- How to define dajngo variable in template by javascript variable?
Is their any way to define django variable in template by javascript variable -
How to change task status in django scrum app
I need help with this to change task status for user groups (developer,owner,quality analyst,admin) for a scrum app built with Django. I need to change the status of the task from daily goal to weekly goal through a html template and I got stuck path('/changestatus/', views.ChangeTaskStatus, name='change_status'), def ChangeTaskStatus(request, goal_id): message = '' if request.user.is_authenticated: current_user = request.user current_user_group = current_user.groups.all() if current_user_group : if request.method =="POST": form = ChangeTaskStatusForm(request.POST) if form.is_valid: new_status = request.POST.get('status_id') status_object = GoalStatus.objects.get(id=new_status) try: goal = ScrumyGoals.objects.get(id=goal_id) goal_status = goal.status_id except ScrumyGoals.DoesNotExist: raise Http404('No goal assigned with the id ' + str(goal_id)) if str(current_user_group[0]) == 'OWNER': goal.status_id = status_object elif str(current_user_group[0]) == 'QUALITY ANALYST': if str(goal_status) == 'V' and status_object.status == 'D': goal.status_id = status_object else: print('Access denied to move this status') elif str(current_user_group[0]) == 'DEVELOPER': if str(goal_status) == 'WT' and status_object.status == 'DT': goal.status_id = status_object else : print('Access denied to move this status') else: message += 'You do not have permission to change this goal status' return HttpResponse('No permission defined for this group') goal.save() return redirect('app:index') else: form = ChangeTaskStatusForm() context = {'form':form} return render(request, 'okoroscrumy/changestatus.html',context) else: print('user does not belong to any group') return HttpResponse('user does not belong to any group') else: … -
Test that RedisChannelLayer is available
I'm setting up websocket communication in my django project using Channels. I receive a Multiple exceptions: [Errno 61] Connect call failed ('::1', 6379), [Errno 61] Connect call failed ('127.0.0.1', 6379) which is not surprising, since I have not started the redis server yet. But how would I go about testing for the availability of redis before calling function upon it, like "self.channel_layer.group_add()" in my consumer? -
Allow user moving specific topic up and down in an interactive mode
In Django's template, I could list some topic as below: with codes: <ol> {% for topic in topics %} <li> <h5> <a href="{% url "learning_logs:topic" topic.id %}">{{ topic }}</a> </h5> </li> {% endfor %} </ol> The problem is that they are read-only to the users. How to allow user moving specific topic up and down to resort them? -
Get element 'id' when clicked, then activate corresponding 'sibling'. JS & Django
I am working on a Django website where customers can book mobile barbers for appointments in their own home. All the barbers in our model 'BarberProfile' are visible on our /barbers page (image below). Each barber has a profile image with a left and right arrow on either side. When these arrows are clicked, I want the specific barber's haircut demo images to appear instead of their profile image, essentially an 'image slider'. I have successfully made an image slider using the JS code below (profile.js). But, I'm now having this problem: How do I prevent other barber's image sliders being activated when a specific barber's arrows are clicked? When a specific profiles arrows are clicked I only want the corresponding image slider to activate. I'm almost 100% sure the solution lies in giving each set of arrows, and each slider a unique 'id'. So, I gave the arrows and images these id's: id="arrow-left-{{BarberProfile.id}}" id="arrow-right-{{BarberProfile.id}}" id="slide-{{BarberProfile.id}}" I also managed to get an elements 'id' onclick, but I am unsure how to pass this into the 'let' document.querySelector, or if this is even the right thing to do. function printID(e) { e = e || window.event; e = e.target || e.srcElement; … -
Insert a row when you have a foreign key
I have the following model class Hostel(models.Model): class Meta: unique_together = (('name ', 'room_number'),) name = models.CharField(max_length=30, choices=HOSTELS) room_number= models.IntegerField() faculty = models.CharField(max_length=40, choices=FACULTIES, blank=True) def __str__(self): return self.faculty + ': ' + self.name + ' - ' + str(self.room_number) class MultimeStabila(models.Model): room = models.ForeignKey(Hostel, primary_key=True) guest1= models.CharField(max_length=30) guest2= models.CharField(max_length=30) guest3= models.CharField(max_length=30, blank=True, default="") guest4= models.CharField(max_length=30, blank=True, default="") guest5= models.CharField(max_length=30, blank=True, default="") def __str__(self): return self.guest1+ ' - ' + self.guest2+ ' - ' + self.guest3+ ' - ' + self.guest4 + ' - ' + self.guest5 Now I want to do an insert in MultimeStabila table a,b,c,d,e guests in room number 14 c = conn.cursor() c.execute("SELECT * from stable_hostel where room_number = %s", [14]) data = c.fetchall() c.execute("INSERT INTO stable_multimestabila(hostel_id, guest1, guest2, guest3, guest4, guest5) VALUES(%s, 'a', 'b', 'c', 'd', 'e')", [data[0]]) conn.commit() but it tells me (1241, 'Operand should contain 1 column(s)') Where am I wrong? Thanks in advance P.S.: I saw this post which seems to fit my problem, but it does not work. -
Django Admin filter for another model inside edit form
I face the following problem. I have 3 different Models: 1.) Testsuite (which contains a list of Tests) 2.) Test (which have different groups. e.g. "production","live", "frontend", "backend" , etc) 3.) Groups (list of all available groups. The tester needs to create a test suite with a list of tests. But adding them one by one is not suitable. The better option is to add them in bulk sorted by groups. I am looking for 2 solutions. Include the filter option inside the edit form. That filter here would be nice or The other options. The horizontal list in the edit form is able to search for the Group tags. Some code to get a better understanding. in the forms.py: <pre> class TestSuiteForm(forms.ModelForm): class Meta: model = TestSuiteModel fields = ('name','testcases' , 'nutzer' ) widgets = { 'testcases': autocomplete.ModelSelect2Multiple( 'Testcase_autocomplete' ) } class TestCaseForm(forms.ModelForm): class Meta: model = TestCaseModel fields = ('name', 'testsuite' , 'gruppen' , 'portal' ) widgets = { 'testsuite': autocomplete.ModelSelect2Multiple( 'Testsuite_autocomplete' ), 'gruppen': autocomplete.ModelSelect2Multiple( 'Gruppen_autocomplete' ), } class GroupForm(forms.ModelForm): class Meta: model = GroupModel fields = ('name', 'testcases' ) widgets = { 'testcases': autocomplete.ModelSelect2Multiple( 'Testcase_autocomplete' ) } </pre> the admin.py <pre> class TestSuiteFormAdmin(admin.ModelAdmin): search_fields = ('name',) form … -
How can I understand what is the method performed when an API implemented in Django is called?
I am absolutly not a Python developer (I am a Java dev) but I have to do some minor change on a Python projcet based on Django framework and I am finding some difficulties trying to understand how it works. Basically I have to do a change into an API that have the following endpoint: https://MY-PROJECT-NAME-backend.herokuapp.com/api/v1/accounts:accounts/ (I retrireved it analyzing te call made by a web application using the Chrome DevTool Network tab) Coming from Java Spring framework I am pretty sure that also DJango should map this endpoint to a method that implement my API logic, is it? How can I retrieve this method? (I need to understand what method is performed when this call happens). Another doubt is: I think that this is the endpoint URL: https://MY-PROJECT-NAME-backend.herokuapp.com/api/v1/accounts but what is this :accounts/ appended at the end of the URL? Thank you