Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Business Logic Between 2+ Models in Django rest Framework
i've read a lot about this but i still can't get to the bottom of how to implement it. I'm new into Python/Django programming and i'm making an application with DRF+PostgreSQL. All good, i'm making basic post/get operations wich basically return the models as they are, no business logic or data treatments between. My complication now is that i need to build a "custom response" with business logic and i don't know how to do it or where to implement it, for example, i have these models: class Parking(models.Model): adress = models.ForeignKey(Adress, on_delete=models.CASCADE, null=False, related_name='adress') price = models.DecimalField(max_digits=4, decimal_places=2, null=True, blank=True) class ParkingLot(models.Model): parking = models.ForeignKey(Parking, on_delete=models.CASCADE, null=False, related_name='parkinglots') floor = models.IntegerField(null=False) class ParkingAvailability(models.Model): parkinglot = models.ForeignKey(ParkingLot, on_delete=models.CASCADE, null=False, related_name='availability') available = models.BooleanField(null=False, blank=False) if i return a Parking, i get all the other models in the response(parkinglot and availability), wich is fine. Now, i want to return the adress of the parking, but just the total of the ParkingLots that meet x conditions, for example: number of parkinglots that the floor is 4 and that are available. Where should i implement this? I've read about a service or manager file that implement these types of business conditions but some … -
Python, how to perform an iterate formula?
I'm trying to export from excel a formula that (as usual) iterate two other value. I'm trying to explain me better. I have the following three variables: iva_versamenti_totale, utilizzato, riporto iva_versamenti_totalehave a len equal to 13 and it is given by the following formula iva_versamenti_totale={'Saldo IVA': [sum(t) for t in zip(*iva_versamenti.values())],} Utilizzato and riporto are simultaneously obtained in an iterate manner. I have tried to get the following code but does not work: utilizzato=dict() riporto=dict() for index, xi in enumerate(iva_versamenti_totale['Saldo IVA']): if xi > 0 : riporto[index] = riporto[index] + xi else: riporto[index] = riporto[index-1]-utilizzato[index] for index, xi in enumerate(iva_versamenti_totale['Saldo IVA']): if xi > 0 : utilizzato[index] == 0 elif riporto[index-1] >= xi: utilizzato[index] = -xi else: utilizzato[index]=riporto[index-1] Python give me KeyError:0. EDIT Here my excel file: https://drive.google.com/open?id=1SRp9uscUgYsV88991yTnZ8X4c8NElhuD In grey input and in yellow the variables -
How else can I write a timestamp with timezone in postgresql/django python shell?
I am working on a django API project with a postgres db. I have also added a serializers.py file. I am trying to test what I've done by adding a row to the db via python shell but I keep getting this error: django.db.utils.ProgrammingError: column "date_created" is of type timestamp with time zone but expression is of type time without time zone LINE 1: ...bility" = NULL, "rating" = NULL, "date_created" = '00:00:00'... ^ HINT: You will need to rewrite or cast the expression. This is the code: from vendor.models import Vendors from vendor.serializers import VendorsRegisterSerializer p = Vendors(id=1, first_name='Flavio', last_name='Akin', email='sheeku@gmail.com', profession='plumber', username='Flanne', pin='1234', phone_number='12345678901', number_of_jobs=300, number_of_patrons=788, date_created='21:00:00 +05:00') I have tried replacing date_created value '21:00:00 +05:00' with '21:00:00 EST', '21:00+05' and '21:00:00+05' but I keep getting the same error. Any help will be appreciated. Thanks in advance. -
OperationalError in Django Migrations
First I created a Model named 'userorders' having fields : id(by default), user_id, and order_id. Then after realizing I don't need order_id, I deleted it from MySQL DB first (using Workbench), then I made changes in the model in Django, but it keeps showing errors now. 0013_orderdetails_userorders.py migrations.CreateModel( name='userorders', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('user_id', models.IntegerField()), ('order_id', models.IntegerField()), ], ), 0014_remove_userorders_order_id.py dependencies = [ ('shoppingCart', '0013_orderdetails_userorders'), ] operations = [ migrations.RemoveField( model_name='userorders', name='order_id', ), ] 0015_userorders_order_id.py dependencies = [ ('shoppingCart', '0014_remove_userorders_order_id'), ] operations = [ migrations.AddField( model_name='userorders', name='order_id', field=models.IntegerField(default=None), preserve_default=False, ), 0016_remove_userorders_order_id.py dependencies = [ ('shoppingCart', '0015_userorders_order_id'), ] operations = [ migrations.RemoveField( model_name='userorders', name='order_id', ), ] 0017_auto_20200508_1639.py dependencies = [ ('shoppingCart', '0016_remove_userorders_order_id'), ] operations = [ migrations.RenameField( model_name='orderdetails', old_name='user_id', new_name='order_id', ), ] ERRORS - when I try to make migrations for any changes I do (Changes are not reflected in DB) MySQLdb._exceptions.OperationalError: (1091, "Can't DROP 'order_id'; check that column/key exists") The above exception was the direct cause of the following exception: django.db.utils.OperationalError: (1091, "Can't DROP 'order_id'; check that column/key exists") Currently, userorders contains 2 fields- id and user_id How can I fix this? -
static files in the media folder not showing when i upload on live server
Hey guys sorry to bother you, I'm new to django and I made a personal portfolio and locally everything is perfect but the deployed one is not loading the images that I upload on the live app. I tried to see youtube videos a lot of topics over here and I cant find a solution...:( Heres my code: settings.py import os import django_heroku from decouple import config import dj_database_url # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False ALLOWED_HOSTS = ['***********'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'portfolio', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'my_portfolio.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], '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', ], }, }, ] WSGI_APPLICATION = 'my_portfolio.wsgi.application' # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS … -
Can i embed interactive matplotlib plots in a webpage?
I have numerous scripts that prompt for user input, pull relevant data from the web, manipulate it in pandas and visualize it in matplotlib. The matplotlib plots have a cursor feature that updates as the mouse is moved and displays the x and y points in a text box, which I'd like to keep. I want to move these scripts to a webpage so I can access them quickly from anywhere. Maybe instead of prompting the user for input it would make more sense to use input fields, drop down menus or radio buttons. Either say, can this be done via Django or some other way in python? -
How do I show loading animation on Django while rendering PDF?
What do i need to show a progress bar or a loading animation while I am generating PDF on Django? Currently I am using Weasyprint to generate PDF from HTML and it takes about 8-15 seconds to load one. And I am wondering if it is possible to show a loading or progress bar while it is being loaded so people will not mistake the link as broken or bug or anything. -
Django Sending Modelform as an email
I created a site where my techs submit their inventory using model forms. Everything is working as intended but I would like to add the function of sending the whole form as an email when they submit their inventory. This would allow for my inventory team to verify counts without having to log in and check the website. Here is my view.py I know it works if I remove the email bits and saves to my models. Currently returns an error: 'dict' object has no attribute 'splitlines' form = Inventory_Form() if request.method == 'POST': form = Inventory_Form(request.POST) tech_field = form.save(commit=False) tech_field.technician = request.user tech_field.save() if form.is_valid(): form.save() name = form.cleaned_data['initials_date'] from_email = 'operations@imbadatthis.com' subject = 'Weekly Inventory', form.cleaned_data['initials_date'] message = form.cleaned_data try: send_mail(subject, message, from_email, ['myemail@n00b.com'], name) except BadHeaderError: return HttpResponse('Invalid header found.') return response, redirect('inventory_submitted') return render(request, 'inventory.html', {'form': form}) Would it be better to save the form to a csv then attach it as an email? I looked at this and also had issues with that part. -
One of the pages of my application is displayed by a code
Help me by advice, please. When I go to one of the pages, its code is displayed, in inspector I see, that all the code is taken in the <pre> tag, although the code does not have this tag. How can this be overcome? Thanks in advance! navbar: python <li {% if 'about' in request.path %} class="active" {% else %} {% endif %}><a href="{% url 'about' %}" class="nav-link">About</a></li> Main url: urlpatterns = [ path('', include("pages.urls")), ... Url of app pages: urlpatterns = [ path('', views.index, name="index"), path('about', views.about, name = "about"), ... I'm at first here, don't know, maybe page with code shold be placed separately About page: {% extends 'base.html' %} {% block title %} About {% endblock %} {% load static %} {% block content %} {% include "partials/_header_internal.html" %} <div class="site-section"> <div class="container"> <div class="row"> <div class="col-lg-6 mb-5 mb-lg-0 order-lg-2"> <img src="{% static 'images/hero_2.jpg' %}" alt="Image" class="img-fluid"> </div> <div class="col-lg-4 mr-auto"> <h2>Car Company</h2> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit suscipit, repudiandae similique accusantium eius nulla quam laudantium sequi.</p> <p>Debitis voluptates corporis saepe molestias tenetur ab quae, quo earum commodi, laborum dolore, fuga aliquid delectus cum ipsa?</p> </div> </div> </div> </div> <div class="site-section bg-light"> <div … -
DJANGO - Order table by a column
I have two models: Worktime : month = charfield time = timefield Sales: month = charfield sales = decimalfied my view is : times = Worktime.objects.values('Month__Month').annotate(total_hour=Sum('time')) sales = Sales.objects.values('Month__Month').annotate(total_sales=Sum('sales')) my template is : {% for time in times %} <tr> <td>{{time.Month__Month}}</td> <td>{{time.total_hour }}</td> {% for sale in sales %} {% if time.Month__Month== sale.Month__Month%} <td>{{sale.total_sales }}</td> {% endif %} {% endfor %} </tr> {% endfor %} Question : How can I order my table by the last column ? (total sales) I tried to do sales= sales.order_by('-total_sales') but I do nothing, only the order_by on time works FYI : there can be worktime but no sales dependings on month, i don't know if it's can cause an issue -
Cpanel SQLite 3.8.3 or later is required (found 3.7.17)
so i want to create a simple web page with django on Cpanel. I followed the tutorial right here : https://www.jvmhost.com/articles/django3-python3.7-cpanel/ But when i try to run the command : ./manage.py collectstatic it gives me this error : SQLite 3.8.3 or later is required (found 3.7.17). In the tutorial they say you need to modifiy the ~/.bashrc file and add this too lines : export LD_LIBRARY_PATH='/opt/atomicorp/atomic/root/usr/lib64/' export PATH=/opt/atomicorp/atomic/root/bin:$PATH I don't understand what these two lines do, but it don't change the problem and i still get the same error What could i do to upgrade the sqlite in Cpanel ? -
Query to get data in particular format in Django
My Models: class Student(models.Model): name = models.CharField(max_length=100) email = models.CharField(max_length=100, unique=True) password = models.CharField(max_length=25) class Subject(models.Model): name = models.CharField(max_length=100) class Student_subject_mapping(models.Model): student = models.ForeignKey(Student, on_delete=models.CASCADE) subject = models.ForeignKey(Subject, on_delete=models.CASCADE) I'm trying to get all Student_subject_mapping data in the database in a format given below: { "results": [{ "id": 1, ----------------> student id "email": "student_1@gmail.com",------------> student email "subjects": [ { "id": 1, "name": "subject_1" }, { "id": 2, "name": "subject_2" }, ... ] }, What will be the query to get the data in the following manner? How can I achieve data in the above format? -
how to display forms values before form_name.is_valid () in views.py on django?
I want to make a condition for checking the entered data views.py class ViewName(View): def post(self, request, id): pk = ModelName.objects.get(id=id) another = AnotherModel.objects.get(id=id) form = FormName() if form.is_valid(): model_value = pk.model_field form_value = form.cleaned_data['model_field'] if model_value > form_value: another.title = x_value another.save() form.save() forms.py class FormName(forms.ModelForm): class Meta: model = ModelName fields = ['model_field'] I want to fulfill if the of comparing values, but after is_valid () the value of model_value becomes the same as form.cleaned_data ['form_value'] -
I am doing a training project and have encountered a problem
I am doing a training project and have encountered a problem. I try to display the "events" block and the "news" block on the main page, but when I run the loop cycle, only one block is displayed, and the second is not displayed. Explain who knows what I'm doing wrong. I have been solving this problem for three days now. Thanks in advance who will respond to help <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> {% if post %} {% for post in post %} {{ post.title }} {% endfor %} {% else %} <p>У вас нет материала</p> {% endif %} {% if event %} {% for event in event %} {{ event.name }} {% endfor %} {% else %} <p>У вас нет материала</p> {% endif %} </body> </html> Views: from django.shortcuts import get_object_or_404, render from django.views.generic.base import View from .models import Blog, Event # Create your views here. class EventView(View): def get(self, request): event = Event.objects.all() return render(request, "home/home_list.html", {"event": event}) class BlogView(View): def get(self, request): post = Blog.objects.all() return render(request, "home/home_list.html", {"post": post}) Urls: from django.urls import path from . import views urlpatterns = [ path("", views.EventView.as_view()), path("", views.BlogView.as_view()) ] Models: from django.db import models from … -
Django doesn't seem to mock model methods
I am trying to write some test cases for the following method as part of a model called Project: def to_mouse_model(self): details = mm.ProjectDetails( self.name, self.larc, self.investigator, self.release_date, self.priority) details_query = self.strategies.all() designs = {details.design.to_mouse_model() for details in details_query} strategies = {details.strategy.to_mouse_model() for details in details_query} return mm.Project(details, designs, strategies) The trouble seems to be in the details.design.to_mouse_model() and details.strategy.to_mouse_model() and I cannot seem to accurately mock this function. This is the test I have (self.details2 is the only model linked to the project in this test case, so it would be the only record returned by self.strategies.all()): @patch(PROJECT_STR) @patch(DETAILS_STR) def test_to_mouse_model_one_strategy(self, mock_details, mock_project): details = MagicMock() mock_details.return_value = details project = MagicMock() mock_project.return_value = project mm_design = MagicMock() self.details2.design.to_mouse_model = MagicMock(return_value=mm_design) mm_strategy = MagicMock() self.details2.strategy.to_mouse_model = MagicMock(return_value=mm_strategy) self.assertEqual(self.project2.to_mouse_model(), project) mock_details.assert_called_once_with( "Project2", 456, self.inv, RELEASE2, 3) mock_project.assert_called_once_with( details, {mm_design}, {mm_strategy}) And here is the error message I get: AssertionError: Expected call: Project(<MagicMock name='ProjectDetails()' id='172695792'>, {<MagicMock id='172758448'>}, {<MagicMock id='172771504'>}) Actual call: Project(<MagicMock name='ProjectDetails()' id='172695792'>, {<MouseModel.LabWork.DesignTask.DesignTask object at 0x0A4C8CB0>}, {<MouseModel.LabWork.Strategy.Strategy object at 0x0A4C8BD0>}) So from the error message I can see that it is not actually mocking the to_mouse_model() method. I have tried to assert that the method was called and that … -
Check if record with multiple fileds exists in database before saving the form
I have this model: class Venue(models.Model): venue_name = models.CharField(max_length=50) venue_city = models.CharField(max_length=50) and I have a form where users input the venue name and city. I'd like to check if a record already exists in the database, with both fields already taken in the same record. There could be the same venue name in different cities for example. I've added a check in my forms.py: class VenueForm(forms.ModelForm): class Meta: model = Venue fields = ['venue_name', 'venue_city', 'venue_country'] def save(self, commit=True): venue = super(VenueForm, self).save(commit=False) venue_name = self.cleaned_data['venue_name'] venue_city = self.cleaned_data['venue_city'] if Venue.objects.filter(venue_city=self.cleaned_data['venue_city']).exists() and Venue.objects.filter(venue_name=self.cleaned_data['venue_name']).exists(): # I know this doesn't work: it's as far as I can get. logger.error(venue_name + ' already exists') if commit: venue.save() return venue and, finally, my view.py: def venue_add_view(request): form_venue = VenueForm(request.POST or None) if form_venue.is_valid(): form_venue.save() context = { 'form_venue': form_venue, } return render(request, "venue-add.html", context) As it is now it successfully checks if name or city already exist. What I want to do is ask the database if they exist in the same record. How can I do that? -
Creating a QuerySet manually in django from list of ids
Let's say I have a model My_model and I have a list of ids for this model; my_ids = [3,2,1,42] Now I want to get a QuerySet with the My_model.objects of the ids. I already found this solution, but it doesn't work for me, because I want to have the objects in the QuerySet in the same order as the ids in my_ids. How can I turn a list of ids in a QuerySet in Django,Python? thx for your help and stay healthy! -
Django Rest Framework : string return b'' string
I am using Django Rest Framework and I create few API calls. API calls return primarily data from model objects. All other API work normally but one parameter in JSON in one API return b'' string instead of a normal string. I can't found a difference between others and this one. What could be the problem? class ApiVisit(APIView): authentication_classes = (TokenAuthentication, SessionAuthentication, BasicAuthentication) permission_classes = (IsAuthenticated,) @logging__time def get(self, request, pk, call_type): r = {} user = self.request.user ... notes = .... r['notes'] = notes return Response(r) From Postman I get -
InvalidQueryError: Cannot resolve field "point" MongoEngine
I am using below code to fetch nearest location from PointField using MongoEngine restra = ResLocation.objects(point__near=[lat, lon], point__max_distance=distance) all_res = [] for res in restra: all_res += [ { "res_name": res.res_name, "res_address": res.res_address } ] While I am getting below error InvalidQueryError: Cannot resolve field "point" How can I solve this please suggest -
How to update template variable in Django
I want to update value of 'log_data_full' from django template, i have extracted updated value in json from AJAX, i dont' want to refresh the page . i just want to update table view with updated value. Is that possible? <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"> <thead> <tr> <th>=Id</th> <th>Category</th> <th>Fee</th> <th>Search</th> </tr> </thead> <tbody> {% for log in log_data_full %} <tr> <td>{{ log.Id }}</td> <td>13</td> <td>100</td> <td>{{ log.search }}</td> </tr> {% endfor %} </tbody> </table> AJAX query $.ajax({ url: "/filter", type: "POST", data: { from_date:from_date, to_date:to_date, csrfmiddlewaretoken: '{{ csrf_token }}', }, success : function(json) { debugger if(json != 'error'){ var res = JSON.parse(json); } else{ alert('Server Error! Could not get data'); } }, error : function(xhr,errmsg,err) { alert("Could not send URL to Django. Error: " + xhr.status + ": " + xhr.responseText); } }); How to update value by of template variable 'log_data_full'? -
Django get_current_site and build_absolute_uri always say the site is localhost
This is a Django website being tested via the little server that comes with Django: python manage.py runserver 8080 The testing client comes in from a browser running on a machine on an external network. I.e. the browser is not running on the server, but rather is running on a desktop and the requests come in over the Internet. A request would have a typical form of https://sub.awebsite.com/path An ajax POST view incorporates a vendor call that you might recognize: class view_class ... def post(self, request) ... new_session = stripe.checkout.Session.create( api_key=djstripe.settings.STRIPE_SECRET_KEY ,line_items=[item] ,payment_method_types=['card'] ,success_url='https://a.awebsite.com/path?session_id={CHECKOUT_SESSION_ID}' ,cancel_url='https://a.awebsite.com/other_path' ) Note the last two arguments are embedding literal URI strings into the website. To python and Django those do not have any special meaning. They are just strings. However later the client will use them to redirect back to awebsite. This literal encoding is really a problem because the site changes depending on who is testing it or if it has been released. I would much rather use the functions build_absolute_uri, or get_current_site, to build those strings. However these functions just print 'localhost'. E.g. I put these two print statements just above the function call to stripe.checkout.Session.create: print("get_current_site: ", get_current_site(request)) print("post absolute uri: ", … -
Chart function suggestions
hope you are doing well ! I want to create Charts based on my models , I want you to advice me some chart ideas , I couldn't figure out what should I put in my view function can you help me out PS : I already used some simple models and the charts was quite easy but those models are so hard I hope you can advice me from django.db import models # Create your models here. class Country(models.Model): Country = models.CharField(max_length=100) def __str__(self): return '{} '.format(self.Country) class Reason(models.Model): Reason_cd = models.IntegerField(blank=True) Reason_NM = models.CharField(max_length=100, blank=True) def __str__(self): return '{}'.format(self.Reason_NM) class Mesure(models.Model): Mesure_cd = models.IntegerField(blank=True) Mesure_NM = models.CharField(max_length=100,blank=True) def __str__(self): return '{}'.format(self.Mesure_NM) class Client(models.Model): last_name = models.CharField(max_length=250) first_name = models.CharField(max_length=250) Adresse = models.CharField(max_length=560) city = models.CharField(max_length=100) code_postal = models.IntegerField() phone number = models.IntegerField(blank=True,null=True) mail = models.CharField(max_length=100) def __str__(self): return '{}, {}'.format(self.last_name,self.first_name) class Delivery_Agent(models.Model): last_name = models.CharField(max_length=250) first_name = models.CharField(max_length=250) def __str__(self): return '{}, {} '.format(self.last_name,self.first_name) class Office(models.Model): office_cd = models.CharField(max_length=10) office_NM = models.CharField(max_length=50) def __str__(self): return '{}, {} '.format(self.office_cd,self.office_NM) class Mail_item_Event(models.Model): mail_item_fid = models.CharField(max_length=36) Event_cd = models.IntegerField(auto_created=True,unique=True) #Event code office_Evt_cd = models.ForeignKey(Office, on_delete=models.CASCADE, related_name='office_Evt') Date_Evt = models.DateTimeField() Date_Capture = models.DateTimeField() Next_office = models.ForeignKey(Office, on_delete=models.CASCADE, related_name='Next_office') def __str__(self): return '{}'.format(self.Event_cd) … -
Upload files from Host Django application to the Apache server on virtual box
I want to upload encrypted file from Django application which is running on my windows 10 machine to the Apache server created on Ubuntu in virtual box. So as to make it a cloud server for my project. so how i can achieve it and other ideas for related to the creating cloud server are also appreciated. As of my project is to compare the encryption algorithm for cloud computing , so i want to upload those file on Ubuntu server.Any ideas related to implementation of this are also appreciated. -
TypeError :ModelBase object argument after ** must be a mapping, not list
I'm trying to make embedded models using djongo framework that help me to connect to mongodb and it gives me error when i want to add it in admin views This is my models in tests.py from djongo import models from django import forms class Logauth(models.Model): date = models.CharField(max_length=50) name = models.CharField(max_length=50) server = models.CharField(max_length=50) message = models.CharField(max_length=50) class Meta: abstract = True class LogauthForm(forms.ModelForm): class Meta: model = Logauth fields = ( 'date', 'name', 'server', 'message' ) class Serveruser(models.Model): host = models.CharField(max_length=50) port = models.CharField(max_length=10) userServer = models.CharField(max_length=50) pwdServer = models.CharField(max_length=50) logs = models.EmbeddedField( model_container=Logauth, model_form_class=LogauthForm ) class Meta: abstract = True class ServeruserForm(forms.ModelForm): class Meta: model = Serveruser fields = ( 'host', 'port', 'userServer', 'pwdServer', 'logs' ) class UserSv(*models.Model): usernameSv = models.CharField(max_length=50) pwdSv = models.CharField(max_length=50) emailSv = models.CharField(max_length=50) servers = models.EmbeddedField( model_container=Serveruser, model_form_class=ServeruserForm ) and this is my admin.py from django.contrib import admin from p01.tests import UserSv admin.site.register(UserSv) when i try to add, it gives me this error TypeError at /admin/p01/usersv/add/ ModelBase object argument after ** must be a mapping, not list -
Apache2.4.43/mod_wsgi4.7.1/Python3.7/Django2.2.9 Windows10 infinite loope
This issue appeared when I upgraded my Django app to Python3.7/Django2.2.9: I'm no more able to get it loaded by Apache => I have no errors, only an infinite "waiting for server". I checked for 2 days all Apache, wsgi & Django settings. I compared the Apache log file with the old one, every thing is OK. It seems to me that mod_wsgi module doesn't load the Django APP, but I don't understand why??? The server responds only When I insert an error in the Django settings (for exp. a false ALLOWED_HOSTS), in this case I can get the Django debug interface. I'will be grateful if you can help NB: OS => Windows10