Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Why is the Django serializer.data step slow?
I am doing a GET request to return around 100,000 objects from my Django rest framework API. The request is somewhat slow to complete (nearly 2 seconds) and upon further inspection, the slow part is storing the result of serializer.data. The total response size is <5MB so I would expect the response time to be much quicker than this. From reading various articles online, most "Django slowness problems" seem to stem from the N+1 problem which can easily be solved with prefetch_related but this doesn't seem to be relevant to my problem as my model has no foreign key. I've used django-extensions's runserver --print-sql to see what queries Django is doing. But when I time the individual segments (as shown in the code block below) the actual query and serialization steps are almost instant. Indeed, the query that django-extensions shows is sensible. I also looked at the source for Django's serializers but I'm still none the wiser as to why the .data step might take so long. The GET request in question (including timing statements) is as follows: class ExampleList(generics.ListCreateAPIView): queryset = Example.objects.all() serializer_class = ExampleSerializer def get(self, request): start_time = time.time() queryset = Example.objects.all() query_time = time.time() - start_time … -
Playing HTML5 videos in Django. Static file injection is not working
I am trying to play a video in a HTML5 tag. The video will be loaded from static files in the Django project. This is my html file currently: {% extends "base.html" %} {% load staticfiles %} {% block title %} Courses {% endblock %} {% block content %} <h1>Media Content!</h1> {% if video %} This is a video content <video name='demo' controls autoplay width='50%' height='40%'> <source src="{% static '{{video.video}}' %}" type="video/mp4"></source> </video> <p></p> <p>{{ video.video }}</p> {% endif %} {% if article %} This is an article content {% endif %} {% endblock %} {{ video.video }} gives me the injection "courses/course_video/TR_outro_1.mp4" which is where the static file lives. If I copy and paste this directory directly into the src in the HTML tag, it works and the video appears. But when I use {{ video.video }}. The video doesn't load. -
Django annotate exclude with Case & When (Conditional Expression)
I'm using Django 2.2 While making queryset, I want count of related model, based on few conditions like queryset = self.model.objects.filter(user=self.request.user).annotate( count_videos=Count('video'), count_completed=Count( Case( When(video__status__in=Video.STATUS_LIST_COMPLETED) ) ), count_failed=Count( Case( When(video__status__in=Video.STATUS_LIST_FAILED) ) ), count_pending=Count( Case( When( video__status__not_in=Video.STATUS_LIST_PENDING_EXCLUDE ) ) ) ) Here 3 counts are working, but in last count count_pending, I have to count against exlude(). i.e., count number of records excluding the passed list. How can I use exclude with the above statement? -
Insert image to djnago templates
I am trying to display image in django templates, but I allways get error file not found. I set up MEDIA_ROOT and MEDIA_URL in djnago settings MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media') I add my picture to the network_scanner/network_scanner/media/logos/VM.png A tried to use this in my html file, but it did not work: <img src="{{ MEDIA_URL }}logos/VM.png"> I got error: Not Found: /display_network/87/logos/VM.png What I am doing wrong? -
count() method of the list class applied to queryset. Strange behaviour. Django
Cant find out why I keep getting following following error: TypeError at /boats/reversion/ count() takes 1 positional argument but 2 were given #views … … … memory_limiter = BoatImage.objects.filter(boat_id__isnull=True).exclude( memory__in=existing_boats_pk).values_list("memory", flat=True) for i in memory_limiter: if memory_limiter.count(i) > 3: memory_limiter.remove(i) what shell says about memory limiter: >>> for memory in memory_limiter: ... print(memory, type(memory)) ... 93 <class 'int'> 93 <class 'int'> 93 <class 'int'> 93 <class 'int'> 93 <class 'int'> 93 <class 'int'> 93 <class 'int'> 100 <class 'int'> 102 <class 'int'> 102 <class 'int'> 102 <class 'int'> >>> memory_limiter <QuerySet [93, 93, 93, 93, 93, 93, 93, 100, 102, 102, 102]> >>> following method brings same results: for i in [ x for x in memory_limiter]: if memory_limiter.count(i) > 3: memory_limiter.remove(i) Question is whats wrong with the count? I copy pasted this list to a separate *.py module and there it works fine… Tried to turn qs to iterator -same results. in separate *.py a = [93, 93, 93, 93, 93, 93, 93, 100, 102, 102, 102] for i in a: if a.count(i) > 3: a.remove(i) print(a) output - > [93, 93, 93, 100, 102, 102, 102] -
Django dont find installed apps in setting.py
I'm trying to create a web app with python / django but an app error occured on the app and they were not explicitly present in setting.py Due to my routine I use two computers to do the development, in one of them the error happens and in the other it does not. I've done a good search on google, but all the solutions have had no effect, what is making me more frustrated is the fact that the code works on one computer and another does not. setting.py INSTALLED_APPS = [ 'django.contrib.staticfiles', 'django.contrib.contenttypes', 'django.contrib.auth', 'simple_history', 'blog.apps.BlogConfig', 'users.apps.UsersConfig', 'django.contrib.admin', 'django.contrib.sessions', 'django.contrib.messages', 'crispy_forms', 'storages' ] *Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\ProgramData\Anaconda3\lib\site- packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute super().execute(*args, **options) File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 364, in execute output = self.handle(*args, **options) File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle self.run(**options) File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run autoreload.run_with_reloader(self.inner_run, **options) File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader start_django(reloader, main_func, *args, **kwargs) File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 564, in start_django reloader.run(django_main_thread) File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 272, … -
click to add user's like item to current user in Django
I am creating a project on mobile comparision. the project have user's profile section, what i want when a user click on the items like_button, it should add to the current user's profile like items and when it click again on button, it should be remove from the current user'like items. please give me some idea.but i don't know how to do that. -
How to define logging level in Sentry Python SDK
python 3.5 sentry-sdk 0.8.0 Hello, I'm trying to get in Sentry.io some informations (INFO level) coming from a view in Django and I'm not sure to understand how to make it. This is what I have tried : In settings.py sentry_logging = LoggingIntegration( level=logging.INFO, event_level=logging.INFO ) sentry_sdk.init( dsn="https://###", integrations=[DjangoIntegration(), sentry_logging], server_name="MyServerName", ) In views.py def myview(request, something): # Here I do something # Log some data logger.info('Interesting info !', extra={ 'something_modified': something_modified, }) With this code, I don't see my event info in Sentry. If I call logger.error(###) it shows this event and I have the red "error" flag, like expected with error level. So I tried : def myview(request, something): # Here I do something # Log some data with configure_scope() as scope: scope.level = 'info' logger.info('Interesting info !', extra={ 'something_modified': something_modified, }) It doesn't work either With logger.error(###) it shows this event and I have a blue info flag in Sentry But the other real errors now appear in blue too, which is a bit too monochrome Some concepts from the documentation are still unclear for me, I may have mixed "context / scope / levels" together. Thanks for your help. -
How merge two querysets from same model without ordering them
I have create two queryset from same model and merge them as a single queryset. But don't want doing any ordering on new created queryset. I want that my queryset elements listed as how i merged them. queryset1 = modelA.objects.filter(id=modelB.rel_id) queryset2 = modelA.objects.exclude(id=modelB.rel_id) queryset = queryset1 | queryset2 I expect the output of should be queryset = , , ]> Because is a queryset1 and i merge it as a first element But result was : queryset = , , ]> It ordering by modelA id again. Even i don't set any ordering in modelA and new queryset. -
Django application freezes on Google App Engine
I'm having some trouble with a Django application deployed on Google App Engine. I still don't know how to replicate the issue. It seems like the application randomly freezes. It just stops responding (no log is produced in the meanwhile) and, if I go in any application page, I get this error: Error: Server Error The server encountered an error and could not complete your request. Please try again in 30 seconds. No error is shown in the logs and the only strange warning I found is this one: OpenBLAS WARNING - could not determine the L2 cache size on this system, assuming 256k I don't have any issues when I run the application on my Ubuntu machine. I'm using Django 2.1.5 with Python 3.7 and Django connects to a MySQL instance (on Google Cloud SQL). -
How to access previous value of a field in django model form before save?
I need to access the previous value of the Django model instance field before saving the form. For example in for_valid method. How can I achieve this? -
How to do redirect with ajax and django?
I have a form, which create new record in db. It works because of ajax. I have argument 'id', which is created automatically, when new record is being created (after fill form). I want to use this id, because I need to redirect users to page /127.0.0.1:8000/<id>, when they fill form or maybe simply print this link in page. How can I do this? views.py def add_new(request): """ Function which upload new file to UploadModel. """ form_upload = UploadForm(request.POST, request.FILES, prefix='upload_form') if form_upload.is_valid() and request.is_ajax(): new_file = form_upload.save(commit=False) if request.user.is_authenticated: new_file.author = request.user new_file.created_date = date.today() new_file.is_worked = True if new_file.ended_date <= date.today(): new_file.is_worked = False new_file.delete() else: new_file.is_worked = True new_file.save() return redirect('index') form_upload = UploadForm() return render(request, 'sharing/index.html', {'form_upload': form_upload}) js file function upload(event) { event.preventDefault(); var data = new FormData($('form').get(0)); $.ajax({ url: $(this).attr('data-url'), type: $(this).attr('method'), data: data, cache: false, processData: false, contentType: false, success: handleSuccess(), }); return false; } function handleSuccess(){ $("form")[0].reset(); alert('Success uploading!'); window.location.href = '/'; } $(function() { $('form').submit(upload); }); -
field name and help text disappear in multiple form in django
I have multiple form that handle with one view. When I want to show my form in index.html and specific the field,Such as {{form_1.some_field}} All help texts and fields name disappear! When I use {{ form_1}} everything run correctly. What is the problem? This is my files: index.html <form method="post" class="mos-rtl"> {% csrf_token %} <div> <h4 class="mos-rtl">Section 1</h4> <p>{{ form_1.some_field }}</p> </div> <div> <h4 class="mos-rtl">Section 2</h4> {{ form_2.some_field }} <button type="submit" >submit</button> </div> </form> forms.py class Form1(ModelForm): class Meta: model = Model1 fields = '__all__' class Form2(ModelForm): class Meta: model = Model2 fields = '__all__' Views.py def my_view(request): if request.method == "POST": form_1 = Form1(request.POST) form_2 = Form2(request.POST) if form_1.is_valid() and form_2.is_valid(): new_record_1 = form_1.save(commit=False) new_record_1.save() new_record_2 = form_2.save(commit=False) new_record_2.record_1 = new_record_1 new_record_2.save() return redirect('administrator:view_admin_curriculum') else: form_1 = Form1(request.POST) form_2 = Form2(request.POST) template = 'index.html' context = {'form_1': form_1, 'form_2': form_2} return render(request, template, context) -
Select database rows within a column
I have set up a Jupyter Notebook that calls my description column within a table from a Postgresql database and apply a Machine learning model from the Ibm watson studio API to these datas. I was able to correctly get a response back with a prediction, but the problem is that my datas are all being displayed and read as a single object instead of an individual object for each row. My goal is to apply the model to each of these description rows but as you can see below the prediction is applied to the column itself, not to the rows: { "collection": [ { "top_class": "hot", "text": "{\"description\":{\"0\":\"Lorem ipsum sjvh hcx bftiyf, hufcil, igfgvjuoigv gvj ifcil ,ghn fgbcggtc yfctgg h vgchbvju.\",\"1\":\"Lorem ajjgvc wiufcfboitf iujcvbnb hjnkjc ivjhn oikgjvn uhnhgv 09iuvhb oiuvh boiuhb mkjhv mkiuhygv m,khbgv mkjhgv mkjhgv.\",\"2\":\"Lorem aiv ibveikb jvk igvcib ok blnb v hb b hb bnjb bhb bhn bn vf vbgfc vbgv nbhgv bb nb nbh nj mjhbv mkjhbv nmjhgbv nmkn\",\"3\":\"Lorem jsvc smc cbd ciecdbbc d vd bcvdvbj obcvb vcibs j dvx\",\"4\":\"Lorem jsvc smc cbd ciecdbbc d vd bcvdvbj obcvb vcibs j dvx\",\"5\":\"Lorem jsvc smc cbd ciecdbbc d vd bcvdvbj obcvb vcibs j dvx\",\"6\":\"Lorem jsvc smc cbd … -
Django says "ManyToManyField" is not defined
I'm trying to use a ManytoManyField, but whenever I run makemigrations, Django returns this error: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "/home/user/app/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/home/user/app/lib/python3.5/site-packages/django/core/management/__init__.py", line 357, in execute django.setup() File "/home/user/app/lib/python3.5/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/user/app/lib/python3.5/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/home/user/app/lib/python3.5/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/home/user/app/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 665, in exec_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "/home/user/app/bin/app/app_main/models.py", line 7, in <module> class user(AbstractUser): File "/home/user/app/bin/app/app_main/models.py", line 8, in user blocking = models.ManytoManyField('self', symmetrical=False) AttributeError: module 'django.db.models' has no attribute 'ManytoManyField' Why is this happening? I have looked at other SO questions with similar issues, but they usually stem from the coder calling it "ManyToManyField" instead of "models.ManyToManyField". Thanks in advance for any help. -
Customising Django Crispy forms for formatted user input (formatted by the user)
In a Django project, I have used crispy forms to generate a form for a user to enter a title and a comment. For the comment section, I wish the user to be able to format their input (e.g add bold and italics tags, and also embed youtube videos, so use embed snippets). This is typical of a wordpress widget (admin) which allows text formatting for any text entry. Is it possible to do this with Django's Crispy forms, and if so, what is the best way forward? I am looking for suggestions for documentation, imports (any existing libraries compatible with Django?), as I as I couldn't find any, or an idea as to how to implement this manually. e.g. specifically, in which 'file' would it be implemented. I've looked at the other questions-answers, but none answers this specifically. The current post_form.html code is below {% extends "socialmedia/base.html" %} {% load crispy_forms_tags %} {% block content %} <div class="content-section"> <form method="POST"> {% csrf_token %} <fieldset class="form-group"> <legend class="border-bottom mb-4">Post your message</legend> {{form|crispy}} </fieldset> <div class="form-group"> <button class="btn btn-outline-info" type="submit">Post</button> </div> </form> </div> {% endblock content %} post_detail.html {% extends "socialmedia/base.html" %} {% block content %} <article class="media content-section"> <img class="rounded-circle … -
Django Indexes with Model Inheritance
I'm trying to add indexes for my abstract base class model so that its subclasses can also have the same index. First I had this: class Test(models.Model): id = models.BigAutoField(primary_key=True) class Meta: abstract = True indexes = models.Index(fields=['-id']) class Testing1(Test): pass class Testing2(Test): pass Traceback: File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\yoom\Code\test\indexTestingVel\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\yoom\Code\test\indexTestingVel\venv\lib\site-packages\django\core\management\__init__.py", line 357, in execute django.setup() File "C:\Users\yoom\Code\test\indexTestingVel\venv\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\yoom\Code\test\indexTestingVel\venv\lib\site-packages\django\apps\registry.py", line 114, in populate app_config.import_models() File "C:\Users\yoom\Code\test\indexTestingVel\venv\lib\site-packages\django\apps\config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "C:\Users\yoom\Code\test\indexTestingVel\venv\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\yoom\Code\test\indexTestingVel\public\models.py", line 4, in <module> class Test(models.Model): File "C:\Users\yoom\Code\test\indexTestingVel\venv\lib\site-packages\django\db\models\base.py", line 305, in __new__ new_class._meta.indexes = [copy.deepcopy(idx) for idx in new_class._meta.indexes] TypeError: 'Index' object is not iterable This is what I tried next only to get the EXACT same error: class Test(models.Model): id = models.AutoField(primary_key=True) class Meta: abstract = True class Testing1(Test): … -
Django Allauth - Add context to password reset e-mail
For this project I'm using Django Allauth to get users to signup and authenticate. To add the users "first_name" to the context of the confirmation e-mail link I've inherited from the DefaultAccountAdapter and added the first_name to the e-mail context. #adapter.py class CustomEmailAdapter(DefaultAccountAdapter): def get_email_confirmation_url(self, request, emailconfirmation): """Constructs the email confirmation (activation) url. Note that if you have architected your system such that email confirmations are sent outside of the request context `request` can be `None` here. """ url = reverse( "account_confirm_email", args=[emailconfirmation.key]) ret = build_absolute_uri( request, url) return ret def send_confirmation_mail(self, request, emailconfirmation, signup): current_site = get_current_site(request) activate_url = self.get_email_confirmation_url( request, emailconfirmation) ctx = { "first_name": emailconfirmation.email_address.user.first_name, # <-- Added first_name to the context "user": emailconfirmation.email_address.user, "activate_url": activate_url, "current_site": current_site, "key": emailconfirmation.key, } if signup: email_template = 'account/email/email_confirmation_signup' else: email_template = 'account/email/email_confirmation' self.send_mail(email_template, emailconfirmation.email_address.email, ctx) I now want to do the same for the password reset e-mail but I don't think this is possible to add this to the custom AccountAdpater. Any ideas how to add some context to the password reset e-mail, I would like to start my e-mail with "Dear John," Thanks in advance! -
django large FileField Initialization and Memory
Another service writes a lot of large Files (around 20 GB) into my Djangos MEDIA directory. Once the Files are complete, a django shell script is executed that attaches the files to a respective filefield of an associated model. Minimal Example: from django.core.files import File local_file = open("/MEDIA/big_file.dat") djangofile = File(local_file) SomeModel.SomeFileField.save('big_file.dat', djangofile) local_file.close() Can I use an approach like this on a production server, where approx. every minute 2-3 of those 20GB files are created? My worries are that the python open() or the Django File() function (which seems to use open() as well) read the whole file into memory, which would so to speak overflow my stack -
Load multiple random values from list into template
I need to apply a color class for every object I have in my template. This value must be randomly selected so there's different colors for each object. I have some code now which selects a random color from my list but it's the same for every single object in my template, which I don't want. I want it to be mixed. How can i consult this? Views: import random color_list = ['purple', 'blue', 'green', 'yellow', 'red'] colors = random.choice(color_list) return render(request, 'dashboard.html',{'color':colors,}) Template: person -
docker compose not copying any files
Quite simple: the docker-compose configuration below does not allow any files to persist after running. So when I do docker exec -i -t aas-job-hunter_web_1 ls /app -alt, I see nothing. I'm on windows 10, I've allowed mounted drives and enabled the TLS connection. I'm not sure what else to do. The thing that most confuses me is that requirements.txt is clearly copied over (since it installs it all) but it isn't there when I have a look docker exec. My directory structure is: parent/ website/ manage.py ... Dockerfile docker-compose.yml ... Dockerfile: FROM python:3.6 #WORKDIR /app # By copying over requirements first, we make sure that Docker will cache # our installed requirements rather than reinstall them on every build COPY requirements.txt /app/requirements.txt RUN pip install -r /app/requirements.txt # Now copy in our code, and run it COPY . /app EXPOSE 8000 CMD python website/manage.py runserver 0.0.0.0:8000 # CMD tail -f /dev/null # use when testing docker-compose.yml: version: '2' services: web: build: . ports: - "8000:8000" volumes: - .:/app links: - db db: image: "postgres:9.6" ports: - "5432:5432" environment: POSTGRES_PASSWORD: hunter2 Traceback: > docker-compose -f docker-compose.yml up --build Building web Step 1/6 : FROM python:3.6 ---> 0668df180a32 Step 2/6 : COPY … -
Admin Site shows the timezone wrong
Trying my hands on Django. TIME_ZONEat admin module shows different than the local time. I would like to edit the time according to the current time. Which Django file should I edit to synchronize the time? I tried the documentation on official Django website but did not help me out. -
Unable to open app on heroku. Heroku push successful
2019-05-25T11:36:36.289133+00:00 app[web.1]: File "/app/ecommerce/settings.py", line 16, in <module> 2019-05-25T11:36:36.289134+00:00 app[web.1]: import env 2019-05-25T11:36:36.289178+00:00 app[web.1]: ModuleNotFoundError: No module named 'env' 2019-05-25T11:36:36.289942+00:00 app[web.1]: [2019-05-25 11:36:36 +0000] [11] [INFO] Worker exiting (pid: 11) 2019-05-25T11:36:36.438624+00:00 app[web.1]: [2019-05-25 11:36:36 +0000] [4] [INFO] Shutting down: Master 2019-05-25T11:36:36.438708+00:00 app[web.1]: [2019-05-25 11:36:36 +0000] [4] [INFO] Reason: Worker failed to boot. 2019-05-25T11:36:36.520758+00:00 heroku[web.1]: State changed from starting to crashed 2019-05-25T11:36:36.504539+00:00 heroku[web.1]: Process exited with status 3 2019-05-25T12:23:44.883193+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=django-project-helmy.herokuapp.com request_id=f5cce178-1385-40ef-aa28-1bec8c12d412 fwd="121.7.201.198" dyno= connect= service= status=503 bytes= protocol=https 2019-05-25T12:23:45.573689+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=django-project-helmy.herokuapp.com request_id=a6a496e6-5dd6-49cf-91b5-fac3fdff9de2 fwd="121.7.201.198" dyno= connect= service= status=503 bytes= protocol=https 2019-05-25T12:28:55.739148+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=django-project-helmy.herokuapp.com request_id=c7f46f87-e1a3-4d6a-8169-15b6c6c94d8e fwd="121.7.201.198" dyno= connect= service= status=503 bytes= protocol=https 2019-05-25T12:28:56.174385+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=django-project-helmy.herokuapp.com request_id=4f0b3a7f-84bd-4d93-864e-5299625af45d fwd="121.7.201.198" dyno= connect= service= status=503 bytes= protocol=https -
how to get HttpResponse key value and get the response from some url?
I need to get a key value of HttpResponse from some URL and send the value again to the url to get some results through Restapi resp = requests.get('https://someurl.io') data = HttpResponse(resp) return data with this code i got a response like, {"status":200,"result":{"postcode":"BN14 9GB","quality":1,"eastings":515087,"northings":105207,"country":"England","nhs_ha":"South East Coast","longitude":-0.36701,"latitude":50.834955,"european_electoral_region":"South East","primary_care_trust":"West Sussex","admin_ward":"Offington","ced":"Cissbury","ccg":"NHS Coastal West Sussex","nuts":"West Sussex (South West)","codes":{"admin_district":"E07000229","admin_county":"E10000032","admin_ward":"E05007703","parish":"E43000150","parliamentary_constituency":"E14000682","ccg":"E38000213","ced":"E58001617","nuts":"UKJ27"}}} I have to send only the latitude and longitude value to some URL and get results. I would like to do this in rest api. I dont know how to get only latitude and longitude value and through the value how to get response from someurl.io. -
What is this codes means? I am not able to run the category.html which is included in index.html?
what is the meaning of list line ? can someone give me an example to solve it ? Using the URLconf defined in forum.urls, Django tried these URL patterns, in this order: 1.^admin/ 2.^$ 3.^$ 4.^$ 5.^$ 6.^$ 7. ^static/(?P.*)$ The current path, category.html, 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.