Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
redirection from old urls to new urls
Hello everyone I want to redirect URLs like this from https://www.example.co.uk/pages/terms-conditions to https://www.example.co.uk/terms-conditions I developed the updated site using the Django framework and now want to redirect old site URLs to new URLs and not losing traffic. what is the best way of doing…? -
Django Query: aggregate() + distinct(fields) not implemented
I have the following model: class Data(models.Model): metric = models.IntegerField(choices=....) date = models.DateField() value = models.IntegerField() linkedObject = models.ForeignKey() ..... What I would like to achieve is to create the sum of all values for the newest metric and date. What I already use is order_by + distinct to get the newest value for each metric choice. This works. Data.objects.all().order_by("metric", "-date").distinct("metric") I tried to combine this with aggregate to make the next step: Data.objects.all().order_by("metric", "-date").distinct("metric").annotate(Sum("value")) Unfortunately, I get the following error message: aggregate() + distinct(fields) not implemented. Hint: I use postgres as database -
Separate Model for storing Choices vs Choices Field in a Model Django
Currently, I implemented the status as a separate model like this class OrderStatus(models.Model): name = models.CharField(max_length=200) class Order(models.Model): status = models.ForeignKey(OrderStatus, on_delete=models.CASCADE, null=True, blank=True) but I just realized that Django has a field called "choices". Django docs: https://docs.djangoproject.com/en/2.2/ref/models/fields/#choices based on that Django docs, I think my model should be like this: class Order(models.Model): UNPAID = 'UNPAID' PAID = 'PAID' ORDER_STATUS_CHOICES = [ (UNPAID, 'UNPAID'), (PAID, 'PAID'), ] status = models.CharField( max_length=2, choices=ORDER_STATUS_CHOICES, default=UNPAID, ) By using this, I think I don't need a separate model called "OrderStatus" anymore. Here are my questions. Is there any downside if I keep my implementation? If I change/refactor my code to use the "choices" field. Can I add more status in the future? do I only have to add more items in the ORDER_STATUS_CHOICES variable? Are there other things that I have to do? -
Getting no such table: auth_user error and also not able to access the admin page
I am trying to add the Django default user creation form for my registration and getting errors. I even removed all my old migration files any solution? Can anyone guide me on how I can fix this? Settings.py INSTALLED_APPS = [ 'users.apps.UsersConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', #third party apps 'crispy_forms', 'crispy_tailwind', 'ckeditor', #local apps #'leads', 'waqart', ] MODELS.PY from django.contrib.auth.models import User MODEL CLASS class Item(models.Model): title = models.CharField(max_length=100) description= RichTextField(blank=True, null=True) main_image= models.ImageField(null=True, blank=True,upload_to='images/') date = models.DateTimeField(auto_now_add=True) item_category = models.ForeignKey(Categories, default='Coding', on_delete=SET_DEFAULT) slug = models.SlugField(unique=True, blank=True, null=True) # new author = models.ForeignKey(User, on_delete=models.CASCADE) VIEW from django.shortcuts import render, redirect from django.contrib.auth.forms import UserCreationForm from django.contrib import messages # Create your views here. # Register View def register (request): if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') messages.success (request, f'Account created for {username}!') return redirect('waqart-home') else: form = UserCreationForm() return render(request, 'users/register.html', {'form': form}) -
How to send data into word document with Django?
I'm using Django I want to send some data from my database to a document word, I'm using py-Docx for creating word documents I use the class ExportDocx it can generate a static word file but I want to place some dynamic data (e.g. product id =5, name=""..) basically all the details to the "product" into the document class ExportDocx(APIView): def get(self, request, *args, **kwargs): queryset=Products.objects.all() # create an empty document object document = Document() document = self.build_document() # save document info buffer = io.BytesIO() document.save(buffer) # save your memory stream buffer.seek(0) # rewind the stream # put them to streaming content response # within docx content_type response = StreamingHttpResponse( streaming_content=buffer, # use the stream's content content_type='application/vnd.openxmlformats-officedocument.wordprocessingml.document' ) response['Content-Disposition'] = 'attachment;filename=Test.docx' response["Content-Encoding"] = 'UTF-8' return response def build_document(self, *args, **kwargs): document = Document() sections = document.sections for section in sections: section.top_margin = Inches(0.95) section.bottom_margin = Inches(0.95) section.left_margin = Inches(0.79) section.right_margin = Inches(0.79) # add a header document.add_heading("This is a header") # add a paragraph document.add_paragraph("This is a normal style paragraph") # add a paragraph within an italic text then go on with a break. paragraph = document.add_paragraph() run = paragraph.add_run() run.italic = True run.add_text("text will have italic style") run.add_break() return … -
how to call on('keyup') inside ajax success
i'm trying to make live search based on returned json data via ajax call , this is what i tried , but unfortunately it doesnt work function returnVistors(){ k = ''; $.ajax({ type:'GET', url:'/vistors/list', success:function(data){ const searchInput = document.getElementById('search_visitors').val(); if(searchInput.length > 0){ $('#search_visitors').on('keyup',function(){ for(i = 0;i < visitors.length; i++){ const full_name = visitors[i]['full_name'].toLowerCase(); if(full_name.incudes(searchInput)){ k+='<p class="mr-2">'+visitors[i]['full_name'] + ' - '+ visitors[i]['city']+'</p>' } k+='<p class="mr-2">'+visitors[i]['full_name'] + ' - '+ visitors[i]['city']+'</p>' } }); } else{ for(i = 0;i < visitors.length; i++){ const id = visitors[i]['id'] const detail_url = '{% url "vistors:vistor_obj" id=1111 %}'.replace(/1111/,parseInt(id)); k+='<a href="'+detail_url+'" class="flex hover:bg-purple-900 hover:text-white items-center border rounded-xl mt-1 p-2"></a>'; k+='<p class="mr-2">'+visitors[i]['full_name'] + ' - '+ visitors[i]['city']+'</p>' } document.getElementById('visitors_results').innerHTML = k } }, }); } <div class="mt-10 p-2 header rounded-xl md:rounded-tr-none md:rounded-tl-none rounded-bl-xl rounded-br-xl w-full md:w-2/12 h-96 md:h-screen"> <div class="p-3 bg-white rounded-xl"> <button class="text-lg focus:outline-none"><i class="bi bi-search"></i></button> <input type="text" class="w-11/12 focus:outline-none" name="search_visitors" id="search_visitors" placeholder="search here"> </div> <div id="visitors_results" class="p-3 bg-white rounded-xl mt-4 md:mt-5 p-2 overflow-y-scroll" style="height: 90%;"> <div class=" flex justify-center items-center" id="spinner"> <div class="animate-spin rounded-full h-10 w-10 border-b-2 border-gray-900"></div> </div> </div> </div> is it possible creating a new function inside ajax success !? thank you for letting me know -
Django image saving issue
VIEWS.PY def Profile(request): if request.method == "POST": profile = UserForm(request.POST, request.FILES, instance=request.user) if profile.is_valid(): profile.save() return redirect("Profile") profile = UserForm(instance=request.user) return render(request, "book/Profile.html", context={"user": request.user, "profile": profile}) FORMS.PY class UserForm(forms.ModelForm): username = forms.CharField(max_length=50, label='Username', widget=forms.TextInput(attrs={"class": "form-control"})) email = forms.EmailField(label='Email', widget=forms.EmailInput(attrs={"class": "form-control"})) first_name = forms.CharField(max_length=50, required=False, label='First name', widget=forms.TextInput(attrs={"class": "form-control"})) last_name = forms.CharField(max_length=50, required=False, label='Last name', widget=forms.TextInput(attrs={"class": "form-control"})) avatar = forms.ImageField(required=False, widget=forms.FileInput(attrs={"class": "form-control"})) class Meta: model = User fields = ('username', 'first_name', 'last_name', 'email', 'avatar') MODELS.PY class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) avatar = models.ImageField(upload_to='UserAvatar/%Y/%m/%d/', blank=True) @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) @receiver(post_save, sender=User) def save_user_profile(sender, instance, **kwargs): instance.profile.save() PROFILE.HTML <div class="modal-body"> <form method="post" enctype="multipart/form-data"> {% csrf_token %} {{ profile }} <div class="modal-footer"> <button type="submit" class="btn btn-primary">Save changes</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> </div> </form> </div> Well, I'm kind of having an issue here. I'm new in Django and I've recently uploaded an image from forms.Form but now I'm using forms.ModelForm and don't really know what the problem is. What am I doing wrong ? -
In Django guardian, how can I determine which group gave the user permissions to the object instance?
I am trying to set up object-level permissions using Django guardian and groups; where I give permissions to the groups - not the users - and add/remove users from the groups as required. When a user has permission to interact with an object instance - because they are in a group that has the necessary permissions - how can I determine which of the user's groups gave them the permission? As an example, building off the example in the django-guardian-docs , ideally there would be something like: >>> joe.has_perm_from_groups('sites.change_site', site) [site_owners_group] -
Virtual Printer / Printing from Django
I want to print labels from a django app, the site this app is on has 4 printers in the same network, all with different label sizes and colours. To create the labels I used fpdf2 for python to get .pdf files and the user can view them in the browser they are using. The problem is: How can I automate the printing process? The user still needs to open the document, which happens in Firefox/Chrome, press CTRL+P and select the right printer. I have 2 ideas, but don't know how to do either of them. Create a "virtual printer" that they always print to, this printer sees the document, categorizes it, and redirects it to the correct printer Somehow print directly from django, which is python and I already know that. Any ideas on how to do either of those? I can't find information on the first and don't know if the second one is a good approach. -
How do I remove duplicate children from django-rest-framework and django-mptt?
I followed this answer How to serialize a Django MPTT family and keep it hierarchical? I could serialize mptt-model but I am also receiving duplicate children from mptt-model. I have simple Menu model class Menu(MPTTModel, BaseModel): parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children') serializer class MenuSerializer(serializers.ModelSerializer): children = RecursiveField(many=True) class Meta: model = Menu fields = ('id', 'title', 'children',) I am receiving duplicate menu like this Duplicate response API I am on Python 3.9 Django 3.2.6 django-rest-framework 3.12.4 How do I remove duplicate menu children from djagno-mptt? -
How to make schedule basis delivery and lock the time and date in django
this is my UI design class OrderDashboard(models.Model): time = models.TimeField() reserved = models.BooleanField(default=False) class Reserved(models.Model): time = models.TimeField() date = models.DateField() # @login_required() def order_fuel(request): from django.db.models import Q date_time = OrderDashboard.objects.all() reservation = False if request.method == "POST": time = request.POST.get('time') date = request.POST.get('date') reserved = Reserved.objects.filter(Q(time=time) & Q(date=date)) if reserved: reservation = True print(reservation) return HttpResponse('Time already reserved!') else: reserved_ins = Reserved( time=time, date=date ) reserved_ins.save() return HttpResponse('Order confirmed') dict = {'date_time': date_time, 'reservation': reservation} return render(request, 'Uftl_App/orderfuel.html', context=dict) We building a Django application where we want to manage time slots such that where multiple users can use the same time slot to order their fuel. On the contrary a delivery truck can ship fuel up to 9 times per day (9:30 AM, 10:30AM, 12:30 PM, 02:30PM, 04:00PM, 06:00PM, 08:00PM, 09:00PM, 12:00AM) . If we have 2 trucks then we can deliver our product at 9:30 AM twice a day. We manage to lock/reserve/order the date only one time. We can’t manage to order the same time slot multiple times. How we can implement multiple orders in the same time slot? -
Authentication with react and django
I am an Intermediate django developer. What is the best possible way to implement authentication system in django + react framework. -
Search for multiple words via one django forms field
Hej! I have a result table in which I can filter entries via a django form. For example: country: 'Sweden' Where I would get all entries where 'Sweden' is the value in the column 'country'. I want that if I type in 'Sweden, Germany' I'd get all the results where the country in my database is 'Sweden' or 'Germany'. A boolean input ('Sweden OR/AND Germany') would also be great! This is my current view: #views.py def search_institution(request): if request.method == "POST": form = SearchInstitutionsForm(request.POST) if form.is_valid(): query_set = Institution.objects.filter( name__contains=form.cleaned_data['name'] ) context = { "result_data": list(query_set.values()), 'form': form } return render(request, "search_form.html", context) else: form = SearchInstitutionsForm() context = { "result_data": list(Institution.objects.values()), "form": form } return render(request, "search_form.html", context) I tried: query_set = Institution.objects.filter(name__contains=x) for x in ['name'])) query_set = Institution.objects.filter( name__search=form.cleaned_data['name'] ) Here I got the error: >Unsupported lookup 'search' for CharField or join on the field not permitted. Than I put django.contrib.postgres.search in my settings in installed apps and now geht the error >unrecognized token: "@" My form and template: #forms.py class SearchInstitutionsForm(forms.Form): name = forms.CharField(label='Name', required=False) #search_form.html <form method="post"> {{ form.as_table }} {% csrf_token %} <input type="submit" value="Search"> </form> Any ideas how to solve my problem? Thanks … -
django multiple modals with forms not rendering
I have a list of terminals and for each terminal I want to render an update form using a modal. For this, I am creating a list in the view with forms and pass the list to context as terminal_update_forms. class TerminalManagementView(LoginRequiredMixin, TemplateView): template_name = "app/terminal&location/terminal_management.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) terminal_update_forms = [] for terminal in terminals: form = TbTerminalUpdateForm( customer=self.request.user.customer, initial={'id': terminal.id}) terminal_update_forms.append(form) context['tb_terminal_update_forms'] = terminal_update_forms return context class TbTerminalUpdateForm(forms.ModelForm): class Meta: model = TbTerminal fields = ['terminal_name', 'terminal_desc', 'room', 'device_model'] I am creating a modal for each terminal and an update button. {% for terminal in terminals %} {% if terminal.category %} {% include 'app/terminal&location/modals/update_terminal_modal.html' with obj=terminal form=terminal_update_forms.forloop.counter %} {{terminal_update_forms}} <tr> <td class="txt-oflo">{{ terminal.terminal_name }}</td> <td class="txt-oflo">{{ terminal.terminal_id }}</td> <td class="txt-oflo">{{ terminal.room.room_name }}</td> <td class="txt-oflo">{{ terminal.create_time }}</td> <td class="txt-oflo">{{ terminal.create_user }}</td> <td> <button class="btn btn-lg" data-toggle="modal" data-target="#{{ terminal.id }}"> <span> Remove </span> </button> <button class="btn btn-lg ml-4" data-toggle="modal" data target="#update_{{terminal.id}}"> <span> Update </span> </button> </td> </tr> {% endif %} {% endfor %} This is the modal <!-- Modal --> <div class="modal fade" data-backdrop="static" data-keyboard="false" id="update_{{obj.id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog modal-sm" role="document"> <div class="modal-content"> <form enctype="multipart/form-data" action="{% url 'tb-terminal-update-form' %}" method="POST"> <div class="row d-flex justify-content-center"> … -
Integrate a multioption dropdown list in calculator Django
I will try to explain this issue the better I can. So built a calculator using django. The user can put the desired input, and then he sees all the results in a table, only by pressing the button: 'select'. Like this: However, now I want to add some more calculations by a dropdown list, and when the user selects this options, the output appears right away in the table.Like this: Here is my code: models.py class CalcAnalyzer(models.Model): sequence = models.TextField() gc_calc = models.CharField(max_length=2000000) person_of = models.ForeignKey(User,null=True,on_delete=models.CASCADE) def save(self, *args, **kwargs):# new if self.sequence != None: self.gc_calc = gc_calc(self.sequence) super(CalcAnalyzer,self).save(*args, **kwargs) def __str__(self): return self.sequence class addcalc_1(models.Model): name_sequence = models.ForeignKey(OligoAnalyzer, on_delete=models.SET_NULL, null=True) Option1_5 = models.FloatField(default=0) def save(self, *args, **kwargs): self.Option1_5 = Option1_5(self.sequence) class addcalc_3(models.Model): name_sequence = models.ForeignKey(OligoAnalyzer, on_delete=models.SET_NULL, null=True) optional_3 def save(self, *args, **kwargs): self.optional_3 = optional_3(self.sequence) views.py def calc_sequence(request): sequence_items=Calanalisis.objects.filter(person_of=request.user) form=AddSequenceForm(request.POST) if request.method=='POST': form=AddSequenceForm(request.POST) if form.is_valid(): profile=form.save(commit=False) profile.person_of = request.user profile.save() return redirect('calc_sequence') else: form=AddSequenceForm() myFilter=SequenceFilter(request.GET,queryset=sequence_items) sequence_items=myFilter.qs context = {'form':form,'sequence_items':sequence_items,'myFilter':myFilter} return render(request, 'Add_Calc.html', context) How can I insert this in the view.py? If the user selects the 5 or 3 box, the result should appear in the table bellow, if not, the result will stay the same. -
How to custom a search filter in django rest framework
Model class Student(models.Model): id = models.UUIDField(primary_key=True, default=uuid4, editable=False) first_name = models.CharField(verbose_name=_('first name'), max_length=20, blank=True, null=True) last_name =models.CharField(verbose_name=_('last name'), max_length=20, blank=True, null=True) class Bicycle(models.Model): id = models.UUIDField(primary_key=True, default=uuid4, editable=False) name = models.CharField(verbose_name=_('bicycle name'), max_length=20, blank=True, null=True) student_id = models.UUIDField(default=uuid4) View: class BicycleList(AdUpdateMixin, AdDestroyMixin, AdListMixin, AdCreateMixin, generics.GenericAPIView): permission_classes = [IsAuthenticated] queryset = Bicycle.objects.all() search_fields = ['name', 'id', 'first_name', 'last_name'] Now, I want create a custom search field in django rest framework. So that I can search first_name and last_name ? -
Django upload file to category name
I have such a task. There are two classes in the Model File, the first class is a category and the second class is a product. In the product class, you can select a category and you can upload a file, I need to do so which category I chose there will be uploaded the file, that is, if the category is called Document, the file will be uploaded to this folder. How to do it? -
Migrations are not made for all applications (some apps just skipped)
Django 3.2.6 Could you have a look at the picture. From themes downward are my apps. But when I make migrations, they are made only for articles. But when I make migrations for apps individually, migrations are made: Could you help me understand the reason of such behaviour and cope with this problem? -
How to connect to mysql database on aws in django?
I moved from php to django recently. I am trying to connect to Mysql database but its giving error django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'something.amazonaws.com' (timed out)") I used to connect to database in php like this public $default = array( 'datasource' => 'db', 'persistent' => false, 'host' => 'something.amazonaws.com', 'port'=> '', 'login' => 'username', 'password' => 'password', 'database' => 'mydatabase', 'prefix' => '', 'encoding' => 'utf8', ); setting.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mydatabase', 'USER': 'username', 'PASSWORD': 'password', 'HOST': 'something.amazonaws.com', } } -
I can't import dotenv from python-dotenv
Windows, Visual studio, django. I tried to install python-dotenv: https://pypi.org/project/python-dotenv/#getting-started. But when I want to import this command, I get error: Import "dotenv" could not be resolvedPylancereportMissingImports. I made such imports: (venv) PS C:\Users... pip3 install python-dotenv Requirement already satisfied: python-dotenv in c:\users...\venv\lib\site-packages (0.19.0). But import doesn't work. What can be wrong? -
Django SCSS, does not apply flex display
Hello I wanted to make a Django app but the problem is, app does not apply flex display. Rest of styles it applied. Any reason why Django ignores flexbox display or it is issue on SCSS side and i should have done it in pure css? html { font-size: 62.25%; box-sizing: border-box; } * { margin: 0; padding: 0; } *, *::before, *::after{ box-sizing: inherit; } .navbar{ color: pink; font-size: 5rem; display: flex; &__list{ display: flex; } &__item{ color:aqua; display: flex; } } .flex{ color: pink; } -
My datatable using js in django is very slow when i load more than 50000 rows
**My Model: ** class PartyMaster(models.Model): party_name = models.CharField(max_length=200,null=True, blank=True) email = models.EmailField(null=True, blank=True) contact = models.CharField(max_length=100,null=True, blank=True) address = models.CharField(max_length=350,null=True, blank=True) country = models.CharField(max_length=30,null=True, blank=True) sub_country = models.ForeignKey(CountryCategory,max_length=200,on_delete=models.CASCADE,null=True,blank=True,related_name='party_sub_country') state = models.CharField(max_length=50,null=True, blank=True) city = models.CharField(max_length=50,null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.party_name + " "+ self.email My View: In My Model there are around 50000+ rows def party_list(request): parties = PartyMaster.objects.all() context = { 'parties':parties, } return render(request,'party_master/party_edit.html',context) **My Template: ** {% extends 'base.html' %} {% block title %} Party List's {% endblock %} {% block body %} <div class="container"> <a href="{% url 'add_party' %}" class="btn btn-primary button_class mt-5">Party Master Form</a> <div class="py-3"> <div class="table-responsive"> <table class="table table-striped table-hover text-center table-responsive-sm" id="party_table"> <thead class="table-head"> <tr> <th scope="col">Party Name</th> <th scope="col">Email</th> <th scope="col">Contact</th> <th scope="col">Country</th> <th scope="col">Sub Country</th> </tr> </thead> <tbody> {% for party in parties %} <tr> <td class="pt-3">{{party.party_name}}</td> <td class="pt-3">{{party.email}}</td> <td class="pt-3">{{party.contact}}</td> <td class="pt-3">{{party.country}}</td> <td class="pt-3">{{party.sub_country.country_category}}</td> </tr> {% endfor %} </tbody> </table> </div> </div> </div> {% endblock %} {% block js %} <!-- Datatable --> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css"> <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script> <script src="https://code.jquery.com/jquery-3.5.1.js"></script> <script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script> <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script> <script> $(document).ready(function() { $('#party_table').DataTable( { dom: … -
Filter by django choices?
I want to filter by categories. But, it's not working. views.py def BytovyeTexnikiPylesosy(request): products = BytovyeTexniki.objects.filter(category='pylesosy') context = { 'products': products, } return render(request, 'store/product.html',context) models.py TEXNIKI = ( ('pylesosy','Пылесосы'), ('stiralki','Стиральные машины'), ('xolodilniki','Холодильники'), ) lass BytovyeTexniki(models.Model): name = models.CharField(max_length=200) category = models.CharField(max_length=300, choices=TEXNIKI) price = models.FloatField() image = models.ImageField(null=True, blank=True) def __str__(self): return self.name @property def imageURL(self): try: url = self.image.url except: url = '' return url I am trying to use this code. But, it's not working. I want to filter by category. Please help? -
Django url pattern is not a registered view function or pattern
I have a small Django web app, with multiple applications inside them. I have used the include in the urls.py files, but whenever I reference the URLs in the HTML files they don't load. Below are my 3 urls.py files. The one I'm having an issue will specifically is the nodes url pattern in the nodes urls.py #main urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('account/', include('account.urls')), ] #account urls.py from django.urls import path, include from django.contrib.auth import views as auth_views from . import views app_name = 'account' urlpatterns = [ path('login/', auth_views.LoginView.as_view(), name='login'), path('logout/', auth_views.LogoutView.as_view(), name='logout'), path('dashboard/', views.dashboard, name='dashboard'), path('nodes/', include('nodes.urls')), ] #nodes urls.py from django.urls import path from . import views app_name = 'nodes' urlpatterns = [ path('', views.nodes, name='nodes'), ] This is my HTML file where I am referencing the URL pattern: <li {% if section == 'nodes' %}class="active"{% endif %}> <a class="nav-link" href="{% url 'nodes' %}">Nodes</a> </li> Any help would be great, thanks -
django-machina search feature not working
I am using django-machina for creating forums. But the search feature provided by machina is not working. I have followed the docs. And have also updated the index as mentioned. But still the search is not working. I can't see any error in the log and there are no results.