Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
search user by username in django
views.py class CreateUserM(CreateModelMixin, ListAPIView): serializer_class = UserSerializer def get_queryset(self): qs = User.objects.all() query = self.request.GET.get('q') if query is not None: qs = qs.filter(username__search=query) return qs class Updareuser(UpdateModelMixin, RetrieveAPIView): def get_queryset(self): username = self.kwargs['pk'] return User.objects.filter(id=username) serializer_class = UserSerializer ``` url.py ```python urlpatterns = [ url(r'^$', CreateUserM.as_view(), name='list_view'), url(r'^(?P<pk>\d+)$', Updareuser.as_view(), name='list_vfiew'), ] I want to search a user by its username but this code have some errors when i filtering by id it works but about the other things have error i changed the Django User model with OneToOnefield . -
I am not able to get that why this error. And what is the solution for this
I am beginner so please bear silly questions if i remove highlighted lines 1,2,3(+ static line) my localhost it shows normal django homepage but after adding these highlighted lines, it shows error Page not found (404) Request Method: GET Request URL: http://localhost:8000/ Using the URLconf defined in portfolio.urls, Django tried these URL patterns, in this order: admin/ ^media/(?P<path>.*)$ The empty path didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. but admin page loads with no problem #urls.py file from django.contrib import admin from django.urls import path`enter code here` from django.conf import settings **<----- 1** from django.conf.urls.static import static **<----- 2** urlpatterns = [ path('admin/', admin.site.urls), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ** <--- 3** -
optional int(request.POST.get('timeout') throws error when empty
This field timeout = int(request.POST.get('timeout')) throws an error saying invalid literal for int() with base 10: '' this is my model field: timeout = models.IntegerField(default=10) The forms submits just fine if I submit number because the form interprets it as a string but my form handler will convert it into integer. But it fails if I leave the field blank. Seems like it can't process an empty string. What can I do ? -
django .validate() should return the validated data
I am able to get to the pdb.set_trace of the validate() function of the subclassed serializer, however I am still receiving this error: assert value is not None, '.validate() should return the validated data' AssertionError: .validate() should return the validated data class UserSerializer(BaseUserSerializer): user = BaseUserSerializer() class UnitSerializer(BaseUnitSerializer): prop = BasePropertySerializer() def to_internal_value(self, data): if isinstance(data, int): return self.Meta.model.objects_all.get(pk=data) class ProjectListViewSerializer(BaseProjectSerializer): unit = UnitSerializer() coordinators = UserSerializer(many=True) due_date = serializers.DateTimeField() start_date = serializers.DateTimeField() project_type = serializers.ChoiceField(choices=Project.PROJECT_TYPE_CHOICES, ) name = serializers.CharField() description = serializers.CharField() def validate(self, attrs): if hasattr(attrs, 'unit') and hasattr(attrs['unit'], 'is_active') and not attrs['unit'].is_active: raise serializers.ValidationError({'unit': ['Unit is not active, please activate this unit.']}) coordinators = attrs.get('coordinators', []) if not len(coordinators): raise serializers.ValidationError('Coordinator(s) required when creating a project.') if not attrs.get('due_date', ''): raise serializers.ValidationError('Due date required when creating a project.') if not attrs.get('start_date', ''): raise serializers.ValidationError('Start date required when creating a project.') if not attrs.get('project_type', ''): raise serializers.ValidationError('Project type required when creating a project.') if not attrs.get('name', ''): raise serializers.ValidationError('Project name required when creating a project.') if not attrs.get('description', ''): raise serializers.ValidationError('Project description required when creating a project.') import pdb;pdb.set_trace() return attrs class Meta: model = models.Project -
Using UUIDField in Django keeps creating new migrations
I have a simple model:: class HasUUID(models.Model): name = models.CharField(max_length=10) batchid = models.UUIDField(default=uuid.uuid4(), unique=True) running makemigrations gives me the migration:: operations = [ migrations.CreateModel( name='HasUUID', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=10)), ('batchid', models.UUIDField(default=uuid.UUID('79a2d9fe-e1d0-4d4b-884f-fad0bfb14f0f'), unique=True)), ], ), ] Running migrate gives me the new table no problem. But I can run makemigrations again and I get:: operations = [ migrations.AlterField( model_name='hasuuid', name='batchid', field=models.UUIDField(default=uuid.UUID('3b96231c-5848-430b-aa90-b6e41b11fd0a'), unique=True), ), ] and while I have lived with this for a while, manually removing the unnecessary code, I need to resolve it. so I think, make the default a separate function in the migrations as shown in various examples:: def create_uuid(apps, schema_editor): m = apps.get_model('web', 'HasUUID') for inst in m.objects.all(): inst.batchid = uuid.uuid4() inst.save() ... migrations.CreateModel( name='HasUUID', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=10)), ('batchid', models.UUIDField(blank=True, null=True)), ], ), migrations.RunPython(create_uuid), migrations.AlterField( model_name='hasuuid2', name='batchid', field=models.UUIDField(default=uuid.uuid4, unique=True) ), same problem. So I tried making the default a separate function in the model:: def create_uuid(): return uuid.uuid4() class HasUUID2(models.Model): name = models.CharField(max_length=10) batchid = models.UUIDField(default=create_uuid(), unique=True) and this gets me this migration:: migrations.CreateModel( name='HasUUID3', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=10)), ('batchid', models.UUIDField(default=uuid.UUID('335c3651-b04e-4ed8-a91d-f2da3f53dd8f'), unique=True)), ], ), and again, keeps generating new migrations. I've also tried without … -
Use 'generator object grouped' in Paginator. Django
I added to my queryset, function which groups my objects. It is necessary in my template to add <ul> every 3 occurrences of the object. My code in the template looks like this. {% for group in groups %} <ul> {% for object in group %} <li>{{ object }}</li> {% endfor %} </ul> {% endfor %} My views.py (queryset and function) def grouped(l, n): for i in range(0, len(l), n): yield l[i:i+n] groups = grouped(City.objects.all(), 3) Now trying to add Paginator in my views.py # paginator page = request.GET.get('page', 1) paginator = Paginator(groups, 5) try: objects = paginator.page(page) except PageNotAnInteger: objects = paginator.page(1) except EmptyPage: objects = paginator.page(paginator.num_pages) and it returns the following error (in my template): object of type 'generator' has no len() How can i use generator object grouped in Paginator. Is it possible to change the code easily to keep grouping and use Pagination (together)? Any help will be appreciated. -
after installing create project how to reopen django project 3.7 version in python windows 10
http://127.0.0.1:8000/ after successfully installed django how to reopen and what are the main purpose ? Can I again open in Python 3.7 version ? -
why am i getting a NameError at /?
NameError at / name 'respose_html' is not defined Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 2.2.4 Exception Type: NameError Exception Value: name 'respose_html' is not defined Exception Location: C:\Users\Jerry\Desktop\development\myproject\Blogs\boards\views.py in home, line 14 Python Executable: C:\Users\Jerry\AppData\Local\Programs\Python\Python37\python.exe Python Version: 3.7.4 from django.shortcuts import render from .models import Board from django.http import HttpResponse Create your views here. def home(request): boards = Board.objects.all() boards_names = list() for board in boards: boards_names.append(board.name) response_html = '<br>'.join(boards_names) return HttpResponse(respose_html) -
How can i customize the reset password email
I add html tags to password_reset_email.html but when the email is sended the tags is showed like string <div style="width: 100%; height: 450px; border: 1px solid #e8e8e8"> {% load i18n %}{% autoescape off %} Usted está recibiendo este correo electrónico porque ha solicitado un restablecimiento de contraseña para su cuenta de usuario. {% trans "Please go to the following page and choose a new password:" %} {% block reset_link %} {{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} {% endblock %} {% trans "Your username, in case you've forgotten:" %} {{ user.get_username }} {% endautoescape %} </div> -
DRF Serializing multiple models
I can't serialize multiple object as this answers says to do. In particular it gives me this error "Got AttributeError when attempting to get a value for field Functional on serializer GeneralSerializer. The serializer field might be named incorrectly and not match any attribute or key on the QuerySet instance. Original exception text was: 'QuerySet' object has no attribute 'Functional'." Someone can help me? My views.py is made like this General = namedtuple('General', ('Functional', 'Pfm')) @csrf_exempt def listall(request): if request.method == 'GET': general = General( Functional= SnpsFunctionalelement.objects.values('countexperiments','filetype',rsid=F('snpid__rsid'), FunctionalElement=F('elementid__name'), CellLine=F('celllineid__name')), Pfm = SnpsPfm.objects.values('start','strand','type','scoreref','scorealt',rsid=F('snpid__rsid'), pfm_name=F('pfmid__name')) ) serializer = GeneralSerializer(general, many = True) return JsonResponse(serializer.data, safe=False) my serializers.py class SnpsFunctionalelementSerializer(serializers.ModelSerializer): rsid = serializers.CharField(max_length=20) FunctionalElement = serializers.CharField(max_length=55) CellLine = serializers.CharField(max_length=55) class Meta: model = SnpsFunctionalelement fields = ['rsid', 'FunctionalElement', 'CellLine', 'countexperiments', 'filetype'] class SnpsPfmSerializer(serializers.ModelSerializer): rsid = serializers.CharField(max_length=20) pfm_name = serializers.CharField(max_length=50) class Meta: model = SnpsPfm fields =[ 'rsid','pfm_name','start','strand','type','scoreref','scorealt'] class GeneralSerializer(serializers.Serializer): Functional = SnpsFunctionalelementSerializer(many=True) Pfm = SnpsPfmSerializer(many=True) P.S.: I even tried to work without the DRF serializers doing this all_objects = [SnpsFunctionalelement.objects.values('countexperiments','filetype',rsid=F('snpid__rsid'), FunctionalElement=F('elementid__name'), CellLine=F('celllineid__name')), SnpsPfm.objects.values('start','strand','type','scoreref','scorealt',rsid=F('snpid__rsid'), pfm_name=F('pfmid__name'))] ser = serializers.serialize('json',all_objects) return JsonResponse(ser) but it gives me this error "QuerySet object has no attribute _meta" -
When to use React combined with Django?
I've been working with the django framework and mostly have been using html templates for its front end but im wondering whether i should switch to React if it's a big project? Alternativelyl, can i create a user interface application without using React as front end or is React / ReactRedux advisable when using Djngo? -
How can I update heroku requirements.txt?
I've had pkg-resources==0.0.0 in my requirements.txt so heroku can't run the app. After removing this string and commiting it still can't. Tried to remove whole project and create new -- nothing. If I commit again I see "nothing to commit, working tree clean" remote: Building source: remote: remote: -----> Python app detected remote: -----> Installing python-3.6.8 remote: -----> Installing pip remote: -----> Installing SQLite3 remote: -----> Installing requirements with pip remote: Collecting Django==2.2.3 (from -r /tmp/build_00cd1392df5f26408e135a402fc2038d/requirements.txt (line 1)) remote: Downloading https://files.pythonhosted.org/packages/39/b0/2138c31bf13e17afc32277239da53e9dfcce27bac8cb68cf1c0123f1fdf5/Django-2.2.3-py3-none-any.whl (7.5MB) remote: Collecting pkg-resources==0.0.0 (from -r /tmp/build_00cd1392df5f26408e135a402fc2038d/requirements.txt (line 2)) remote: Could not find a version that satisfies the requirement pkg-resources==0.0.0 (from -r /tmp/build_00cd1392df5f26408e135a402fc2038d/requirements.txt (line 2)) (from versions: ) remote: No matching distribution found for pkg-resources==0.0.0 (from -r /tmp/build_00cd1392df5f26408e135a402fc2038d/requirements.txt (line 2)) remote: ! Push rejected, failed to compile Python app. remote: remote: ! Push failed -
Why django is adding an extra slash / in the last , i want to remove it?
I am getting an extra slash in the end it is giving me error , but when i remove the slash after 2 (i.e. from last) i am getting my result.enter image description here http://127.0.0.1:8000/book/2/ -
Django Messages + Pinax
I get this error when I try to install pinax notifications together with django messages: django_messages.Message.sender: (fields.E304) Reverse accessor for 'Message.sender' clashes with reverse accessor for 'Message.sender'. HINT: Add or change a related_name argument to the definition for 'Message.sender' or 'Message.sender'. django_messages.Message.sender: (fields.E305) Reverse query name for 'Message.sender' clashes with reverse query name for 'Message.sender'. HINT: Add or change a related_name argument to the definition for 'Message.sender' or 'Message.sender'. pinax_messages.Message.sender: (fields.E304) Reverse accessor for 'Message.sender' clashes with reverse accessor for 'Message.sender'. HINT: Add or change a related_name argument to the definition for 'Message.sender' or 'Message.sender'. pinax_messages.Message.sender: (fields.E305) Reverse query name for 'Message.sender' clashes with reverse query name for 'Message.sender'. HINT: Add or change a related_name argument to the definition for 'Message.sender' or 'Message.sender'. Where can I change the fields? I cant find them in dist-packages Thank you -
Running my own daemon on Heroku, how can I contact it from the Internet?
I have a Django application that runs fine on Heroku. At this point, I'd like to start a second process that implements a daemon that exchanges data with other devices and populates the database of the Django app. I implemented this second daemon as a custom command of a Django app, so in my Procfile I have web: gunicorn portal.wsgi --log-file - listener: python manage.py listen_to_devices At this point I start the daemon with heroku ps:scale listener=1. Devices are not able to connect. While debugging, I noticed that my app has several entries in the DNS, I guess for load balancing: ottavio@debian:~$ nslookup xxx.herokuapp.com Server: 192.168.69.2 Address: 192.168.69.2#53 Non-authoritative answer: Name: xxx.herokuapp.com Address: 52.51.85.80 Name: xxx.herokuapp.com Address: 52.212.106.249 Name: xxx.herokuapp.com Address: 54.171.30.127 Name: xxx.herokuapp.com Address: 54.171.254.93 Name: xxx.herokuapp.com Address: 54.194.235.52 Name: xxx.herokuapp.com Address: 99.80.174.196 Name: xxx.herokuapp.com Address: 52.18.173.71 Name: xxx.herokuapp.com Address: 52.48.204.199 ottavio@debian:~$ So, I guess I am doing something wrong. Port 8080 does not seem to be open whenever I try to telnet to it. How can I have my devices reach my daemon port? -
Send form context through an html file by mail
I want to send the context of my form rendering an HTML template, which I send by mail, but it sends me on behalf of the fields. Not the data that is entered in the fields. I've tried several tags in the html file like: {{form.name_field}}. But it doesn't show the information my funtion or views.py def solit(request): """Gestion de solicitudes""" if request.method == 'POST': form = SolitForm(request.POST) if form.is_valid(): form.save() subject = 'Bienvenido {}'.format(request.user) from_email = 'xxxxxn@xxxx.com' html_content = render_to_string('plantillas/mailsended.html', {'form':form,'user':request.user}) text_content = strip_tags(html_content) msg = EmailMultiAlternatives(subject, text_content, from_email, ['xxxxxxxx@xxxxx.com']) msg.attach_alternative(html_content, 'plantillas/mailsended.html') msg.send() print (form) return redirect ('home') else: form = SolitForm() return render(request, 'plantillas/testform.html', {'form':form}) my forms.py class SolitForm(forms.ModelForm): class Meta: """Formulario de solicitud""" model = peticion fields = [ 'disponer', 'razon2', 'periodo_init', 'periodo_fin', 'horas_r', 'dias_r', ] labels = { 'disponer':'Tipo de Solicitud', 'razon2':'Razon', 'periodo_init':'Rango de fecha inicial', 'periodo_fin':'Fecha final', 'horas_r':'Dias a adicionar, si es mas de 8 horas', 'dias_r':'Horas a adiciona, si es menos de 1 dia', } my models class peticion(models.Model): #Modelo para (solicitar vacaciones y reportar tiempo) peticion_choice = ( ('Reportar', 'Reportar Tiempo'), ('Vacaciones', 'Vacaciones') ) disponer = models.CharField(max_length=255, choices=peticion_choice, null=True, blank=False) usuario = models.ForeignKey(users, on_delete=models.CASCADE, null=True, blank=True) razon2 = models.TextField(max_length=255, null=True, blank=False) periodo_init = … -
Django CreateView reload without double submitting
I'm trying to add data to a createview on form save (using a modal), and then just close the modal and stay on the same page OR reload page. However when I reload the page the data saves twice. I've tried multiple changes but nothing seems to help. Im new to coding, apologies if this is simple. Would sincerely appreciate any help! My views.py @login_required(login_url="/login") # Home (Logged In Dashboard) page view def vhome(request): prescription_table = Prescription.objects.filter(veterinary_practice = request.user.veterinary_practice) # veterinary practice id context = {'prescription_table': prescription_table} return render(request, 'app/veterinary/vhome.html', context) class PrescriptionCreateView(BSModalCreateView): template_name = 'app/veterinary/snippets/create_prescription.html' form_class = PrescriptionForm def form_valid(self, form): form.instance.prescription_type = 'Prescriber-Initiated' # prescription type form.instance.status = Prescription_status.objects.get(pk=2) # draft status form.instance.veterinary_practice = self.request.user.veterinary_practice # veterinary practice id form.instance.save() return redirect('vhome') -
Django restframework as a backend for offline first mobile app
I've just finished django app for mutliple choice questions. However,I wanted to develop Ionic android app version of the web app. It's my first app and I am still learning web development. I'm not sure if Django RestFramework or firebase backend is more suitible for offline first app,particularly with respect to mostly text based questions. -
How to get primary key inside detailview and use to pre fill a hidden field in a form?
I have two models: Properties and Bedroom, which are connected through a foreign key "Property" on the Bedroom model. #models.py class Property(models.Model): property_reference = models.CharField(db_column='Property_Reference', max_length=10, unique=True) # Field name made lowercase. address = models.CharField(db_column='Address', max_length=250, blank=True, null=True) # Field name made lowercase. post_code = models.CharField(db_column='Post_Code', max_length=15, blank=True, null=True) # Field name made lowercase. type = models.CharField(db_column='Type', max_length=25, blank=True, null=True, choices=HOUSE_TYPE_CHOICES) # Field name made lowercase. bedrooms = models.IntegerField(db_column='Bedrooms', blank=True, null=True) # Field name made lowercase. bathrooms = models.IntegerField(db_column='Bathrooms', blank=True, null=True) # Field name made lowercase. usual_cleaning_requirements = models.CharField(db_column='Usual_Cleaning_Requirements', max_length=250, blank=True, null=True) # Field name made lowercase. notes = models.CharField(db_column='Notes', max_length=500, blank=True, null=True) # Field name made lowercase. feature_image = models.ImageField(upload_to='properties',null=True) class Meta: db_table = 'Property' def __str__(self): return self.property_reference def get_absolute_url(self): return reverse("properties:property_detail",kwargs={'pk':self.pk}) class Bedroom(models.Model): type = models.CharField(db_column='Type', choices=BEDROOM_TYPE_CHOICES, max_length=50) bed_dimensions = models.CharField(db_column='Bed_Dimension', choices=BED_DIMENSION_CHOICES, max_length=30) image = models.ImageField(null=True, blank=True) ensuite = models.BooleanField(default=False) notes = models.CharField(db_column='Notes', max_length=500, blank=True, null=True) # Field name made lowercase. property = models.ForeignKey(Property, null=False, on_delete=models.CASCADE, related_name='bedroom') I have a Property DetailView Class that shows all the details on my template at "property-detail.html". Also on my template I have a button like this: <a class="btn btn-secondary float-right" href="{% url 'properties:add_bedroom' pk=object.pk %}"><i class="fas fa-plus-circle"></i> Add New</a> This … -
Push rejected, failed to compile Python app in heroku (Python Crash Course)
I am working through the learning log project in Python Crash Course by Eric Matthes, specifically working on the learning log app. I am trying to deploy to heroku but get this error: (ll_env) C:\Users\benpg\Documents\Coding\Python\learning_log>git push heroku master Enumerating objects: 54, done. Counting objects: 100% (54/54), done. Delta compression using up to 4 threads Compressing objects: 100% (46/46), done. Writing objects: 100% (54/54), 16.54 KiB | 940.00 KiB/s, done. Total 54 (delta 4), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Python app detected remote: ! Python has released a security update! Please consider upgrading to python-3.7.3 remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes remote: -----> Installing python-3.7.4 remote: -----> Installing pip remote: -----> Installing SQLite3 remote: -----> Installing requirements with pip remote: ! Push rejected, failed to compile Python app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to pacific-refuge-12657. remote: To https://git.heroku.com/pacific-refuge-12657.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/pacific-refuge-12657.git' Tried everything here including the two other questions linked at the start, no luck. Here's my requirements.txt: Django==1.8.4 dj-database-url==0.3.0 dj-static==0.0.6 django-bootstrap3==6.2.2 gunicorn==19.3.0 static3==0.6.1 psycopg2>=2.6.1 -
Why does get and filter work differently for annotated fields?
I have a get_queryset in a custom Manager for a Model that renames fields: class Manager: def get_queryset(self): return super(Manager, self).get_queryset().values(renamed_field=F('original_field')) Why is it that I can do a .filter on the renamed field but when I do a .get I need to use the original field name? This works: Model.objects.filter(renamed_field='Test') But this errors out with matching query does not exist: Model.objects.get(renamed_field='Test') -
How to run for loops in template? (django)
I want to run the for loop to show all images but the problem is that I have to change the "id" of each image (pic-1 -> pic-2 ...so on) I know how to do it in normal python but I'm lose on how to do this in template of django. Please someone help me out? <div class="preview-pic tab-content"> <div class="tab-pane active" id="pic-1"><img src="{{product.image.url}}"></div> {% for image in image_list %} <div class="tab-pane" id="pic-2"><img src="http://placekitten.com/400/252" /></div> <div class="tab-pane" id="pic-3"><img src="http://placekitten.com/400/252" /></div> <div class="tab-pane" id="pic-4"><img src="http://placekitten.com/400/252" /></div> <div class="tab-pane" id="pic-5"><img src="http://placekitten.com/400/252" /></div> {% endfor %} </div> <ul class="preview-thumbnail nav nav-tabs"> <li class="active"><a data-target="#pic-1" data-toggle="tab"><img src="http://placekitten.com/200/126" /></a></li> {% for image in image_list %} <li><a data-target="#pic-2" data-toggle="tab"><img src="http://placekitten.com/200/126" /></a></li> <li><a data-target="#pic-3" data-toggle="tab"><img src="http://placekitten.com/200/126" /></a></li> <li><a data-target="#pic-4" data-toggle="tab"><img src="http://placekitten.com/200/126" /></a></li> <li><a data-target="#pic-5" data-toggle="tab"><img src="http://placekitten.com/200/126" /></a></li> {% endfor %} </ul> </div> -
Selenium - show notes about what is going on in browser
I'm working on Selenium test which simulates every User action on my website. From registration to modifying forms etc. There are hundreds of actions so I would like to see what is currently going on. Is there a way to add some notes to Selenium so I can see them in the browser real time? For example some transparent overlay with text? I think it is possible to create a workaround using AJAX but maybe there is something built in. -
How to get multiple files from a django FileField after model form object has been saved when form.save() does not return object
I have a django form class that extends django-postman's WriteForm (which is a ModelForm) with an additional field to upload some files. from postman.forms import WriteForm class MyWriteForm(WriteForm): file_field = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True})) However, I need the saved model before I can do anything with the files. If I follow the example in the docs, I can extend postman's FormView and overwrite the save() method: from postman.views import FormView class MyFormView(FormView): form_class = MyWriteForm def post(self, request, *args, **kwargs): form_class = self.get_form_class() form = self.get_form(form_class) files = request.FILES.getlist('file_field') if form.is_valid(): for f in files: # Do something with each file. result = form.save() # result is a Boolean instead of the object! return self.form_valid(form) else: return self.form_invalid(form) However, django-postman WriteForm's save() method does not return the object as expected, and instead returns a Boolean. Is there any other way I can get the ModelForm's object after it is saved? Either through the view or the form? -
Transferring django settings to Environment Variables
I set the django project settings and added values to environment variables at my local ubuntu mashine and AWS Ubuntu server using .bashrc file at the root folder. ... export DEBUG="True" ... At local all working good, but at production server values are not importing. Why doesn't it work on both machines? How do I set up production?