Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how to display results(dataframe) from a python script in django
class TweetAnalyzer(): """" Class for tweet analysis """ def tweet_to_data_frame(self, tweets): df = pd.DataFrame(data=[tweet.text for tweet in tweets ], columns=['tweets']) df['id']= np.array([tweet.id for tweet in tweets]) df['len'] = np.array([len(tweet.text) for tweet in tweets]) return df #this is the python script class views.py from Filmatory.tweetstream import TweetAnalyzer def tweetsPageView(request): object = TweetAnalyzer() x = object.tweet_to_data_frame('pandas.txt') return render(request,'tweets.html',{'x':x.to_html}) -
Ajax refresh browser to return page with the JSON data (Django)
I'm trying to make a simple todo page in my app, and I tried to use ajax for a better user experience. However, when I submit data I get a page with the data in JSON form instead of appending new data ( i use Django). views.py: from django.shortcuts import render, redirect from django.http import JsonResponse from django.forms.models import model_to_dict from django.contrib import messages from .forms import TodoForm def create_todo(request): if request.method == 'POST': form = TodoForm(request.POST) todo = form.save(commit=False) todo.user = request.user todo.save() messages.success(request, 'Creted Todo, Good Luck!') return JsonResponse({'todo': model_to_dict(todo)}, status=200) the todo form in base.html: <div class="modal fade" id="createtodo" tabindex="-1" role="dialog" aria-labelledby="createtodoLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="createtodoLabel">Create Todo</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="modal-body"> <form action="{% url 'production:create_todo' %}" method="post" id="todoForm" data-url = "{% url 'home' %}"> {{todo_form|crispy}} {% csrf_token %} </div> <div class="modal-footer"> <input type="submit" value="Add" class="btn btn-success"> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#todos"> Todos </button> </form> </div> </div> </div> </div> Ajax Script in base.html <script> $('#todoForm').submit(function (event) { event.preventDefault() let data = $('#todoForm').serialize() $.ajax({ url: $('#todoForm').data('url'), data = data, type = 'post', success: function (response) { $('#todosList').append(`<div class="card"> <div class="card-body todoItem" id=""> <input type="checkbox" name="" … -
DJANGO RESTFRAMEWORK WITHOUT ORM METHOD [closed]
Is there any tutorials or book for django rest framework without using orm method ? please suggest me -
Accessing account information in Django Allauth confirmation email
I am using a custom e-mail message by overriding the default confirmation email of Django Allauth email_confirmation_message.txt I have a custom signup form that also collects first and last name so I would like to access the first name that they have given during signup, in my e-mail confirmation. So you can address someone with his first name. This is what the default template looks like: {% load account %} {% user_display user as user_display %} {% load i18n %} {% autoescape off %} Dear {{ first name given at registration here }} ... {{ activate_url }} ... {% endautoescape %} It uses {% user_display user as user_display %} to display the username. So there must be a way to access the first name as well? How can I access the first name in this e-mail? Or is this not possible without completely writing a custom confirmation e-mail? -
'bytes' object has no attribute 'objects'
def searchfromimage(request): image_file = request.FILES['file'] os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'home/ServiceAccountToken.json' client = vision.ImageAnnotatorClient() content = image_file.read() image = vision.types.Image(content=content) response = client.document_text_detection(image=image) docText = response.full_text_annotation.text docText.replace('\n',' ') searchquery = docText allposts = content.objects.filter(title__icontains=searchquery) context = {'allposts':allposts} return render(request,'searchpage.html',context) when I am trying to print docText it gives the desired output but I am not able to use it to search it showing the error 'bytes' object has no attribute 'objects' I have tried to decode 'utf-8' but it is giving 'str' object has no attribute 'decode' error and I also tried with base64 and ASCII but nothing is working -
validate if instance exists django
I am building a REST Api on DRF. I have a ModelViewSet endpoint from rest_framework.viewsets. I have a Post and a Comment model. Each comment belongs to a post. So I have defined 2 endpoints, sort of: 1) router.register(r"posts", views.PostView 2) router.register(r"(?P<pk>[^/.]+)/comments", views.CommentView Both of them inherit from ModelViewSet so I can perform CRUD operations on them. I have a question regarding the second endpoint. Since we create comments to posts, I am getting a post pk from posts/int:pk/comments. But the problem is when I do a GET request on this endpoint it'll return the list of all comments, but I need those to belong to a post (id in url). When I try make a POST request on this endpoint if the post does not exist it raises DoesNotExist error which is logical. What I have done so far is: redefined a get_queryset() to retrieve only objects belonging to a particular post. If the post does not exist it returns an empty list (though I think it should raise 404) redefined validate() in my serializer to check if the post exists. Returns 404 if it does not But when I check PUT, DELETE, PATCH methods on posts/int:pk/comments/int:pk it won't … -
How do I check for the existence of a specific record in Django?
If I retrieve a QuerySet from a Django model (using filter(), for example), I can use the QuerySet methods exists() or count() to determine if the result will be void or not: if myModel.objects.filter(id__lte=100).exists(): # Do something... However, if I want to retrieve a specific record (using get(), for example) myModel.objects.get(id=100) the record object returned has no exists() or count() method. Moreover, if this record doesn't exist, instead of doing the expected thing and returning None, Django flips its crap entirely and breaks with a DoesNotExist exception, so I can't even test for the record's existence in the normal Pythonic way: # This throws a DoesNotExist exception if not myModel.objects.get(id=100): # Do something else... How do I test for the existence of a specific record (an element of a QuerySet, not a QuerySet itself) so that the app doesn't break? (Django 3.0) -
Profile Model in django not saving new update
i trying to create update profile, but its doesnt work i think its because instance(?) but i cant fix it, please help to solve my problem this is my views.py post_update def post_update(request, pk): instance = User.objects.get(pk=pk) instance2 = Profile.objects.get(pk=pk) user_form = PasswordChangeForm(user = request.user , data=request.POST) profile_form = ProfileForm(request.POST, instance=instance2) postingan = Profile.objects.filter(id=pk) postingan2 = User.objects.filter(id=pk) if user_form.is_valid(): instance = user_form.save(commit=False) instance.save() return render(request, 'pengurusan/index.html') if profile_form.is_valid(): instance2 = profile_form.save(commit=False) instance2.save() return render(request, 'pengurusan/index.html') context={ "user_form" : user_form, "profile_form" : profile_form, "instance2" : instance2, "postingan" : postingan, "instance" : instance, "postingan2" : postingan2, } return render(request, 'pengurusan/update-form.html', context) and this is my forms.py class ProfileForm(forms.ModelForm): class Meta: model = Profile fields = ['nama', 'nik', 'email', 'nomor_hp'] widgets = { 'nama': forms.TextInput(attrs={ 'id' : 'exampleFirstName', 'placeholder' : 'Name'}), 'nik' : forms.NumberInput(attrs={'id' : 'exampleLastName', 'placeholder' : 'Nomor Identitas Penduduk'}), 'email' : forms.EmailInput(attrs={'id' : 'exampleInputEmail', 'placeholder' : 'Email Address', 'name' : 'email'}), 'nomor_hp' : forms.NumberInput(attrs={'size':'4', 'maxlength':'12', 'class':'phone', 'placeholder' : 'Nomor Handphone'}), } and this is my models.py userr = User() class Profile(models.Model): user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE) nama = models.CharField(max_length=30, blank=True) nik = models.CharField(max_length=30, blank=True) email = models.EmailField(max_length=75, blank=True) nomor_hp = models.TextField(max_length=15, blank=True) def __str__(self): return self.user def create_profile(sender, instance, created, … -
Is there any way to run manage.py collectstatic command in CPANEL?
I tried to host my app in CPANEL. Everything works fine but when I try to collect static files through python manage.py collectstatic, It shows error. python manage.py collectstatic File "manage.py", line 14 ) from exc ^ SyntaxError: invalid syntax The python app on my cpanel is version 3.7.3 and I have also completed my app in Python version 3.7.3 -
Why do I have to keep all django applications in root folder?
Topic explains everything by itself. In all other web-frameworks (Symfony etc.) there is a clear separation of the folder structure logic. It is more logical and easier to observe and maintain. Why it isn't so in Django, why is it so messy? Yes, I have seen that solution, but it still seems strange... -
Validate get_queryset GET parameters
I am building an application that allows user to view certain records from the database. Since I want the users to be able to filter the number of records per page via the paginate_by attribute I also want to validate that input. Here is a snipped of my code. def get_queryset(self): q = self.request.GET.get('paginate_by') if q is None: return Syslog.objects.all() elif ( int(q) > 0): return Syslog.objects.all() else: raise PermissionDenied Firstly I am getting the queryset and more specifically the paginate_by parameter and I am trying to validate it. When a user provide a positive integer or the home page the view returns the queryset. If the user provide a negative number a PermissionDenied is returned. The problem is that when the user provide a string, it throws a 500 Server Error. What I am trying to do is to check if the provided GET parameter is positive integer or None (for home page), and if it is not to render a custom error template. Regards, Jordan -
ModelChoiceField: remove empty option and select default value
I'm using the default form field for a models.ForeignKey field, which is a ModelChoiceField using the Select widget. The related model in question is a Weekday, and the field was made nullable so that it didn't force a default value on hundreds of existing entries. However, in practice, our default should be Sunday, which is Weekday.objects.get(day_of_week=6). By default the select widget for a nullable field when rendered displays the null option. How can I discard this option and have a default value instead? If I set a initial value, that one is selected by default on a new form: self.fields['start_weekday'].initial = Weekday.objects.get(day_of_week=6) But the empty value is still listed. I tried overriding the widget choices: self.fields['start_weekday'].widget.choices = [(wd.day_of_week, wd.name) for wd in Weekday.objects.all()] However now Sunday isn't selected by default. I thought maybe I need to use the option value as the initial one but that didn't work either: self.fields['start_weekday'].initial = Weekday.objects.get(day_of_week=6).pk In short: how can I remove the empty option in a nullable model field and select a default instead? -
Pyodbc - Invalid connection String- Login failed for user
Im getting this error, trying to connect an external SQL Server from Django through VPN i tried different ways of formatting the string, but doesnt work. '28000', "[28000] [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'sa'. (18456) (SQLDriverConnect); [28000] [Microsoft][ODBC Driver Manager] Invalid connection string attribute (0); [28000] [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'sa'. (18456)") The code: from django.http import HttpResponse from django.shortcuts import render from django.template import loader import pyodbc def stock(request): #ConDB password='eUHf?+adF6;w' server='tcp:10.10.45.1,1433' database='master' username='sa' cnxn = pyodbc.connect('DRIVER={ODBC Driver 11 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password) cursor = cnxn.cursor() template = loader.get_template('polls/stocks.html') return HttpResponse(template.render({}, request)) Thank you in advance. -
In Django, how can I load images based on screen size?
Apologies for not having specific broken code here. I already know that what I would try won't work from a different question here, and I have a vague idea of something that might work, but is likely not the best way to do it. I'm building a website for a photographer, so it's important that I'm loading the best looking photos that the user is capable of seeing. The starting file size for the images is a few MB, but the model uses Pillow to save down-scaled copies. There are times when I want a full-screen image at high resolution, but I want to serve a smaller image if the user is on mobile, for example. What I would have done was load the images from CSS background-image with media queries, but I understand that I can't use template tags in css. My next guess would be to build two separate versions of each template, and have the views render a different template based on the user-agent of the request, but that strikes me as probably not a great solution to put that much trust in the request headers, and the functionality could break as easily as a new browser … -
I am getting an Attribute Error when attempting POST request to API - Django
im using Django and DRF to make a very basic API, however when i use a POST request, i get an error i cant solve for some time now. This is the Views.py def user_list(request): """ List all code users, or create a new user. """ if request.method == 'GET': users = Users.users.all() serializer = UserSerializer(users, many=True) return JsonResponse(serializer.data, safe=False) elif request.method == 'POST': data = JSONParser().parse(request.body) serializer = UserSerializer(data=data) if serializer.is_valid(): serializer.save() return JsonResponse(serializer.data, status=201) return JsonResponse(serializer.errors, status=400) This is the traceback Internal Server Error: /users/ Traceback (most recent call last): File "C:\Users\35988\anaconda3\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\35988\anaconda3\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\35988\anaconda3\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\35988\Desktop\GitHubRepos\DjangoSalesPlatform\SalesPlatform\Sales\views.py", line 36, in user_list data = JSONParser().parse(request.body) File "C:\Users\35988\anaconda3\lib\site-packages\rest_framework\parsers.py", line 65, in parse return json.load(decoded_stream, parse_constant=parse_constant) File "C:\Users\35988\anaconda3\lib\site-packages\rest_framework\utils\json.py", line 31, in load return json.load(*args, **kwargs) File "C:\Users\35988\anaconda3\lib\json\__init__.py", line 293, in load return loads(fp.read(), File "C:\Users\35988\anaconda3\lib\codecs.py", line 496, in read newdata = self.stream.read() AttributeError: 'bytes' object has no attribute 'read' [30/Jul/2020 14:16:43] "POST /users/ HTTP/1.1" 500 87662 -
Adding extra field with Many to many relationship in DRF
I have scenario where I need to add the extra field with the ManytoMany relationship. But when I am trying to do so I am getting the error. My model class is as: class Person(models.Model): name = models.CharField(max_length=128) def __unicode__(self): return self.name class Group(models.Model): quantity = models.IntegerField() members = models.ForeignKey(Person,on_delete=models.CASCADE) class Membership(models.Model): code = models.CharField(max_length=64) group = models.ManyToManyField(Person, through='Group') date_joined = models.DateField() invite_reason = models.CharField(max_length=64) What I am looking here is in a Membership modal I want my code to be unique and in group I want the multiple person with quantity but something I am doing wrong and I am getting the error and my error is : The model is used as an intermediate model by 'oss.Membership.group', but it does not have a foreign key to 'Membership' or 'Person'. Any suggestions will be of great help. Thanks in advance -
How to do GET request from Jquery-confirm dialog to django view and show results inside dialog?
I am trying to make an app from Django(version 3.0) and Python 3.7 and also involves the use of Jquery(version 3.5) and jquery-confirm (version 3.3.4). I am using jquery-confirm dialog to display content to my users like this, In the Custom Javascript File for Project- var showRecipeToEnterButton = $('#show-recipe-to-enter'); showRecipeToEnterButton.click(function(){ showRecipeToEnterButton = $(this); var accTypeInput = showRecipeToEnterButton.parent().children("#acc_type")[0]; var accType = accTypeInput.value; var userInput = showRecipeToEnterButton.parent().children("#user_pk")[0]; var userPk = userInput.value; var contestInput = showRecipeToEnterButton.parent().children("#contest_pk")[0]; var conPk = contestInput.value; $.dialog({ title: 'Select '+accType, content: "url:/contest/get/user/?&pk="+userPk+"&cpk="+conPk+"&at="+accType, theme:'modern', animation: 'scale', columnClass: 'large', closeAnimation: 'scale', backgroundDismiss: true, draggable: false, }); }); The content field in the $.dialog() function is a url and it leads to this function in my views.py: def contest_select_recipe_foodpost(request): data = request.GET user = data.get('pk') acc_type = data.get('at') cpk = data.get('cpk') if cpk is None or user is None or acc_type is None: return HttpResponse('<h4>Insufficient Data!</h4>') contest = Contest.objects.get(pk=cpk) qs = None if acc_type == 'Food Recipe': qs = Recipe.objects.filter(user__pk=user) if acc_type == 'Food Post': qs = FoodPost.objects.filter(user__pk=user) if not qs.exists(): qs = None context = { 'qs': qs, 'contest': contest, 'cpk': cpk, 'at': acc_type, } return render(request, 'contest/entry_filter_foodpost.html', context=context) This is the contest/entry_filter_foodpost.html {% load static %} {% if qs == … -
Run django jupyter note book in custom server and port
Script i am using to run jupyter. python manage.py shell_plus --notebook Using this script it runs on localhost thats fine, But i can is run it inside server with custom port python manage.py shell_plus --notebook 0.0.0.0:8000 When m running like thism getting error usage: manage.py shell_plus [-h] [--bpython | --idle | --ipython | --lab | --kernel | --notebook | --plain | --ptipython | --ptpython] [--connection-file CONNECTION_FILE] [--no-startup] [--use-pythonrc] [--print-sql] [--print-sql-location] [--dont-load DONT_LOAD] [--quiet-load] [--vi] [--no-browser] [-c COMMAND] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color] [--skip-checks] manage.py shell_plus: error: unrecognized arguments: 0.0.0.0:8000 PLease have a look -
How to pull or read image in Django from AWS s3 bucket for OpenCV to process?
When user uploads images from (react as frontend) and django receives the images from static folder and begins to process those images and later user can download. Below is my django python code imagePath = os.path.commonprefix(['images']) #<------coming from static files when user # upload via react axios.post. instead # of "imagePath" i want django to read # from s3 bucket 'images' folder. #other process for img in imagePath: image = cv2.imread(img) ##other process but now i'm using amzazon s3 instead of local static files. AWS_ACCESS_KEY_ID = '********' AWS_SECRET_ACCESS_KEY = '***************' AWS_STORAGE_BUCKET_NAME = '********' AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = None DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' my question is : How to make django to read images directly from s3 bucket? so that instead of "imagePath" i can use s3 files? Any related answer will be really appreciated thank you :) -
Django admin for external relation/mapping table
Schema <employee> id name <task> id title <employee_task_mapping> id employee_id # foreign key to <employee> task_id # foreign key to <task> time_spent I have some tables which are not managed in Django, I already registered Django Admin for master tables such as employee and task. But not sure how to handle the relation/mapping table with the following cases: In Django Admin user should be able to map one employee to multiple task. A task can be mapped to only one employee. I believe if the tables were managed in Django itself, could have done something like a ManyToManyField in task and Django will automatically create the relation/mapping table. -
Python - Django - NoReverseMatch
I'm doing an exercise from the book Python Crash Course and I've been stuck on this problem for three days. I've been searching everywhere but can't find a solution. I'm making a blog, so far I've made a form so that I can add new posts, now I'm trying to make a form so that I can edit each post. This is the error I'm getting: NoReverseMatch at /edit/1/ Reverse for 'edit' with arguments '('',)' not found. 1 pattern(s) tried: ['edit/(?P<post_id>[0-9]+)/$'] Request Method: GET Request URL: http://127.0.0.1:8000/edit/1/ Django Version: 3.0.8 Exception Type: NoReverseMatch Exception Value: Reverse for 'edit' with arguments '('',)' not found. 1 pattern(s) tried: ['edit/(?P<post_id>[0-9]+)/$'] Exception Location: C:\Users\paulr\Desktop\Blog\blog_env\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 677 Python Executable: C:\Users\paulr\Desktop\Blog\blog_env\Scripts\python.exe Python Version: 3.8.1 Python Path: ['C:\Users\paulr\Desktop\Blog', 'C:\Users\paulr\AppData\Local\Programs\Python\Python38-32\python38.zip', 'C:\Users\paulr\AppData\Local\Programs\Python\Python38-32\DLLs', 'C:\Users\paulr\AppData\Local\Programs\Python\Python38-32\lib', 'C:\Users\paulr\AppData\Local\Programs\Python\Python38-32', 'C:\Users\paulr\Desktop\Blog\blog_env', 'C:\Users\paulr\Desktop\Blog\blog_env\lib\site-packages'] Server time: Thu, 30 Jul 2020 10:26:16 +0000 urls.py """Defines url patterns for blogs.""" from django.urls import path from . import views app_name = 'blogs' urlpatterns = [ # Home page. path('', views.index, name='index'), # Page for blog posts path('posts/', views.posts, name='posts'), # Page for adding a new blog post path('new_post/', views.new_post, name='new_post'), # Detail page for a single post path('posts/<int:post_id>/', views.post, name='post'), # Edit post path('edit/<int:post_id>/', views.edit, name='edit'), ] views.py … -
Filter a list of queries on datetime field gives warning
I am querying a model from my ORM in Djnago like the following: client = Client.objects.get(pk=cname).user items = Allotment.objects.filter(sales_order__owner=client).order_by('-id') and want to filter it by datetime that I am getting as parameters from URL URL: GET /allotment-reports/?cname=3&to=2020-07-30+15:07&from=2020-07-01+15:07 So I tried this: f = request.GET['from'] t = request.GET['to'] items = items.filter(dispatch_date__range = [f,t]) but keep getting the warning: RuntimeWarning: DateTimeField Allotment.dispatch_date received a naive datetime (2020-07-30 15:07:00) while time zone support is active. RuntimeWarning) I am using the same format as I have used in my models, then Why is it showing the warning? -
Django manytomany fields to populate the data when one field is selected and its data can be shown on next box
So I know my topic is very vague and I do not know what could be right wording but here I will explain my problem. This is my modal Course: class Course(models.Model): COURSE_TYPE = ( ('Theory', 'Theory'), ('Lab', 'Lab') ) course_id = models.CharField(max_length=100, primary_key=True) course_name = models.CharField(max_length=200, null=True) course_type = models.CharField(max_length=200, null=True, choices=COURSE_TYPE) credit_hours = models.IntegerField(null=True) contact_hours = models.IntegerField(null=True) def __str__(self): return self.course_id + ' - ' + self.course_name and this is my Professor Modal class Professor(models.Model): professor_id = models.AutoField(primary_key=True) professor_name = models.CharField(max_length=200, null=True) courses = models.ManytoManyFields(Course, null=True, on_delete=models.CASCADE working_hours = models.IntegerField(null=True) available_hours = models.IntegerField(null=True) Now I have saved data but when I want to retrieve this data on my interface. I want to select course in dropdown then all the professors availabe should be shown in next dropdown. Like this to this I have been stuck on this for days. Kindly help me this. -
how to creater a signup register form with my own reqired field form in django?
Im new to django i want create signup form with my own feild ,i dont want to signup form in default that is in user table i want to created own custom sign up forn any can hepl plz Im new to django i want create signup form with my own feild ,i dont want to signup form in default that is in user table i want to created own custom sign up forn any can hepl plz here is my example how my form feild look like [enter link description here][1] <form id="contact-form" method="post" action="/addyourschool/" role="form"> <input type="hidden" name="csrfmiddlewaretoken" value="vhcAZ5w1HpK2mUXMhdqHR1to9Yv2LeOB85E2kR7Z1ZsPo5fjtWZ5P7o23kj8lDsk"> <div class="messages"></div> <div class="controls"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="form_name">School Name</label> <input type="text" name="schoolname" id="product" class="form-control ui-autocomplete-input" placeholder="Type few letter &amp; select from down *" required="required" data-error="Lastname is required." autocomplete="off"> <div class="help-block with-errors"></div> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="form_cfschp">Can't find your School *</label> <input id="form_cfschp" type="text" name="form_cfschpool" class="form-control" placeholder="Can't find your School *" required="required" data-error="Can't find your School"> <div class="help-block with-errors"></div> </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="Pessonname">Contact person Name *</label> <input id="Pessonname" type="text" name="Pessonname" class="form-control" placeholder="Contact person Name *" required="required" data-error="Contact person Name "> <div class="help-block with-errors"></div> </div> </div> <div … -
Still having issues with the logout on tutorial
I followed the tutorial Authentication and I seem to still be having trouble with the website because when I clicked the arrow, I could not get the dropdown list to work and the logout still isn't there when I clicked on it. I got this error when I was testing the Django Boards page. This is causing me problems to see the dropdown list. I followed the tutorial to the point and checked. In order for the logout to work, I had to type in 127.0.0.1:8000/logout/ just so I could get the site to logout. Error: GET /static/js/bootstrap/bootstrap.min.js HTTP/1.1 404 1683 Here's a tree listing of the files. Here's my base.html file, which may the root of the problem {% load static %}<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>{% block title %}Django Boards{% endblock %}</title> <link href="https://fonts.googleapis.com/css?family=Peralta" rel="stylesheet"> <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"> <link rel="stylesheet" href="{% static 'css/app.css' %}"> {% block stylesheet %}{% endblock %} </head> <body> {% block body %} <nav class="navbar navbar-expand-sm navbar-dark bg-dark"> <div class="container"> <a class="navbar-brand" href="{% url 'home' %}">Django Boards</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainMenu" aria-controls="mainMenu" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="mainMenu"> {% if user.is_authenticated %} <ul class="navbar-nav ml-auto"> <li …