Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how to import csv data to postgres database using python
I am trying to import the data in my excel sheet to the postgresql database using python, and when i do that i get the following error. i have already converted my excel to csv and then tried using the 'copy' statement to import the data to postgres database. import psycopg2 conn = psycopg2.connect("host=localhost dbname=djangotest user=postgres password=*******") cur = conn.cursor() with open('C:\\Users\\********\\Desktop\\excelsheet.csv', 'r') as f: next(f) # Skip the header row. cur.copy_from(f, 'us_arrays', sep=',') conn.commit() psycopg2.errors.BadCopyFileFormat: missing data for column "ip_address_or_service_machine" CONTEXT: COPY us_arrays, line 1: "(CMDB)",.Device Type,.Frame or Data Tier,.Corp Device,.Encrypt Enabled,.Dedicated Device,".IP Addres..."``` -
Object of type OAuthConnection is not JSON serializable
I'm retrieving products using the bigcommerce API using the following code def get_bigcommerce_products(request): a = api.Products.all() return json.dumps(a) I need a response in JSON. So I used json.dumps. But it's giving me the following error 'Object of type OAuthConnection is not JSON serializable'. I've tried to convert it into a dictionary but not working. So please help me with this. I'm using Python 3.7 and Django 2.2. -
AttributeError: 'UserProfile object has no attribute 'artist_category' django
i have three model i am trying to creating to create Artist and UserProfile when user register this part working fine and i also want to update Artist model when i update UserProfile. models.py: custom user model: class CustomUser(AbstractBaseUser, PermissionsMixin): artist_choice = [ (0, 'celebrities'), (1, 'singer'), (2, 'comedian'), (3, 'dancer'), (4, 'model'), (5, 'Photographer') ] artist_category = models.IntegerField(choices=artist_choice, null=True) email = models.EmailField(max_length=100, unique=True) name = models.CharField(max_length=100) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) is_superuser = models.BooleanField(default=False) last_login=models.DateTimeField(null=True, blank=True) date_joined = models.DateTimeField(auto_now_add=True) USERNAME_FIELD = 'email' EMAIL_FIELD='email' REQUIRED_FIELDS=[] objects=UserManager() def get_absolute_url(self): return "/users/%i/" % (self.pk) artist model: class Artist(models.Model): CHOICES = ( (0, 'celebrities'), (1, 'singer'), (2, 'comedian'), (3, 'dancer'), (4, 'model'), (5, 'Photographer') ) name = models.CharField(max_length=100) artist_category = models.IntegerField(choices = CHOICES, null=True) artist_image = models.ImageField(upload_to= 'media',null=True) bio = models.TextField(max_length = 500) def __str__(self): return self.name profile model: class Artist(models.Model): CHOICES = ( (0, 'celebrities'), (1, 'singer'), (2, 'comedian'), (3, 'dancer'), (4, 'model'), (5, 'Photographer') ) name = models.CharField(max_length=100) artist_category = models.IntegerField(choices = CHOICES, null=True) artist_image = models.ImageField(upload_to= 'media',null=True) bio = models.TextField(max_length = 500) def __str__(self): return self.name creating profile after user register: def create_profile(sender,**kwargs ): if kwargs['created']: user_profile=UserProfile.objects.get_or_create(user = kwargs['instance']) post_save.connect(create_profile,sender=CustomUser) this is the part when i am getting error: … -
Django - Multiple custom models on the same form
I'm using Django 2.1 and PostgreSQL. My problem is that I'm trying to create a form to edit two different models at the same time. This models are related with a FK, and every example that I see is with the user and profile models, but with that I can't replicate what I really need. My models simplified to show the related information about them are: # base model for Campaigns. class CampaignBase(models.Model): .... project = models.ForeignKey(Project, on_delete=models.CASCADE) creation_date = models.DateTimeField(auto_now_add=True) start_date = models.DateTimeField(null=True, blank=True) end_date = models.DateTimeField(null=True, blank=True) .... # define investment campaign made on a project. class InvestmentCampaign(models.Model): .... campaign = models.ForeignKey(CampaignBase, on_delete=models.CASCADE, null=True, blank=True) description = models.CharField( blank=True, max_length=25000, ) .... And the form that I want to create is one that includes the end_date of the FK CampaignBase, and the Description from the InvestmentCampaign. Now I have this UpdateView to edit the InvestmentCampaign, and I need to adapt to my actual needs, that are also update the CampaignBase model: class ProjectEditInvestmentCampaignView(LoginRequiredMixin, SuccessMessageMixin, generic.UpdateView): template_name = 'webplatform/project_edit_investment_campaign.html' model = InvestmentCampaign form_class = CreateInvestmentCampaignForm success_message = 'Investment campaign updated!' def get_success_url(self): return reverse_lazy('project-update-investment-campaign', args=(self.kwargs['project'], self.kwargs['pk'])) # Make the view only available for the users with current fields def … -
'Game' object does not support item assignment
Getting error 'Game' object does not support item assignment games = [] for i in range(len(filterList)): durations = findDurationInHour(filterList[i].startDate,filterList[i].endDate) filterList[i]['duration'] = durations games.append(filterList[i]) filterList = games i am trying to add duration into array object as a key. but on line filterList[i]['duration'] = durations getting error: 'Game' object does not support item assignment -
Why am I getting form is invalid error in django?
During development of website in Django web framework I am getting form is invalid error when validating form. I have searched online for solution but not able to solve my problem. My files are as below. models.py class Customer(models.Model): f_name = models.CharField(max_length = 30, null=True) last_name = models.CharField(max_length = 30, null= True) cont_no = models.CharField(max_length = 30, null= True) pincode = models.IntegerField(default=0) def __str__(self): return self.f_name class Product(models.Model): name = models.CharField(max_length = 30, null= True) uniq_price = models.IntegerField(default=0) def __str__(self): return self.name class Order(models.Model): cust_name = models.ForeignKey(Customer,related_name='first_name', on_delete=models.CASCADE) prod_name = models.ForeignKey(Product, related_name='uniqe_price', on_delete=models.CASCADE) unit_price = models.IntegerField(default=0) quantity = models.IntegerField(default=0) total = models.IntegerField(default=0) forms.py class CustomerForm(forms.ModelForm): class Meta: model = Order fields = "__all__" views.py def add_order(request): if request.method == "POST": form = CustomerForm(request.POST) form.save() return redirect("place_ord") else: form = CustomerForm() home.html <form id="myForm" action="{% url 'add_order' %}" method="POST"> {% csrf_token %} <h1>add order</h1> <label>Customer</label> <select id="custs" name="customer"> <option value="">Select Customer</option> {% for cust in customers %} <option id="{{ cust.id }}" value="{{ cust.f_name }}"> {{ cust.f_name }} </option> {% endfor %} </select><br><br> <label>Product</label> <select id="singleSelectTextDDJS" name="prods" onchange="singleSelectChangeText()"> <option>Select Product</option> {% for prod in products %} <option value="{{ prod.uniq_price }}"> {{ prod.name }} </option> {% endfor %} </select><br><br> <label>Price:</label> <input type="text" name="price" … -
how to set range in calendar for 1 week in Django
I want to set range Monday to Saturday in the calendar in Django where user can select the date between this date and on Sunday user can not change the date def tech_form(request): if request.method == "POST":form = TechForm(request.POST)if form.is_valid():start_date = datetime.date(2019, 1, 1)end_date = datetime.date(2020, 3, 31)Tech.objects.filter(pub_date__range=(start_date, end_date))form=form.save(commit=False)form.save()messages.success(request,"Form Submited succesfully")return redirect('tech')else:form = TechForm()return render(request, 'hellogymapp/forms/tech_form.html', {'form': form})def tech_form(request):if request.method=="POST":form =TechForm(request.POST)if form.is_valid():start_date = datetime.date(2019, 1, 1)end_date = datetime.date(2020, 3, 31)Tech.objects.filter(pub_date__range=(start_date,end_date))form=form.save(commit=False)form.save()messages.success(request,"Form Submited succesfully")return redirect('tech')else:form = TechForm()return render(request, 'hellogymapp/forms/tech_form.html', {'form': form}) please explain -
Can't run the Django Server
I want to run the Djando server. I did everything that requires to do it, but when I type the command " python3 manage.py runserver " nothing happened at all.. I've run " django-admin startproject "project_name" " Then run " cd "project_name" , but nothing happened Then ls And finally tried to run the server, but still nothing.. ' -
Django Call Python Function From Query
When I querying a Model in Django, I want to create a custom field (using "extra" function) which may use as a sorting field. For example, result = foo_model.objects.filter(active=True).extra(select={'cal_field': pythonFunction()}).extra(order_by=['cal_field']) I have 2 questions: Can I create a field which calling a Python function inside "extra"? If it can, how can I pass the current row into the function? Thanks a lot! -
Django admin save_model not advancing primary key in Postgres
So I have a function in the Django admin that allow me to create a duplicate MyModel in the database: def save_model(self, request, obj, form, change): if '_saveasnew' in request.POST: old_obj_id = resolve(request.path).args[0] old_obj = MyModel.objects.get(id=old_obj_id) obj.other_id = old_obj.other_id obj.status = old_obj.status obj.project_id = old_obj.project_id obj.test_url = old_obj.test_url obj.save() super(MyModelAdmin, self).save_model(request, obj, form, change) This creation works fine, but I have another system interacting with this database that is seeing insert failures for every time this function has been called. For example, if I create 2 duplicates entries in the Django admin this way, then the other system will see two errors like IntegrityError duplicate key value violates unique constraint "my_model_pkey" DETAIL: Key (id)=(1234) already exists. -
Ordering list by date of child page
So I have a list that is displaying individual blog pages and they are currently being order by last updated. However I want them ordered by post.specific.date. How can I do this? If more code is needed to help please say. {% for post in posts %} <div class="..."> <div class="..."> {% for item in post.specific.blogpage_images.all|slice:"1" %} {% image item.image fill-400x400-c100 %} <p>{{ item.caption }}</p> {% endfor %} </div> <div class="..."> <h3 class="...">{{ post.title }}</h3> <h5>{{ post.specific.intro }} <span class="...">{{ post.specific.date }}</span></h5> </div> <div class="..."> {{ post.specific.body|richtext }} <div class="..."> <div class="..."> <p> <button class="..."><b><a class="effect-shine" href="{% pageurl post %}">READ MORE »</a></b> </button> </p> </div> <div class="..."> <p> <span class="..."> <span class="..."> <a href="{% pageurl post %}#disqus_thread"> _ </a> </span> </span> </p> </div> </div> </div> </div> <hr> {% endfor %} -
Django Template overriding
I was wondering, when using templates in django, I'm able to extend other base templates and override some of the blocks in the base template. so my question is when I override, would the code in the overridden block still get rendered then overridden, or would it never be run and only the new block is rendered? Example: base.html {% block menu %} {% for option in menu %} ...Create the menu entries {% endfor %} {% endblock menu %} extender.html {% extends base.html %} {% block menu %} ... some other tags {% endblock menu %} In this case does the original for loop in the base.html run if it gets overridden? -
Django POST request in template (without form or a better solution)
I have a shopping cart and I want to add an object to that shopping cart. There is a button which I press and when that happens I want the request to go through. This is what I want to do in the POST request (When Button Is Pressed): Check for Item with the same id as the product I pressed. Create a CartItem with the same Item as the one I checked for above. Add that cart item to my shopping cart linked to my profile. (Not started work yet) Models: class Item(models.Model): name = models.CharField(max_length=100, null=True) info = models.CharField(max_length=100, null=True) price = models.IntegerField(default=0, null=True) discount = models.CharField(max_length=100, null=True, blank=True) discountPrice = models.IntegerField(default=0, null=True) inStock = models.BooleanField(default=False) imagefield = models.ImageField() reviews = models.ManyToManyField(Review, blank=True, related_name="itemreview") class Meta: verbose_name_plural = 'Items' def __str__(self): return "{name}".format(name=self.name) class CartItem(models.Model): item = models.ForeignKey(Item, blank=True, related_name="CartItem", on_delete=models.CASCADE) quantity = models.IntegerField(default=0, null=True) price = models.IntegerField(default=0, null=True) class Meta: verbose_name_plural = 'Cart Items' def __str__(self): return self.item.name def get_total_item_price(self): return self.quantity * self.item.price class ShoppingCart(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) items = models.ManyToManyField(CartItem, blank=True, related_name="orderitem") class Meta: verbose_name_plural = 'Shopping Carts' def __str__(self): return self.user.username def get_total(self): total = 0 for cart_item in self.items.all(): total += cart_item.get_total_item_price() … -
oTree (Django): How to show-hide single choice options depending on selection
I want to make a survey where you can 'accept', 'refuse' or ask for 'more information' (3 options). I already have set up all the single choices, but I need a certain programming into the 3rd option 'more information'. This is my thoughts: 1. Once you click on 'more information' 2.it should ask something like 'are you sure?' and then you can proceed with 'yes' or return to the question with 'no'; then if you click 'yes' a box appears where it gives you certain information and the 2nd 'more information' option appears; 3. then again it follows step 2. This one should be able up to 3 times, but it is not necessary to ask for more information and you can just 'accept' or 'refuse'. I don't know what I can do to approach this task question_1 = models.IntegerField( choices=[[20, 'Accept'], [-20, 'Refuse'], [-3, '1. More Information'], [-2, '2. More Information'], [-1, '3. More Information']], label='Choices', widget=widgets.RadioSelect ) -
Python multiple inheritance only working for one parent's method but calling method from both parents
I have a Python/OOP question. You are all familiar with diamond problem in C++ right? This is something similar. I have the following classes class BaseAuth(TestCase): def setUp(self): # create dummy user and client, removing code of that for simplicity. self.user.save() self.client.save() def _get_authenticated_api_client(self): pass class TokenAuthTests(BaseAuth): def _get_authenticated_api_client(self): super()._get_authenticated_api_client() print("I AM IN TOKEN AUTH") api_client = APIClient() # do stuff with api_client return api_client class BasicAuthTests(BaseAuth): def _get_authenticated_api_client(self): super()._get_authenticated_api_client() print("I AM IN BASIC AUTH") api_client = APIClient() # do stuff with api client return api_client class ClientTestCase(BasicAuthTests, TokenAuthTests): def test_get_login_response(self): api_client = self._get_authenticated_api_client() # login test code def test_get_clients(self): api_client = self._get_authenticated_api_client() # get client test code def test_get_client_by_id(self): api_client = self._get_authenticated_api_client() # get client by id test code def test_update_client_by_id(self): api_client = self._get_authenticated_api_client() # update client test code def test_add_client(self): api_client = self._get_authenticated_api_client() # add client test code def test_delete_client_by_id(self): api_client = self._get_authenticated_api_client() # delete client test code Now, when I run the code, I can see that this is printed out: I AM IN TOKEN AUTH I AM IN BASIC AUTH .I AM IN TOKEN AUTH I AM IN BASIC AUTH .I AM IN TOKEN AUTH I AM IN BASIC AUTH .I AM IN TOKEN AUTH I … -
How can I detect that my code is running through the Django shell?
In some cases, we do manual cleanup for our app via the Django shell (python manage.py shell). Of course this should be done with care but in this particular internal app it's just the most effective way to do the work. When running in the Django shell, I'd like to disable some behavior that otherwise would be triggered. How do I detect that my code is running through the shell? I'm imagining something like: if not django.SHELL: # Don't notify chat when running from the shell notifications.send(dev_user, ...) -
How to pass parameters to a mixin on a per-view basis
I have an app for managing test cases, which are organised into various projects. I'm trying to set permissions on a per project basis, i.e. every user has different permissions for each project. Here's what I've come up with so far: class TestProjectMember(models.Model): """Per project permissions - a role can be set for each user for each project""" member_name = models.ForeignKey(User, on_delete=models.SET_NULL) project = models.ForeignKey(TestProject, on_delete=models.CASCADE) member_role = models.CharField(choices=Choices.roles) class TestCase(models.Model): """Test cases""" tc_title = models.CharField(max_length=500, unique=True) tc_project = models.ForeignKey(TestProject, on_delete=models.CASCADE) class TestProject(models.Model): """Projects""" project_name = models.CharField(max_length=200) project_desc = models.CharField(max_length=500) class TestCaseEditHeader(View): def get(self, request, pk): case = get_object_or_404(TestCase, id=pk) if self.get_perm(case.tc_project, request.user, 'TA'): form = TestCaseHeaderForm(instance=case) context = {'case': case, 'form': form} return render(request, 'test_case/tc_header_edit.html', context) else: return redirect('case_list') def get_perm(self, curr_project, curr_user, perm): model_perm = TestProjectMember.objects.filter(member_name=curr_user, project=curr_project).values_list('member_role', flat=True) if perm in model_perm: return True return False It works, but it's a bit clunky. I'd have to call the get_perm() method from every get() or post() method from each view. A better solution would probably be a mixin. What has me stumped is how to pass the required role to the mixin for each view. For each view there is a required role that the user has to have … -
django result of annotate doesn't include in serializers
Django 2.2 I'm serializing a Queryset to use AJAX. This is my simple code def datatables_ajax_test_api(request): users_object = User.objects.filter(created_gte=today).annotate(user_points=Sum('pointlog__point_money')) users = serializers.serialize('json', users_object) return HttpResponse(users, content_type="text/json-comment-filtered") This code passes json data very well its own objects. But not include 'user_points' which is from annotate. How can I include it? -
django upload image to S3, (work on localhost but gives access denied error on server)
error: an error occurred (accessdenied) when calling the putobject operation access denied I am having problem in uploading image to s3 from django, it works fine on local host, but gives access denied error on server with same credentials. here are my settings DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID', 'JFHKSF*&^SFJKSF') AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY', 'asdkl8e8/Qnakisfd89598er7fd') AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME', 'my-static-files') AWS_S3_FILE_OVERWRITE = os.environ.get('AWS_S3_FILE_OVERWRITE', False) note: I only want to upload image to s3 not all of my static files -
Create .json file from .env file and define as global var
I want to use authenticate the Google Cloud API. So far that's only possible through a .json file. My application is hosted on Heroku. Now I don't want to push that .json file in my GitHub repository. I found a buildpack that actually works. However, I don't want to rely on external buildpacks and wonder if there is another solution. My idea similar to the buildpack: Defining GOOGLE_CREDENTIALS in .env with: { "type": "service_account", "project_id": "natural-language-254706", "private_key_id": "XXX", "private_key": "-----BEGIN PRIVATE KEY-----\nXXXXX\n-----END PRIVATE KEY-----\n", "client_email": "abc@natural-language-254706.iam.gserviceaccount.com", "client_id": "12345", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/starting-account-5yzg5dipgu01%40natural-language-254706.iam.gserviceaccount.com" } Take GOOGLE_CREDENTIALS and write google-credentials.json file with Python <<< here I need help Define GOOGLE_APPLICATION_CREDENTIALS=google-credentials.json I am not struggling with 2. How can I create a .json file out of the credentials in 1. I will add this second step (2.) then as part of the release-tasks in Heroku python manage.py create_json_for_google_credentials -
Django store attachment in Data Lake
I have a Django application, I have written the API to handle files uploads with Django-Rest-framework. I have tested everything and it works with storing the attachments in my local laptop. However, I want the attachment to be store in a data lake, and I have tried to search what I should put in the settings, or what should be done so that instead of creating a local folder in our laptop and store the attachment, the attachment will be stored in the data lake. Does anyone have any experience with it? -
Why isn't the User information appending the mysql database using django?
I am having issues with a django-ajax project in which whenever I try to register a user, it does not append the user information to the mysql database and instead I get this in the terminal when I run the server: Not Found: /sign-up/ajax-sign-up [Time of request] " POST /sign-up/ajax-sign-up HTTP/1.1" 404 2430 Furthermore, I get this error that does not go away on VScode regarding the User class on the forms.py: Class 'User' has no 'objects' member I have added the pylint add-on to remove the error assuming is the Class 'User' error is the issue and I have rewriting the views.py but nothing has worked. Here is my forms.py script: from django import forms from django.contrib.auth import authenticate from django.db.models import F from project.models import User from django.contrib.auth.hashers import make_password, check_password from urllib.request import urlopen from random import randint import json, re class Ajax(forms.Form): args = [] user = [] def __init__(self, *args, **kwargs): self.args = args if len(args) > 1: self.user = args[1] if self.user.id == None: self.user = "NL" def error(self, message): return json.dumps({ "Status": "Error", "Message": message }, ensure_ascii=False) def success(self, message): return json.dumps({ "Status": "Success", "Message": message }, ensure_ascii=False) views.py script: from django.shortcuts import … -
Authenticated API call to AWS with requests
I am running a django application with some data in an AWS bucket. Data is mostly files (powerpoint, word etc..). When I create a new file I get a link attached to it which I show in my REST list view like: "store_file": "https://mybucketname.s3.amazonaws.com/media/private/myfile?AWSAccessKeyId=XXXX&Signature=XXXXXExpires=1571731023" I would like to get this file by doing an authenticated request to the endpoint with the library requests and I don't get it to work. I get a 200 when doing this: def get_data(method='get'): endpoint = "https://mybucket.s3.amazonaws.com/pathtomyfile?AWSAccessKeyId=XXX&Signature=XXXExpires=1571731023" r = requests.request(method, endpoint) return r.status_code get_data() But it doesn't download my file What works is doing it with the AWS CLI like aws s3 cp s3://pathtomyfileinbucket /pathtomysavelocation/filename.pptx Even though this works it's not good for my use case, since I want to use it on different machines and with tests etc... I was also trying to use aws_requests_auth like: auth = AWSRequestsAuth(aws_access_key='...', aws_secret_access_key='...', aws_host='restapiid.execute-api.eu-west-1.amazonaws.com', aws_region='eu-west-1', aws_service='execute-api') response = requests.get('https://restapiid.execute-api.us-east-1.amazonaws.com/stage/mybucket.s3-eu-west-1.amazonaws.com/pathtomyfile', auth=auth, headers=headers) Is there a way to do what I want to do?? I am grateful for any help. Thanks so much in advance! -
PasswordResetConfirmView is not working proeprly?
Here I am not using PasswordResetView because i am sending email through my dynamic email configuration so for this I made my own view which generates the token using PasswordResetTokenGenerator and it also sends the email to the user. the password reset link in my email looks like this http://127.0.0.1:8000/password-reset/confirm/NQ/5as-b3502199950ff028a6ef/ But after click in that link it redirect to the password_reset_confirm which is good but in this view the {{form.as_p}} is not working.It is only displaying the button but before using auth-views.PasswordresetView the form was working but now the form is not being passed in the template. How can i solve this? urls.py path('password-reset/',views.send_password_reset_email,name='password_reset'), path('password-reset/done/',auth_views.PasswordResetDoneView.as_view(template_name='password_reset_done.html'),name='password_reset_done'), path('password-reset/confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html', success_url=reverse_lazy('password_reset_complete'),),name='password_reset_confirm'), views.py def send_password_reset_email(request): form = CustomPasswordResetForm() if request.method == 'POST': form = CustomPasswordResetForm(request.POST) if form.is_valid(): email = form.cleaned_data['email'] user = get_user_model().objects.get(email__iexact=email) site = get_current_site(request) mail_subject = "Password Reset on {} ".format(site.domain) message = render_to_string('organization/password_reset_email.html', { "user": user, 'domain': site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode(), 'token': activation_token.make_token(user) }) config = EmailConfiguration.objects.order_by('-date').first() backend = EmailBackend(host=config.email_host, port=config.email_port, username=config.email_host_user, password=config.email_host_password, use_tls=config.email_use_tls) email = EmailMessage(subject=mail_subject, body=message, from_email=config.email_host_user, to=[user.email], connection=backend) email.send() return redirect('password_reset_done') return render(request, 'password_reset.html',{'form':form}) password_reset_email.html {% block reset_link %} http://{{domain}}{% url 'password_reset_confirm' uidb64=uid token=token %} {% endblock %} password_reset_confirm.html <form action="" method="post"> {% csrf_token %} {{form.as_p}} <button type="submit" class="btn … -
How to make simple web application which will display data which i pass dynamically using Django?
I am very new to Django just started learning using RealPython website through which i just understood the basics of it. I wanted to create a simple we application which will display data in a table format like in a HTML table format with some data displayed, this data is dynamic. What i wanted to achieve using Django is the following: Dynamic data is retrieved from a rest api The API provide me data in a JSON format I'll convert into a required table format Pass this table data stream to the view -> Html dummy template created When i open the application or the page the given API in the code should get called and the data should be displayed What i wanted to know: Can you please let me know: How to achieve the above requirement using Django? I kindly request you to please provide the details or guide or steps or any kind of material which will help me to achieve the above functionality. Please try to provide me detailed steps as detailed as it may be as i tied to explain initially i am very new to Django. I have read the blogs on how to …