DRF: Avoid exposing the API

Utilizing Django in conjunction with Django Rest Framework, I have made the browseable api inaccessible in the settings.py file. Despite this configuration, when I navigate to http://example.com/api - with "example.com" representing my domain - I encounter the following response:

{"api/projects":"http://example.com/api/projects/"}

I do not desire this output, it should remain empty as I did not define that specific endpoint myself. How can I instruct DRF to avoid disclosing any details about my API unless explicitly directed to?

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    )
}

Answer №1

I'm struggling to comprehend the issue you are facing. Please be sure to provide sufficient code examples for better understanding.

My suggestion: Implement the SimpleRouter to configure API URLs, as opposed to the DefaultRouter.

The DefaultRouter is comparable to SimpleRouter, but it also includes a default API root view that displays hyperlinks to all list views. It can generate routes with optional .json formatted suffixes.

https://www.django-rest-framework.org/api-guide/routers/#defaultrouter

Does this align with what you were inquiring about?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error message "Connection refused because of timeout duration exceeded"

File "/home/abhigenie92/stanford2/Code/dependencies.py", line 18, encountering error in the get_dependencies function: result = loads(server.parse(sentence)); File "/home/abhigenie92/stanford-corenlp-python/jsonrpc.py", line 934, while making a call ...

Python Package limit exceeded when uploading Lambda Function

My python code has several dependencies that need to be included: import json import pydicom from pydicom.dataset import Dataset, FileDataset from pydicom.uid import ImplicitVRLittleEndian import numpy as np from PIL import Image import cv2 import datetime ...

Unable to transfer a bulky Excel document with Openpyxl

In a dilemma with a 9000 row x 30 column Excel file that needs to be transferred from one Excel workbook to another. The challenge arises when the code never seems to stop running, consuming a significant portion of my laptop's memory (screenshot). I ...

issue with accessing global variable within class block

While the Python code within the 'outer' function runs smoothly on its own, placing it inside a class seems to cause issues that are difficult for me to comprehend. (I am aware that I could simply pass data as a variable inside the function or d ...

Error: 'Key(s) not found: 'io.excel.zip.reader''

When attempting to combine several files with the extension .xlsx.zip into one, I keep encountering this particular error. To start off, I am utilizing glob.glob to select the files which is working perfectly: stock_files = glob.glob('*/*.xlsx.zip&ap ...

Navigate to the correct page when the Button is clicked in a ReactJS/Django project

Embarking on my web development journey, I opted for django/Reactjs to build a social network platform. I created several API methods like account/view_user/ to retrieve a list of users and account/view_user/ for specific user attributes. In React, I cra ...

Reportlab is unable to locate the _imaging module when using the production server

I'm encountering an issue while attempting to deploy a Django app on the production server. The error message reads: ImportError: The _imaging C module is not installed Interestingly, the application works perfectly fine when running on the develo ...

I am looking to transform intricate json data into csv format with the help of either python or R programming

Converting values to rows in CSV and keys to columns in CSV format would be beneficial. { "_id": { "$uId”: “12345678” }, “comopany_productId”: “J00354”, “`company_product name`”: “BIKE 12345”, "search_resu ...

Execute the for loop on the initial x tuples within a list

Managing a lengthy list of tuples can be quite challenging. Take for example the list [(1,2), (18,485), (284,475)...]. I am attempting to utilize a for loop to carry out a function on 68-tuple groups at a time. The objective is to run the loop on the initi ...

Discovering the xpath with a certain condition based on text length using Python Selenium

In my quest to extract the specific content I need from countless pages, I have devised a reliable rule that works 99% of the time: //a[@class='popular class' and not (contains(text(),'text1')) and not (contains(text(),'text2&apos ...

Conceal a specific entry in Django

I have a table displaying records from a model using a for loop. Each row has a button that, when clicked, removes the row. However, upon refreshing the page, the removed rows reappear. I want to prevent this. How can I achieve this? <tabl ...

Ordering results of Python script by location and grouping by shared identifier

There are numerous occurrences of data sharing the same location IDs, like in the output below where '3' is repeated multiple times: 121 {'data': {'id': 3, 'type': 'location'}, 'links': {&ap ...

Troubleshooting problems with SQLite3 when multiple users are accessing the database concurrently

I am encountering difficulties with data reads in my SQLite3 database. Scenario: I have created a python program that runs two scripts simultaneously: Script1: Constantly retrieves messages from an MQTT broker at intervals of 30 seconds and writes data t ...

What can be done to address Tensorflow's preference for utilizing CPUs over GPUs?

For my project on Windows 10, I am using Anaconda with TensorFlow 2.3 and Keras 2.4.3 for a CNN example. So far, I've set up Visual Studio 2019 Community Edition, installed CUDA 10.1, and added cudnn 8.0.5 for compatibility. In my Anaconda environmen ...

Can you explain the significance behind the error message " 'numpy.ndarray' object is not callable"?

I am trying to create an array, k of dimension N X 1 in MATLAB by using the following code: N = 2^15 dx = 0.1 k = [0:N/2-1 0 -N/2+1:-1]'*2*pi/(N*dx) However, when I attempted to do this in Python, I encountered a problem because I couldn't "flip ...

Is there a way I can retrieve the count of questions bearing a specific tag that have been posted today and within the current week?

My goal is to retrieve the daily and weekly count of questions associated with a specific tag. For instance, I am interested in obtaining the daily and weekly counts for the top 100 languages or tags: https://i.stack.imgur.com/J7l7b.png I managed to loc ...

Extract dropdown menu options

OBJECTIVE The aim is to explore every possible combination from this website: WHAT I'M SEEKING ADVICE ON I need some guidance on how to proceed with the task. ISSUE AT HAND I am facing a problem where I can retrieve a list of options for the first ...

Python throws a syntax error when attempting to filter a list

Having trouble filtering an item from a list? Encounter a syntax error: SyntaxError: invalid syntax Check out the code below: a['name'] = 'Dan' b['name'] = 'Joe' ppl = [a,b] inputName = raw_input('Enter name: ...

What causes a blank page to appear in Firefox upon initial execution with Selenium?

from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Firefox() #driver.set_preference("browser.startup.homepage_override.mstone", "ignore") driver.get("https://url.aspx/") username = driver.find_element_by_name ...

What are the possible reasons behind the malfunctioning of my attributes after I replaced my method with a new one

My Computer Science lessons have been focused on Object Orientated Programming, but the code provided as an example seems to be malfunctioning. class bankAccount(): '''This is a bank account class''' def __init__(s ...