Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Customize Django admin login with additional parameter
I'm trying to find a way to add an extra parameter to the Django admin login POST method. I'm customizing an existing app that sends username, password to admin login where I want to capture a 3rd 'database name' in the form payload. The user will be authorized with a single auth database, but the business end lives on another (multiple) databases. I have a form with username, password, and drop down list of databases. This is somewhat similar to this question: Extending Django-Admin Login (username, password, sites) However I found no working answers to that post. -
How to change what is displayed in ManyToMany field on a form
I've recently joined a group in school that uses Django so I'm still trying to get the hang of things and I've been stuck trying to figure out how to change what is displayed in a ManyToMany field on a form. I'm wanting to display the name of the Tags (the db that's being linked through the field), but all it's doing is displaying 'Tag object (name)'. How can I make it display just the name? Here's the Model for the Tag class Tag(models.Model): name = models.CharField( primary_key=True, max_length=256, ) priority = models.IntegerField( default=1, ) And the ManyToMany field in the Event class tags = models.ManyToManyField( Tag, verbose_name=_('Event Tags'), help_text=_('Different categories for the event.'), ) And the template for the form {% for field in form %} <div class="flex-item"> <label class="field-label" for="{{field.name}}">{{field.label}}:</label> <span class="field-input"> {% for error in field.errors %} <div class="error-message"> <strong>*{{ error }}</strong> </div> {% endfor %} {{field}} </span> </div> {% endfor %} -
Django on Digitalocean with Python and Gunicorn throws 500 error no matter the Debug settings
I'm REALLY confused. Ive been using the same settings for years and they have worked great... until today. Setup: Django on Gunicorn with NGINX on Digitalocean Python 3 Anytime I go to a URL it looks liek the 500 error is being triggered and then the 500.html template is displayed. But this is happening regardless of the Debug settings. Additionally, there is nothing that is being written to the Gunicorn errors. The only error I'm getting is a 404 on the template directory. As a sanity check, here is some sample configurations that I'm using. NGINX Location: root /home/myname/myrepoproject; error_page 500 502 503 504 /500.html; location = /500.html { root /home/myname/myrepoproject/myproject/app/templates; } NGINX Error: 2018/03/26 17:09:14 [crit] 3267#3267: *35 connect() to unix:/home/myname/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: ZZZ.ZZZ.ZZZ.ZZZ, request: "GET /500.html/ HTTP/1.1", upstream: "http://unix:/home/myname/myproject/myproject.sock:/500.html/", host: "arecord.domain.name" Gunicorn ExecStart: ExecStart=/home/myname/.virtualenvs/myve/bin/gunicorn --error-logfile ~/logs/gunicorn/gunicorn-errors.log --workers 3 --bind unix:/home/myname/myve/myproject.sock production The static and upload directories work. Any troubleshooting ideas welcome. -
Django 2 different URLs for separate apps
I appreciate that similar questions have been asked in the past but given that a number of things changed in Django 2 I would like to know if there is a simple way to run -- under the same project -- 2 apps with a distinct root domains (e.g. a.com and b.com). I am currently using uwsgi for deployment and my 2 apps work under root and /blog but I would like to use 2 different domains. Thanks in advance. -
How to store Post data to submit
I am just learning how to create forms and use them while submitting a title and message for a "blog". While I am able to type the title and message then click submit and it redirects to the index of posts, the post I typed will not save. my submission form: <a href = "/bb/index">index</a><br> <a href = "/login/">login</a> <form method="post" action="{% url 'index' %}">{% csrf_token %} Title: <form> <textarea name= "posttitle" id= "title" ></textarea><br> Message: <textarea name= "posttextbox" id= "message" ></textarea> <input type="submit" value="submit"/> </form> my view file: def index(request): post_list = Post.objects.order_by('-pub_date') template = loader.get_template('bb/index.html') context = {'post_list': post_list,} return HttpResponse(template.render(context, request)) def submission(request): if request.user.is_authenticated() == True: if request.method == 'POST': form = PostForm(request.POST) if form.is_valid() == True: post_to_submit = form post_to_submit.post_title = form.cleaned_data['title'] post_to_submit.user = request.user post_to_submit.save() template = loader.get_template('bb/forms.html') context = { 'form' : PostForm } else: return HttpResponse(form.errors.__str__()) else: form = PostForm() template= loader.get_template('bb/forms.html') context = {'form' : PostForm} else: template = loader.get_template('bb/login.html') context = { 'form' : form} return HttpResponse (template.render(context, request)) -
Django: copy queryset or get updated objects to update them twice
I've broke my head in attempts to update queryset twice >>> users = User.objects.filter(source=1) >>> users <QuerySet [<User: 'Max'>]> >>> users.update(source=2) 1 Then I need to update users again, but: >>> users <QuerySet []> So, what options are available here? Big thx -
Unable to download file in django
I'm new to django and I have developed a django website which allows people to download epub file by typing the book's name. I have checked the django api about download and the code seems to work fine (no error reported), but there is no download window pops up by my browser. I'm testing on 127.0.0.1:8000 and here is part of my code view.py def download(request, file_path, book_name): if os.path.exists(file_path): response = HttpResponse(content_type="application/epub+zip") response['X-Sendfile'] = file_path response['Content-Disposition'] = 'attachment; filename=abc.epub' print (response) return response raise False According to my console it could find the file path, and by printing the message it shows <HttpResponse status_code=200, "application/epub+zip"> [26/Mar/2018 18:31:03] "POST / HTTP/1.1" 200 509 Everything seems to work fine, just the download window does not pop up. Does anyone have any idea where is goes wrong? Thanks! ========== Supplementary: To give you a full sight of the view file, download is called by index and thats all: def index(request): template = loader.get_template('index.html') book_name = '' result = '' if request.method == "POST": # check if user actually type a book name book_name = request.POST.get("book_name") cwd = os.getcwd() if book_name != '': # search and create are functions from other file which … -
Gunicorn fails to find django application
I am trying to run a django app on a server using Gunicorn and Nginx. I have done every step according to digitalocean. However, I still get 502 Bad Gateway. Here's the error I get from Gunicorn's log: Failed to find application: 'amiidemo.wsgi' And this is the error from Nginx's log: 2018/03/26 16:32:04 [error] 19950#0: *5 connect() to unix:/tmp/gunicorn.sock failed (111: Connection refused) while connecting to upstream, client: 142.244.5.6, server: meerkat-srv.aicml.ca, request: "GET /amiimotion/ HTTP/1.1", upstream: "http://unix:/tmp/gunicorn.sock:/amiimotion/", host: "meerkat-srv.aicml.ca:8000" Anybody can help? -
creating multiple foreign keys Django
I am trying to create a database where you have 3 columns. Column A, Column B, Column C. Column B selection is based on the selection of Column A and Column C is based on both column B & A. I wasn't able to find information on multiple foreignKey instances. class Color(models.Model): """A color that can be entered for a drop down list""" part = models.ForeignKey('Part', on_delete=models.CASCADE, null=True) text = models.TextField() date_added = models.DateTimeField(auto_now_add=True) Color is tied to 'Part' but I also want 'Part' to be connected to a class called 'Program' So I want to associate a color with a certain part which is associated with a certain program. Hope this makes sense any help is appreciated. Thanks! -
Django 2.0 - Trying to show detail record from a URL that has 2 pk segments
I am having trouble getting 2 pk segments in my URL to filter my view. The first pk segment is the client's ID and the second pk segment is the server record id. I have tried not using the default pk and instead using spk for the server id but I just keep getting errors no matter what I try. Any help is greatly appreciated. Model class HardwareClientServers(models.Model): server_type = models.ForeignKey(HardwareServerTypes, null=True, on_delete=models.PROTECT, blank=True) client = models.ForeignKey(Clients , on_delete=models.CASCADE) os = models.ForeignKey(HardwareOperatingSystems, null=True, on_delete=models.PROTECT, blank=True) virtual = models.BooleanField(default=False) memory = models.CharField(max_length=25, null=True, blank=True) server_name = models.CharField(max_length=75, null=True, blank=True) URL urlpatterns = [ path('', views.client_list, name='client_list'), path('<int:pk>/', views.ClientsDetailView.as_view(), name='client_detail'), path('<int:pk>/serverlist/', views.ServerListView.as_view(), name='server_list'), path('<int:pk>/serverlist/<int:spk>/', views.ServerDetailView.as_view(), name='server_detail'),] View class ServerListView(ListView): model = models.HardwareClientServers context_object_name = 'client_servers' template_name = 'server_list.html' ordering = ['server_name'] def get_queryset(self): return HardwareClientServers.objects.filter(client=self.kwargs['pk']) class ServerDetailView(DetailView): model = models.HardwareClientServers context_object_name = 'client_server_details' template_name = 'server_details.html' def get_queryset(self): self.spk = get_object_or_404(HardwareClientServers, id=self.kwargs['spk']) return HardwareClientServers.objects.filter(id=self.spk) The error I am getting TypeError at /clients/37563347/serverlist/1076/ int() argument must be a string, a bytes-like object or a number, not 'HardwareClientServers' Request Method: GET Request URL: http://127.0.0.1:8000/clients/37563347/serverlist/1076/ Django Version: 2.0.2 Exception Type: TypeError Exception Value: int() argument must be a string, a bytes-like object or a number, … -
trying to get django / python to generate a urlencoded twitter web intent that shortens the url
I have a django template which is supposed to generate a twitter web intent share URL: <a href="https://twitter.com/intent/tweet?text={{ block.value|urlencode }}%26url={{ page.get_site.root_url|urlencode }}{{ page.url|urlencode }}%26via=pathtweets My understanding is that if everything is encoded properly, the URL should automatically be shortened to a t.co URL. Is that correct? If so, what am I doing wrong? In the template as shown, the final text renders to something like: https://twitter.com/intent/tweet?text=Nostrud%20voluptate%20tempor%20eu%20elit%20laborum%20do%20excepteur%20commodo%20ipsum%20veniam%20velit%20minim.%20Proident%20irure%20velit%20enim%20tempor%20labore%20voluptate%20laboris%20esse%20excepteur%20nostrud%20et.%20Fugiat%20cillum%20magna%20reprehenderit%20qui%20irure%20sint%20in%20occaecat%20officia%20cillum%20proident%20elit%20ea%20pariatur.Nostr%26url=http%3A//localhost/en/my-article-2/%26via=pathtweets in the URL, where the content of the tweet box renders as: Nostrud voluptate tempor eu elit laborum do excepteur commodo ipsum veniam velit minim. Proident irure velit enim tempor labore voluptate laboris esse excepteur nostrud et. Fugiat cillum magna reprehenderit qui irure sint in occaecat officia cillum proident elit ea pariatur.Nostr&url=http://localhost/en/my-article-2/&via=pathtweets -
Python Django ModelForm, how can I modify a form fields before rendering it depending on the model
Using a ModelForm, the model contains a value of a field I should render in the form : class MyClass(models.Model): my_field = models.CharField(max_length=256) # this contains the type of the form's field for example a CharField or a DateTimeField My view : class MyView(FormView): form_class = CustomForm model = MyClass And the form class: class MyForm(forms.ModelForm): class Meta: model = MyClass fields = ? How can I dynamically set my form's field type? -
In Django, How to call the 'User Group' as a foreign key in a model class?
I created a model class named Question. I want only particular user group can answer the questions. NOW, How can I bring a foreign key here from user group? class Question(models.Model): # Fields qs_title = models.CharField(max_length=350) qs_status = models.IntegerField() # Relationship Fields qs_f_track = models.ForeignKey('cmit.QuestionTrack', ) responsible = models.ForeignKey(Group) -
Query for grouping of successful attempts when order matters
Let's say, for example, I have a db table Jumper for tracking high jumpers. It has three columns of interest: attempt_id, athlete, and result (a boolean for whether the jumper cleared the bar or not). I want to write a query that will compare all athletes' performance across different attempts yielding a table with this information: attempt number, number of cleared attempts, total attempts. In other words, what is the chance that an athlete will clear the bar on x attempt. What is the best way of writing this query? It is trickier than it would seem at first because you need to determine the attempt number for each athlete to be able to total the final totals. I would prefer answers be written with Django ORM, but SQL will also be accepted. -
Django - How to save javascript variable into Django Database?
I have a javascript variable called "counter", which I want to use to update a counter variable instantiated in models.py. Here is a snapshot of models.py class Player(BasePlayer): #track the number of times the user has lost window focus blur_quantity = models.IntegerField(initial=0) Here is an example of pages.html {% block content %} <button name="blur_button" value=counter onclick="Warn()" class="btn btn-primary btn-large">Blur Button</button> {% endblock %} {% block scripts %} <script> var counter = 0; // Tracks window blurs $( document ).ready(function() { function onchange (evt) { counter++; console.log(counter); } window.onblur = onchange; }); function Warn() { alert(counter); } </script> {% endblock %} Now, whenever the user clicks the button, the value of "counter" should be stored somewhere. How do I update the value of blur_quantity in models.py (e.g. my Django database) to reflect the value attached to the blur_button? -
How to fix error: django.db.utils.NotSupportedError: URIs not supported
in my Django project in Linux machine (in AWS) I'm using: Python 3.5.1 Django 1.11.7 I've created virtual environment for my project and all dependencies are installed perfectly there. For the database I'm using sqlite3. See below for the version details. >>>import sqlite3 >>>sqlite3.version '2.6.0' >>>sqlite3.sqlite_version_info (3, 7, 17) In settings.py the DATABASES section is as below: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } While running runserver I am getting one exception as sqlite3.NotSupportedError: URIs not supported which is generating an error django.db.utils.NotSupportedError: URIs not supported, that I am not able to fix. I have gone through the posts like djangoproject.com and google.forum, but still not able to understand the reason for this error. I also tried to do python manage.py makemigrations but same error coming for that also. Note: In windows machine this my project is running fine. Please see the traceback below: # python manage.py runserver Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread started by <function check_errors. <locals>.wrapper at 0x7f07ff09c2f0> Traceback (most recent call last): File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection self.connect() File "/tech/poc/env/lib/python3.5/site- packages/django/db/backends/base/base.py", line 189, in connect self.connection = self.get_new_connection(conn_params) File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 198, … -
Displaying AUTH_LDAP_PROFILE_ATTR_MAP in Django
I am trying to map certain attributes of an ldap user by using django-auth-ldap. I can not figure out how to display AUTH_LDAP_PROFILE_ATTR_MAP but AUTH_LDAP_USER_ATTR_MAP works because it compatible with the user-model in django. Settings.py AUTH_LDAP_USER_ATTR_MAP = { "first_name": "givenName", "last_name": "sn", "email": "mail", } AUTH_LDAP_PROFILE_ATTR_MAP = { "salutation": "titel", "phone": "telephoneNumber", "mobile": "mobile", } views.py def view_profile(request, pk=None): if pk: user = User.object.get(pk=pk) else: user = request.user args = {'user': user} return render(request, ('accounts/profile.html'), args) profile template <input value="{{ user.first_name}}"></input> <input value="{{ user.last_name}}"></input> <input value="{{ user.email}}"></input> <input value="{{ user.salutation }}"></input> <input value="{{ user.phone}}"></input> <input value="{{ user.mobile}}"></input> Is there a way to work with models and to copple the ldap attributes to the model? Thanks in advance. -
attempting to push a web dino in heroku get error: couldn't find that process type Procfile exists and on heroku django python
I am attempting to scale my dynos from 0 to 1. when I run the command heroku ps:scale web=1 i get the error: Scaling dynos... ! ▸ Couldn't find that process type. my procfile is on heroku and contains following. web: gunicorn suitsandtables.wsgi --log-file - I am using django 11.1 with python 2.7 (yes I will be upgrading soon) what could the issue be? -
Django + IIS Error 500
trying to place my project in production with iis I get an error trying to access from my own computer with the browser: Error occurred while reading WSGI handler: Traceback (most recent call last): File "c:\users\e10136\appdata\local\programs\python\python36-32\lib\site-packages\wfastcgi.py", line 791, in main env, handler = read_wsgi_handler(response.physical_path) File "c:\users\e10136\appdata\local\programs\python\python36-32\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler handler = get_wsgi_handler(os.getenv("WSGI_HANDLER")) File "c:\users\e10136\appdata\local\programs\python\python36-32\lib\site-packages\wfastcgi.py", line 616, in get_wsgi_handler raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb)) ValueError: "C:\inetpub\wwwroot\vp_canales" could not be imported StdOut: StdErr: when I access from another computer it says: Server Error 500 Any idea how I can handle the error? -
How to debug a pip install issue with Djblets and --no-index?
I'm trying to package Djblets for internal use and it fails for this command ./venv/bin/pip install --upgrade --force-reinstall --no-binary :all: --no-index --find-links ./cache Djblets==1.0.5 or just ./venv/bin/pip install --no-index --find-links ./cache Djblets==1.0.5. But I am able to get it to build using ./venv/bin/pip install --upgrade --force-reinstall --no-binary Django,Pillow,django-pipeline,dnspython,feedparser,futures,fillowfight,publicsuffic,pytz --find-links ./cache Djblets==1.0.5. So I've narrowed it down to issues with --no-index and --no-binary and I'm working through the --no-binary issue, but I can't figure out why --no-index would cause an issue. Does anyone know why trying to install offline with --no-index would fail? Some extra information. This is what's in my cache: ls cache Django-1.10.8.tar.gz Pillow-5.0.0.tar.gz dnspython-1.15.0.zip futures-3.1.1.tar.gz pillowfight-0.3.tar.gz pytz-2018.3.tar.gz Djblets-1.0.5.tar.gz django-pipeline-1.6.14.tar.gz feedparser-5.2.1.tar.bz2 futures-3.2.0.tar.gz publicsuffix-1.1.0.tar.gz and ./venv is a fresh virtual environment ls venv/lib/python2.7/site-packages/ easy_install.py pip/ pkg_resources/ setuptools-33.1.1-py2.7.egg-info/ wheel-0.29.0.dist-info/ easy_install.pyc pip-9.0.1.dist-info/ setuptools/ wheel/ I'm able to -
Django sitemap.xml and robots.txt working in dev but not production
I've a couple of django projects and I'm defining my sitemaps.xml and robots.txt within urls.py as follows: url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^robots\.txt$', TemplateView.as_view (template_name='robots.txt', content_type="text/plain")), Both work fine in Development and sitemap actually works on one site (run as a subdomain) but gives a 404 when the root site. Also the robots.txt is working in development but giving an apache 404 page not found when run in live (as opposed to the site specific 404 error page). I'm lost by this. I'm clearly doing something obviously dumb but I cannot see it. -
Right number of rows, but they're empty
I'm trying to display some tables, but they come up empty. The part that gets me is the number of rows is correct, but they are completely blank. If the table has 9 entries, I get 9 empty rows. The same code is working for a different table tables.py: class VouchersTable(tables.Table): class meta: model = Vouchers fields = ('event_name', 'pk', 'valid_start', 'valid_end', 'lab_duration', 'user_email', 'redeem_date' ) views.py: class ReportsView(LoginRequiredMixin, TemplateView): template_name = 'reports.html' def get_context_data(self, **kwargs): context = super(ReportsView, self).get_context_data(**kwargs) vouchers = VouchersTable(Vouchers.objects.all()) RequestConfig(self.request, paginate=False).configure(vouchers) context['vouchers'] = vouchers return context reports.html: {% extends "base.html" %} {% load render_table from django_tables2 %} {% block content %} {% render_table vouchers %} {% endblock content %} resulting html (empty lines removed): <div class="table-container"> <table> <thead> <tr> </tr> </thead> <tbody> <tr class="even"> </tr> <tr class="odd"> </tr> <tr class="even"> </tr> <tr class="odd"> </tr> <tr class="even"> </tr> <tr class="odd"> </tr> <tr class="even"> </tr> <tr class="odd"> </tr> <tr class="even"> </tr> </tbody> </table> </div> -
"A {% csrf_token %} was used in a template, but the context "
views.py @csrf_exempt def change_password(request): """ View for change Password url: /auth/change_password/ """ context = RequestContext(request) if request.method == 'POST': password1 = request.POST['oldpassword'] password2 = request.POST['newpassword'] user_name = request.session['user_name'] print(user_name) user = User.objects.get(email=user_name) print(user) user.set_password(request.POST['newpassword']) user.is_active = True user.save() print("1") django_logout(request) print("2") request.session.flush() return render_to_response('base.html') change_password.js......on success in ajax call getting error success: function(response) { console.log("change_password"); if(JSON.parse(response) == "success") { alert("Password changed successfully"); location.reload(true); $("#changeDropId").toggleClass('dropdown dropdown-list open'); $("#changeDropId").addClass('dropdown dropdown-list'); } else if(JSON.parse(response) == "failure") { $('#form').find('#errorId').html("given credential is not correct."); } }, html page..... <div class="modal-body"> <form id="change_password_form" method = "post" class="form-horizontal" role="form"> {% csrf_token %} <div class="form-group"> <div class="col-sm-12"> <input type="text" name="old_password" placeholder="old password" id="oldpassword"> </div> </div> <div class="form-group"> <div class="col-sm-12"> <input type="text" name="new_password" placeholder="new password" id="newpassword"> </div> </div> <div class="form-group"> <div class="col-sm-12"> <input type="text" name="re_password" placeholder="re password" id="renewpassword"> </div> </div> <div class="modal-footer"> <button id="btn-change_password" type ="button" class="btn btn-success">Change </button> </div> </form> </div> </div> error on browser console..... VM215:2 Uncaught SyntaxError: Unexpected token < in JSON at position 1 at JSON.parse (<anonymous>) at Object.success (change_password.js:47) at fire (jquery.js:3099) at Object.fireWith [as resolveWith] (jquery.js:3211) at done (jquery.js:8264) at XMLHttpRequest.<anonymous> (jquery.js:8605) on system console...... UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value. … -
Django queryset gets empty after if, but it shouldn't
Maybe the title is a bit confusing, English is not my primary language. I apologize about that. To the point: I have a table of clients that can be active or not, simple field that says 'yes' or 'no'. So in the html form I have a Select input with 3 options: Indifferent (all clients, has value 0), yes (active clients, value 'yes'), no (not active, value 'no'). The thing is, when I want to get all the clients (active and inactive) the queryset becomes empty for a reason that I don't understand. This is part of the html form: <select name="ClienteActivo"> <option value="" selected="selected">Indiferente</option> <option value="Si">Si</option> <option value="No">No</option> </select> This is the view: def resultadosClienteAvanzadoView(request): #Here I retrieve all clients. clientes=ClientesCompradores.objects.all() #Active can be 0, yes or no. 0 means both, so no filter. active=request.GET.get('ClienteActivo') #If activo is not 0 then filter the clients. if active != 0: clientes=clientes.filter(nulo=active) #Create the context. Again, when active is 0 i want all the clients. context={ 'clientes':clientes, 'cantidad':len(clientes) } return render(request,'catalog/resultadosClienteAvanzado.html',context) If someone needs more info I have no problem providing it. I'm sure it is a rookie mistake since I'm still learning Django. Thanks in advance! -
Is there any way to save and HTML table including forms without creating a model in Django?
I have created a table with django forms in it. The forms do get data from the database, from two different models. Since this form has 42 fields consisting of 7 days and 6 shifts, i would love to save it as the table it is rendered. Is there any way to do this? forms.py class EditSchedule(forms.Form): def __init__(self,*args,**kwargs): super(EditSchedule, self).__init__(*args,**kwargs) for k in range(1,8): for i in range(1,7): self.fields["S"+str(i)+"D"+str(k)] = forms.ChoiceField(choices=get_my_choices(i,k)) self.fields["S"+str(i)+"D"+str(k)].widget.attrs.update({"class":"form-control select2 select2-hidden-accessible"}) html file <div class="box"> <form method="POST" action="">{% csrf_token %} <div class="box-body"> <div class="table-container table-responsive"> <table class="table table-bordered table-hover dataTable" role="grid" > <thead> <tr> <th class = "shicht"><h3>Schicht</h3></th> <th class = "montag"><h3>Montag</h3></th> <th class = "dienstag"><h3>Dienstag</h3></th> <th class = "mittwoch"><h3>Mittwoch</h3></th> <th class = "donnerstag"><h3>Donnerstag</h3></th> <th class = "freitag"><h3>Freitag</h3></th> <th class = "samstag"><h3>Samstag</h3></th> <th class = "sonntag"><h3>Sonntag</h3></th> </tr> </thead> <tbody> <tr class="even"> <td class="shicht">Schicht 1</td> <td class="montag">{{ form.S1D1 }}</td> <td class="dienstag">{{ form.S1D2 }}</td> <td class = "Mittwoch">{{ form.S1D3 }}</td> <td class = "donnerstag">{{ form.S1D4 }}</td> <td class = "freitag">{{ form.S1D5 }}</td> <td class ="samstag">{{ form.S1D6 }}</td> <td class ="sonntag">{{ form.S1D7 }}</td> </tr> <tr class="odd"> <td class="shicht">Schicht 2</td> <td class="montag">{{ form.S2D1 }}</td> <td class="dienstag">{{ form.S2D2 }}</td> <td class = "Mittwoch">{{ form.S2D3 }}</td> <td class = "donnerstag">{{ form.S2D4 }}</td> …