Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Send form and object in ajax
I'm trying to send a form an a javascript object in an ajax call like so: $("#formTabla").submit(function(event){ event.preventDefault(); var formData = new FormData(this); $.ajax({ url : "{% url 'submit' %}", type: "POST", processData: false, contentType: false, data: { "checkboxes": formData, "datos": data } }); }); But all I'm getting as output is [object Object]. What am I doing wrong? -
ENV variable in docker environment
Hello how can I use env variable in Docker / docker-compose in the most convenient way? I am working with Django and in local environment I have something like this which works perfect - stripe.api_key = os.environ.get('stripeAPI') What should I do to do it in Docker container? When I wrote docker exec -e stripeAPI=(secret key) <container_id>I got an error command not found, but when I wrote at the end echo or bash I get into shell but Stripe does not work. -
Django Multiprocessing: How can I run multiple processes simultaneously
I am using a multiprocessing module to perform a task that is very time-consuming. With a single request, it works fine. but I am unable to generate multiple processes simultaneously. So How can I perform multiple requests at the same time when other is already running. -
python django framewExpected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a `<class 'NoneType'>`
def post(self,request): try: profile_image=request.FILES['profile_image'] except: profile_image="" full_name=request.data.get('full_image') email=request.data.get('email') mobile_number=request.data.get('mobile_number') gender=request.data.get('gender') print(is_alcoholic) dob=request.data.get('dob') country=request.data.get('country') state=request.data.get('state') city=request.data.get('city') -
cURL POST Request - Ralph3 API (django)
i have the following problem, I’m trying to create a new VM in Ralph3 (inventory) via the API with the followed cURL command. However, i get the message “{” hypervisor “: [” This field is required. “]... It looks to me as if he is not accepting the values. Apparently it's because of my formatting Command: curl -X POST https://api.example.de/api/virtual-servers/ -H ‘Authorization: Token XXXXXXXXXXXXX’ -H ‘Content-Type: application/json’ -d ‘{“hostname”:“test”, “hypervisor”:{“url”:“http://api.example.de/api/data-center-assets/3/”}, “status”: “in use”}’ Tried: In addition, I tried to specify the url/ui_url with [, ] and {, } as a sub-section for the hypervisior information, without success. 1.) “hypervisor”:{“url”:“http://api.example.de/api/data-center-assets/3/”} 2.) “hypervisor”:[“url”:“http://api.example.de/api/data-center-assets/3/”] GET-Result if i used a GET-Request for informations about a System, i got this values for hypervisor. "hypervisor": { "url": "http://api.example.de/api/data-center-assets/9/", "ui_url": "http://api.example.de/r/11/9/" Can someone help me with this little difficulty? -
Annotate name without using annotate in view
I am building a BlogApp and I am trying to sort in list every thing is working fine, But when I add another list in sorting then i noticed that sorting was working with annotate name but in third query list I don't want to use any annotate so I cannot use annotate query name so it is not sorting the list according to date. views.py def page(request): query_1 = list(BlogPost.objects.filter(user=request.user).annotate(counting=Count('blog_likes')).order_by('-date'))[:2] query_2 = list(Comments.objects.filter(commenter=request.user).annotate(counting=Count('comment_likes')).order_by('-date_added'))[:2] # THIRD QUERY - which is causing error (Not really an error). I am not using annotate and i am # ordering through date query_3 = list(ThirdModel.objects.filter(user=request.user).order_by('date_created')) result_list = sorted(chain(query_1, query_2,query_3),key=attrgetter('counting')) context = {'result_list':result_list} return render(request, 'page.html', context) When i add the query_3 in sorted to sort the list then it is showing 'ThirdModel' object has no attribute 'counting' So I think it is is sorting third query according to below to two queries But I have no idea how can I name third query counting without annotate. Any help would be much Appreciated. Thank You -
select filtering and removal if they are already present in the db
look at the picture before answering me. that group2 is inside saved in the db with the button I open a modal that allows me to save other groups in the db and I would like that the same groups no longer appear in that select if I have already added them -
Django AttributeError with object
I want to display my product the front page this is the error I'm getting I can't figure out how to solve this. I can give you model of product and vendor. Thanks in advance. Environment: Request Method: GET Request URL: http://127.0.0.1:8000/vendor/vendor-admin/ Django Version: 3.2.8 Python Version: 3.9.7 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'apps.core', 'apps.product', 'apps.vendor'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "C:\Users\Saad\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\Users\Saad\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Saad\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view return view_func(request, *args, **kwargs) File "C:\Users\Saad\Desktop\fypm-c\mastercrafter\apps\vendor\views.py", line 30, in vendor_admin products = vendor.products.all(Vendor) Exception Type: AttributeError at /vendor/vendor-admin/ Exception Value: 'Vendor' object has no attribute 'products' -
ModelViewSet does not provide `create` url in Django Rest Framework
I have a viewset as below: class EntryViewSet(viewsets.ModelViewSet): queryset = Entry.objects.all() serializer_class = EntrySerializer permission_classes = [permissions.IsOwnerStaffOrReadOnly] filter_backends = [DjangoFilterBackend, CustomOrderingFilter] filterset_class = EntryFilterSet ordering_fields = ["created_at", "last_update"] ordering = "created_at" @method_decorator(cache_page(60 * 5, key_prefix="entry")) def list(self, *args, **kwargs): return super().list(*args, **kwargs) @method_decorator(cache_page(60 * 60, key_prefix="entry")) def retrieve(self, *args, **kwargs): return super().retrieve(*args, **kwargs) ...which is added to urls.py of the related app using DefaultRouter as: _router.register("entries", EntryViewSet, basename="entry") However, doing reverse("api:entry-create") fails to find create on my test. I also quickly check the URLs with Django Extensions subcommand show_urls but it does not print api:entry-create, which means it is not registered. What I do: python manage.py show_urls | grep "api:entry" The result is: /api/entries/ api.viewsets.entry.EntryViewSet api:entry-list /api/entries/<pk>/ api.viewsets.entry.EntryViewSet api:entry-detail /api/entries/<pk>\.<format>/ api.viewsets.entry.EntryViewSet api:entry-detail /api/entries\.<format>/ api.viewsets.entry.EntryViewSet api:entry-list ...which shows only entry-detail and entry-list are registered while my model clearly is not ReadOnlyModelViewSet. Why do I not have api:entry-create url? Environment django ^2.2 djangorestframework ^3.12.4 -
django nginx not serving static files
I am depploying django using nginx and gunicorn. When I access the website I get the following errors. open() "/home/x/aroundu/core/static/static/rest_framework/js/default.js" failed it's accessing static files wrong, because the path should be like this open() "/home/x/aroundu/core/core/static/rest_framework/js/default.js" failed server { listen 80; location /static/ { alias /home/x/aroundu/core/core/static/; } location /media/ { alias /home/x/aroundu/core/media/; } location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; } } STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = "/media/" -
Can't read session data from database
I have inherited a legacy django application (currently on 2.2.24), that I am trying to modernize step by step. One requirement is to move from MySQL to an Azure SQL database. Unfortunately, I ran into an issue, where I just can't read back the session data from the database. This is what my settings.py looks like. As you can see, django.contrib.sessions is set, as well as django.contrib.sessions.middleware.SessionMiddleware. Also, I have explicitly set SESSION_ENGINE = 'django.contrib.sessions.backends.db', which should be the default. # ... INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework_swagger', # ... ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'simple_history.middleware.HistoryRequestMiddleware', ] SESSION_ENGINE = 'django.contrib.sessions.backends.db' ] DATABASES = { 'default': { 'ENGINE': 'mssql', # https://github.com/microsoft/mssql-django 'NAME': '<hiden>', 'USER': '<hiden>', 'PASSWORD': '<hiden>', 'HOST': '<hiden>', 'PORT': '1433, 'OPTIONS': { 'driver': 'ODBC Driver 17 for SQL Server', } } } # ... This is what the misbehaving views.py looks like, which is part of an Azure AD login procedure (def auth(request) => sso/login & def complete(request) => sso/complete) After execution leaves def auth(request), I can see a new entry in the table dbo.django_session. However, when execution enters def complete(request), the session dictionary is empty. @never_cache def auth(request): … -
AttributeError: 'CharField' object has no attribute 'encode' Django
I'm building an smtp mail tool, recently I encountered an attribute error. I would really appreciate someone help me fix the bug. Here are my codes. Views.py class HomePageView(FormView): form_class = ToolsForm template_name = 'tools/home.html' success_url = reverse_lazy('success') def form_valid(self, ToolsForm): ''' This method is called when valid form data has been posted ''' ToolsForm.send_email() return super().form_valid(ToolsForm) Forms.py class ToolsForm(forms.Form): sender_mail = forms.CharField(required=True, widget=forms.EmailInput(attrs={'placeholder': 'Enter your mail account here:'})) receiver_mail = forms.CharField(required=True, widget=forms.EmailInput(attrs={'placeholder': 'Enter your mail account here:'})) subject = forms.CharField(max_length=100, required=True, widget=forms.TextInput(attrs={'placeholder': 'Enter the subject here:'})) message = forms.CharField(required=True, max_length=200, widget=forms.TextInput(attrs={'placeholder': 'Enter your body text here'})) password = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Enter your password here'})) def send_email(self): sender = self.cleaned_data.get("sender_mail") receiver = self.cleaned_data.get("receiver_mail") subject = self.cleaned_data.get("subject") message = self.cleaned_data.get("message") password = self.cleaned_data.get("password") send_mail(subject, message, sender, [receiver], auth_password=password) Error File "C:\Users\EMMA\.virtualenvs\Cyberproj-h6KxjFSR\lib\site-packages\django\core\mail\backends\smtp.py", line 102, in send_messages new_conn_created = self.open() File "C:\Users\EMMA\.virtualenvs\Cyberproj-h6KxjFSR\lib\site-packages\django\core\mail\backends\smtp.py", line 69, in open self.connection.login(self.username, self.password) File "c:\users\emma\appdata\local\programs\python\python38-32\lib\smtplib.py", line 723, in login (code, resp) = self.auth( File "c:\users\emma\appdata\local\programs\python\python38-32\lib\smtplib.py", line 634, in auth response = encode_base64(initial_response.encode('ascii'), eol='') AttributeError: 'CharField' object has no attribute 'encode' [14/Oct/2021 09:36:52] "POST / HTTP/1.1" 500 110749 -
How to design django model to build multiple similar forms
I have a website with multiple links where each links sends the user to a form. The Forms have overlapping attributes but some are category specific. I am using the ModelForm class to map my model to the form fields. Now I wonder which approach would be best so that I have all the necessary Form fields in the individual form page. I though of three approaches: Make one really big class that contains all the form fields Create a single model for every individual form (lots of duplication would happen) Create a base model from which I inherit the fields that are widely used and then one individual model for every form. The Problem is that the labels are different for the specific forms (One form might need the label "Full title of Book", while another form needs the label "Full title of Journal"). So I need to be able to change the labels based on in which form I am using them. Right now my code looks like this (I am not very happy with it) models.py: class JournalModel(models.Model): full_publication_title = models.CharField(max_length=250) is_instrumental = models.BooleanField() journal = models.CharField(max_length=len( journal_categories), choices=prepare_journal_choices(), default='other_journal') class ProceedingsModel(models.Model): full_title_of_the_publications_in_the_proceedings = models.CharField(max_length=250) is_instrumental = … -
How do I store a contentfile into ImageField in Django
I am trying to convert an image uploaded by user into a PDF , and then store it into an ImageField in a mysql database ,using a form, but am facing an error when trying to store the PDF into the database My views.py is: from django.core.files.storage import FileSystemStorage from PIL import Image import io from io import BytesIO from django.core.files.uploadedfile import InMemoryUploadedFile from django.core.files.base import ContentFile def formsubmit(request): #submits the form docs = request.FILES.getlist('photos') print(docs) section = request.POST['section'] for x in docs: fs = FileSystemStorage() print(type(x.size)) img = Image.open(io.BytesIO(x.read())) imgc = img.convert('RGB') pdfdata = io.BytesIO() imgc.save(pdfdata,format='PDF') thumb_file = ContentFile(pdfdata.getvalue()) filename = fs.save('photo.pdf', thumb_file) linkobj = Link(link = filename.file, person = Section.objects.get(section_name = section), date = str(datetime.date.today()), time = datetime.datetime.now().strftime('%H:%M:%S')) linkobj.save() count += 1 size += x.size return redirect('index') My models.py: class Link(models.Model): id = models.BigAutoField(primary_key=True) person = models.ForeignKey(Section, on_delete=models.CASCADE) link = models.ImageField(upload_to= 'images', default = None) date = models.CharField(max_length=80, default = None) time = models.CharField(max_length=80,default = None) Error I am getting is: AttributeError: 'str' object has no attribute 'file' Other methods I have tried: 1) linkobj = Link(link = thumb_file, person = Section.objects.get(section_name = section), date = str(datetime.date.today()), time = datetime.datetime.now().strftime('%H:%M:%S')) RESULT OF ABOVE METHOD: 1)The thumb_file doesnt throw … -
Django blog. How to add HTML to post description from DB and insert image in any line?
I have a django application with a blog with listed models: Post one-to-many PostImage. class Post(models.Model): title = models.CharField(max_length=256, null=True) description = models.TextField(null=True, blank=True) image_path = CloudinaryField(null=True, blank=True, transformation={'quality': 'auto:eco'}, folder=f'/blog/{time.strftime("/%Y/%m/%d")}') created_at = models.DateTimeField(auto_now_add=True, null=True) updated_at = models.DateTimeField(auto_now=True, null=True) is_published = models.BooleanField(default=True) class PostImage(models.Model): caption = models.CharField(max_length=128, null=True, blank=True) post = models.ForeignKey(Post, on_delete=models.CASCADE) # post_id image_path = CloudinaryField(null=True, blank=True, transformation={'quality': 'auto:eco'}, folder=f'/blog/{time.strftime("/%Y/%m/%d")}') I am using django template tags and filters. Images are been displayed using {% for %}. {% for i in post_list %} <img src="{{ i.image_path.url }}" alt=""> {% endif %} {{ i.description }} is responsible for post description (body). Is there a way to apply html markup for this or that PART of description? How can i insert img in any line of description? (i.e. i have an installation guide so my instructions are accompanied by screeenshot image). At the moment structure is like this: {% block blog %} <div class="page-max-width fill-page-vertically inner-container"> {% for i in post_list %} <div class="post-container"> <h2>{{ i.title }}</h2> <div class="post-meta"> <span>Published at: {{ i.created_at|date:"d E Y G:i" }}</span> <span>Updated at: {{ i.updated_at|date:"d E Y G:i" }}</span> </div> {% if i.postimage_set.all %} <img src="{{ i.image_path.url }}" alt=""> {% endif %} <div class="post-description"> {{ … -
"Select a valid choise. this id is not one of the available choices." when using django FilterSet and autocomplete
I get this error when I want to filter by an item. "Select a valid choice. 37537 is not one of the available choices." I think the problem is with the ComparisonFilter class but i can't figure out what the problem is. models class Drug(models.Model): name = models.CharField(max_length=255, null=True, blank=True) classification_code = models.CharField(max_length=255, null=True, blank=True) views class ComparisonFilter(django_filters.FilterSet): id = django_filters.ChoiceFilter( label=_('Drug'), widget=autocomplete.ListSelect2( url='comparison-drug-autocomplete', attrs={ 'data-placeholder': _('Select drug...'), 'onChange': "this.form.submit()", }, ), ) class Meta: model = Drug fields = ['id', ] class ComparisonView(FilterView, SingleTableView): template_name = 'consultations/comparison.html' model = Drug table_class = ComparisonTable table_pagination = { "per_page": 50 } filterset_class = ComparisonFilter def get_queryset(self): return Drug.objects.filter(classification_code__isnull=False) The view filters drug by the given name and shows that drug in a table. -
Web app design pattern and technical choices using React and Python implementing OAuth2
we would like to get some help in the conception of an application frontend/backend where we want to implement OAuth2 with Facebook, LinkedIn and Google. Basically the problem is that we are just testing/playing around Django for the API and React for the front. In the API we are using Django-allauth to handle the OAuth2 but it seems that it is more adapted to work with a template than API endpoints, actually we were able to implement a login page but not a logout… functionality, so maybe you can help us making our choices between : React for the front, Django for the api, React for the front, Flask for the api, React for the front, Express.js for the api, React for the front, and 2 servers for the back, express.js for OAuth2 and Django for the rest of the application, A classical MVT using Django and html-css-javascript Thank you in advance, -
Why makemigrations and migrate command are run without creating model?
from django.shortcuts import render from django.contrib.auth.forms import UserCreationForm # Create your views here. def homepage(request): return render(request,'homepage.html') def register(request): if request.method == 'POST': fm = UserCreationForm(request.POST) if fm.is_valid(): fm.save() fm = UserCreationForm() return render(request,'register.html',{'form':fm}) def login(request): return render(request,'login.html') On filling the details in the form on register URL, I am getting an error that auth.table is not there. I ran these both commands then py manage.py makemigrations py manage.py migrate py manage.py createsuperuser As a result the form details got submitted and I could see it through superuser. My question is what is the use of these commands when I did not create any model. I thought only after creating the model class, these commands are run so that table can be formed. But without creating the model class, how come details are saved on running makemigrations and migrate command ? -
Django Queryset annotate() date based on two columns
The problem I have is the following: Problem: I need to calculate a coupon end-of-use date and for this I have to use the coupon redemption date and the number of months the coupon grants. class Coupon(...): ... numMonths -> int ... class CouponUses(..): ... redeemDate -> datetime coupon -> FK Coupon ... I tried: 1 - Create a property in the CouponUses model to calculate the sum of redeemDate + relativeDelta (months = self.coupon.numMonths) which works but not in the queryset. 2 - Try directly annotate on CouponUses queryset ExpressionWrapper (F ('redeemDate') + relativeDelta (months = F ('coupon.numMonths')) and neither. However, the problem only happens when I try to use the value of months from the column numMonths, if I put a value directly it works. -
Django: `not F("is_show")` did not work properly
I am learning Django. When I use F to modify the is_show field, I can only switch True to False, but cannot switch False to True ... @admin.action(description='switch show') def make_switch_show(modeladmin, request, queryset): # This code does not work properly, so I have to use `for` # Why this code cannot work like the following `for` # queryset.update(is_show=not F('is_show')) for it in queryset: it.is_show = False if it.is_show else True it.save() actions = [make_switch_show] ... Some environmental information django = "3.2.8" Python 3.9.7 Database SQLite -
Django Admin: Add Hyperlink to related model
I would like to add a hyperlink to the related model Training It would be nice to have declarative solution, since I want to use this at several places. -
Django & Vue axios / [Deprecation] csrf solution?
Web development is underway using Django. Although the development of Vue and axios communication was successful, a [Deprecation] warning appears in the console. I don't want to solve the warning so that any warning appears in the console, so what should I do? However, except for csrf verification, I would like to solve it in a way that does not cause security problems. And I added the following code to Vue/main.js. axios.defaults.xsrfCookieName = 'csrftoken' axios.defaults.xsrfHeaderName = 'X-CSRFToken' Django/settings.py CSRF_COOKIE_NAME = 'XSRF-TOKEN' CSRF_HEADER_NAME = 'X-XSRF-TOKEN' [Deprecation] The website requested a subresource from a network that it could only access because of its users' privileged network position. These requests expose non-public devices and servers to the internet, increasing the risk of a cross-site request forgery (CSRF) attack, and/or information leakage. To mitigate these risks, Chrome deprecates requests to non-public subresources when initiated from non-secure contexts, and will start blocking them in Chrome 92 (July 2021). See https://chromestatus.com/feature/5436853517811712 for more details. -
Save Image from Web Scraping to Django
I have a model like this: #models.py class Post(models.Model): cover = models.ImageField(upload_to="news/", blank=True, max_length=255) I have a function to pull or scraping website like this: #views.py def pull_feeds(request, pk): source = Autoblogging.objects.get(pk=pk) url = requests.get(source.url) soup = BeautifulSoup(url.content, "html.parser") img_link = body[body.find('src=')+5:body.find('alt')-2] resp = requests.get(img_link) fp = BytesIO() fp.write(resp.content) file_name = img_link.split("/")[-1] post = Post() post.cover.save(file_name, files.File(fp)) I created that function with this link as reference : https://stackoverflow.com/a/43650607/14288119 But it only works when there is no production settings file. If there is production.py file, it returns an error saying "Empty file" This is my settings/production.py: import os import dj_database_url from .base import * SECRET_KEY = os.environ.get('SECRET_KEY', 'your-default-secret-key') DEBUG = False ALLOWED_HOSTS = ['topvineyards.herokuapp.com'] INSTALLED_APPS += [ 'cloudinary', 'cloudinary_storage', ] db_from_env = dj_database_url.config() DATABASES['default'].update(db_from_env) # Cloudinary config CLOUDINARY_STORAGE = { 'CLOUD_NAME': os.environ.get('CLOUD_NAME'), 'API_KEY': os.environ.get('CLOUD_API_KEY'), 'API_SECRET': os.environ.get('CLOUD_API_SECRET') } DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage' CORS_REPLACE_HTTPS_REFERER = True HOST_SCHEME = "https://" SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SECURE_SSL_REDIRECT = True SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True SECURE_HSTS_INCLUDE_SUBDOMAINS = True SECURE_HSTS_PRELOAD = True SECURE_HSTS_SECONDS = 1000000 SECURE_FRAME_DENY = True Does anyone know why the error appears? Or does anyone have a solution for this problem (save image from another website to my django image field)? -
Add image to folium popup from Django DB
I try to pull out image src from DB and display it in the folium popup... I searched on google and didn't found a solution how to do it with django. I will be happy for some help thanks ! My View def search_on_map(request): loc_list = [] img_list = [] for i in Add_Item.objects.all(): city = str(i.city) street = str(i.street) home = str(i.home_number) loc_list.append(city +" "+ street +" "+ home) img = i.header_img img_list.append(img) geolocator = Nominatim(user_agent="Your_Name") m = folium.Map(width=800, height=500, location=['32.078225', '34.768516'], zoom_start=15) for index, place in enumerate(loc_list): try: loc = loc_list[index] location = geolocator.geocode(loc) lat = location.latitude long =location.longitude # Add Marker html = f'<img src="{[i for i in img_list][index]}" width="42" height="auto" >' link = "<a href='{% url 'item-page' item.id %}'>More Details..</a>" iframe = folium.IFrame(html, width=632, height=420) popup = folium.Popup(html, max_width=650) folium.Marker([lat,long], tooltip=loc ,popup=popup, icon=folium.Icon(color='purple')).add_to(m) except Exception as e: print(e) return render(request, 'search_on_map.html', {"loc":m._repr_html_(),}) -
Bootstrap navbar-link not working unless I right click and open in new tab
This might be a multy-layered problem as I am using multiple technologies I am not proficient with but I hope I can get some help. I have a HTML/CSS/JS front-end which I have purchased from a random template website. I am making my own back-end using the Django framework. I am running into an issue with the navbar-link objects that the front-end has on the navbar object. Originally the front-end is a single page application for a personal portfolio website, and I am splitting the sections up to be in actual pages. Originally the link code looks like this: Where I can see that the href property is linking to different sections defined later on in the webpage. After my moving around of contents into different pages and adding the django relevate templating it looks like this: We can see I modified the href property and introduced the different links using django's commands. At first I thought it was a django issue but then I tested that by disabling javascript and everything works fine without it. Then I thought that something I messed up the main.js file that this front-end came with, yet I have not found anything in it …