Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how do i match two scripts to an object in models
how do i match the headlines code to the content code for the models in my views.py . it keeps repeating one headline. how do i match the headlines code to the content code for the models in my views.py . it keeps repeating one headline. how do i match the headlines code to the content code for the models in my views.py . it keeps repeating one headline. this my views.py code from django.shortcuts import render, redirect import django import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "untt.settings") django.setup() import requests import urllib3 from bs4 import BeautifulSoup from datetime import timedelta, timezone, datetime urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) from news.models import Headline, UserProfile def scrape(request): user_p = UserProfile.objects.filter(user=request.user).first() user_p.last_scrape = datetime.now(timezone.utc) user_p.save() for i in range(1): r = requests.get("https://www.dailypost.ng/hot-news/page/{}".format(i)) soup = BeautifulSoup(r.content, "html.parser") mydivs = soup.findAll("span", {"class": "mvp-cd-date left relative"}) for div in mydivs: mytags = div.findNext('h2') for tag in mytags: allheadlines = (tag.strip()) z = [linkk.get('href', '/') for linkk in soup.find_all("a", {"rel": "bookmark"})] for url in z: r = requests.get("https://www.dailypost.ng/hot-news/") response = requests.get(url) soup = BeautifulSoup(response.content, "html.parser") conteent = soup.find(id="mvp-content-main") article = '' for i in conteent.findAll('p'): article = article + ' ' + i.text news_headline = Headline() news_headline.title = allheadlines news_headline.contentt = article news_headline.save() return redirect('/') … -
Local Variable 'user_form' referenced before assignment
I am running a website using Django . Here is the code (views.py): def signup(request): registered=False failed_ref=False wrong_ref=False if request.method=='POST': if 'city' in request.POST: user_form = UserForm(data=request.POST) profile_form = ProfileForm(data=request.POST) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() profile = profile_form.save(commit=False) profile.user = user try: ref_con = profile.referral_contact if ref_con == profile.mobile_no: failed_ref=True elif ref_con == Profile.objects.get(mobile_no=ref_con).mobile_no: prof = Profile.objects.get(mobile_no=ref_con) wallet_rec = Wallet.objects.get(profile=prof) wall = Wallet.objects.get(profile=profile) registered = True except Profile.DoesNotExist: wrong_ref = True data={'registered':registered,'failed_ref':failed_ref,'wrong_ref':wrong_ref} return JsonResponse(data,safe=False) else: user_form=UserForm() profile_form=ProfileForm() return JsonResponse({'user_form':user_form,'profile_form':profile_form,'registered':registered, 'failed_ref':failed_ref,'wrong_ref':wrong_ref}) For this, i need to get response in JSON . When i run , i am getting error "local variable 'user_form' referenced before assignment".What change i need to do ?. I am bit confused. -
Can we use concept of inheritance in Django rest frame work in ModelViewSets?
Im repeating my code again and again in different ModelViewSets, The only thing that is changing here is Models name, i want to write a base class for this and send models name as arguments but its not working. any Help?? class RemitterQueryViewViewset(viewsets.ModelViewSet): queryset = RemitterQueryView.objects.all() serializer_class = RemitterQueryViewSerializer http_method_names = ['get'] def get_base_path(self): splitted_url = self.request.build_absolute_uri().split('?') base_url = splitted_url[0] return base_url def get_queryset(self): limit = self.request.query_params.get('limit', 26) offset = self.request.query_params.get('offset', 0) filter_list = self.request.query_params.get('filter_list', None) sort_list = self.request.query_params.get('sort_list', None) if filter_list is None and sort_list is None: return RemitterQueryView.objects.filter(id__gt=int(offset))[0:int(limit)] elif filter_list is not None and sort_list is not None: filter_columns = self.get_filter_list() sort_columns = self.get_sort_list() sort_columns = list(itertools.chain(*sort_columns)) return RemitterQueryView.objects.filter(id__gt=int(offset), **filter_columns).order_by(*sort_columns)[0:int(limit)] elif filter_list is None and sort_list is not None: sort_columns = self.get_sort_list() sort_columns = list(itertools.chain(*sort_columns)) return RemitterQueryView.objects.filter(id__gt=int(offset)).order_by(*sort_columns)[0:int(limit)] elif filter_list is not None and sort_list is None: filter_columns = self.get_filter_list() # print(filter_columns) # print(MockData.objects.filter(id__gt=int(offset), **filter_columns)[0:int(limit)]) return RemitterQueryView.objects.filter(id__gt=int(offset), **filter_columns)[0:int(limit)] -
Django model's choice field not able to capture appropriate value
I am working on creating a user profile when the user signs up. I'm using DjangoRestFramework for that. I was able to create a Viewset for that model and getting the HTML form to create a new record in database. I have a drop down field in the signup form which contains 3 values. I'm trying to capture the value selected by the user. class UserStack(BaseModel): TEST_TYPES = ( ('SDT', 'Sample Task'), ('SAT', 'Solution Task'), ('PT', 'Programming Task'), ) user_name = models.CharField(unique=True, max_length=50) test_type = models.CharField(max_length=50, choices=TEST_TYPES) When the user sends POST request, I'm not able to capture the value of test_type in the backend. I checked the browser's network request section, it is sending the appropriate value when making a post request like task_type = 'SDT' or 'SAT' or 'PT'. However, if I try to access the details of instance of the model using vars(instance), I'm getting it as {'test_type', ''} even if I choose a choice field in the django rest viewset form. -
How to go back to the previous page of a form
I am creating a quiz app in django . I collected the users answer via a form when the user click "next " in the quiz it goes to the next question , but I don't know how to add "previous" button to the form that allows user to go to the previous questions he has selected .. I tried using window.history.back() in JavaScript but it only goes back once .note there is no URL for individual question -
category subcategory not showing properly drf django
i have this category models: class Category(MPTTModel): name = models.CharField(max_length = 100) slug = models.SlugField() parent = TreeForeignKey('self',blank=True, null=True, related_name='children', on_delete=models.CASCADE, db_index = True) class MPTTMeta: unique_together = ('slug', 'parent') verbose_name_plural = "categories" order_insertion_by = ['name'] def __str__(self): full_path = [self.name] k = self.parent while k is not None: full_path.append(k.name) k = k.parent return ' -> '.join(full_path[::-1]) serializers.py: class SubCategroySerializer(serializers.ModelSerializer): class Meta: model = Category fields = ('id', 'name','slug', 'children') category Listing Api class CategorySerializers(serializers.ModelSerializer): children = SubCategroySerializer(many=True, required=False) class Meta: model = Category fields = ('id','name','slug','children') currently its working but i want to show subcategory inside category only not as a main category as you can see subcategory are listed inside main category and with maincategory also I am expecting this result: [ { "id": 1, "name": "Animals & Wildlife", "slug": "animals_wildlife", "children": [] }, { "id": 2, "name": "main cat", "slug": "mai_cat", "children": [ { "id": 3, "name": "sub_cat", "slug": "submaincat", "children": [] } ] }, { "id": 4, "name": "maincat2", "slug": "maincat2", "children": [ { "id": 5, "name": "submaincat2", "slug": "submaincat2", "children": [] } ] }, { "id": 6, "name": "maincat3", "slug": "maincat3", "children": [] } ] ............................................... -
Implementing access control in django based on role
i need help in implementing access control on my django project. There are 2 main roles , sales and developer. In these 2 roles , there is another hierarchy , manager and non-manager. Based on their roles , i would want to display different things and do different types of queries. The method i am using currently using is to extend my user model to include these roles , and using if statements within my template to display the functionalities accordingly. Here is my model: class UserProfile(models.Model): role = ( ('sm','sales_manager'), ('s','sales'), ('rm','rnd_manager'), ('r','rnd') ) user = models.OneToOneField(User,on_delete=models.CASCADE) user_type = models.TextField(max_length=500, choices= role) contact = models.IntegerField(default=92388112) def __str__(self): return str(self.user.username) Here is my view: @login_required(login_url='login') def rnd/home(request): print(request.user.username) context = { 'userProfile' : UserProfile.objects.all(), } return render(request, 'rnd/home.html',context) here is a relevant part of my template: {%if user.get_UserProfile.user_type == 's' or user.get_UserProfile.user_type == 'sm' %} <p>Sales</p> {%else%} <p>RnD</p> {%endif%} <li> However , my for loop does not work. It does not throw any error , but does nothing as well. When im logged in as a 'r' type , sales still gets shown on my screen. It would be great if someone could answer me as well as leave some … -
Copy datas from PostgreSQL to CSV file
I have a Django application on server with PostgreSQL database and now I want to copy all datas in this database to some CSV file on my local storage. I'm running this command: db_name=# \COPY table_name TO '\Users\username\Desktop\applicants.csv' DELIMITER ',' CSV HEADER; But this command returns me Permission denied error. How can I fix it ? -
Web design trends for rendering large amount of information
This is a web design technology/approach question. What are the modern web design trends for presenting, serving a large amount of user data to the user in a way - All information is available on the page, no reloads and multiple requests, less clicking and navigation Data is mostly text, and tables, some infographics At a glance, the user should perceive the abstract Have the most significant information to be presented with the best use of screen real estate Prioritize major, minor information Apart from the use of ajax, pagination, widgets, what are the modern ways to build layouts, an intuitive presentation of the information? -
login(request, user) function not working in django.contrib.auth
I am currently building a web app using Django that requires users to login, and I have this function in views.py def post(self, request, format=None): login = request.data user = authenticate( username=login['username'], password=login['password']) if user is not None: login(request, user) return Response({'message': 'Login successful', 'status': 1}) else: return Response({'message': 'Login unsuccessful', 'status': 0}) But the login function keeps triggering an error File ".../views.py", line 58, in post login(request, user) TypeError: 'dict' object is not callable I don't know why the user is identified as 'dict' object. Can please anyone help me? -
NOT NULL constraint failed: baseapi_movie.admin_id without using django forms
I created Theimdb movie API and I store all the movies' data into database but I got error when I used foreign key.some users liked different film so I want show different user can see different data, so I used model relationship, can anyone please suggest me how to do it. views.py @login_required(redirect_field_name="log") def trending(request): movie_list=[] try: if request.method=="POST": if "taskAdd" in request.POST: title=request.POST["title"] release=request.POST["release"] poster=request.POST["poster"] vote_average=request.POST["vote_average"] movie_id=request.POST["movie_id"] task=Movie(title=title,release=release,poster=poster,vote_average=vote_average,movie_id=movie_id) task.save() return redirect('/') models.py class Movie(models.Model): title=models.CharField(verbose_name='movie_name',max_length=30) #overview=models.TextField(blank=True, null=True) release=models.DateField() poster=models.ImageField(upload_to=None, height_field=None, width_field=None, max_length=100) vote_average=models.CharField(max_length=30,default=True) movie_id=models.IntegerField(default=True) admin=models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return self.title -
Celery worker failed to start in devstack open edx environment
I have been trying to start a celery worker in an open edx devstack environment in order to test how my tasks will run asynchronously. However I have been failing to get the celery worker up and running. I have tried the solution provided in the documentation https://edx-document.readthedocs.io/en/latest/environment/celery.html but I keep on getting an error [2020-01-03 06:41:22,082: ERROR/MainProcess] consumer: Cannot connect to amqp://celery:**@127.0.0.1:5672//: [Errno 111] Connection refused.. Tried searching online but haven't been able to get match information in regards to the open edx devstack environment. Any help will be much appreciated. -
extracting value from Mysql and converting to varibale in python
I am new to Django which is linked tp Mysql and has data about students grades. How to import students grades from Mysql and covert to varibel in python code in Django. i created a file in the app grade.py i have already put from django.db import subjects. The table has subjects name and class hours. I want to assign specific subject Math to python variable math. How i can do it ? Woudl appreciate any tips and help. -
How to disable choicefield and charfield when user want to edit/update, but enable during register? [Django]
I have role as choicefield and division as charfield. All I want is that they are disabled when user edit their profile, but enabled when register new user. I have tried to disable it but when it comes to register, they are also disabled. If I enable it, they also enabled during edit/update. Please help me, thank you. Here is my models.py class UserProfileInfo(models.Model): user = models.OneToOneField(User,on_delete=models.CASCADE,related_name='profile') division = models.CharField(max_length=250, blank=True) role = models.ChoiceField(max_length=250, blank=True) description = models.TextField(max_length=250, blank=True) address = models.CharField(max_length=250, blank=True) phone = models.CharField(max_length=250, blank=True) cell = models.CharField(max_length=250, blank=True) profile_pic = models.ImageField(upload_to='profile_pics',blank=True) def __str__(self): return self.user.username Here is my forms.py class MyForm(forms.Form): ROLE_1 = 'Business Analyst' ROLE_2 = 'Manager' ROLE_3 = 'Segment Manager' ROLE_4 = 'Admin' ROLE_CHOICES = ( (ROLE_1, u"Business Analyst"), (ROLE_2, u"Manager"), (ROLE_3, u"Segment Manager"), (ROLE_4, u"Admin") ) role = forms.ChoiceField(choices=ROLE_CHOICES,widget=forms.Select(attrs={'class':'form-control'})) division = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'})) description = forms.CharField(widget=forms.Textarea(attrs={'class':'form-control'})) address = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'})) phone = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'})) cell = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'})) class Meta(): model = UserProfileInfo fields = ('role','division','description','address','phone','cell','profile_pic') Here is my profile.html {% load staticfiles %} {% block body_block %} {% if registered %} <h1>Thank you for updating!</h1> {% else %} <form class="cmxform form-horizontal style-form" id="commentForm" enctype="multipart/form-data" method="POST" action=""> {% csrf_token %} {{ user_form.as_p }} {{ profile_form.as_p }} <input type="submit" … -
Django + Nginx + UWSGI resource not available error - after using max-request = 500 in uwsgi.ini
To overcome the memory usage of the server, we have introduced max-requests = 500 to the uswgi.ini file. We face side effects like below 10.115.21.68 - - [01/Jan/2020:04:09:50 +0000] "GET / HTTP/1.1" 502 157 "-" "check_http/v2.2.1 (nagios-plugins 2.2.1)" "-" 2020/01/01 04:09:50 [error] 30522#0: *22690 connect() to unix:///tmp/uwsgi.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 10.115.21.68, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:" 10.115.13.75 - - [01/Jan/2020:04:09:48 +0000] "GET / HTTP/1.1" 502 157 "-" "check_http/v2.2.1 (nagios-plugins 2.2.1)" "-" 2020/01/01 04:09:48 [error] 30523#0: *22688 connect() to unix:///tmp/uwsgi.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 10.115.13.75, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:" 10.115.21.68 - - [01/Jan/2020:04:09:06 +0000] "GET / HTTP/1.1" 502 157 "-" "check_http/v2.2.1 (nagios-plugins 2.2.1)" "-" 2020/01/01 04:09:06 [error] 30522#0: *22682 connect() to unix:///tmp/uwsgi.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 10.115.21.68, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:" 10.115.13.75 - - [01/Jan/2020:04:08:49 +0000] "GET / HTTP/1.1" 502 157 "-" "check_http/v2.2.1 (nagios-plugins 2.2.1)" "-" 2020/01/01 04:08:49 [error] 30523#0: *22680 connect() to unix:///tmp/uwsgi.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 10.115.13.75, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:" 10.115.21.68 - - [01/Jan/2020:04:08:23 +0000] "GET / HTTP/1.1" … -
i am trying to pass the title form model to a template for nav dropdown but it is working in main html page but not showing others
i am trying to create a nav dropdown that with the model titles but it is showing drop down on the main html page but it is not showing other pages and also i tried to make a one header html template in it also its is not showing the titles , so how can i pass the objects to multiple template my template drop down <li class="menu-has-children"><a href="#services">All Services</a> <ul style="display: inline;"> {% for detailinfo in detail.all %} <li><a href="{% url 'details' services.slug %}">{{ detailinfo.title }}</a></li> {% endfor %} </ul> </li> my view def details(request, services_slug): q = services.objects.filter(slug=services_slug) if q.exists(): q=q.first() else: return HttpResponse("<h1> page not found </h1>") detail = {'detail': q} return render(request, 'detail.html', detail,) -
How to export django admin changelist as csv
I want to export my changelist (fields in list_display) as csv. I used the code from https://books.agiliq.com/projects/django-admin-cookbook/en/latest/export.html But it creates csv for the model fields. But in my case, I want to export changelist as csv, not the model fields. Also, note that most of the fields in changelist(list_display) are calculated fields in Admin. -
Django creates automatic migrations despite no changes being made
So this is ultimately rather minor issue, but something that annoys me to no end. At the moment, one of our Apps keeps creating automatic migrations despite no changes being applied to the model. All these "changes" are applied to the state field of the model. Model is below, alongside the TICKET_STATE. No other field is causing issues, just this one field. I tried deleting database and all migrations, but new migrations are constantly being made, named for example 0002_auto_20200103_0834.py These all follow the same format, <migration number>_auto_<date>_<time>.py. I have not found anything related to this and no ohter model or field is causing this. All these migrations contain the same section message: Alter field state on ticket TICKET_STATES = { (1, 'Odottaa käsittelyä'), (2, 'Käsitellään'), (3, 'Vaatii lisäselvitystä'), (4, 'Selvitetään'), (5, 'Suljettu'), (6, 'Peruutettu') } class Ticket(models.Model): state = models.IntegerField(default=1, choices=TICKET_STATES) type = models.IntegerField(default=9, choices=TICKET_TYPE) priority = models.IntegerField(default=2, choices=TICKET_PRIORITY) heading = models.CharField(max_length=255, default='Uusi tiketti') description = models.TextField(default='') attachment = models.FileField(upload_to='tickets/attachment', null=True, blank=True) date_modified = models.DateTimeField(auto_now=True, null=True) date_created = models.DateTimeField(auto_now_add=True, null=True) date_closed = models.DateTimeField(null=True, blank=True) created_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name='tickets_created') modified_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name='tickets_modified') closed_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name='tickets_closed') def get_type(self): return TYPES_DICT[self.type] def get_state(self): return … -
Django: 'WSGIRequest' object has no attribute 'serialnumber'
I am making a form where the input is taken for a job vacancy. As soon as I click on save, I get the following error: My forms.py is: from django import forms from .models import listitem class uploadajob(forms.ModelForm): class Meta: model= listitem # fields=(jobtitle','joblocation','jobcountry','jobcompany','jobdescription','joblink') fields = "__all__" this is the model: class listitem(models.Model): serialnumber=models.CharField(max_length=10) jobtitle=models.CharField(max_length=200) joblocation=models.CharField(max_length=500) jobcountry=models.CharField(max_length=50) jobcompany=models.CharField(max_length=50) jobdescription=models.TextField() joblink=models.TextField() objects = models.Manager() def __str__(self): return str(self.jobtitle+self.jobcompany) and views.py is: def post_new(request): if request.method == "POST": form = uploadajob(request.POST) if form.is_valid(): post = form.save(commit=False) # post.serialnumber = request.serialnumber post.jobtitle= request.jobtitle post.joblocation= request.joblocation post.jobcountry= request.jobcountry post.jobcompany= request.jobcompany post.jobdescription= request.jobdescription post.joblink= request.joblink post.save() return redirect('') else: form = uploadajob() return render(request, 'jobslist/uploadajob.html', {'form': form}) -
how to Retrieve value from template and pass to view
i am trying to get the student name via label in template and pass to views. templates: <td><label id='sname' name='sname'>{{q.name}}</label></td> view.py: z = request.POST.get('sname') print(z) when i click submit, it printed none instead of the name. How can i retrieve the student name from view.py -
Can I change the initial none value displayed for a ModelChoiceField so it's not "---------"?
I've built an inline form, where the field labels don't show up, so the form relies on placeholders to tell the user what the field is: The second field in is a ModelChoiceField. Is there any way to change the default "none" value to use the field name instead of the "---------" dashes? -
one-to-many inline select with django admin - cannot be used in ORM query
I used this to model the admin form for the one-to-many relationship. In my case I have: #houses_hub.models class House(models.Model): agency = models.ForeignKey(CustomUser,on_delete = models.CASCADE) #login_register_hub_service.models class CustomUser(AbstractUser): house = models.ForeignKey('houses_hub.House',on_delete = models.CASCADE, blank = True, null = True, related_name = "students") I then have the following admin setup class HouseForm(forms.ModelForm): class Meta: model = House fields = '__all__' students = forms.ModelMultipleChoiceField(queryset = CustomUser.objects.all()) def __init__(self, *args, **kwargs): super(HouseForm,self).__init__(*args,**kwargs) if self.instance: if self.instance.students: self.fields['students'].initial = self.instance.students.all() else: self.fields['students'].initial = [] def save(self, *args, **kwargs): instance = super(HouseForm,self).save(commit = False) self.fields['students'].initial.update(house = None) self.cleaned_data['students'].update(house = instance) return instance class HouseAdmin(admin.ModelAdmin): form = HouseForm I am able to trace the error being thrown on the line self.cleaned_data['students'].update(house = instance) The error is ValueError at /admin/houses_hub/house/add/ Unsaved model instance <"some house"> cannot be used in an ORM query. This error gets thrown only when creating a new record. When updating, it works fine I'm assuming that the house does not actually get saved in the db until my save method returns and hence updating the house the students belong to with an object not yet saved fails (although I am not 100% sure). What approach could be used then to be able to … -
How to access foreign key depends on current active user in django
models.py class Shop(models.model): shop_name = models.CharField(max_length=100, blank=True) slug = AutoSlugField() logo = models.ImageField(upload_to='restaurant_profile', blank=True) related_user = models.ForeignKey(User, on_delete=models.CASCADE) class Product(models.Model): name = models.CharField(max_length=200) price = models.FloatField() slug = models.SlugField() created by = models.ForeignKey(Shop, on_delete=models.DO_NOTHING, default="") each shop has a related user, when a product is created, created_by field in Product models needs to filled with created_by = models.ForeignKey(Shop.filter(related_user = request.user) -
How to edit/update formset in django?
I am creating a formset using modelformset_factory and it is successfully creating .Now i want to edit the formset data which is basically contains 3 field which is degree,year and college, how will i achieve it. Here is my code: views.py def edit_member(request,mem_id): mem_edit = MemberShip.objects.get(id=mem_id) context = {} quaFormset = modelformset_factory(Qualification, form=QualificationForm) formset = quaFormset(request.POST or None, queryset=Qualification.objects.none(),prefix='qualification') if request.method == 'POST': if formset.is_valid(): formset.save() context = {'formset':formset} return render(request,'member/member_edit.html',context) ``` forms.py ``` class QualificationForm(forms.ModelForm): class Meta: model = Qualification fields = [ 'degree', 'year', 'college', ] widgets = { 'degree': forms.TextInput(attrs={'class': 'formset-field'}), 'year': forms.TextInput(attrs={'class': 'formset-field'}), 'college': forms.TextInput(attrs={'class': 'formset-field'}) } ``` member_edit.html ``` <table class="table form-table table-bordered table-sm"> <thead class="text-center" style="background-color:red;"> <tr> <th>Degree</th> <th>Year</th> <th>College</th> <th></th> </tr> </thead> <tbody> {% for form_data in formset %} <tr class="item"> <td><span style="color: red;"></span> {{ form_data.degree }} </td> <td><span style="color: red;"></span> {{ form_data.year }} </td> <td><span style="color: red;"></span> {{ form_data.college }} </td> <td> <button type="button" class="btn btn-danger btn-sm remove-form-row" id="{{ formset.prefix }}"> Delete </button> </td> </tr> {% endfor %} <tr> <td colspan="9" style="border-left: none!important; border-right: none !important; border-bottom: none!important;"> <button type="button" class="btn btn-sm btn-success add-form-row" id="{{ formset.prefix }}"> Add </button> </td> </tr> </tbody> </table> {{ formset.management_form }} -
How can make a form for redirecting user to the entered address in Django?
I am a little confused as to how should I be working on making a simple form that takes a website url input from a user and redirects on clicking the submit form button. Should I be using the UserCreationForm , if so , what fields should I be using for the same. Or should I be creating a custom form for the same .