Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to populate a select list in a Django Template dynamically using Javascript?
I've recently been learning Django and HTML but I'm completely new to JS and I'm having a go at creating a database display page with a filter menu at the side. For this page I have the following code: Model.py: class Part(models.Model): PartID = models.AutoField(primary_key=True, unique=True) SiteID = models.ForeignKey('Site', on_delete=models.CASCADE, null=True) Comment = models.CharField(max_length=255, blank=True) Subtype = models.ForeignKey('Subtype', on_delete=models.CASCADE, null=True) Location = models.CharField(max_length=255, blank=True) ConnectedTo= models.ManyToManyField('self', null=True) BatchNo = models.CharField(max_length=32, blank=False, null=True) SerialNo = models.CharField(max_length=32,blank=True) Manufacturer = models.CharField(max_length=32, blank=False, null=True) Length = models.FloatField(blank=True, null=True) InspectionPeriod = models.IntegerField(blank=True, null=True) LastInspected = models.DateField(blank=True, null=True) InspectionDue = models.CharField(max_length=255, blank=True) View.py: @login_required(login_url='/accounts/login/') def sites(request, site): siteselected = site warnings = 0 expired = 0 good = 0 PartsAtSite = Part.objects.filter(SiteID = siteselected) TypesList = Type.objects.values_list('TypeName', flat=True).distinct() InspectionList = Part.objects.values_list('InspectionPeriod', flat=True).distinct() LengthList = Part.objects.values_list('Length', flat=True).distinct() LocationList = Part.objects.values_list('Location', flat=True).distinct() ManufacturerList = Part.objects.values_list('Manufacturer', flat=True).distinct() for part in PartsAtSite: if part.LastInspected == None: part.InspectionDue = "Yes" expired = expired + 1 else: Deadline = part.LastInspected + timedelta(days=part.InspectionPeriod) if datetime.now().date() > Deadline: part.InspectionDue = "Yes" expired = expired + 1 elif datetime.now().date() > (Deadline - timedelta(days=30)): part.InspectionDue = "<30 Days" warnings = warnings + 1 else: part.InspectionDue = "No" good = good + 1 part.save() context = { … -
Cannot access to Django admin
If I do create a user with superuser status in django admin and I cannot log in to django admin. It says Please enter the correct phone and password for a staff account. Note that both fields may be case-sensitive. here is my code class UserManager(BaseUserManager): use_in_migrations = True def _create_user(self, phone, password, **extra_fields): user = self.model(phone=phone, **extra_fields) user.set_password(password) user.save(using=self._db) return user def create_user(self, phone, password=None, **extra_fields): extra_fields.setdefault('is_staff', False) extra_fields.setdefault('is_superuser', False) return self._create_user(phone, password, **extra_fields) def create_superuser(self, phone, password, **extra_fields): if password is None: raise TypeError( 'Superuser must have a password' ) user = self._create_user(phone=phone, password=password, **extra_fields) user.is_superuser = True user.is_staff = True user.save(using=self._db) return user class User(AbstractUser): username = models.CharField(blank=True, null=True, max_length=50) phone = models.CharField(max_length=13, unique=True) USERNAME_FIELD = 'phone' verified = models.BooleanField(default=False) objects = UserManager() REQUIRED_FIELDS = ['email', 'first_name', 'last_name'] def __str__(self): return self.phone If I create user in terminal I can easily log in to django admin. If I do in django admin I cannot. Can anyone tell please if something is wrong or missing in my code? Thank you in advance! BTW it returns True of superuser status in terminal with created user in django admin but cannot have access. -
Is it possible to send multi-layered file inside json array in post request?
I have been trying to send multiple files along json objects in post request. { name:"Most recent", file:text.png, tracks:[{ name:"amber", file:amber.png, desc:"", }] } I want to save data of first file in one model and tracks file in different model. -
is it possible to render a editable table use django tables? if so how?
this is my models.py class bio_broken_eq(models.Model): bio_eq_id = models.IntegerField(primary_key = True) student = models.ForeignKey("chem_lab.student", verbose_name=("student"), on_delete=models.CASCADE) bio_eq_name = models.CharField(max_length=50) bio_eq_number = models.IntegerField() bio_eq_cost = models.IntegerField() class bio_eq(models.Model): bio_eq_id = models.IntegerField(primary_key=True) bio_eq_name = models.CharField(max_length=50) bio_eq_amount = models.PositiveIntegerField this needs to be rendered an editable table. how should i go about doing this? -
Getting error : Could not resolve URL for hyperlinked relationship using view name "user-detail" in django python
i am new here in django python, so pardon me for my silly mistake I am working on the Rest API, when i do run API http://127.0.0.1:8000/api/v1/users/ I am getting this error : Could not resolve URL for hyperlinked relationship using view name "user-detail". You may have failed to include the related model in your API, or incorrectly configured thelookup_fieldattribute on this field., below i have placed my whole file, can anyone please look my code and help me to resolve this issue ? thanks in advance views.py from django.shortcuts import render # Create your views here. import rest_framework.generics from rest_framework import generics from .models import Songs from .serializers import SongsSerializer from .serializers import UserSerializer from django.contrib.auth.models import User class ListSongsView(generics.ListAPIView): """ Provides a get method handler. """ queryset = Songs.objects.all() serializer_class = SongsSerializer class UserViewSet(generics.ListAPIView): #viewsets.ModelViewSet queryset = User.objects.all() serializer_class = UserSerializer serializers.py from rest_framework import serializers from .models import Songs from .models import UserProfile from django.contrib.auth.models import User class SongsSerializer(serializers.ModelSerializer): class Meta: model = Songs fields = ("title", "artist") class UserProfileSerializer(serializers.ModelSerializer): class Meta: model = UserProfile fields = ('title', 'dob', 'address', 'country', 'city', 'zip', 'photo') class UserSerializer(serializers.HyperlinkedModelSerializer): profile = UserProfileSerializer(required=True) class Meta: model = User fields = ('url', … -
Django models count children and grand children
In Django models I need help selecting count of children and count of grand children. My models: Parent: Child: parent = models.Foreignkey(Parent) GrandChild: child = models.Foreignkey(Child) I did Parent.objects.annotate(num_child =Count('parent'), num_grandchild=('child__grandchild')) With this, I get num_child is exactly same value as num_grandchild Can you please help -
Django ImageField - AttributeError 'PublicMediaStorage' object has no attribute 'generate_filename'
I'm getting the titled error, when trying to submit a Django form with an imageField. Following are the relevant code snippets: Settings DEFAULT_FILE_STORAGE = 'newt.storage_backends.PublicMediaStorage' Model from django_upload_path.upload_path import auto_cleaned_path class FoodLogging(models.Model): food_image = models.ImageField('Food Image', upload_to=auto_cleaned_path, null=True, blank=True, default="NA") Form class FoodLoggingForm(BetterModelForm): class Meta: model = FoodLogging fieldsets = ( ... ('Food Logging Report', { 'fields': ('food_image',), 'legend': "Food Logging Report", 'template_name': "fieldset_template.html" }), ... View class FoodLoggingCreate(PermissionRequiredMixin, CreateView): model = FoodLogging form_class = FoodLoggingForm success_url = reverse_lazy('foodloggings') permission_required = ('catalog.add_foodlogging') def form_valid(self, form): form.instance.user = self.request.user return super(FoodLoggingCreate, self).form_valid(form) def get_form_kwargs(self): kwargs = super(FoodLoggingCreate, self).get_form_kwargs() kwargs.update({'request': self.request}) return kwargs HTML <input type="file" name="food_image" accept="image/*" id="id_food_image"> Please support Thanks ahead, Shahar -
Is it possible to call a class instance by using a variable which has a valid instance name?
I am a newbie in Object Oriented Programming. The problem might sound silly. I have a class named Dogs(). And this class has some instances age, height, weight which are stored in the database. class Dogs(): age=IntegerField() height=FloatField() weight=FloatField() Now if I call the class in a variable and then call the instances with the name inside the class it works fine. dog=Dogs.objects.all()[0] dog.age #works fine dog.height #works fine dog.weight #works fine Now I have another variable which contains one of the instance's name say (temp='age'). I want to call the instance (which is in the variable temp) of the class Dogs using the variable. dog.temp #Does not work Is it possible to get the instance by calling with the variable? If yes then how should I do it? If no then what should be my approach? -
Format a FloatField column in the admin and display the formatted column value
Is there a way to format a FloatField (ideally directly in the model) or even create a new column and display the value with the formatted values (which I am trying to do): # Model: class MyModel(models.Model): id = models.AutoField(db_column='Id', primary_key=True) # Field name made lowercase. # ... price = models.FloatField(db_column='Price', blank=True, null=True) # Field name made lowercase. # Admin class MyModelAdmin(admin.ModelAdmin): list_display = ( 'id', # ... 'new_price' ) def new_price(self, obj): formatted_num = '{:,}'.format(int(obj.price)) print(formatted_num) return formatted_num # Currently, the formatted_num has a value such as: -1,012,010,000 but for some reason, the column 'new_price' in my admin model view is empty -
ImproperlyConfigured at /news/create/
class CreateNewsView(LoginRequiredMixin,CreateView,): login_url='/accounts/login' news_form_class=NewsCreateForm template_name='news/create_news.html' success_url=reverse_lazy('home') def form_valid(self,form): tag_list = [] news = form.save(commit=False) title= form.cleaned_data['title'] tags= form.cleaned_data['tags'] tag_list = [Tag.objects.get_or_create(name=tag)[0] for tag in tags.split()] # news_tag=form.cleaned_data['news_tag'] news.author = self.request.user news.slug = slugify(title) for tag in tag_list: news.tags.add(tag) news.save() return super(CreateNewsView,self).form_valid(form) def form_invalid(self,form): print (form.errors) return super(CreateNewsView,self).form_invalid(form) my models: its news website with tags in it to create and i have faced error while adding tag . I havent used TaggableManager() for tags rather i have created my own models class Tag(models.Model): name = models.CharField(max_length=30) class News(models.Model): CATEGORY=(("0","Politics"),("1","Sports"),("2","Health"),("3","Business"),("4","International"),("5","Finance")) title=models.CharField(max_length=250) story= models.TextField() count= models.IntegerField(default=0) tags = models.ManyToManyField(Tag) video_url = models.URLField(max_length=270, null=True) #makemigrations garna baki xa category= models.CharField(choices=CATEGORY, max_length=2) slug=models.SlugField(max_length=270,blank=True,null=True) created_at=models.DateTimeField(auto_now_add=True) updated_at=models.DateTimeField(auto_now=True) cover_image=models.ImageField(upload_to="uploads") author= models.ForeignKey(User, on_delete=models.SET_NULL,null=True) video_image = models.ImageField(null=True) def get_absolute_url(self): return reverse("detail_news",kwargs={"category":self.get_category_display(), "pk":self.pk, "slug":self.slug}) -
getting invalid syntax error in python 3.8
guys, I am trying to make my first Django application but I keep seeing invalid syntax error at the second url. urlpatterns = [ url(r'^$',views.index, name='index') url(r'^details/(?P<id>\d+)/$',views.details, name ='details') ]; -
How to create an API endpoint in django to stop a Get/Post http request?
I am trying to allow the user to stop a get/post http request whenever he wants to during the process. -
Synonymous many to many model relationship in Django
I'm trying to achieve what you could call a "synonymous" relationship on a self referencing many to many field in Django. Take this model for example (in reality I don't use real words, but category tags instead): class Word(models.Model): name = models.CharField(max_length=30, unique=True) synonymous = models.ManyToManyField('self', blank=True, related_name='synonymous') def __str__(self): return self.name What I want to achieve, is when I have 3 objects, and add any combination of them to the synonymous field, I want all of them to be connected. # Create synonymous words bunny = Word.objects.create(name='bunny') hare = Word.objects.create(name='hare') rabbit = Word.objects.create(name='rabbit') # Set synonymous words to rabbit rabbit.synonymous.set([bunny, hare]) Now when I get the synonymous objects of rabbit, it has what I want: (Pdb) rabbit.synonymous.all() <QuerySet [<Word: bunny>, <Word: hare>]> But when I take the synonymous objects of bunny and hare, they only return rabbit. (Pdb) bunny.synonymous.all() <QuerySet [<Word: rabbit>]> (Pdb) hare.synonymous.all() <QuerySet [<Word: rabbit>]> What I'd like to achieve, is all the synonymous objects, to be "symmetrical". Now, the m2m field is already symmetrical, but it only stops at one object, not all given synonymous objects. So, the ideal result would be this: # Create synonymous words bunny = Word.objects.create(name='bunny') hare = Word.objects.create(name='hare') rabbit = Word.objects.create(name='rabbit') … -
django, How to set up function to modify models variables
i am new in django, please can somone explain me how this should work properly: I have created app called taskai: from django.db import models # Create your models here. class taskai(models.Model): title = models.TextField() image = models.ImageField(upload_to='images/',null=True) desc = models.TextField(blank=True) inp = models.IntegerField(null=True) def __str__(self): return self.title def skaiciai(self, inp): for i in range(10): self.inp += i return print(self.inp) i am just playing with models and functions in django, i want to print in site modified inp value. I am adding in admin panel title, image, desc and inp (for exmaple 5). Output should be 50, how can i make it work ? -
How to create Django models with ManyToMany relation with tables in different PostgreSQL schemas, one model using just part of unmanaged table
I have a Django application which works just fine. Problem is that it needs to be migrated and that brings some changes. Whole application used to be in PostgreSQL schema intake. Problem is with following models. class Authority(models.Model): id = models.IntegerField(primary_key=True) code = models.IntegerField() name = models.CharField(max_length=255) class Doc(behaviors.Timestampable): id = models.IntegerField(primary_key=True) authorities = models.ManyToManyField(Authority, related_name="docs", ) I need Authority model to use existing table named authority_list. Table is in different schema named lists and it contains many columns. I need only three of them. Table is used by other apps too and is used only for reading. I tried creating router like this: ROUTED_MODELS = [models.Authority] class DefaultRouter: def db_for_read(self, model, **hints): if model in ROUTED_MODELS: return 'lists' return None def db_for_write(self, model, **hints): if model == models.Authority: raise Exception("This model is read only!") return None DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'OPTIONS': { 'options': '-c search_path=intake,lists,public' }, 'NAME': 'dmx', 'USER': 'postgres', 'HOST': 'localhost', }, 'lists': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'OPTIONS': { 'options': '-c search_path=lists,intake,public' }, 'NAME': 'dmx', 'USER': 'postgres', 'HOST': 'localhost', }, DATABASE_ROUTERS = ('dmx.db_routers.DefaultRouter',) Changed Authority model class Authority(models.Model): class Meta: managed = False db_table = "authority_list" It didn't work like I wanted so I found somewhere … -
Table 'django_migrations' already exists after dropping database
I recently had a database issue so I decided to nuke it since I had no important data. I deleted my migrations folder in my app directory and dropped the database. However now when I go to recreate everything with manage.py migrate I get the following error: File "../manage.py", line 21, in <module> main() File "../manage.py", line 17, in main execute_from_command_line(sys.argv) File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/django/core/management/commands/migrate.py", line 234, in handle fake_initial=fake_initial, File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/executor.py", line 91, in migrate self.recorder.ensure_schema() File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/recorder.py", line 69, in ensure_schema raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc) django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1050, "Table 'django_migrations' already exists")) I have tried running this after deleting the database, and after recreating the empty database. I can be 100% sure there are no tables there right now. So I have no idea why it thinks that table is there. -
How many ways we can save values from Django form to Database
I have started learning Django recently using a Udemy course. While going through the course instructor asked to save values from a Form to database. After searching on the internet I figured out how to put form values into database and everything is working fine. Below is my views.py and forms.py files. forms.py class FormName(forms.Form): fname = forms.CharField( label="First Name") lname = forms.CharField(label="Last name:") email = forms.EmailField() verify_email = forms.EmailField(label='Verify Email:') def clean(self): all_clean_data = super().clean() email = all_clean_data['email'] vmail = all_clean_data['verify_email'] if email != vmail: raise forms.ValidationError("Check the emails") views.py def signup(request): form = forms.FormName() if request.method == 'POST': form = forms.FormName(request.POST) if form.is_valid(): post = User() post.fname=request.POST.get('fname') post.lname=request.POST.get('lname') post.email=request.POST.get('email') post.save() return render(request,'third_app/greet.html') else: return render(request,'third_app/oops.html',{'form':form}) return render(request, 'third_app/signup.html',{'form':form}) Now coming to question, the instructor is using meta class to store the form values to the database. Below are his forms.py and views.py files. I am curious about what is the difference between my method and the instructor's. forms.py class FormName(forms.ModelForm): class Meta(): model = User fields = 'all' views.py def signup(request): form = forms.FormName() if request.method == 'POST': form = forms.FormName(request.POST) if form.is_valid(): form.save(commit=True) return render(request,'third_app/greet.html') else: return render(request,'third_app/oops.html',{'form':form}) return render(request, 'third_app/signup.html',{'form':form}) Thanks. -
Edit data Query using graphene
I would like to edit data with a query (GraphQL) using graphene Group Model: class GroupEntity(models.Model): uuid = models.TextField() namegroup = models.CharField(max_length=100) description = models.TextField() profilimage = models.TextField() and i have a query to query all groups and their data class Query(object): all_entitygroup = graphene.List(EntityType) def resolve_all_entitygroup(self, info, **kwargs): return GroupEntity.objects.all() And I can get the data with a query this by: { "data": { "allEntitygroup": [ { "id": "1", "description": "descrlol", "uuid": "11112", "namegroup": "nom", "profilimage": "img" } } How can I modify this data, for example if I want to change the 'uuid' of this specific user ? -
get image as per category django drf
Everything working but i want to fetch image based on category. models.py: class Image(models.Model): title = models.CharField(max_length = 100) image = models.ImageField(upload_to = 'home/tboss/Desktop/image' , default = 'home/tboss/Desktop/image/logo.png') category = models.ForeignKey('Category', null=True, blank=True, on_delete=models.CASCADE) image_keyword = models.TextField(max_length=1000) def __str__(self): return self.title serializers.py: class ImageSerializer(serializers.ModelSerializer): class Meta: model = Image fields = ('title','category','image') views.py: class ImageView(generics.ListCreateAPIView): authentication_classes = [] permission_classes = [] pagination_class = None serializer_class = ImageSerializer def get_queryset(self): cat = int(self.request.query_params['category']) return Image.objects.all().filter(category = cat) urls.py: path('image/', views.ImageView.as_view(), name = 'category_image') current its working like this: localhost:8000/image?category=<category_id> no trailing slash what i want to achieve add category parameter with trailing slash: path('image/<category>/', views.ImageView.as_view(), name = 'category_image') i was not able to pass category parameter in get_query function any suggestions -
Export zip file with Django Rest Framework
I created this view that should return a zip file to be downloaded: class ExportAgents(APIView): """ View to export requested agents """ def post(self, request): """ Export requested agents will receive list of agent ids, export data, and return a zip file """ print(request.data["agents_list"]) list_ids = request.data["agents_list"] response = Response(export_agent(list_ids, user_id=1), content_type='application/zip') # export_agent(list_ids, user_id=1) will return a zip file, works fine. response['Content-Disposition'] = "attachment; filename=exported_data.zip" response.accepted_media_type = None response.renderer_context = None return response But it doesn't return a zip file to the frontend. It returns this error instead: UnicodeDecodeError at /intents/agents_export 'utf-8' codec can't decode byte 0xb7 in position 10: invalid start byte Any help? Thanks. -
Display django chartit graph in right order with PivotDataPool
How to display chartit graph in the right order with PivotDataPool When I use PivotDataPool the graphe is not in the right order. It concern the month number. Chartit PivotDataPool graph is in this order 1, 10, 11, 2, 3, 4, 5, 7, 8, 9. I want to have right order like 1, 2, 3, 4 , 5, 6, 7, 8, 9, 10, 11. ![Graph image][1] ![1]:(https://imgur.com/UPBZY8G) PivotDataPool( series= [{'options': { 'source': DerangementAdsl.objects.filter(annee=year), 'order_by': ['mois'], 'categories' : ['mois'], 'legend_by': ['sous_traitant'], 'legendIndex':1, }, 'terms': { 'total': Count('id') } } ]) pivcht = PivotChart( datasource=ds, series_options=[{ 'options': { 'type': 'column', 'stacking': True, 'order_by': 'mois', }, 'terms': ['total'] }], chart_options={ 'title': { 'text': 'Répartition dérangements relevés / structure' }, 'xAxis': { 'title': { 'text': 'Semaine' } } } ) -
Django Pagination for search results
How to paginate dynamically generated data like search results, I have tried this but its not working. This is my code in views paginator = Paginator(search_result, 25) page = req.GET.get('page') results = paginator.get_page(page) return render(req, 'search.html', {'results': results}) This is what I have in my template {% for result in results %} {{ result }} {% endfor %} -
git add . && git commit -m 'Initial commit
At line:1 char:11 + git add . && git commit -m 'Initial commit' + ~~ The token '&&' is not a valid statement separator in this version. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine -
Filtering for the Infinite Scroll list does not work - Django, Ajax
I'm trying to implement filtering for mine infinite scroll list in Django. My example looks like this: views.py def search(request): search = Influencer.objects.all() #get data media = request.GET.get('media', False) popularity_compartment = request.GET.get('popularity_compartment', False) if media: search = search.filter(media=media) if popularity_compartment: search = search.filter(popularity_compartment=popularity_compartment) #paginator paginator = Paginator(search, 20) page = request.GET.get('page', 1) try: search_paginator = paginator.page(page) except PageNotAnInteger: search_paginator = paginator.page(1) except EmptyPage: search_paginator = paginator.page(paginator.num_pages) context = {'search_paginator': search_paginator,} return render(request, 'app/template.html', context) So I have two filters that should work on my infinite list. I use them in this way in a template.html <!-- Paginator with object --> <div class=" infinite-container"> {% for object in search_paginator %} <!-- Object --> <div class="card mb-3 hover-shadow-lg infinite-item"> [...] </div> {% endfor %} </div> <!-- Load more --> {% if search_paginator.has_next %} <div class="mt-4 text-center"> <a href="?page={{ search_paginator.next_page_number }}" class="btn btn-sm btn-neutral rounded-pill shadow hover-translate-y-n3 infinite-more-link">Loading...</a> </div> {% endif %} <!-- Infinite Scroll --> <script src="{% static 'assets/js/jquery-3.1.1.min.js' %}"></script> <script src="{% static 'assets/js/jquery.waypoints.min.js' %}"></script> <script src="{% static 'assets/js/infinite.min.js' %}"></script> <script> var infinite = new Waypoint.Infinite({ element: $('.infinite-container')[0] }); </script> Although my example looks complex, I think it presents a minimal configuration to show the problem. The problem is that the filter … -
Need to get the output in the same page (using django model forms with ajax)
I've tried to reinvent a situation, I've faced recently with a simple example, as follows: I'm new to using ajax with django and this is what I'm trying to do.. I have a single page ('home') and there are two buttons Form1 and Form2; clicking either one of the buttons executes an ajax call and gets it's corresponding form without refreshing (I'm able to pass a get request properly using jquery function with ajax call to display it on the 'home' page itself, without refreshing). It looks like this: Each of those select fields are pre-populated with django model values thorugh Model.object.create(name=name) in the IDLE, and have only one field(besides the pk id). If I select a value from either of both dropdowns and hit process, it should display the length of the selected string, without refreshing the page (just as how the page doesn't refresh while switching the forms) ----> This is where I'm exactly struck and I know the approach I'm using is wrong, but not sure on how to correct it. Can someone please help me in completing the intended purpose of this django app. Sorry for the pasted length of the whole code; for helpers' convenience …