Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Adding Video Field in Django
I want be add a video field in the django.I am not able to add it. How can I add a videofield in django in the admin portion like that of ImageFeild? -
how to Integrate modules of python scripts and print result on html
I am new to django and python. I want to execute a python script (not from views.py) and display the results to an HTML file as output. The problem is with modules. There are three modules that the python script getoffense.py uses. I have tried to run the script but it gives me modules import error below. I have saved the modules in a directory "modules" in my main app "Project1" and the python script is in my main project i.e. Project1. The modules i have imported are running indirectly when i am running getoffense.py. this is my project tree. C:. ├───.idea └───project1 ├───modules │ └───__pycache__ ├───templates └───__pycache__ when this was not integrated with django the file structure was scripts |--modules |--RestApiClient.py |--config.py |--SampleUtilities.py |--siem |-getoffense.py |--config(type=configuration settings) This worked fine when executed seperatly I tried executing the file in django project as view. please help me out get rid of this issue. I have tried integrating it just as we do views.py and display the data in home.html getoffense.py from django.shortcuts import render import importlib sys.path.append(os.path.realpath('./modules')) client_module = importlib.import_module('./modules/RestApiClient') SampleUtilities = importlib.import_module('./modules/SampleUtilities') def getalloffense(request): # First we have to create our client client = client_module.RestApiClient(version='9.0') # ------------------------------------------------------------------------- # Basic … -
AttributeError: 'QuerySet' object has no attribute 'id'
I-m trying to show a date on the template, and I have that in the get context data but it gives me this error. def get_queryset(self): """Get queryset for loan list.""" approved_loans = self.model.objects.order_by('-date_disbursed').filter( Q(status=Loan.LOAN_STATUS_PENDING) | Q(status=Loan.LOAN_STATUS_ON_LOAN) | Q(status=Loan.LOAN_STATUS_CLOSED) | Q(status=Loan.LOAN_STATUS_WRITTEN_OFF) | Q(status=Loan.LOAN_STATUS_RESCHEDULED) ) loan_performances = LoanPerformance.objects.order_by('loan__id', '-date_created').distinct('loan__id') for loan in approved_loans: loan_performance = loan_performances.filter(loan=loan).first() if loan_performance and loan_performance.interest_due_today and loan_performance.principal_due_today: loan.amount_due = loan_performance.interest_due_today + loan_performance.principal_due_today return approved_loans def get_context_data(self, **kwargs): """Get loan list context.""" context = super(LoanListView, self).get_context_data(**kwargs) loan_manager = LoanManager(self.get_object().id) context['page_name'] = 'loan_list' context['summary'] = { 'end_date': loan_manager.get_repayment_end_date(), } # data uploaded from sheets is stored in session immediately after context['uploaded_data'] = self.request.session.get('uploaded_data') if context['uploaded_data']: del self.request.session['uploaded_data'] return context def get_object(self, queryset=None): """Get loan detail object.""" return self.model.objects.all() -
What should I do - I want to allow user to search by username or email address for password reset
I am using Django in- built password_reset form. But it doesn't allow user to search by username for password reset. It only allows search by email address. I want to allow user to search by username or email for forgot password. -
Admin Panel Showing Only User ManyToManyField Area
my model has manytomany field in django and when I want to show it in admin panel, it appears in other user's objects, how can I show only those objects of that user? -
Writing a csv file into SQL Table using python
Hi I am trying to write a csv file into a table in SQL Server database using python. I am facing errors. Here is the code I am executing. CSV file contains more than 500 rows def LoadFile(self, hierarchySetId, fileName): try: with open('csvfilePath', 'r') as f: reader = csv.reader(f) columns = next(reader) query = ( 'INSERT INTO DummyTprFileType (RBNode1,RBNode2,RBNode3,RBNode4,RBNode5,RBNode6,RBNode7,BusinessSegment,DividendPartner,Region,TPRRBNode1,TPRRBNode2,TPRRBNode3,TPRRBNode4,TPRRBNode5,TPRRBNode6,TPRRBNode7,TPRRBNode8,TPRRBNode9,TPRRBNode10,TPRRBNode11,TPRRBNode12) values ({1})' ) cursor = connection.cursor() for data in reader: cursor.execute(query, data) cursor.commit() except pyodbc.Error as err: print('Error') print(err.args[0]) return True TypeError at /api/tprMappings/loadMappingsFile/ not all arguments converted during string formatting Request Method: GET PyCharm Terminal shows below: (0.000) QUERY = 'INSERT INTO DummyTprFileType (RBNode1,RBNode2,RBNode3,RBNode4,RBNode5,RBNode6,RBNode7,BusinessSegment,DividendPartner,Region,TPRRBNode1,TPRRBNode2,TPRRBNode3,TPRRBNode4 ,TPRRBNode5,TPRRBNode6,TPRRBNode7,TPRRBNode8,TPRRBNode9,TPRRBNode10,TPRRBNode11,TPRRBNode12) values ({2})' - PARAMS = (); args=['IST', 'Global Gas', 'Canada', '', '', '', '', '', 'Post Dividend', 'Americas', 'IST', 'Global Oil', 'Global Crude', 'Canada', 'Canada Crude Trading', '1C', '', '', '', '', '', ''] -
Requested setting INSTALLED_APPS, but settings are not configured
when I try to import "models" into my scraper, I get this error. The error appears when I try running the scraper. from django.movierater.api.models import * Error: from django.movierater.api.models import * ModuleNotFoundError: No module named 'django.movierater' I think the code below is what I need in a scraper, but the problem is also with it: import os os.environ['DJANGO_SETTINGS_MODULE'] = 'movierater.api.settings' django.setup() from movierater.api.models import * When I try : from api.models import * I get: % (desc, ENVIRONMENT_VARIABLE)) django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. Here is my scraper: import requests from bs4 import BeautifulSoup as bs from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager from collections import Counter url = 'https://teonite.com/blog/page/{}/index.html' all_links = [] headers = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0' } with requests.Session() as s: r = s.get('https://teonite.com/blog/') soup = bs(r.content, 'lxml') article_links = ['https://teonite.com' + item['href'][2:] for item in soup.select('.post-content a')] all_links.append(article_links) num_pages = int(soup.select_one('.page-number').text.split('/')[1]) for page in range(2, num_pages + 1): r = s.get(url.format(page)) soup = bs(r.content, 'lxml') article_links = ['https://teonite.com' + item['href'][2:] for item in soup.select('.post-content a')] all_links.append(article_links) all_links = [item for i in all_links for item in i] … -
Django: Show button in template for certain group level
I have 3 groups: viewer, editor and creator. I want to show the right amount of button according to the permissions. viewer: can see list and detail editor: viewer permissions + can edit creator: editor permissions + can create and delete I've tried to run this for the template: {% load groupfilter %} {% if request.user|group:"creator" %} <p>creator permissions</p> {% endif %}{% if request.user|group:"editor" || request.user|group:"creator" %} <p>editor permissions</p> {% endif %}{% if request.user|group:"editor" || request.user|group:"creator" || request.user|group:"viewer"%} <p>viewer permissions</p> {% endif %} but I get this error: Could not parse the remainder: '||' from '||'. groupfilter.py: from django import template register = template.Library() @register.filter(name='group') def group(u, group_names): return u.groups.filter(name=group_names) What have I done wrong? Is there an easier way to do this? Thanks -
Converting aggregate of total length of ListField value from all rows based on condition on another column in django
I am using this code to find number of values in list field imported_leads based on condition on other column message_from by iterating over for loop. om_leads = OttMessage.objects.filter(message_from=message_from, imported_leads__0__exists=True) total_leads_count = 0 for lead in om_leads: total_leads_count+=1 print total_leads_count Is there any way to find total_leads_count variable value efficiently? I am trying to use aggregate to find total_leads_count but don't know how to use it on ListField in django. Can anybody help me or give some direction. Thanks -
How to disallow adding a specific plugin to a PlaceholderField in a custom Django (CMS) application
I made a custom Django app for adding simple blog posts functionality with different sections that can be hooked to any page showing a selected section. It was made as an Apphook to a Django CMS page. It works by adding the post's title and metadata (date etc.) and upon save there is an Edit button to live edit the post on a page. I am using the PlaceholderField model field which adds a placeholder that accepts all the available plugins. Since I also made a CMS Plugin that can show Latest posts from any available section I would like to prevent users to add the CMS plugin to my post's detail page placeholder since it raises the RecursionError. The thing is, a CMS plugin should not be added to the application's PlaceholderField. I managed to resolve the problem (for now) by adding the CMS_PLACEHOLDER_CONF to my settings.py file with the restriction for my Latest Posts plugin but since it is a GitHub public repo I would like to disallow it in my app's config by default if possible. It currently works as follows. CMS_PLACEHOLDER_CONF = { 'post_detail': { # name of my model's PlaceholderField 'name': _("Post content"), # override … -
Type error in models.py - 'str' object is not callable
After data migration I want to assign settings.AUTH_USER_MODEL user.username to author field. @property def author(self): return self.user.username() #'line-17' getting: TypeError at /posts/ (homepage) 'str' object is not callable models.py in author, line 17 -
Renaming Custom User Model created by extending Abstract User
I created a custom user model by extended AbstractUser. I now want to rename my model. Ran make migrations but am getting an error class MyUser(AbstractUser): is_student = models.BooleanField(default=False) is_teacher: bool = models.BooleanField(default=False) username = models.CharField(max_length=10, blank=False, unique=True) email = models.EmailField('email address', blank=False) first_name = models.CharField(max_length=50, blank=False) last_name = models.CharField(max_length=50, blank=False) Class MyUser was earlier called User class TeacherProfile(PersonProfile): class Meta: verbose_name_plural = 'Teacher Profiles' user = models.OneToOneField(MyUser, on_delete=models.CASCADE, null=True, related_name='teacher_profile') doj = models.DateField("Date of Joining", null=True, blank=False) photo = models.ImageField(upload_to='teacher/') I also have onetoone relationship like so and class StudentProfile(PersonProfile): class Meta: verbose_name_plural = 'Student Profiles' YEAR_CHOICES = [] for r in range(1980, datetime.datetime.now().year + 1): YEAR_CHOICES.append((r, r)) user = models.OneToOneField(MyUser, on_delete=models.CASCADE, null=True, related_name='student_profile') gr_phone_no = models.CharField("Guardian's Phone No", max_length=10) yoe = models.IntegerField('year of enrollment', choices=YEAR_CHOICES, default=datetime.datetime.now().year) photo = models.ImageField(upload_to='student/%Y/') Am getting this error when i migrate raise ValueError("\n".join(error.msg for error in errors)) ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'main.myuser', but app 'main' doesn't provide model 'myuser'. The field main.StudentProfile.user was declared with a lazy reference to 'main.myuser', but app 'main' doesn't provide model 'myuser'. The field main.TeacherProfile.user was declared with a lazy reference to 'main.myuser', but app 'main' doesn't provide model 'myuser'. -
How to build a DRF API and consume it in the same project
I'm working on a DRF API, i will like to consume the API on the same project rather than using Django ORM structure, I have successfully Login a user and generated a token. Now i want to restrict a Django View based on a response of an API call class Login(generic.FormView): template_name = 'registration/login.html' form_class = LoginForm success_url = reverse_lazy('customer_dashboard') def form_valid(self, form): parameters = { 'username': str(form.cleaned_data['username']), 'password': str(form.cleaned_data['password']), } # Param from LOGIN form posted to API, if token response, means user is authenticated and active headers = {"Content-Type": 'application/json'} response = requests.post(str(settings.API_END_POINT + '/api-token-auth/'), json=parameters, headers=headers) data = response.json() # response CODE 2xx means a success, if POST request is success, then save USE TOKEN and ID to session if response.status_code in settings.SUCCESS_CODES: self.request.session['validated_user_token'] = data['token'] self.request.session['validated_user_id'] = data['user_id'] # get request from all_user end_point and match USER ID from before to list to fetch user details headers = {"Content-Type": 'application/json', "Authorization": "Token " + settings.API_TOKEN} response = requests.get(str(settings.API_END_POINT + '/users_api/'), headers=headers) users = response.json() print(self.request.session['validated_user_id']) for user in users: if user['id'] == self.request.session['validated_user_id']: messages.success(self.request, 'Hi' + ' ' + user['first_name'] + ' ' + user['last_name']) else: messages.error(self.request, 'Invalid Credentials') return super(Login, self).form_valid(form) Here i have the … -
Run migrations against the test database
I do not want migrations to be run before each test round, that's why I run my tests with --reusedb --nomigrations I still need to setup the database, once. For that I do: python manage.py migrate How do I tell migrate to run in "test" mode, so taht the right databases (with the test_ are used)? -
How to do wildcard search for single character replacement ( ? ) in Django ORM?
I have a case where I need to do a wildcard search using Django ORM. I have a column - column1 which contains mobile numbers. I need to do a wildcard search for a single character replacement which is ? in SQL. I can do that like Mobilenumbers.objects.raw('SELECT * FROM MOBILENUMBERS WHERE COLUMN1 LIKE '98765?7644'). But how do I do that same thing in Django ORM. This is not a duplicate of Wildcard searching in Django. -
How do I add PointField in django-admin?
I can't seem to add a value in django-admin for PointFied. I am still new in django-admin so I don't really know what I'm missing here. Any help would be appreciated. I am using Django 2.2.2 and python 3.x -
The view accounts.views.profile didn't return an HttpResponse object. It returned None instead
here is my views. def profile(request, username): if User.objects.filter(username=username).exists(): u = User.objects.filter(username=username)[0] if not Followers.objects.filter(user=username, follower=request.user.username).exists(): following = "Follow" cls = "btn-p" else: following = "Following" cls = "btn-t" if u.profilepic == "": u.profilepic = "static/assets/img/default.png" followers_p = 0 following_p = 0 posts = 0 name = u.name bio = u.bio posts = Photo.objects.filter(owner=username) posts = len(posts) followers_p = len(Followers.objects.filter(user=username)) following_p = len(Followers.objects.filter(follower=username)) context = { 'ProfilePic': u.profilepic, "whosprofile": username, "logged_in_as": request.user.username, "following": following, "cls":cls, "posts":posts, "followers_p":followers_p, "following_p": following_p,"name":name, "bio":bio } if request.user.is_authenticated: return render(request, 'logged-in-profile.html', context) return render(request, 'profile.html', context) -
How to get the current stock quantity for each item in an inventory system?
I wanna summarize the current stock quantity of each item in django admin. In item page, each item have a column, and I wanna show the number in each column of item. This is my model: from django.contrib.auth.models import User from django.db import models class Item(models.Model): item_name = models.CharField(max_length=128) class In(models.Model): in_date = models.DateTimeField(') item = models.ForeignKey(Item, on_delete=models.CASCADE, related_name='ins') quantities = models.IntegerField() class Out(models.Model): out_date = models.DateTimeField() item = models.ForeignKey(Item, on_delete=models.CASCADE, related_name='outs') quantities = models.IntegerField() Model In means stock-in, Out means stock-out I write functions in my ADMIN.PY like below: class ItemAdmin(admin.ModelAdmin): list_display = ['item_name', 'pattern', 'vendor', 'item_ins', 'item_outs'] def item_ins(self, obj): return obj.ins.aggregate(Sum('quantities')).get('quantities__sum') item_ins.short_description = 'stock-in' def item_outs(self, obj): return obj.outs.aggregate(Sum('quantities')).get('quantities__sum') item_outs.short_description = 'stock-out' I already knew how to aggregate total stock-in/stock-out number of each item, but I don't know how to get current stock quantity(stock-in subtract sotck-out) of each item. Please help me! Thank you! -
Checkbox in Dropdown Django
I have a form in my django app and it contains a dropdown. Models.py class Quiz(models.Model): mtypes = (('A', 'A'), ('B', 'B'), ('C', 'C'), ('D', 'D'), ('E', 'E')) material_type = models.CharField(max_length=255, default=0, choices=mtypes) Views.py class QuizCreateView(CreateView): model = Quiz fields = ('material_type') template_name = 'classroom/teachers/quiz_add_form.html' def form_valid (self, form): quiz = form.save(commit=False) quiz.owner = self.request.user quiz.save() return redirect('teachers:quiz_change', quiz.pk) html {% load crispy_forms_tags %} {% block content %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="{% url 'teachers:quiz_change_list' %}">RFQs</a></li> <li class="breadcrumb-item active" aria-current="page">Post New RFQ</li> </ol> </nav> <h2 class="mb-3">Post New RFQ</h2> {% csrf_token %} {#<h3>Material Details</h3>#} <div class="form-group col-md-4 mb-0"> {{ form.material_type|as_crispy_field }} </div> <button type="submit" class="btn btn-success">Save</button> I am able to display material_type as a dropdown list but can I add checkboxes to this DropDown? This is what the closest I could find but the documentation on the listed libraries is not so clear. How do I do that? -
Save the data in the Postgresql database
I don't catch how to save the scraped data in the Postgresql database. I tried to use Psycopg2 without effect... I learned that I can use django models for this The scraper should scrape every blog post on each page Data from the scraper should go to the Postgresql database, where the following statistics will be counted: 1.The 10 most common words along with their numbers under the address /stats 2.The 10 most common words with their numbers per author available under the address / stats / / posts authors with their name available in the address / stats / / available under the address / authors / in the code below, for example, I tried to get the names of the authors but I get such an error : authors = Author(name='author name') TypeError: 'NoneType' object is not callable importing models to the scraper does not help either... Here is my scraper: import requests from bs4 import BeautifulSoup as bs from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager from collections import Counter url = 'https://teonite.com/blog/page/{}/index.html' all_links = [] headers = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0' } with requests.Session() as s: r = s.get('https://teonite.com/blog/') soup = bs(r.content, 'lxml') article_links = … -
celery not working in django and just waiting (pending)
i'm trying found how celery is working. i have a project that have about 10 app.now i want use celery . setting.py: CELERY_BROKER_URL = 'amqp://rabbitmq:rabbitmq@localhost:5672/rabbitmq_vhost' CELERY_RESULT_BACKEND = 'redis://localhost' i created a user in rabbitmq with this info:username: rabbitq and password:rabbitmq . then i create a vhost with name rabbitmq_vhost and add rabbitmq permission to it. all is fine i think because all of error about rabbitmq disappear . here is my test.py: from .task import when_task_expiration def test_celery(): result = when_task_expiration.apply_async((2, 2), countdown=3) print(result.get()) task.py: from __future__ import absolute_import, unicode_literals import logging from celery import shared_task from proj.celery import app @app.task def when_task_expiration(task, x): print(task.id, 'task done') return True now when i call test_celery() in python shell it's pending.i try to replace @shared_task and @app.task(blind=True) but noting changed.even i try use .delay() instead apply_async((2, 2), countdown=3) and again nothing happend. i'm trying to use celery to call a function in specific time during this queation that i ask in past.thank you. -
How to count total occurrence of distinct field of same model in django?
I am trying to get the total count of occurrence of a field in same model in django. Is it possible to do it or not? for example I have a model as below: class Blog(DateTimeModel): title = models.CharField(max_length=255) description = models.TextField() category = models.CharField(max_length=255, null=True, blank=True) and a table of data as below: id | title | description | category ----+-------------------------------------+----------------------+---------- 1 | blog title first | description 1 | social 2 | blog title second | description 2 | social 3 | blog title third | description 3 | community 4 | blog title fourth | description 4 | community 5 | blog title fifth | description 5 | people I want a result to be as: <QuerySet [{'category': 'social', 'blog_count': '2'}, {'category': 'community', 'blog_count': '2'}, {'category': 'people', 'blog_count': '1'}]> I have tried doing Blog.objects.values('category').order_by('category').distinct('category').count() and got result as 3 which is true because it had count the total distinct values related to category. Django annotate count with a distinct field this post provide a solution where we can count fields based on two models. But i want the results from the same model. -
Re-write a php script in python using django framework
I have recently started learning python using the Django framework. I have a PHP script that I wrote that consumes some web services using Curl. I would like to re-write this script in Django but I have nowhere to start. Below is the PHP script <?php if($_POST) { $selectedGrowerNo = $_POST['vnumber']; $bookingDate = $_POST['bookingdate']; $selectedSaleDate = $_POST['dated']; $bales = $_POST['bales']; $reoffer = $_POST['reoffer']; $floorCode ="ATT"; //take from parameters table $bookedBy = "USERNAME"; $data_Array = array(); $url = "https://webserviceexample.com/insertbookingWebservices"; $post_data = array( 'grower' => $selectedGrowerNo, 'saleDate' => $selectedSaleDate, 'floor' => $floorCode, 'bookingDate' => $bookingDate, 'balesBooked' => $bales, 'saleDate' => $selectedSaleDate, 'bookedBy' => $bookedBy, 'reoffer' => $reoffer ); $headers[] = 'Accept: */*'; $headers[] = 'Content-Type: application/x-www-form-urlencoded'; $headers[] = 'Authorization: Digest nonce="4jM0NjkxNDY3NDU3NzYuNDo3YWNiNjk3NjIzNmY2MWU2ZmY2ZGRlZWRlMWFiYmVhNw",nc="1",cnonce="20eb5a87df578f43b2b780a610ed2f68",qop="auth",username="USERNAME",uri="/insertbookingWebservices",response="6ac54919e2547192f82cd0a431cee47b"'; $options = array( CURLOPT_URL => $url, CURLOPT_HEADER => false, CURLOPT_HTTPHEADER => $headers, CURLOPT_VERBOSE => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => false, CURLOPT_SSL_VERIFYPEER => false, // for https CURLOPT_HTTPAUTH => CURLAUTH_DIGEST, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($post_data) ); $ch = curl_init(); curl_setopt_array( $ch, $options ); try { $raw_response = curl_exec( $ch ); // validate CURL status if(curl_errno($ch)) throw new Exception(curl_error($ch), 500); // validate HTTP status code (user/password credential issues) $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($status_code != 200) throw new Exception("Response with Status … -
How to combine the values of two models under another model
I have an app which includes three models as below. 'PersonelBilgisi' and 'SalonBilgisi' have thousands entries. I want to relate these two model to SinavBilgisi. Since 'PersonelBilgisi' and 'SalonBilgisi' have many entries, I cannot use ManyToManyField to relate. I want to create an entry for SinavBilgisi, assign the entries of 'PersonelBilgisi' and 'SalonBilgisi' to the entry of SinavBilgisi automatically and save to the database. models.py class PersonelBilgisi(models.Model): unvan = models.CharField(max_length=75) adsoyad = models.CharField(max_length=75) class SalonBilgisi(models.Model): bina =models.CharField(max_length=45) kat =models.CharField(max_length=45) class SinavBilgisi(models.Model): donem =models.CharField(max_length=45) ders = models.CharField(max_length=45) I tried to relate it in views.py and listed in html file but could not manage to relate with SinavBilgisi. views.py def atama (request): personels =[p for p in PersonelBilgisi.objects.all()] salon = [sa for sa in SalonBilgisi.objects.all()] return render(request, 'organizasyon/home.html', {'personels ':personels , 'salon':salon}) EXPECTED OUTCOME In html file donem: 2019-2020 ders: AA unvan | adsoyad| bina | kat Dr | Alice | Karaagac | Second Prof. Dr | Jonny| MYO| Third *In admin page under SinavBilgisi * donem: 2019-2020 ders: AA (When I clik it, I want to see the entries listed in html file as shown above) donem: 2019-2020 ders: AB donem: 2019-2020 ders: AC -
Weather request can't send to open weather map
I am sending request to openweathermap for weather but it can't send to it. from django.shortcuts import render import requests def index(request): url = 'api.openweathermap.org/data/2.5/weather?q={}&units=imperial&appid=*************************' city = 'lahore' r = requests.get(url.format(city)) print(r.text) return render(request,'weather/weather.html') Invalid URL 'api.openweathermap.org/data/2.5/weather?q=lahore&units=imperial&appid=**********************': No schema supplied. Perhaps you meant http://api.openweathermap.org/data/2.5/weather?q=lahore&units=imperial&appid=***********************? Error Picture