Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to check if queryset is empty, without querying the database?
In Django, is there any way we can check if a queryset is empty or not, without querying the database. I know that .exists() is the least expensive one, but it still hits the database. So how do I check for queryset existence, without hitting the database? -
default_attrs.update(attrs) ValueError: dictionary update sequence element #0 has length 1; 2 is required
I got this error when I wrote the new class, before that everything was working fine I read different links with the same error but I got no clue how to fix it from django import forms from .models import Topic, Entry class TopicForm(forms.ModelForm): class Meta: model = Topic fields = ['text'] labels = {'text': ''} class EntryForm(forms.ModelForm): class Meta: model = Entry fields = ['text'] labels = {'text': 'Entry:'} widgets = {'text': forms.Textarea(attrs={'cols': 80})} -
How can I do to display all the name?
Hello I would like to create a select using Django I have a model : class Test(models.Model): name = models.CharField(null=True, default=None) And I would like to create a select with option of name from the table Test. How can I do this ? I tried this : <select class="form-control"> <option value=""></option> {{ for name in Test }} <option value="{{ name.id }}">{{ name.name }}</option> {% endfor %} </select> But it does not work... Could you help me please ? -
unable to import xlsx writer in Django
Problem to Solve: -export selected models data to xlsx format from django admin. Tried Solutions: -Using xlsxwriter. I tried to install it in my django Environment using. pip install xlsxwriter Error: ERROR: Could not find a version that satisfies the requirement xlsxwriter (from versions: none) ERROR: No matching distribution found for xlsxwriter Argument: I have used xlsx writer in many python code before and as django is a python framework it should work in this as well but I don't understand why this error is popping up. -
Python 0.35 + 0.1 is what? [duplicate]
without havin' to think about it 0.35+0.1 is 0.45. Can't Python add these two numbers? Or am i doing smthing wrong here? 😂🤦🏻♂️ -
Annotate queryset with boolean where one field is equal or not to another field
Question is regarding annotation in Django. For example I have a following model: class Example(models.Model): field_1 = PositiveIntegerField() field_2 = PositiveIntegerField() And I want to annotate queryset based on this model with boolean True or False based on whether field_1 == field_2 I managed to find 2 solutions on this, both of that don't satisfy me. Example.objects.extra(select={'equal': r' field_1 = field_1'}) Use Raw SQL, and extra() that is about to get deprecated. 2) Example.objects.all()\ .annotate( equal= Case( When(field_1=F('field_2'), then=True), default=False, output_field=BooleanField(), ) ) Which is quite verbose and makes queryset 4 times slower. Question is - is it possible to express such logic in Django ORM without useage of RAW SQL and with less verbose and more straightforward logic? Thank you. -
Django foreign key relationship in model.py problem
I am new to django and don´t know how to solve the problem(google and stack didnt "helped"/i dont get it). Since yesterday i tryed many options. This is my desired output: enter image description here Function.py def test(): .... return(author, title, view....) Models.py class Pers(models.Model): author = models.CharField(max_length=50) class Title(models.Model): authors = models.ForeignKey('Pers', on.delete=models.CASCADE) title = models.CharField(max_length=20) view = models.CharField(max_length=10) p = test() t = Pers(author = p[0]) t.save() z = test() y = Title(authors = z[0], title = z[1], view = z[2] y.save() My Function.py works fine but i have problems with the db. I can fill the Pers-Table with "DJ ES" but i want to have it just one time( ID[0] = DJ ES, ID1 = MAX VA and so on). With my table i get multiply DJ ES(ID[0] = DJ ES, ID1 = DJ ES, ID[2] = DJ ES....). And i am not able to save DJ ES to my Title-Table. My latest error: ValueError: Cannot assign "'DJ ES'": "Title.authors" must be a "Pers" instance. " -
How to set initial value of ForeignKey dynamically in CreateView?
I want to set ForeignKey initially as a dynamic value. But is there any simple way to do this ? And I tried like this[https://stackoverflow.com/questions/18277444/set-initial-value-in-createview-from-foreignkey-non-self-request-user](as answer of this link). But it is not working. #models.py class Album(models.Model): credit = models.CharField(max_length=250) album_title = models.CharField(max_length=100) logo = models.FileField() def get_absolute_url(self): return reverse('picture:detail', kwargs={'pk': self.pk}) def __str__(self): return self.album_title + ' - ' + self.credit class Item(models.Model): album = models.ForeignKey(Album, on_delete=models.CASCADE) file_type = models.CharField(choices=TYPE_CHOICES, max_length=1) caption = models.CharField(max_length=100) class Meta: ordering = ('upload_date', 'caption') def get_absolute_url(self): return reverse('picture:item-detail', kwargs={ 'id': self.album_id , 'pk': self.pk}) def __str__(self): return self.caption #views.py class ItemCreate(CreateView): model = Item fields = ['album', 'file_type', 'caption'] def get_initial(self): album = get_object_or_404(Album, pk=self.kwargs.get('album.pk')) return { 'album': album, 'file_type': 't', } #urls.py urlpatterns = [ # /picture/<album_id>/ url(r'^(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'), # /picture/<album_id>/<pic_id> url(r'^(?P<id>[0-9]+)/(?P<pk>[0-9]+)/$', views.ItemDetailView.as_view(), name='item-detail'), # /picture/<album_id>/pic/add url(r'^(?P<id>[0-9]+)/pic/add/$', views.ItemCreate.as_view(), name='item-add'), ] -
Django send email after deleting object
I hope someone will be able to help. I am new in Django and struggling with sending email after using CBV DeleteView. Here is my model: class Bookings(models.Model): service = models.CharField(max_length=255, null=True) your_email = models.EmailField() name = models.CharField(max_length=155) date = models.DateField() time = models.TimeField() user = models.ForeignKey(CustomUser, on_delete=models.CASCADE) def __str__(self): return self.your_email def get_absolute_url(self): return reverse('booking_list') and this is my view: class BookingDeleteView(DeleteView): model = Bookings template_name = 'booking_delete.html' context_object_name = 'booking' success_url = reverse_lazy('booking_list') def delete(self, request, *args, **kwargs): self.object = self.get_object() success_url = self.get_success_url() send_mail( subject='CANCELLATION!!', message=str(Bookings.service) + str(Bookings.date) +/ str(Bookings.time), from_email=Bookings.your_email, recipient_list=['testadmin@admin.com'] ) self.object.delete() return HttpResponseRedirect(success_url) Unfortunately I get only location of the data in the email, here is an example of the email received: Subject: CANCELLATION!! web_1 | From: <django.db.models.query_utils.DeferredAttribute object at web_1 | 0x7ff230211e50> web_1 | To: testadmin@admin.com web_1 | Date: Fri, 10 Jul 2020 14:15:29 -0000 web_1 | Message-ID: <159439052931.455.4373660896961612525@992781d7c153> web_1 | web_1 | <django.db.models.query_utils.DeferredAttribute object at 0x7ff230211df0><django.db.models.query_utils.DeferredAttribute object at 0x7ff230211f10><django.db.models.query_utils.DeferredAttribute object at 0x7ff230211d60> Which is not ideal. I guess it might be something stupid that I am missing but like I said I am quite new and I have tried almost everything but nothing is working. Could anyone help me, please? -
django related object reference not displaying items
I have two models SubCategory and Product i created a listview with model set to SubCategory and reference its related product set in template but items are not being loaded don't know what I have missed models class SubCategory(models.Model): name = models.CharField(max_length=200) description = models.CharField(max_length=300) category = models.ForeignKey(Category, on_delete=models.CASCADE) def __str__(self): return self.name class Product(models.Model): name = models.CharField(max_length=120) price = models.FloatField() image = models.ImageField(upload_to='pdt_imgs/') sku = models.IntegerField() available = models.BooleanField(default=True) discount = models.IntegerField(default = 0) category = models.ForeignKey(SubCategory, on_delete=models.CASCADE) seller = models.ForeignKey(Seller, on_delete=models.CASCADE) def __str__(self): return self.name Template in which I tried to reference product items related to subcategories <div class="ps-block__categories"> <h3>Clothing & <br> Apparel</h3> <ul> {% for subcategory in object_list %} <li><a href="#">{{ subcategory.name }}</a></li> {% endfor %} </ul><a class="ps-block__more-link" href="#">View All</a> </div> <div class="ps-block__slider"> <div class="ps-carousel--product-box owl-slider" data-owl-auto="true" data-owl-loop="true" data-owl-speed="7000" data-owl-gap="0" data-owl-nav="true" data-owl-dots="true" data-owl-item="1" data-owl-item-xs="1" data-owl-item-sm="1" data-owl-item-md="1" data-owl-item-lg="1" data-owl-duration="500" data-owl-mousedrag="off"><a href="#"><img src="{% static 'img/slider/home-3/clothing-1.jpg' %}" alt=""></a><a href="#"><img src="{% static 'img/slider/home-3/clothing-2.jpg' %}" alt=""></a><a href="#"><img src="{% static 'img/slider/home-3/clothing-3.jpg' %}" alt=""></a></div> </div> <div class="ps-block__product-box"> {% for product in object.product_set.all %} <div class="ps-product ps-product--simple"> <div class="ps-product__thumbnail"><a href="product-default.html"><img src="{{ product.image.url }}" alt=""></a> {% if product.discount > 0 %} <div class="ps-product__badge">-{{ product.discount }}%</div> {% endif %} {% if product.available == False %} <div class="ps-product__badge … -
Django perform division in annotate sum expression and return as float
I have data like this: some_foreign_key date rank 1 2020-07-10 20:15 23 1 2020-07-10 20:15 2 2 2020-07-10 21:15 9 3 2020-07-10 21:15 12 1 2020-07-10 21:15 400 ... I would like to sum 1 / rank and group it by date and filter by some value from the foreign_key. The raw sql would be something like SELECT SUM(1/rank) FROM ... WHHERE [foreign key constraint] GROUP BY date I've tried the following in Django: data = MyModel.objects.values('date').annotate( score=Sum(1/F('rank'), filter=Q(myforeignobject__bla__bla__name="Some name")) ) The worked somewhat, but the resulting score is an integer which won't work since the numbers will usually be very small. I also tried the following, but still get and integer: data = MyModel.objects.values('date').annotate( score=Cast(Sum(1/F('rank')), FloatField()) ) Note, I do not want to sum rank and then have it be divided by one, it has the be one divided by each entry since it won't yield the same result otherwise. -
How to read data from uploaded csv file using django?
How can I open uploaded csv file like in raw python? Path is proper views.py def csv_read(request): with open('C:/Users/filepath.csv') as csv_file: rows = [] csv_reader = csv.reader(csv_file) for row in csv_reader: rows.append(row) context = { 'rows': rows, } return render(request, "dataframe.html", context) dataframe.html {% for row in rows %} <tr> <td>{{ row }}</td> </tr> {% endfor %} -
Django - TypeError at /result/ result() missing 7 required positional arguments:
I am trying to create a form in Django which has 8 integer input bars which are the stats of the Pokemon which will tell me exactly which Pokemon has those stats. I've also used a Machine Learning model to do so. The form works perfectly fine when i test it for the first 2-3 times. But after that it shows the following error: TypeError at /result/ result() missing 7 required positional arguments: 'attack', 'defense', 'special_attack', 'special_defense', 'speed', 'generation', and 'legendary' Please can anyone figure out why the error is occurring. Nothing wrong with Indentation that i know. I've searched a lot about this but didn't find any solution that helped. The Views.py file - def result(base_hp,attack,defense, special_attack,special_defense,speed,generation,legendary): df = pd.read_csv("C:/Users/Yadnesh/Downloads/pokemre.csv") df.head() Y = df.Name features = ['HP', 'Attack', 'Defense', 'Sp. Atk', 'Sp. Def', 'Speed', 'Generation', 'Legendary'] X = df[features] train_X, val_X, train_y, val_y = train_test_split(X, Y, test_size=0.3, random_state=66) iowa_model = RandomForestClassifier(random_state=1, criterion="entropy") iowa_model.fit(train_X, train_y) val_prediction = iowa_model.predict(val_X) # print(val_prediction) #print("Enter the following info") # Total1=input("Enter total-:") HP1 = base_hp Attack1 = attack Defense1 = defense SpAtk1 = special_attack SpDef1 = special_defense Speed1 = speed Generation1 = generation Legendary1 = legendary pre = [[HP1, Attack1, Defense1, SpAtk1, SpDef1, Speed1, Generation1, … -
RuntimeError: populate() isn't reentrant django1.11
I am new to django hosting, while hosting on server I am keep getting RuntimeError: populate() isn't reentrant Is there something wrong with my configuration file? > [remote 127.0.0.1:248] mod_wsgi (pid=15404): Target WSGI script > '/var/www/vhosts/mywebsite.com/httpdocs/mydjango_app/wsgi.py' cannot > be loaded as Python module. Apache error [remote 127.0.0.1:248] > mod_wsgi (pid=15404): Exception occurred processing WSGI script > '/var/www/vhosts/mywebsite.com/httpdocs/mydjagno_app/wsgi.py'. Apache > error [remote 127.0.0.1:248] Traceback (most recent call > last): Apache error [remote 127.0.0.1:248] File > "/var/www/vhosts/mywebsite.com/httpdocs/mydjango_app/wsgi.py", line > 21, in <module> Apache error [remote 127.0.0.1:248] application = > get_wsgi_application() Apache error [remote 127.0.0.1:248] File > v"/var/www/vhosts/mywebsite.com/Envs/MyEnv/lib/python2.7/site-packages/django/core/wsgi.py", > line 13, in get_wsgi_application Apache error [remote > 127.0.0.1:248] django.setup(set_prefix=False) Apache error [remote 127.0.0.1:248] File "/var/www/vhosts/mitsubishimidelivery.com/Envs/mitsubishimidelivery.com/lib/python2.7/site-packages/django/__init__.py", > line 27, in setup Apache error [remote 127.0.0.1:248] > apps.populate(settings.INSTALLED_APPS) Apache error [remote > 127.0.0.1:248] File "/var/www/vhosts/mywebsite.com/Envs/mydjangoapp/lib/python2.7/site-packages/django/apps/registry.py", > line 78, in populate Apache error [remote 127.0.0.1:248] raise > RuntimeError("populate() isn't reentrant") Apache error [remote > 127.0.0.1:248] RuntimeError: populate() isn't reentrant Here is my WSGI Configuration WSGIDaemonProcess processname python-path=/var/www/vhosts/mywebsite.com/httpdocs:/var/www/vhosts/mywebsite.com/Envs/myvenv/lib/python2.7/site-packages WSGIProcessGroup processname Alias /media/ /var/www/vhosts/mywebsite.com/httpdocs/media/ Alias /static/ /var/www/vhosts/mywebsite.com/httpdocs/static/ <Directory /var/www/vhosts/mywebsite.com/httpdocs/static> Require all granted </Directory> <Directory /var/www/vhosts/mywebsite.com/httpdocs/media> Require all granted </Directory> WSGIScriptAlias / /var/www/vhosts/mywebsite.com/httpdocs/mydjangoproject/wsgi.py <Directory /var/www/vhosts/mywebsite.com/httpdocs/mydjangoapp> <Files wsgi.py> Require all granted </Files> </Directory> # Possible values include: debug, info, notice, … -
NoReverseMatch at "/result"
I am trying to add a like system to my blog posts in my blog app. I was watching a tutorial on how to add a like button, however it was part of a course so has different variables and models for example. When i try and load my 'detail_post' url i get the following error: Here is my error message: Internal Server Error: /blog/d-test-post/ Traceback (most recent call last): File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\dylan\myblogsite\blog\views.py", line 62, in detail_blog_view return render(request, 'detail_blog.html', {'blog_post': blog_post, File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\shortcuts.py", line 19, in render content = loader.render_to_string(template_name, context, request, using=using) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\loader.py", line 62, in render_to_string return template.render(context, request) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\backends\django.py", line 61, in render return self.template.render(context) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\base.py", line 171, in render return self._render(context) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\base.py", line 163, in _render return self.nodelist.render(context) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\base.py", line 936, in render bit = node.render_annotated(context) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\base.py", line 903, in render_annotated return self.render(context) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\loader_tags.py", line 150, in render return compiled_parent._render(context) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\base.py", line 163, in _render return self.nodelist.render(context) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\base.py", line 936, in render bit = node.render_annotated(context) File "C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\template\base.py", … -
How to Download Youtube video in Django App to my Local direct from Browser Using PyTube Library?
def download(request): obj = YouTube('https://www.youtube.com/watch?v=1Sj-UdjqlFw') obj.streams.first().download() #what path sould i give into download() as param return render(request, 'downloader/home.html',context={}) The video is download into my Django Root Directory. But I want to download it into my Local Directory like Desktop or Download folder. -
Django-REST or Firebase?
We are about to begin working on a project that was started by someone else. It is currently developed in HTML+CSS+Javascript and Firebase. We'll move the frontend to React, but we are used to develop the backend on Django-REST deployed on AWS and have never really worked with Firebase (and honestly, don't really know how it works in detail). React seems to have a nice integration with Firebase, but we would need to learn how it works. Is it worth it to move the backend from Firebase to Django-REST? Which are the pros and cons of both of them? Thank you in advance! -
How could I implement insert if exists / update if not. in scrapy_pipleline
I just intend to if exists item, insert. if not, update. but update part doesn't work. Just insert or nothing. # pipeline.py from fashion.models import ItemList, SelectShopSite from django.core.exceptions import ObjectDoesNotExist class ScraperPipeline: def process_item(self, item, spider): return item class ItemPipeline: def process_item(self, item, spider): try: fashionitem = ItemList.objects.get(item_url=item['item_url']) #if exists, stay in try. if not, go to except item = item.save(commit=False) item.pk = fashionitem.pk # update item. no insert # logging sort of 'Update' except ObjectDoesNotExist: pass # logging sort of 'insert' item.save() return item I implement djangoitem in items.py what's wrong with my code? -
using NamespaceVersioning in drf-yasg - Yet another Swagger generator
I'm facing the same issue with swagger (drf-yasg) and django as this thread: https://github.com/axnsan12/drf-yasg/issues/128 When I give a default version in my REST_FRAMEWORK settings it only gives the endpoints of v1. When I don't give any default_version, it gives all the endpoints of all the versions. I would like to have only the endpoints of v1 when the url is like .../v1/... (and get the version out of the url, but that is not the big issue) However, after hours of trying this code/solution, it didn't do the trick. This is my settings.py REST_FRAMEWORK = { "DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.NamespaceVersioning", } SIMPLE_JWT = {"REFRESH_TOKEN_LIFETIME": timedelta(days=30)} SWAGGER_SETTINGS = { "LOGIN_URL": "rest_framework:login", "LOGOUT_URL": "rest_framework:logout", "APIS_SORTER": None, "OPERATIONS_SORTER": None, "JSON_EDITOR": True, "SHOW_REQUEST_HEADERS": True, "SUPPORTED_SUBMIT_METHODS": ["get", "post", "put", "delete", "patch"], "VALIDATOR_URL": None, } This is my project/urls.py file # ---------- Swagger Section ----------# from drf_yasg.views import get_schema_view from drf_yasg import openapi from rest_framework import permissions # router = routers.DefaultRouter() # router.register(r'groups', GroupsViewSet, base_name='groups') schema_view = get_schema_view( openapi.Info(title="API", default_version="v1", description="## Admin dashboard"), public=True, permission_classes=(permissions.AllowAny,), ) swagger_urlpatterns = [ path("api/v1/swagger/", include("backend.versioning.v1.v1_urls", namespace="v1")), path("api/v2/swagger/", include("backend.versioning.v2.v2_urls", namespace="v2")), ] # ---------- Swagger Section ----------# rest_versioning_urlpatterns = [ # ----- v1 -----# url(r"^devices/", include((device_urls, "devices"), namespace="v1")), # ----- v2 -----# url(r"^devices/", include((device_urls, … -
How to evaluate a queryset in batches?
I have a model with 100,000+ rows. I want to do some operation on it, but can't do it in one go, because of the size. So, I thought of using Paginator like this: def fun(): paginator = Paginator(Model.objects.filter(**some_filter), 10000) for page_no in paginator.page_range: page = paginator.get_page(page_no) queryset = page.object_list # Do some operation on queryset # Check if new records are added in the Model, (if yes, then do the operation on new records only) The final comment in the code says, that while running the above code, if new records are added (because this is a live application), then we have to do the same operation on those records too. So my question is how do I get the remaining (new) records only to run the same code? -
Can I use a for loop counter where there is a number in the property names in Django?
I have this html code but I have 20 products and the only code that changes in them are the image1 caption1 product1 etc. I'm new to Django and not sure if this can be done with a for loop using a counter or if it can be done with an {% include ___ with ____ %}? Or can it be done with Python code? I'm even newer to Python and wouldn't be sure how to do that. I tried a for loop counter but it said i couldnt do {% image page.image{{ forloop.counter }} fill... %} as it expects the %} before the {{ }} {# Product1 #} <div class="document product-card"> <div class="w3-card-4 w3-margin w3-white" data-aos="fade-down"> {% image page.image1 fill-150x150-c100 %} <div class="w3-container"> </div> <hr> <p id="caption">{{ page.caption1 }}</p> {% for download in page.product1.all %} {% with doc=download.product1 %} <div class="download product-info"> <a href="{{ doc.url }}" class="smooth-over-button noDecoration"> <i class="fa fa-download"></i> <p class="btn-txt">{{ doc.title }}</p> </a> </div> {% endwith %} {% endfor %} </div> </div> -
Distinguishing Between Multiple Submit Buttons On The Same Page
I am printing multiple file upload buttons to a page, one per iteration through my loop. {% for unit in user.units.all %} {% if unit.number|add:0 == iteration|add:1 %} <button type="button" class="btn btn-primary js-upload-photos"> <span class="glyphicon glyphicon-cloud-upload"></span> Upload Files</button> <input id="fileupload" type="file" name="user_file" multiple data-url="{% url 'user-file-upload' %}" data-form-data='{"csrfmiddlewaretoken": "{{ csrf_token }}", "unit_id":"{{ unit.id }}"}'> $(function () { $(".js-upload-photos").click(function () { $("#fileupload").click(); }); $("#fileupload").fileupload({ dataType: 'json', done: function (e, data) { if (data.result.is_valid) { $("#gallery tbody").prepend("<tr><td><a href='" + data.result.url + "'>" + data.result.name + "</a></td></tr>") } } }); }); As each fileUpload matches a different unit, I am passing a unit_id variable to javascript with the button press. This variable is to be saved in the DB along with the file. If I inspect the page, each fileUpload has a unique unit_id but it doesn't matter which of the fileUploads' UPLOAD FILES button I click on, the id saved in the DB is always for the first unit. I suspect this is because each fileUploads has the same id, but I am unsure how to change this without breaking my code. I thought maybe I could change the id in my template to class and the two #fileuploads in my javascript … -
How can i fix 502 Bad Gateway NGINX errror while deploying a django app on AWSEB command line?
I have trying to deploy a django application on awsebcli. immmediately i enter the eb open command i get 502 Bad Gateway NGINX error in return in my web browser. Please i need assistance on how to fix this error, below are my codes screenshots.settings.py.502 bad gateway..elasticbeanstalk/config.yml..ebextensions\django.config 3: I look forward to your kind response. Thank you -
how can i prepopulate this update form
i want the form to be prepopulated with data when i am editing the form views.py def edit_task(request, post_id): post = Post.objects.get(id=post_id) form = TaskForm(request.POST, instance=post) if request.method == 'POST': print(request.POST) form = TaskForm(request.POST, instance=post) if form.is_valid(): form.save() return redirect('task') context = {'form': form} return render(request, 'List/add_task.html', context) -
Django + WSGI + NGINX : Need a debugger
Please I'd like to know if there is a server side debugger for django using WSGI + NGINX as server. If Yes can you point me to the debugging tool and its documentation or tell me how to do? Thanks in advance.