Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can't access a parallel app model in Heroku
I have two projects parallel to each other: They share the same database, as indicated by the picture: I need to know if there is a way to display one model from "scalestore-app" into "scalestore-sac". -
How to filter choises in fields(forms) in Django admin?
I have model Tech, with name(Charfield) and firm(ForeignKey to model Firm), because one Tech(for example, smartphone) can have many firms(for example samsung, apple, etc.) How can I crate filter in admin panel for when I creating model, If I choose 'smartphone' in tech field, it show me in firm field only smartphone firms? Coz if I have more than one value in firm field(for example Apple, Samsung, IBM), it show me all of it. But IBM must show only if in tech field I choose 'computer'. How release it? -
Can I use and learn java and python together [on hold]
I have learned some basics of python and C++. Now I am going for Python and django in advanced ,should I learn Java with it for my future, strong basics and good Job? -
Django Show one field and associate it with another with multiple selections in the template
I need to add an amount to a service type class Factura(models.Model): cod_factura = models.IntegerField(primary_key=True) fecha = models.DateTimeField(auto_now=True) id_cliente = models.ForeignKey(Cliente,on_delete=models.CASCADE,default = none) total = models.IntegerField() class DetalleFactura(models.Model): cod_detallefactura = models.AutoField(primary_key=True) cantidad = models.IntegerField() precio = models.IntegerField() id_tiposervicio = models.ForeignKey(TipoServicio,on_delete=models.CASCADE,default = None) cod_factura = models.ForeignKey(Factura,on_delete=models.CASCADE,default = None) enter image description here class FacturaForm(forms.ModelForm): class Meta: model = Factura fields = ['cod_factura','id_cliente'] class DetalleFacturaForm(forms.ModelForm): id_tiposervicio = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple(), queryset=TipoServicio.objects.all()) class Meta: model = DetalleFactura fields = ['id_tiposervicio','cantidad'] def cfactura(request): if request.method == 'POST': form_factura = FacturaForm(request.POST) form_detalle_factura = DetalleFacturaForm(request.POST) if form_factura.is_valid() and form_detalle_factura.is_valid(): #Creacion de datos de factura factura = form_factura.save(commit=False) factura.cod_factura = form_factura.cleaned_data['cod_factura'] factura.id_cliente = form_factura.cleaned_data['id_cliente'] #Creacion detalles factura detalle_factura = form_detalle_factura.save(commit=False) detalle_factura.cantidad = form_detalle_factura.cleaned_data['cantidad'] detalle_factura.precio = detalle_factura.id_tiposervicio.valor factura.total = detalle_factura.id_tiposervicio.valor * form_detalle_factura.cleaned_data['cantidad'] detalle_factura.cod_factura = factura factura.save() detalle_factura.save() return redirect('factura:lfactura') else: form_factura = FacturaForm() form_detalle_factura = DetalleFacturaForm() return render(request,'base/cfactura.html',{'form':form_factura,'formu':form_detalle_factura}) {% csrf_token %} {{ form.as_p }} {% for tiposervicios in formu%} {{tiposervicios}} {%endfor%} <input type="submit" value="Guardar"> </form> -
Does spring framework have a module that creates database tables from Java objects?
I am new to Spring framework. I was trying to see if the framework has modules that create/update database tables from Java objects, similar to what Django python framework does. If not, is there something comparable to what Django does? -
When a django form is submitted, does the POST request contain model ID's?
I have the following django form: class AssayCompoundForm(forms.ModelForm): titrated_compound = forms.ModelChoiceField(queryset=Compound.objects.all()) fixed_compound = forms.ModelChoiceField(queryset=Compound.objects.all()) fixed_concentration = forms.FloatField() class Meta: model = AssayCompound fields = ['titrated_compound', 'fixed_compound', 'fixed_concentration'] and the following HTML: <form method="POST" enctype="multipart/form-data" id="assay-compound-form"> {% csrf_token %} <div class="row"> <div class="col-sm"> <label class="form-input">Titrated Compound</label> </div> <div class="col-sm"> {{ new_assay_compound_form.titrated_compound }} </div> <div class="col-sm"></div> </div> <div class="row"> <div class="col-sm"> <label class="form-input">Fixed Compound</label> </div> <div class="col-sm"> {{ new_assay_compound_form.fixed_compound }} </div> <div class="col-sm"></div> </div> <div class="row"> <div class="col-sm"> <label class="form-input">Fixed Concentration</label> </div> <div class="col-sm"> {{ new_assay_compound_form.fixed_concentration }} </div> <div class="col-sm"></div> </div> <input id="assay-compound-form-submit" type="submit" name="add-assay-compound" style="display:none"> The request.POST that is generated by this form looks like this: <QueryDict: {'csrfmiddlewaretoken': ['blah'], 'titrated_compound': ['3'], 'fixed_compound': ['5'], 'fixed_concentration': ['4'], 'add-assay-compound': ['Submit']}> My question is this: are the lists of strings for the user-selected 'titrated_compound' and 'fixed_compound' the model ID's assigned by Django? Or are they the indices of the indices of the ordered list generated by 'Compound.objects.all()'? -
Possible race condition between Django post_save signal and celery task
In a django 2.0 app I have a model, called Document, that uploads and saves an image to the file system. That part works. I am performing some facial recognition on the image using https://github.com/ageitgey/face_recognition in a celery (v 4.2.1) task. I pass the document_id of the image to the celery task so the face-recognition task can find the image to work on. This all works well if I call the face_recognition task manually from a DocumentAdmin action after the image is saved. I tried calling the face_recognition task from a (models.signals.post_save, sender=Document) method in my models.py, and I get an error from this line in the celery task for face_recognition: document = Document.objects.get(document_id=document_id) and the error is: [2018-11-26 16:54:28,594: ERROR/ForkPoolWorker-1] Task biometric_identification.tasks.find_faces_task[428ca39b-aefb-4174-9906-ff2146fd6f14] raised unexpected: DoesNotExist('Document matching query does not exist.',) Traceback (most recent call last): File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/celery/app/trace.py", line 382, in trace_task R = retval = fun(*args, **kwargs) File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/celery/app/trace.py", line 641, in __protected_call__ return self.run(*args, **kwargs) File "/home/mark/python-projects/memorabilia-JSON/biometric_identification/tasks.py", line 42, in find_faces_task document = Document.objects.get(document_id=document_id) File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/mark/.virtualenvs/memorabilia-JSON/lib/python3.6/site-packages/django/db/models/query.py", line 403, in get self.model._meta.object_name memorabilia.models.DoesNotExist: Document matching query does not exist. Also, this error does not occur all the time, only … -
Are Django cron jobs processes or threads?
We are using django-cron version 0.5.1. Are these cron jobs run as separate process or are these executed as threads inside the main django process ? -
Django Create extraclass for special people
I am creating a registration form in Django. You can select between Student, Teacher, Parent or Guest. I want to create extra fields for every class. Whats the best way to do this? At the moment there will be created (example) a Student with a UserProfile (ForeignKey) my models.py class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, verbose_name="Benutzer") typeOfPerson = models.CharField(max_length=1, default=None, verbose_name="Typ", help_text="Entweder Schüler (S), Elternteil (E), Lehrer (L) oder Gast (G)") birth_date = models.DateField(default=None, verbose_name="Geburtsdatum") gender = models.CharField(max_length=1, default="M", verbose_name="Geschlecht") registration_date = models.DateField(auto_now=True, verbose_name="Registrationsdatum") ip_address = models.CharField(max_length=31, blank=True, null=True, verbose_name="IP-Adresse") is_verified = models.BooleanField(default=False, verbose_name="Ist verifiziert?", help_text="Ist der Benutzer verifiziert? (Wird z.B.: Bei manchen Umfragen gefragt.)") can_verify = models.BooleanField(default=False, verbose_name="Kann verifizieren?", help_text="Kann der Benutzer sich verifizieren? (Wenn ja, dann kann der Benutzer unter URL_ÜBER_STATIS_EINFÜGEN verifizieren.)") private = models.BooleanField(default=False, verbose_name="Privat", help_text="Ist dieses Benutzerprofil privat?") news = models.CharField(max_length=2047, blank=True, null=True) class Meta: ordering = ["user"] verbose_name = "Benutzerprofil" verbose_name_plural = "Benutzerprofile" def __str__(self): return "%s %s" % (self.user.first_name, self.user.last_name) class Student(models.Model): UserProfile = models.ForeignKey(UserProfile, on_delete=models.CASCADE) classNumber = models.CharField(max_length=2, blank=True, null=True, verbose_name="Klassenstufe") parents = models.CharField(max_length=63, blank=True, null=True, verbose_name="Eltern") def __str__(self): return str(self.UserProfile) class Parent(models.Model): UserProfile = models.ForeignKey(UserProfile, on_delete=models.CASCADE) children = models.CharField(max_length=511, blank=True, null=True, verbose_name="Kinder") def __str__(self): return str(self.UserProfile) class Teacher(models.Model): UserProfile = models.ForeignKey(UserProfile, on_delete=models.CASCADE) … -
How to host Angular 6 application in Python Django?
I am wanting to host an Angular 6 application in Django, how do I do this? -
Error while uploading with django-audiofield
Hey i am trying to use django-field but came across this error: Traceback (most recent call last): File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\core\handlers\exception.py", line 35, in inner response = get_response(request) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\core\handlers\base.py", line 128, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 575, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\utils\decorators.py", line 142, in _wrapped_view response = view_func(request, *args, **kwargs) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\sites.py", line 223, in inner return view(request, *args, **kwargs) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 1557, in change_view return self.changeform_view(request, object_id, form_url, extra_context) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\utils\decorators.py", line 62, in _wrapper return bound_func(*args, **kwargs) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\utils\decorators.py", line 142, in _wrapped_view response = view_func(request, *args, **kwargs) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\utils\decorators.py", line 58, in bound_func return func.__get__(self, type(self))(*args2, **kwargs2) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 1451, in changeform_view return self._changeform_view(request, object_id, form_url, extra_context) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 1491, in _changeform_view self.save_model(request, new_object, form, not add) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\contrib\admin\options.py", line 1027, in save_model obj.save() File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\db\models\base.py", line 729, in save force_update=force_update, update_fields=update_fields) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\db\models\base.py", line 769, in save_base update_fields=update_fields, raw=raw, using=using, File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\dispatch\dispatcher.py", line 178, in send for receiver in self._live_receivers(sender) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\django\dispatch\dispatcher.py", line 178, in <listcomp> for receiver in self._live_receivers(sender) File "C:\Users\Sebastian\Envs\blog\lib\site-packages\audiofield\fields.py", line 223, in … -
Linking charts with a DatePicker Bokeh and Django
I'm using Bokeh on top of Django and I'm having trouble allowing a widget to filter the dataframe. With the date picker, I would like that to filter what is shown in the plots, so in this case p1 and p2. Currently this only displays the plots and the datepicker but selecting a date doesn't do anything. Although in this example, filering the data and limiting the view would be equivalent, I would like to accomadate a user filtering the data and then recalculating any aggregate in the Django view. How do I make this work? def bokeh_views(request): start_date = datetime.date(2016, 01, 01) end_date = datetime.date(2018, 01, 01) df = pd.DataFrame(data={ 'reportDate': ['2016-01-01','2016-02-02','2016-03-03','2016-04-04'], 'id' : ['123','234','345','456'], }) source = ColumnDataSource(data=dict(date=df['reportDate'], close=df['id'])) day_or = ColumnDataSource(data=dict(date=df['reportDate'], close=df['id'])) hover = HoverTool( tooltips = [ ("Day", "@date{%Y-%m-%d %H:%M:%S}"), ("Value", "@close"), ], formatters={ 'date': 'datetime', 'close' : 'printf', }, ) p1 = figure(plot_height=300, plot_width=800, tools="pan, reset, box_zoom", toolbar_location='right', x_axis_type="datetime", x_axis_location="above", background_fill_color="#efefef", x_range=(dates[0], dates[30])) p1.line('date', 'close', source=source) p1.circle('date','close', source=source, size=7) p1.yaxis.axis_label = 'Reports' p1.add_tools(hover, LassoSelectTool()) p2 = figure(title="Drag the middle and edges of the selection box to change the range above", plot_height=130, plot_width=800, y_range=p1.y_range, x_axis_type="datetime", y_axis_type=None, tools="", toolbar_location=None, background_fill_color="#efefef") range_rool = RangeTool(x_range=p1.x_range) range_rool.overlay.fill_color = "navy" range_rool.overlay.fill_alpha … -
django-admin pointing outside virtualenv
I've initialised a virtual environment using the virtualenvwrapper command mkvirtualenv -a <path to project> django_project. I then installed django with pip install django. But then if i try to use django-admin i get: Traceback (most recent call last): File "/usr/local/bin/django-admin", line 7, in <module> from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' Now pip list gives me Package Version ---------- ------- Django 2.1.3 pip 18.1 pytz 2018.7 setuptools 40.6.2 wheel 0.32.3 python -m django --version gives 2.1.3 If I run which python it correctly points to my virtualenv, however which django gives: /usr/local/bin/django-admin I'd think that it should point to my venv. Why would it point to a global django admin? How do I fix it so that it'll work for my future virtual environments? I'm on MacOS using zsh and python 3.7.0. Thank you! -
Catch django signal sent from celery task
Catch django signal sent from celery task. Is it possible? As far as I know they are running in different processes @celery.task def my_task(): ... custom_signal.send() @receiver(custom_signal) def my_signal_handler(): ... -
0 vs None: 0 should still be inside my if-call
I write in my template: {% if ticket_price.discounted_price %}. Now that works perfect, until ticket_price.discounted_price = 0. As 0 can happen (original price = 10, discount = 10 > discounted_price = 0) if want to include this option. However, it seems if ticket_price.discounted_price 'thinks' 0 is equal to None. How would you solve that? -
django send email recipient_list
I need to get the email registered in the database and send to this email that is registered, but I can not. If I put an email manually it is sending without problems, but I need it to get the email that is registered in Pessoa to use in MovRotativo to send the payment as soon as it is done models.py from django.db import models from django.core.mail import send_mail import math PAGO_CHOICES = ( ('Não', 'Não Pago'), ('Sim', 'Pago') ) class Pessoa(models.Model): nome = models.CharField(max_length=50, blank=False) email = models.EmailField(blank=False) cpf = models.CharField(max_length=11, unique=True, blank=False) endereco = models.CharField(max_length=50) numero = models.CharField(max_length=10) bairro = models.CharField(max_length=30) telefone = models.CharField(max_length=20, blank=False) cidade = models.CharField(max_length=20) estado = models.CharField(max_length=2, choices=STATE_CHOICES) def __str__(self): return str(self.nome) + ' - ' + str(self.email) class MovRotativo(models.Model): checkin = models.DateTimeField(auto_now=False, blank=False, null=False,) checkout = models.DateTimeField(auto_now=False, null=True, blank=True) email = models.ForeignKey(Pessoa, on_delete=models.CASCADE, blank=False) valor_hora = models.DecimalField( max_digits=5, decimal_places=2, null=False, blank=False) veiculo = models.ForeignKey( Veiculo, on_delete=models.CASCADE, null=False, blank=False) pago = models.CharField(max_length=15, choices=PAGO_CHOICES) def send_email(self): if self.pago == 'Sim': send_mail( 'Comprovante pagamento Estacione Aqui 24 Horas', 'Here is the message.', 'estacioneaqui24@gmail.com', recipient_list=[self.email], fail_silently=False, ) -
Error while doing POST 'UserCreationForm' object has no attribute 'is_vaild'
I'm a django learner and I was trying to create user registration form using the in-build UserCreationForm. view.py from django.shortcuts import render, redirect from django.contrib.auth.forms import UserCreationForm def register(request): if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_vaild(): username = form.cleaned_data['username'] return redirect('blog-home') else: form = UserCreationForm() return render(request, 'users/register.html',{'form':form}) While trying to POST i'm receiving 'UserCreationForm' object has no attribute 'is_vaild'. If i understand correctly for all the django forms there will be a is_valid function to validate. Please help me to find what am i missing here. Let me know if you need any other file details. I'm using Django 2.1,Python 3.6 -
Django group by add non existing choices
I have a model field that contains choices: db_redirection_choices = (('A', 'first'), ('B', 'second')) redirection_type = models.CharField(max_length=256, choices=db_redirection_choices, blank=True, null=True) At some point I'm performing a group by on that column, counting all existing choices: results = stats.values('redirection_type').annotate(amount=Count('redirection_type')).order_by('redirection_type') However, this will give me only results for existings choices. I'd like to add the ones that are not even present with 0 to the results e.g. If the table contains only the entry Id | redirection_type -------------------------- 1 | 'A' then the annotate will return only 'A': 1 of course that's normal, but I'd still like to get all non-existing choices in the results: {'A': 1, 'B': 0} What's the easiest way of accomplishing this? -
How to pass value through unselected checkbox in django forms?
I Used to pass value through selected checkbox <input class="product-active-checkbox" type="checkbox" name="ingredient_id" checked="" value="{{ ingredient.id }}" id="{{ ingredient.id }}"> like wise, I want to pass "0" value through unselected checkbox? Or, Is there any way to identify unselected checkbox in django template? -
Mysqlclient and django issues
I have installed mysql connector , which already has built in sql adapter, i also dont need to install mysqlclient as i have mysql connector. But when i start python manage.py migrate, it is asking me to download mysqlclient. But i can not install mysqlclient. Can anyone help me how to fix the problem. Thanks error: File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\base.py", line 101, in new new_class.add_to_class('_meta', Options(meta, app_label)) File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\base.py", line 305, in add_to_class value.contribute_to_class(cls, name) File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\options.py", line 203, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db__init__.py", line 33, in getattr return getattr(connections[DEFAULT_DB_ALIAS], item) File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\utils.py", line 202, in getitem backend = load_backend(db['ENGINE']) File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\utils.py", line 110, in load_backend return import_module('%s.base' % backend_name) File "C:\Program Files (x86)\Python37-32\lib\importlib__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\mysql\base.py", line 20, in ) from err django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient? -
rendering JSON in django template without having to escape the entire JSON?
In my django view I produce a JSON data that my template needs to use: languages = { ... } context = { 'languages': json.dumps(languages) } return render(request, 'template.html', context) Then in the template, instead of just doing var languages = {{languages}}; I need to do this because some strings might break the javascript: var languages = JSON.parse('{{languages|safe|escapejs}}'); Which outputs a messy blob like this: var languages = JSON.parse('[{\u0022name_english\u0022: \u0022Afar\u0022, \u0022code\u0022: \u0022aa\u0022, \u0022name\u0022: \u0022Afar\u0022}, {\u0022name_english\u0022: \u0022Afrikaans\u0022, \u0022code\u0022:... I would really like to have this in my rendered template: var languages = [{"name_english": "Afar", "code": "aa", "name": "Afar"}, {"name_english": "Afrikaans", "code": "af", "name": "Afrikaans"}, {"name_english": "Akan", ... But as I said there is the need for escaping. Is there a way to just escape the strings that really need escaping and not the whole JSON? Thanks -
Event webhook help in python/ django. Authorization error
I have an api to get, create event and update event too.. for now i want to get push notification for if any attendee accepted the event request or rejected it or did any modification to it. so i did followed the link https://developers.google.com/calendar/v3/push and wrote my code as follow. please help if iam going wrong some where. Here user_email is my calenderId. still i am getting 400 or 401 status response saying authorization error event_notification = { "id": event['id'], "type": "web_hook", "address": "http://www.example.com/notifications" }`enter code here` url = "https://www.googleapis.com/calendar/v3/calendars/"+user_email+"/events/watch" response = requests.post(url=url, data=json.dumps(event_notification), headers={"Content-Type":"application/json","Authorization":"I HAVE ENTERED THE ACCESS TOKEN OF CURRENT USER"}) -
Django logging on AWS lambda using Serverless
I'm working on a Django project running on AWS lambda configured using Serverless and having difficulty with logging. My logging config is below. No logs appear in CloudWatch other than the start/stop logs from AWS. There should be a lot of DEBUG-level messages appearing, but none are (no log messages from Django are appearing at all). Any ideas? Thank you! Logging config from settings.py: # Logging LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s' }, 'error': { 'format': '%(levelname)s <PID %(process)d:%(processName)s> %(name)s.%(funcName)s(): %(message)s' }, }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'formatter': 'standard', 'level': 'DEBUG', }, }, 'loggers': { '': { 'handlers': ['console'], 'level': 'DEBUG', }, }, } -
Two forms in one model. Combining values for table databases
I have simple model in django that looks like : class TimeTable(models.Model): title = models.CharField(max_length=100) start_time= models.CharField(choices=MY_CHOICES, max_length=10) end_time = models.CharField(choices=MY_CHOICES, max_length=10) day1 = models.BooleanField(default=False) day2 = models.BooleanField(default=False) day3 = models.BooleanField(default=False) day4 = models.BooleanField(default=False) day5 = models.BooleanField(default=False) day6 = models.BooleanField(default=False) day7 = models.BooleanField(default=False) for this model I have 2 forms : class TimeTableForm(ModelForm): class Meta: model = TimeTable fields = ['title ', 'start_time', 'end_time'] class WeekDayForm(ModelForm): class Meta: model = TimeTable fields = ['day1', 'day2', 'day3', 'day4', 'day5', 'day6', 'day7'] Now In views.py I need to save this values into database def schedule(request): if request.method == 'POST': form = TimeTableForm(request.POST) day_week = WeekDayForm(request.POST) if all([form.is_valid(), day_week.is_valid()]): form.save() day_week.save() I'm new in Django so I was thinking that this values will be combined into one and I will get proper data but for every one submit I get two separated objects in database for example title | 8:00 | 10:00 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | | | 0 | 1 | 1 | 1 | 1 | 0 | 0 | but I should get title | 8:00 | 10:00 | 0 | 1 | 1 | 1 | 1 … -
Django passing parameter from views hangs server
I try to make simple web site with django, Oracle DB and django web server. And when I make query to db in django shell: mylist=person.objects.filter(name='Anon') everything works fine. Same when I use in views simple render def index(request): return render(request, 'sos/index.html', {}) I get basic site. But when I try to pass parameters from query: def index(request): mylist=person.objects.filter(name='Anon') return render(request, 'sos/index.html', {'mylist': mylist}) server hangs - no matter which browser I use, website is still connectig - only I can do is ctrl+C.