Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Autocomplete Light ... PK vs display field
I am using DAL to provide a selectable dropdown list like this: class OccupationsModel(models.Model): Occupation_Code = models.CharField(max_length = 20, primary_key=True) Occupation_Title = models.CharField(max_length = 150, unique=True) Occupation_Desc = models.CharField(max_length = 1000) class Meta: db_table = 'Occupation_Info' def __str__(self): return self.Occupation_Title Note here that occupation_code is my PK while I am using str to show occupation_title as my display. Mostly everything works fine but then I use instance to prepopulate the form, the title is not displayed. The form field is empty. I have other similar models where the PK is the same as display and those work just fine. So I am pretty sure there is something I am missing here. Here is my DAL view: class OccCreateView(CreateView): model = OccupationsModel template_name = 'dashboard/input_page.html' form_class = InputForm class occautocomplete(autocomplete.Select2QuerySetView): def get_queryset(self): qs = OccupationsModel.objects.all().order_by('Occupation_Code') # Don't forget to filter out results depending on the visitor ! if not self.request.user.is_authenticated: qs = qs[:3] if self.q: qs = qs[:3] if self.q: qs = qs.filter(Occupation_Title__icontains = self.q) return qs Here is my form: def miscuserinfo_view(request): misc_user_info = MiscUserInfoModel.objects.get(user = request.user.id) if request.method == 'POST': if form.is_valid(): obj = form.save(commit=False) # do something here with the form obj.save() return HttpResponseRedirect(reverse('registration:userprofile')) else: # Pre-populate with … -
Django - Populate integer (counter) field based on number of times referenced
I am new to Django and could not wrap my head around this problem. I have two models- Session and Circuit. The goal of these models is to document how many circuits a user completes in a session. Here are the models: (models.py) Class Circuit(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE) _set = models.IntegerField(blank=False) class Session(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) circuits = models.ManyToManyField(Circuit) My goal is whenever the Circuit model is referenced inside of Session I want the _set field to self increment. Any one session will have have many circuits in it. So, when a user adds a instance of the Circuit model to the Session model, I want the _set variable to be updated to the order its added (basically +=1). If the user adds 3 circuits to their session, the _set field for each of those would automatically be updated to set 1, 2, and 3. Thanks in advanced for the help! It is greatly appreciated! -
Django social with apple oauth sends final redirect without cookies
We are trying to get apple oauth working for a web app with a django backend using django-social. The initial login request sets a sessionid cookie but the final auth/complete request doesn't send any of the browser's cookies. No errors in the console and our testing server uses ssl. The redirect_uri is correct, it's just missing it's cookies. Settings in django we have tried: SESSION_COOKIE_SECURE = False SESSION_COOKIE_SAMESITE = "Lax" SOCIAL_AUTH_APPLE_ID_CLIENT = '<our_website_name>' # Your client_id com.application.your, aka "Service ID" SOCIAL_AUTH_APPLE_ID_TEAM = '<our_id>' # Your Team ID, ie K2232113 SOCIAL_AUTH_APPLE_ID_KEY = values.SecretValue() # Your Key ID, ie Y2P99J3N81K SOCIAL_AUTH_APPLE_ID_SECRET_B64 = values.SecretValue() SOCIAL_AUTH_APPLE_ID_SCOPE = ['email', 'name'] SOCIAL_AUTH_APPLE_ID_EMAIL_AS_USERNAME = True # If you want to use email as username USE_X_FORWARDED_HOST = True SOCIAL_AUTH_REDIRECT_IS_HTTPS = True @property def SOCIAL_AUTH_APPLE_ID_SECRET(self): return base64.b64decode(self.SOCIAL_AUTH_APPLE_ID_SECRET_B64 AUTHENTICATION_BACKENDS = ( "rest_framework.authentication.TokenAuthentication", "social_core.backends.open_id.OpenIdAuth", # for Google authentication "social_core.backends.google.GoogleOpenId", # for Google authentication "social_core.backends.google.GoogleOAuth2", # for Google authentication "django.contrib.auth.backends.ModelBackend", 'social_core.backends.apple.AppleIdAuth', # Apple oauth ) This results in the following error: [04/May/2020 22:18:39] "GET /auth/login/apple-id/ HTTP/1.0" 302 0 Internal Server Error: /auth/complete/apple-id/ Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response … -
Python: Update a dictionary value within a list, within another list of dictionaries
Apologies for the confusing title. Essentially- I am looping through a series of model-objects extracting the date and marketname to prepare for a chart. Currently my method is as follows def getData(): projects = Opportunity.objects.all() markets = [] total = { 'marketname': "Total", 'data': [] } for x in projects: d = datetime.date(x.datecreated).strftime('%b-%Y') keytotaldate = "" keydate = "" market = x.market.all()[0].marketname # Check to see if market exists in list if not any(c.get('marketname', None) == market for c in markets): newobj = { 'marketname': market, 'data': [] } newdateobj = { 'date': d, 'count': 1 } newobj['data'].append(newdateobj) markets.append(newobj) keytotaldate = next((s for s in total['data'] if s['date'] == d), None) if keytotaldate is not None: keytotaldate['count'] += 1 else: newtotaldateobj = { 'date': d, 'count': 1 } total['data'].append(newtotaldateobj) else: keymarket = None keydate = None for n in markets: if n['marketname'] == market: keymarket = n break for t in markets: for m in t['data']: if m['date'] == d: m['count'] += 1 keydate = m break if keydate is None: newdateobj = { 'date': d, 'count': 1 } newobj['data'].append(newdateobj) keytotaldate = next((u for u in total['data'] if u['date'] == d), None) if keytotaldate is not None: keytotaldate['count'] += 1 … -
One-to-one based on condition
I have a model that looks like this: class Voting(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) choice = models.ForeignKey(Choice, on_delete=models.CASCADE) answered_at = models.DateTimeField(auto_now_add=True) It works as expected, however, a user is not supposed to be able to vote on the same question twice. In other words, the user shouldn't have the ability to vote twice on the same question: class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice = models.CharField(max_length=120) class Question(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post = models.CharField(max_length=200) Is there a way to add this condition on a model level? -
Django start-up code (like initial caching) conflicts makemigrations. Operational Errors no such columns tables
First of all I'm not a fan of "do it the django way" thing. Instead of spending hours to learn the django way I prefer to utilize my basic programming knowledge when I develop an application. Background : Application I'm developing is a REST backend that stores localization values like language information. I want to take language information that is stored in the database and load it into memory once at startup and then serve that data from memory when a request comes. I created my model class Text(models.Model): language = models.CharField() key = models.CharField() text = models.CharField() Then ran python manage.py makemigrations and migrate commands as a regular step Then I jumped ahead and implemented my caching code and put it directly under admin.py(it could be urls.py it does not matter, it only needs to be run once) cached_languages = models.Text.objects.all() I go ahead and run my app and it is just working fine. Then I wanted to add a field to my Text model like class Text(models.Model): language = models.CharField() key = models.CharField() text = models.CharField() **dummy = models.CharField()** Then hit python manage.py makemigrations command and boom at line cached_languages = models.Text.objects.all() We get an error saying that … -
Django - How to display specific text after the discount is no longer valid
I'm working on a project and I want to know how to display the product 'name' and its 'price' when the validity of the 'discount_price' expires and as long as the 'discount_price' is valid, I would like to display the product 'name', 'price' and 'discount_price'. models.py: from django.db import models from datetime import datetime class Products(models.Model): name=models.CharField(max_length=60) photo = models.ImageField(upload_to='photos/', default='photos/none.png', null=True, blank=True) description=models.TextField() price=models.FloatField() discount_price = models.FloatField(blank=True, null=True) valid_from = models.DateTimeField(('Valid from'), default=datetime.now) valid_until = models.DateTimeField(('Valid until'), blank=True, null=True) stock=models.IntegerField(default=0) my template, index.html: {% extends "./base.html" %} {% load static %} {% block content %} <h3 style="text-align:center"> Product list: </h3> {% for product in products %} <div class="products"> <div class="item"> <table > {% if product.discount %} <tr><td> <a class="products" href ="{% url 'entry' produs.id %}"> {{products.name}} {{product.discount|cut:".0"}} {{product.price|cut:".0"}}</a> {% else %} <tr><td><a class="products" href ="{% url 'entry' product.id %}"> {{product.name}} {{product.price|cut:'.0'}} </a> {% endif %} </table> </div> </div> {% endfor %} {% endblock content %} -
Generating end-user friendly descriptions of unique_together relationships for fields in django models
basically my problem can be summarized as below. Problem domain is Real estate. I have an ApartmentSpace table, where each row represents a rentable apartment_flat/ space with given set of facilities (such as all the utilities, amenities, floor size, number of and type of available rooms etc.) and I have a Property table, which may have one or more apartments added as ManyToMany Field. One single apartment_space_id may be attached to more than one property in this case (as many apartments in the real world may be represented with same set of facilities, I will assume all such apartments to have a single apartment_space_id only) So, a single rentable unit will be represented by a pair of (apartment_space_id, property_id) representing a unique_together relationship for that rentable unit in physical world. Bonus: if possible I would also want to represent within that Property, all the apartments attached to that property as identifiable with a local_apartment_space_id, that will give an auto-incrementing id to all the attached apartments for that property only and not depend on global apartment_space_id primary key for Apartment table. Now my problem is that if I want to send notification to the end-user for the rentable-unit, let's say for … -
How can I lookup a value based on user input and and use display it to the user in django
I'm currently learning to develop websites using Django. I have the following problem, where I have two models: class Model_1(models.Model): id = models.Charfield(max_length=250) account_name = models.Foreignkey(Accounts, on_delete=models.CASCADE) class Model_2(models.Model: account_name = models.Charfield(250) account_type = models.Charfield(250) I have a html form where the user inputs their id, and chooses the account name. I would like that to redirect them to a new html page where they can see the account type that is associated with that account name. What is the best way to do this? -
Is it possible to create own class in Django views to avoid code duplicates?
I have 3 subpages to redirect to and each of them must contain the same piece of code: new_user = User.objects.get(username=user) user_profile = Profile.objects.get(user=new_user) adverts = Advert.objects.filter(user=new_user) editable = False if request.user.username == user: editable = True context = { "objects":adverts, "user_profile":user_profile, "no_data":"No comments", "editable":editable, "user":user } and only "objects" in context change. 3 almost the same methods don;t look good. Is there a way to inherit that code from one class or maybe create own tag to do it ? I'm kinda new in django and I do not know what are the good habits here ;) -
problem in connecting django html templates
whenever i try to connect my template my browser shows following error TemplateDoesNotExist at / test.html Request Method: GET Request URL: http://localhost:8000/ Django Version: 3.0.5 Exception Type: TemplateDoesNotExist Exception Value: test.html Exception Location: C:\Users\NIKHIL MISHRA\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\loader.py in get_template, line 19 Python Executable: C:\Users\NIKHIL MISHRA\AppData\Local\Programs\Python\Python37\python.exe Python Version: 3.7.7 Python Path: ['C:\pro\myproject', 'C:\Users\NIKHIL ' 'MISHRA\AppData\Local\Programs\Python\Python37\python37.zip', 'C:\Users\NIKHIL MISHRA\AppData\Local\Programs\Python\Python37\DLLs', 'C:\Users\NIKHIL MISHRA\AppData\Local\Programs\Python\Python37\lib', 'C:\Users\NIKHIL MISHRA\AppData\Local\Programs\Python\Python37', 'C:\Users\NIKHIL ' 'MISHRA\AppData\Local\Programs\Python\Python37\lib\site-packages'] Server time: Mon, 4 May 2020 21:28:42 +0000 i have created templates folder and having test.html file in it also my myapp\views.py (app name)file code looks like this from django.shortcuts import render def index(request): return render(request,'test.html') and my myapp\urls.py is this from django.conf.urls import url from django.contrib import admin from django.urls import path,include from . import views urlpatterns=[ url(r'^$',views.index), ] ps edit: my templates setting TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] -
Why is my Django App failing on Azure with UUID invalid syntax
My Django App runs fine locally on macOS Catalina with Python 3.8.2 and Django 3.0.5. I am deploying it to Azure as WebApp from Github selecting Python 3.8. I have provisioned the Postgres DB, the Storage Account and the WebApp. The build process is successful. The WebApp fails at startup with: File "/antenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 6, in <module> import uuid File "/antenv/lib/python3.8/site-packages/uuid.py", line 138 if not 0 <= time_low < 1<<32L: ^ SyntaxError: invalid syntax I have verified that the uuid package is not within my requirements.txt file. DB environment variables are set up. Collectstatic successfully replicated my static data. The WebApp is running with Docker. Any help on this greatly appreciated. -
csrf verification failed. request aborted, CSRF cookies not set in Internet Explorer
I am trying to fetch one POST request from javaScript file to my Django endpoint but it is giving error 403 (Forbidden). However it is working fine (no any type of error) in Chrome Browser but not in MicroSoft Edge and Internet Explorer. I have also included csrf token but i am getting this error. After digging in console i found this When i went to that endpoint directly (without post request) from browser in different browser i found error in all browser but i think that is because there is no POST data but other thing that is noticed is in Chrome where it is working fine the COOKIES values are set In Chrome but in Internet Explorer and Microsoft Edge COOKIES values are not set In Internet Explorer And in Microsoft Edge And i m pretty much sure something is wrong with COOKIES. Please Help me to find the bug. -
How do I get my python program onto my portfolio website?
I am fairly new to programming and I have a python program that I developed this past semester at school. I am currently working on my personal portfolio website and would like to include my python program on my site to display my programming skills. If someone could point me in the right direction on where to start that would be much appreciated. Any information would help. Thanks. -
Failed to populate a django3 database
I have an error, at the time of trying to save data in the database, the data is not saved, at the time of filling the data it seems that it saved the data but this does not do it, because each field is validated and when I send it not no error comes out this is the view which is class based. from django.shortcuts import render, redirect from django.views.generic import View from .models import Comment from .forms import CommentForm class IndexView(View): model = Comment template_name = 'home/index.html' form_class = CommentForm def get_queryset(self): return self.model.objects.all().order_by('-pk') def get_context_data(self, **kwargs): context = {} context['commentaries'] = self.get_queryset() context['form'] = self.form_class return context def get(self, request, *args, **kwargs): return render(request, self.template_name, self.get_context_data()) def post(self, request, *args, **kwargs): form = self.form_class(request.POST) if form.is_valid(): form.save() form.errors.as_json() return redirect('home:index') and this is the form from django import forms from django.urls import reverse_lazy from .models import Comment class CommentForm(forms.ModelForm): class Meta: model = Comment fields = ['name', 'comment'] labels = { 'name': 'Nombre', 'comment': 'Comentario' } widgets = { 'name': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Ingrese su Nombre', 'id': 'name', } ), 'comment': forms.Textarea( attrs={ 'class': 'form-control', 'placeholder': 'Ingrese su comentario', 'id': 'comment', } ) } This is … -
Django optimise duplicate query
I'm new to Django, and the ORM is a bit hard for me, I have a search page with a query and a few criteria filters and the get_queryset is as follows (its an app store): def get_queryset(self): ... filter object list based on GET parameter... return object_list.annotate( rating=Avg('reviews__stars'), downloads=Count('order_history', distinct=True), flag1_rate=100*Count( 'reviews', filter=Q(reviews__status=Review.FLAG1) ) / (Count( 'reviews', filter=Q(reviews__status=Review.FLAG2) ) + Count( 'reviews', filter=Q(reviews__status=Review.FLAG1) )) ).order_by(ordered_sort) As you can see I am querying for the Count of FLAG1 twice (not the real name but you get the idea, I am calculating a ratio between two flags that users give during reviews using 100*FLAG1/(FLAG1+FLAG2)): Count( 'reviews', filter=Q(reviews__status=Review.FLAG1) ) How can I prevent this? is there a way to store it in a variable for the annotation? -
Creating user groups and assigning permissions on signup
I'm using Allauth and I am trying to: 1- Create user groups within my code (not in the command line). I found the following code which I think will do this, but I don't know exactly where in my project to put it (also, does this code look right?). from django.contrib.auth.management import create_permissions def create_group(apps, schema_editor): for app_config in apps.get_app_configs(): create_permissions(app_config, apps=apps, verbosity=0) # I dont understand this piece of code group, created = Group.objects.get_or_create(name='registered_users') if created: add_thing = Permission.objects.get(codename='add_thing') group.permissions.add(add_thing) group.save() 2- I am wanting to add users to a group upon signup (rather than manually). I found this code, which seems to look correct to me, but am unsure where to put it (in users/signals? also, does this code look okay?). # set group to registered_user @receiver(post_save, sender=User) def set_group(sender, instance, created, **kwargs): if created: group = Group.objects.get(name='registered_users') instance.groups.add(group) instance.save() Thank you very much. -
display jason data in html with ajax
i want to display jason data in htmal,but not working js {% block js %} {{ block.super }} <script type="text/javascript"> $(document).ready(function () { $.getJSON("{% url 'app_software:list' %}", { get_param: 'value' }, function(data) { $.each(data, function(index, element) { $('#posts').append(element.title) }); }); }); </script> {% endblock js %} html <div id="posts"> </div> view.py def home(request): ctx={} ctx['asd']=Software.objects.all() return render(request,'index.html',ctx) class Pagination_pro(ListAPIView): queryset=Software.objects.all() serializer_class=pagination_ser pagination_class=PageNumberPagination url.py urlpatterns = [ path('', home ,name='home'), path('pagination/', Pagination_pro.as_view(), name='list'), path('software_detail/<str:slug>/',software2, name='software1'), ] noting error display, but not working. Jason's data is shown in the postman. -
Django display html page based on user type
I want to display the home page of my site based on the user type (admin, guest, student, etc.). It would be nice to display a link to the login page for guest users, but this link should be hidden for already authenticated users. For admins there should be a link to django-admin. Besides that there also some differences in the home page for other user roles. What is a good way to implement this? I have several options for that: Create html page for each user role: home_guest.html, home_admin.html, ... Create a single html page but put some if-clauses inside it like {% if user.is_authenticated %} -
How to send POST or GET requests to one API and get data from ERP API?
I have access to API of ERP software. I want to give my clients access to it but not directly, just by another API. I want to restrict what They can POST and GET, but API from ERP couldn't do it so need to create my own like some connector or something. I want to use Django for it. How my clients make POST or GET requests and get info from ERP API? -
how to link between chrome extension and auth system built in django?
I'm making a chrome extension & I've made a log in and create a new account system using Django. When users try to use the extension for the first time it will take them to the "Create new account" page, What I need to know is how to link between the extension & the Django authentication system in a way that it can always remember the user after signing up for the first time or logging in afterwards. I know that I need to use API end point but if someone can give more detailed steps to do so will be much appreciated -
Django, how to reuse views code in other views and template
I'm new in django and I was wondering if is it possible to reuse code and annotate output write in a views.py. I have created a lot of new annotate output that I want to reuse to figure out a dashboard with graphs and key indicator. I don't like to rewrite all code because I wouldn't follow the DRY principles. -
django cannot find object field. error: Items() got an unexpected keyword argument 'sellbtn'
I am trying to access my object but a field I created, it is telling me it is not there. $ cat userdash/views.py from django.shortcuts import render from django.http import HttpResponse, HttpResponseRedirect from .models import AssetList, Items from .forms import CreateNewTrade # Create your views here. #def index(response): # return HttpResponse("<h1>Hello Dark World!</h1>") def userdash(response, id): ls = AssetList.objects.get(id=id) if response.method == "POST": print(response.POST) if response.POST.get("save"): for item in ls.items_set.all(): if response.POST.get("c" * str(item.id)) == "clicked": item.sellbtn = True else: item.sellbtn = False item.save() elif response.POST.get("newItem"): txt = response.POST.get("new") if len(txt) > 2: #this validation is retarded and needs to be fixed ls.items_set.create(user_asset=txt, sellbtn=False) #this is the line in question else: print("invalid") #items = ls.items_set.get(id=1) #return HttpResponse("<h1>User Dashboard!</h1><h2>%s</h2><br></br><p>%s</p>" %(ls.name, str(items.user_asset))) return render(response, "userdash/list.html", {"ls":ls}) def home(response): #pass return render(response, "userdash/home.html", {}) def create(response): if response.method == "POST": form = CreateNewTrade(response.POST) if form.is_valid(): n = form.cleaned_data["user_asset"] t = AssetList(name=n) t.save() return HttpResponseRedirect("/userdash/%i" %t.id) else: form = CreateNewTrade() return render(response, "userdash/create.html", {"form":form}) $ cat userdash/templates/userdash/list.html {% extends 'userdash/base.html' %} {% block title %} List Page {% endblock %} {% block content %} <h2>{{ls.name}}</h2> <form method="post" action="#"> {% csrf_token %} <ul> {% for item in ls.items_set.all %} {% if item.sell_asset == True %} … -
"AttributeError: module 'django.contrib.auth.views' has no attribute 'password_reset' " error in urls.py
I am using Django 3.0.5 and python 3.6 and getting the error from the terminal as : " AttributeError: module 'django.contrib.auth.views' has no attribute 'password_reset' " in my urls.py file. urls.py ``` from django.contrib import admin from django.urls import path from django.contrib.auth import views as auth_views from django.conf.urls import url from blog import views urlpatterns = [ path('admin/', admin.site.urls), path('index/',views.index, name='index'), path('datetime/',views.current_datetime,name='datetime'), path('',views.post_list,name='post_list'), url(r'^blog/(?P<id>\d+)/(?P<slug>[\w-]+)/$',views.post_detail,name="post_detail"), url('post_create/',views.post_create,name = "post_create"), url('login/', views.user_login,name="user_login"), url('logout/', views.user_logout,name="user_logout"), #Password reset urls url('password-reset/',auth_views.password_reset, name='password_reset'), url('password-reset/done/',auth_views.password_reset_done,name="password_reset_done"), url('password-reset/confirm/(?P<uidb64>[\w-]+)/(?P<token>[\w-]+)/',auth_views.password_reset_confirm, name="password_reset_confirm"), url('password-reset/complete/', auth_views.password_reset_complete,name="password_reset_complete"), ] ``` I have checked here which is talking about the same 4 views which I have written then why I am getting the error. When I change "auth_views.password_reset" to "auth_views.PasswordResetForm in "url('password-reset/',auth_views.password_reset, name='password_reset')" then, terminal does not show any error for "password_reset" but then it shows error for "password_reset_done". Can anyone please tell why I am getting this error and how to fix it. Any help would be appreciated. -
How can I avoid hard-coding multiple elements into my Django model?
I'm pretty new to Stack Overflow, so thank you in advance for your insight. This is a question about Django 3.0 (so Python 3.6+). Use case: Let's say I've successfully parsed through the Code of Federal Regulations and I've determined that each regulation has three parts - the citation, the subject, and the regulation itself. I can parse these into a nested dictionary at need (or XML, or CSV, or any format really). Let's also assume I have a complex business that needs to comply with many of these regulations, so I have to figure out whether the regulation is applicable and how I'm going to implement it. So this is my models.py class CFR(models.Model): citation = models.CharField(max_length = 25) subject = models.CharField(max_length = 25) regulation_text = models.TextField() applicable = models.BooleanField(default = True) implementation = models.TextField() My forms.py. Yes I know I shouldn't use __all__. class RegulationForm(forms.ModelForm): class Meta(): model = CFR fields = ('__all__') and my views.py class ApplicabilityView(CreateView): model = CFR template_name = "template.html" form_class = RegulationForm I'd like to use the model to: Iterate through each regulation. Render a form containing each regulation (there could could be hundreds of regulations, so the length of the form doesn't …