I am currently trying to save a Django object. My code looks like this boxscore = BoxScore.objects.create(**defaults) print(defaults) input(boxscore) Here's the output: {'away_first': 0, 'away_second': 6, 'away_third': 7, 'away_fourth': 17, 'away_final': 30, 'home_first': 0, 'home_second': 7, 'home_third': 0, 'home_fourth': …
I have tokens stored in the Django Database Cache. I want to periodically refresh the tokens i.e. after every 5 min. Refreshing involves checking the token validity by calling an External service API and deleting all the tokens which are …
I have a django model with a couple of subtypes which until now I've been handling explicitly. Each record is uniquely identified by three fields: class Entity: type = CharField(max_length=3) released_at = DateTimeField() number = IntegerField() I use a …
We have a website called RentYug on which people can give or take anything on rent. For this, we are taking contact information like mobile number and some other details of renter (who is giving Something on rent). But we …
Am building a simple nearby shops application that lists the shops closest to a user’s location using django and GeoDjango. To list the shops, i want to get a user's location from their browser and then filter the nearest shop …
I use ezhc and pandas to generate data for heatmap def industry_heatmap(csv): df = pd.read_csv(csv).set_index('Industry').groupby(level=0).mean() idx, col, data = hc.build.series_heatmap(df) … return idx, col, data return json However as a result of pandas 1.3.1 deprecating pandas.core.index... C:\Users\lib\site-packages\ezhc\build.py, line 338, …
Given some simple models, including one with a foreign key: class Entry(models.Model): blog = models.ForeignKey(Blog, on_delete=models.CASCADE) headline = models.CharField(max_length=255) body_text = models.TextField() If I have an arbitrary queryset of the Entry objects, say my_entries_queryset Entry.objects.filter(...). How …
I have a simple model: class Expense(models.Model): ... price = models.DecimalField(decimal_places=2, max_digits=6) is_fixed = models.BooleanField(default=False) I'm trying a simple query to group_by and aggregate: >>> from expenses.models import Expense >>> from django.db.models import Sum >>> …
I'm trying to explore Django and djgono for fun. I want to create a document in the db which is similar to the following document: { "title": "Djongo - trying to create a list field", "body": "I cannot do basic …
I've been trying to execute a simple endpoint I made available with Django from my front-end, React. It's a POST request that checks if a URL exists. It's just a demo so I can get familiar with the full stack …
I am working with django an Tinymce. I have an issue with uploading image to s3 bucket from the Tinymce textarea. The same code does the uploading perfectly on my local. but when deployed, it doesnt get to upload. @csrf_exempt …
Should i dockerize Django app as a root user? If yes how can i set up non-root user for Django? Because in node.js app should have USER:node which is a better practice. Code example from official docker page which does …
I'm new to django and still trying to figure out logic. I watched a bunch of videos and I know how to create those examples but I'm not quite there. I'll explain what I want and maybe someone can explain …
I am using django rest framework. From backend everything is fine. But when i display my img src with my conditions.It does not display my image source but My video and audio src displays properly with conditions but img src …
The exact error that I got is: Forbidden You don't have permission to access this resource. In /etc/apache2/sites-enabled/portfolio.conf, I copied 000-default.conf and added the following lines: Alias /static /home/kailicen/portfolio/static <Directory /home/kailicen/portfolio/static> Require all granted </Directory> <Directory /home/kailicen/portfolio/portfolio> <Files …
I am working on a network monitor Django website and want to implement tx and rx monitoring commands. wifi_tx = "apstats -a | grep -i 'Tx Data Bytes' | awk '{print $5}'" wifi_rx = "apstats -a | grep -i 'Rx …
I am trying to generate land ownership certificate using python/django. It needs to include 2d map of the land and I was wondering if there was a way/tool in python to draw it. Thanks in advance
I have a form like <form id="..." class="...">. Inside this form, I have 2 buttons, which are tracked with JS like: function one(event) { $.ajax({ type: 'POST', url: "...", data: { 'csrfmiddlewaretoken': csrf[0].value, }, ... }) } function two(event) { …
I'm trying to save data into my PostgreSQL database but I seem to get an error on the category_id column that it's null. All other data seems to be submitted correctly but I keep getting this error. Null value in …
I've tried numerous ways to fix this error and I can't seem to solve it. I have a form for a user profile, the profile automatically gets created when the user registers and they receive a default photo until they …
I've been searching through StackOverflow about this topic and haven't found anything updated so I'm asking again: What is the best practice to log when using celery? I've tried many ways and it still doesn't work. Also when I'm trying …
I have two models App and Country and there is a many to many field in App to country(the other_countries field) . class Country(models.Model): name = models.CharField(max_length=100, blank=False, null=False) numeric = models.BigIntegerField(blank= True, null= True) key = models.CharField(max_length= 5, blank= …
serializer ///////////////////////////////////////////////////////////////////////////// class CommentSerializer(serializers.ModelSerializer): response_to = CommentSerializer2(many=False, read_only=True) # like = LikeSerializer(many=False, read_only=True) like = LikeSerializer(many=False) class Meta: model = Comment fields = ['id', 'user', 'text', 'created', 'response_to', 'post', 'like'] def create(self, validated_data): comment = Comment(user=self.context["user"], **validated_data) comment.save() …
I want users to be able to share posts in my web app. How can I automatically generate a unique url in the background while doing this using a django form. I tried a little myself but failed. The reason …
A little background-- Our deployment process is now on using gunicorn, so that means specifically our .wsgi file will be used. But since we never used our .wsgi file when we ran it on our local pycharm to view the …
Front I request to the server with something like: { "name": "myname" } Back in request.data <QueryDict>: {"name": ["myname"]} And I had to set this for param, val in params.items(): val = …
I have created a MySQL Database in PythonAnywhere but the problem is that it is taking too long to show results. As shown in the image below, it is taking almost 25 seconds to show the databases which I think …
I would like to look up users by their email without worrying about uppercase letters. How would I do this? I tried customer = Customer.objects.get(email__lower="test@gmail.com") and got this error. django.core.exceptions.FieldError: Unsupported lookup 'lower' for EmailField or join on the …
When I install django or django packages every time I get this error.Pipfile.lock does't occur.Is it a serious problem?If it is, how can ı fix it? <img …
Hello I am new in the community and in the world of programming so I hope you can excuse my ignorance. I'm creating an Instagram-style application with Django 3.2.5. Where users have profiles to visit and upload photos. I am …
I am trying to make website which shows the judgements of various cases based on some conditions. I pushing the data from database, where i upload the title of the judgment and the contents of the judgement. In the html …
I'm in this page: Filling the details The link of orange image is https://upload.wikimedia.org/wikipedia/commons/c/cb/Oranges_white_background.jpg When I'm pressing 'save' it gives me this: Error message Couldn't understand the issues I tried various …
I'm working on a kanji website with Django templates. I have a dictionaries made out of an external xml. I set xml tags as keys. Here is an example of one of those dicitionaries (which casually happens to be about …
Can any one help me how to do django project with Eureka server end to end proper implementation
I am trying to clone an existing item exactly as is, make edits, and save the new version in the admin. However, I do not want to pre-fill specific fields. I need to leave those specific fields empty in the …
I'm newbie to Django. I'm stuck at one thing that, valueError at /login/. I've tried my best to search and try to solve this but i didn't find my problem solution. In Following First Code Sample From Which I Got …
Models.py from django.db import models from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager from django.conf import settings from django.db.models.signals import post_save from django.dispatch import receiver from rest_framework.authtoken.models import Token @receiver(post_save, sender=settings.AUTH_USER_MODEL) # creates token when user registers def create_auth_token(sender, instance=None, created=False, **kwargs): …
I'm working with Python 3, Django and the xhtml2pdf package. I want to create a PDF from an HTML string, but I don't want to write the PDF on disk, but rather just to get its bytes, as in using …
I have the following code in one of my templates: var id = "{{a.id}}"; $.ajax({ url :'{% url 'this:dashboard' id %}',, type : 'POST', data : { }, }); I get the following error? Reverse for '' with …
Как правильно сделать отображение фотографии в тексте статьи на Django так, чтобы в админке можно было вставлять 1 или несколько фото в разные места статьи?