Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
In Template can I access the object from which a form in a ModelFormset was generated?
I am trying to create a view for doing a stock-take. This will update quantity and a few other things for every Stock item in a queryset. So, a ModelFormset? However, one of the things that the person doing the stocktake need to do, is check that the description of the item in the database matches the physical items. In order to do this, the view has to display a property object.description.human_description (derived from several fields with various conditionals and formattings) for the object to which the form in the formset relates. I can't see how to do this in the documentation {% for form in formset %} {{ what.human_description }} <!-- what is what? --> {{form}} {% endfor %} -
Error in deploying django app on Google cloud "google.api_core.exceptions.PermissionDenied: 403 Permission denied on resource project "
I am trying to deploy my own django app on google cloud. I'm following this documentation by Google Cloud to deploy the app. I have changed the settings.py file of my app according to the settings.py file of settings.py file of the sample app provided by google and I think this issue is due to some mistake in that setting file or maybe something else. I'm not able to solve the error after lots of attempts. please help me thank you Settings.py file from pathlib import Path import os import io from urllib.parse import urlparse import environ from google.cloud import secretmanager # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # [START gaestd_py_django_secret_config] env = environ.Env(DEBUG=(bool, False)) env_file = os.path.join(BASE_DIR, ".env") if os.path.isfile(env_file): # Use a local secret file, if provided env.read_env(env_file) # [START_EXCLUDE] elif os.getenv("TRAMPOLINE_CI", None): # Create local settings if running with CI, for unit testing placeholder = ( f"SECRET_KEY=a\n" f"DATABASE_URL=sqlite://{os.path.join(BASE_DIR, 'db.sqlite3')}" ) env.read_env(io.StringIO(placeholder)) # [END_EXCLUDE] elif os.environ.get("GOOGLE_CLOUD_PROJECT", None): # Pull secrets from Secret Manager project_id = os.environ.get("GOOGLE_CLOUD_PROJECT") client = secretmanager.SecretManagerServiceClient() settings_name = os.environ.get("SETTINGS_NAME", "django_settings") name = f"projects/{project_id}/secrets/{settings_name}/versions/latest" payload = client.access_secret_version(name=name).payload.data.decode("UTF-8") env.read_env(io.StringIO(payload)) else: raise Exception("No local .env or GOOGLE_CLOUD_PROJECT detected. No secrets found.") … -
How to find the token (phrase, word), not the sequence of characters in Django text data model
In Django data model, Consider that we have a text like this: I am going to go somewhere. If I use the Entity.objects.filter(column__contains="go"), it will return going word as well. But I only want the go word to be returned. Is there any solution other than using Full Text Search? -
Why would I still get RestrictedError in Django when related records deleted?
I have the following code in a unit test: serum_sample.msruns.all().delete() print(f"THIS SHOULD BE 0: {serum_sample.msruns.count()}") serum_sample.delete() I get out: THIS SHOULD BE 0: 0 In the code, I've deleted the related records that have the RESTRICT relationship, but I still get this error: django.db.models.deletion.RestrictedError: ("Cannot delete some instances of model 'Sample' because they are referenced through restricted foreign keys: 'MSRun.sample'.", {<MSRun: MS run of sample BAT-xz971 with Default by anonymous on 2021-04-29>, <MSRun: MS ... The relation is: class MSRun(HierCachedModel, MaintainedModel): ... sample = models.ForeignKey( to="DataRepo.Sample", on_delete=models.RESTRICT, related_name="msruns", help_text="The sample that was run on the mass spectrometer.", ) I thought that to be able to delete the sample, all I had to do was delete the MSRun records that link to it... Why would this not be the case? -
Django queryset iteration
I need to iterate through the date entries and want compare them to other dates, but I get only one value, what am I doing wrong ? @property def mathe2(self): for i in self.lehrertabelle_set.all(): return i.from_date -
If i am trying to create a diray app using django, how can i get it show show me different diary entries based on the current logged in user?
im currently in the process of building a diary app in django. I have created multiple users (e.g User A and User B). However, when user A logs in, user A can see User B's entries. How can i lock it down, so only User B can see User B's entries and when User A logs in, User A can have a personal entry view? (do i need to create a different view?) views.py for my diary app: from django.urls import reverse_lazy from django.views.generic import ( ListView, DetailView, CreateView, UpdateView, DeleteView, ) from .models import Entry from django.contrib.auth.decorators import login_required from django.shortcuts import render, redirect # Create your views here. class ELV(ListView): model = Entry queryset = Entry.objects.all().order_by("-date_created") #takes all the entries and orders it by date template_name = 'entries\entry_list.html' class EDV(DetailView): model = Entry template_name = 'entries\entry_detail.html' class ECV(CreateView): model = Entry fields = ["title", "content"] success_url = reverse_lazy("entry-list") template_name = 'entries\entry_form.html' class EUV(UpdateView): model = Entry fields = ["title", "content"] template_name = 'entries\entry_update_form.html' def get_success_url(self): return reverse_lazy( "entry-detail", kwargs={"pk": self.object.pk} ) class EntryDeleteView(DeleteView): model = Entry success_url = reverse_lazy("entry-list") template_name = 'entries\entry_delete.html' Does it have anything to do with user sessions? - i'm not sure, please help! -
How to deploy django backend from subfolder of github repository in Railway?
I have created a project where I have my django backend and nextjs frontend in the same repository in different folders, I want to know if there is a way to deply my django backend from its subfolder and not have to make a separate repository for my backend. I put my requirements.txt, runtime.txt and Procfile in the root folder and made the Procfile point to backend.myblog.wsgi but it didn't work. -
NOT NULL constraint failed:
I am creating a website where people under the topics set by the administrator will be able to make their entries. Each record is linked to a user account, but when creating a new record, an error appears - NOT NULL constraint failed: menu_description.topic_id menu/views.py from django.shortcuts import render, redirect from .models import Topic, Description from .forms import DescriptionForm from django.contrib.auth.decorators import login_required def index(request): topic = Topic.objects.all context = {'topic': topic} return render(request, 'Menu/Menu.html', context) @login_required def description(request, topic_id): topic = Topic.objects.get(id=topic_id) description = topic.description_set.filter(owner=request.user).order_by('date_added') context = {'description': description, 'topic': topic} return render(request, 'Menu/Description.html', context) @login_required def new_description(request, topic_id): topic = Topic.objects.get(id=topic_id) if request.method != 'POST': form = DescriptionForm() else: form = DescriptionForm(data=request.POST) if form.is_valid(): new_description = form.save(commit=False) new_description.owner = request.user new_description.save() return redirect('description', topic_id=topic_id) context = {'topic': topic, 'form': form} return render(request, 'Menu/new_description.html', context) @login_required def edit_description(request, entry_id): description = Description.objects.get(id=entry_id) topic = description.topic if request.method != 'POST': form = DescriptionForm(instance=description) else: form = DescriptionForm(instance=description, data=request.POST) if form.is_valid(): form.save() return redirect('description', topic_id=topic.id) context = {'description': description, 'topic': topic, 'form': form} return render(request, 'Menu/Edit_description.html', context) @login_required def delete_description(request, description_id): description = Description.objects.get(id=description_id) topic = description.topic description.delete() return redirect('description', topic_id=topic.id) my code fsdfsfdsfsfas sdfsadklnfajsnflksanfgiljsglidsehseoigusdhoigusdfhoigsdhoigudsfhgoidsfhgokjfdshdsoiughsodfighosidhgosidfghsdoiughdfoigushdfiogsfdhikg menu/models.py from django.db import models from … -
Django ModelForm `fields_for_model` references `_default_manager`, which is None
I am working on a Django project using standard models and ModelForms. I have the following models and forms: # models.py class ApplicationCore(TimestampedModel): user = models.ForeignKey(User, related_name="applications", on_delete=models.PROTECT) organization = models.ForeignKey(Organization, related_name="applications", on_delete=models.PROTECT) overall_status = models.TextField(choices=ApplicationOverallStatus.choices, default=ApplicationOverallStatus.in_progress.value) class Meta: abstract = True ... class Application(ApplicationCore): applicant = models.OneToOneField(ApplicantInformation, null=True, on_delete=models.PROTECT) item_one = models.OneToOneField(ApplicationItemOne, null=True, on_delete=models.PROTECT) item_two = models.OneToOneField(ApplicationItemTwo, null=True, on_delete=models.PROTECT) ... class ApplicationItemOne(ApplicationItemCore): choice = models.TextField(choices=ApplicationItemOneChoice.choices, null=True, blank=True) co_applicants = models.ForeignKey(ApplicantInformation, null=True, related_name="item_ones", on_delete=models.PROTECT) # forms.py class ApplicationForm(forms.ModelForm): has_item_one = False has_item_two = False def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.has_item_one = self.instance.item_one_id is not None self.has_item_two = self.instance.item_two_id is not None class Meta: model = Application fields = ('applicant',) class ApplicationItemOneForm(forms.ModelForm): class Meta: model = ApplicationItemOne fields = '__all__' When I try to run any Django command e.g. python manage.py makemigrations I get the following error: File "/home/noah/dev/github/silica/silica-docs/django/sample-app/application/urls.py", line 5, in \<module\> from application import views File "/home/noah/dev/github/silica/silica-docs/django/sample-app/application/views.py", line 7, in \<module\> from application.forms import CreateApplicationForm File "/home/noah/dev/github/silica/silica-docs/django/sample-app/application/forms.py", line 19, in \<module\> class ApplicationForm(forms.ModelForm): File "/home/noah/.virtualenvs/sample-app/lib/python3.8/site-packages/django/forms/models.py", line 261, in __new__ fields = fields_for_model( File "/home/noah/.virtualenvs/sample-app/lib/python3.8/site-packages/django/forms/models.py", line 183, in fields_for_model formfield = f.formfield(\*\*kwargs) File "/home/noah/.virtualenvs/sample-app/lib/python3.8/site-packages/django/db/models/fields/related.py", line 1060, in formfield return super().formfield(\*\*kwargs) File "/home/noah/.virtualenvs/sample-app/lib/python3.8/site-packages/django/db/models/fields/related.py", line 991, in formfield 'queryset': self.remote_field.model.\_default_manager.using(using), AttributeError: … -
How to use Selenium and django test case
I'm a newbie in the use of Selenium. And I got a problem using it. If I understand correctly, when I run my test suite (./manage.py test), django will create a new database for run the test suite. But if I include Selenium test in those test suite, it seems that Selenium connect to my server and access to my real database, which make my test failed. What I'm trying to do is either be able to use the real database with django test or be able to use test database with Selenium. Is there a solution to my problem ? -
Add stylings to a django email template
I need help on how to go about adding CSS stylings to a Django email template. Django version = 4.0+ -
problem with SSL Version when connecting Rails API to Django API
I have inherited an application where there is a legacy API built with Django that serves up most of the resource and a team that was in the process of migrating the API over to a Rails. The front end currently talks to the Rails app and if the resource is not available, the Rails API will query for it from the Django API. I am trying to get this set-up functioning in my local environment however I am getting an SSL version issue. Wondering if anyone can help with this issue? Processing by Api::LegacyApiController#unknown as HTML Parameters: {"path"=>"v1/users"} Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.0ms | Allocations: 1493) OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=error: wrong version number): Here is the controller for the fall back for when the Rails API doesn't have the resource class Api::LegacyApiController < ActionController::Base include ReverseProxy::Controller skip_before_action :verify_authenticity_token def unknown #noinspection RubyResolve host = Rails.application.config.legacy_api_host headers = { 'Host' => host, 'Accept' => request.headers.to_h['HTTP_ACCEPT'] } reverse_proxy "https://#{host}", headers: headers end end Rails API running on localhost:3000 Django API running on localhost:8000 the legacy_api_host is currently set to 'localhost:8000' Thanks for the help everyone. Unfortunately I am a pretty junior developer and I haven't tried … -
Django: Javascript not loading extra rows
I have a page that allows a doctor to create a prescription. This page as a form that allows you to add as many rows as you want to add elements to your prescription. I will share with you the view and html template. I replicated the exam same thing for creating another type of prescription (lab analysis). This time, the button does not want to add more rows, even though I used the exact same code, and I will tell you exactly what breaks it, but I do not know how to fix it. Here is the code for the first one (the one that works): view: @login_required def createPrescription(request): [...] # ommited because unrelated drugs = Drug.objects.all() return render[...] # ommited because unrelated HTML: <!-- PAGE-HEADER END --> <form method="POST" id="presForm"> {% csrf_token %} [...] # ommited because unrelated <div class="card"> <div class="card-header"> <div class="card-title">Eléments de l'ordonnance</div> </div> <div class="card-body"> <table id="myTable" class="table order-list"> <thead> <tr> <td>Médicament</td> <td>Dosage</td> <td>Posologie</td> <td>Durée</td> <td></td> </tr> </thead> <tbody> <tr> <td class="col-5"> <div class="row"> <div class="col-6"> <input class="form-control mb-4" placeholder="Nom du médicament" type="text" name="medicament0"> </div> <div class="col-6"> <div class="form-group"> <select class="form-control select2-show-search form-select" id="medicament-id0" name="listemedicament0"> <option value="0">Ou choisir de la liste</option> {% for … -
Writing a custom user authentication with email using django
This code is to create a custom authentication which accepts email and password to login instead of username and password. Anytime i use the "python manage.py createsuperuser" and input my details, i always get an error message which says: "return self._create_user(email, password, first_name, last_name, mobile, password, **extra_fields) TypeError: CustomUserManager._create_user() takes 6 positional arguments but 7 were given" How do i go about this models.py from django.db import models from datetime import datetime from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager class CustomUserManager(BaseUserManager): def _create_user(self, email, password, first_name, last_name, mobile, **extra_fields): if not email: raise ValueError("Email must be provided") if not password: raise ValueError("Password must be provided") user = self.model( email = self.normalize_email(email), first_name = first_name, last_name = last_name, mobile = mobile, **extra_fields, ) user.set_password(password) user.save(using=self._db) return user def create_user(self, email, password, first_name, last_name, mobile, **extra_fields): extra_fields.setdefault("is_active", True) extra_fields.setdefault("is_staff", True) extra_fields.setdefault("is_superuser", False) return self._create_user(email, password, first_name, last_name, mobile, password, **extra_fields) def create_superuser(self, email, password, first_name, last_name, mobile, **extra_fields): extra_fields.setdefault("is_active", True) extra_fields.setdefault("is_staff", True) extra_fields.setdefault("is_superuser", True) return self._create_user(email, password, first_name, last_name, mobile, password, **extra_fields) class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(db_index=True, unique=True, max_length=254) first_name = models.CharField(max_length=250) last_name = models.CharField(max_length=250) mobile = models.CharField(max_length=50) address = models.CharField(max_length=250) is_staff = models.BooleanField(default=True) is_superuser = models.BooleanField(default=True) is_superuser = models.BooleanField(default=False) objects = … -
How to create third party login API in Django to save session details?
I am trying to build an external API in django, such that any third party application can log into my Django application with their specific username and password, and further use all the authenticated calls in the Django application. As I understand, in Django, there is a GET call that creates the csrf_token, and an op_browser_state token, which is saved in Cookies. Once the user enters the username and password, and selects login. Internally, the session id is added via the middleware between request and response, after the auth.login is successful, with the username and the password. The session_id, along with the csrf_token and op_browser_state are saved in the cookies, and used for all the further calls made via Django APIs, which may be using SessionAuthentication. So, if I am able to save the cookies for the session__id, csrf_token and op_browser_state for the Django application hostname. I should be able to solve it. I tried creating an external API, which does the login for the given combination of username and password, and returns the values of csrf_token and session_id as generated by the API. However, this didn't work, since looks like it is not storing the cookies for the Django … -
form ModelMultipleChoiceField returns null [IntegrityError]
Using Django 4.0.5, Python 3.10.5. I've created a form which should return a "match" model object. It properly displays "players" to choose from on a form, although after trying to save it I receive an IntegrityError, that I supposedly violate my not-null constraint. The failing row details are below: DETAIL: Failing row contains (2bc3f5f6-3249-4823-ae76-90fe44dc9c89, 2022-09-09, null, null). The values that I'm passing is UUID, date, and two teams that are ManyToManyFields containing Player objects. I can't seem t understand why both teams return empty. Any help is appreciated, posting relevant code below. If anything besides that is required, I'll update it. forms.py [matches app] class PlayerChoiceField(forms.ModelMultipleChoiceField): def label_from_instance(self, obj: Player) -> str: return obj.nickname class MatchForm(forms.ModelForm): date = forms.DateField(widget=forms.SelectDateWidget(), initial=datetime.date.today, label="Match Date") blackTeamPlayers = PlayerChoiceField(queryset=Player.objects.all(), widget=forms.CheckboxSelectMultiple) whiteTeamPlayers = PlayerChoiceField(queryset=Player.objects.all(), widget=forms.CheckboxSelectMultiple) class Meta: model = Match fields = ['date', 'blackTeamPlayers', 'whiteTeamPlayers'] models.py [matches app] class Match(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) date = models.DateField(null=False) blackTeamPlayers = models.ManyToManyField( Player, related_name='%(class)s_black_team_players' ) whiteTeamPlayers = models.ManyToManyField( Player, related_name='%(class)s_white_team_players' ) views.py [matches app, relevant part] class MatchCreateView(CreateView): template_name: str = 'add_match.html' form_class = MatchForm queryset = Match.objects.all() def form_valid(self, form): return super().form_valid(form) models.py [players app] class Player(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) firstname … -
How to get Percentile in Postgresql same as scipy.stats.percentileofscore
I have a table that contains "id" and "score". id | score 1 | 10 2 | 20 3 | 30 4 | 40 How can I find the percentiles of scores using PostgreSQL to get an expected output of: id | score | percentile 1 | 10 | 25.0 2 | 20 | 50.0 3 | 30 | 75.0 4 | 40 | 100.0 In python one way to solve this would be using scipy.stats.percentileofscore >>>from scipy import stats >>>stats.percentileofscore([1, 2, 3, 4], 3) 75.0 but I'd like a way to do this with PostgreSQL I tried using PERCENT_RANK, "%(function)s() OVER (ORDER BY %(expressions)s DESC) *100" But it has not returned the same value as scipy.stats.percentileofscore -
'ManyRelatedManager' object has no attribute 'models'
In my Django+ DRF app I am having trouble adding a field to serializer when the field is from another model. My Order model has the field 'car_make' and I need to also add the field 'car_model' when serializing the order data ('car_model' comes from the CarModel model), and I add it using SerializerMethodField. Instead of getting the data (the name of the car model), I get an error "'ManyRelatedManager' object has no attribute 'models'". I don't get why this does not work. What is the problem with my code? Thanks in advance! Here is my code: models.py from django.db import models import datetime class CarMake(models.Model): # Toyota, Honda, etc. make_name = models.CharField(max_length=20) class CarModel(models.Model): # Corolla, Civic etc. model_name = models.CharField(max_length=20) make = models.ForeignKey(CarMake, on_delete=models.CASCADE, related_name='models') order = models.ForeignKey('Order', on_delete=models.CASCADE, related_name='models') class Order(models.Model): color = models.ForeignKey(Color, on_delete=models.CASCADE, related_name='orders') car_make = models.ManyToManyField(CarMake, through='CarModel', related_name='orders') quantity = models.PositiveIntegerField() ordered_at = models.DateField(default=datetime.date.today) views.py from rest_framework import viewsets from .models import CarMake, CarModel, Color, Order from .serializers import CarMakeSerializer, CarModelSerializer, ColorSerializer, OrderSerializer class CarMakeViewSet(viewsets.ModelViewSet): queryset = CarMake.objects.all() serializer_class = CarMakeSerializer class CarModelViewSet(viewsets.ModelViewSet): queryset = CarModel.objects.all() serializer_class = CarModelSerializer class OrderViewSet(viewsets.ModelViewSet): queryset = Order.objects.all() serializer_class = OrderSerializer serializers.py from rest_framework import serializers from .models … -
Show output of a python sciript as website
I am very new to Python. I just need to see the output of import os for k,v in os.environ.items(): print(k,v) as a website, means <server_ip_address>:port. It will be so kind of you if you can help me by doing this. I dont know very much about flask and django etc. -
Recipe creation and modification not working correctly
I'm trying to implement a recipe creation function. The data is created and then you can get it, with a post request, changes are also made. But when creating a site, a redirect does not occur and gives such an error. AttributeError: Got AttributeError when attempting to get a value for field amount on serializer AmountIngredientForRecipePostSerializer. The serializer field might be named incorrectly and not match any attribute or key on the Ingredient instance. Original exception text was: 'Ingredient' object has no attribute 'amount'. view class RecipesViewSet(viewsets.ModelViewSet): queryset = Recipe.objects.all().order_by('id') filter_backends = (DjangoFilterBackend,) filter_class = RecipeFilter pagination_class = PagePagination permission_classes = (OwnerOrAdminOrSafeMethods,) def get_serializer_class(self): if self.request.method == 'GET': return RecipeGetSerializer return RecipePostSerializer @staticmethod def post_or_delete(request, model, serializer, pk): if request.method != 'POST': get_object_or_404( model, user=request.user, recipe=get_object_or_404(Recipe, id=pk) ).delete() return Response(status=status.HTTP_204_NO_CONTENT) serializer = serializer( data={'user': request.user.id, 'recipe': pk}, context={'request': request}) serializer.is_valid(raise_exception=True) serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) serialaizer class AmountIngredientForRecipePostSerializer(serializers.ModelSerializer): id = serializers.PrimaryKeyRelatedField(queryset=Ingredient.objects.all()) amount = serializers.IntegerField(min_value=1) class Meta: model = AmountIngredient fields = ('id', 'amount') class RecipePostSerializer(serializers.ModelSerializer): author = CostomUserSerializer(read_only=True) ingredients = AmountIngredientForRecipePostSerializer(many=True) tags = serializers.PrimaryKeyRelatedField( queryset=Tags.objects.all(), many=True) image = Base64ImageField() class Meta: model = Recipe fields = ('id', 'author', 'ingredients', 'tags', 'image', 'name', 'text', 'cooking_time') @staticmethod def create_ingredients_tags(recipe, ingredients, tags): for ingredient … -
Writing custom url model field in Django
I am creating one model called Profile in which i have to add a url field for telegram profile. It takes username as input, but in output it should look like this: https://t.me/{username}. How I can create custom model field for this problem. Thanks by the way My expectation is that, you only enter username, but in output it comes with prefix https://t.me/ and full url path will be https://t.me/{username} -
How to delete corresponding row with ManyToMany relationship in Django?
I am trying to make a basic pizza app with two API's, toppings and pizzas. When I delete a topping, I would like for the corresponding pizzas to also be deleted since the topping is no longer available. As it currently stands, when I delete a topping it just keeps an empty pizza object. Models: class Toppings(models.Model): name = models.CharField(max_length=60, unique=True) def __str__(self): return self.name class Pizza(models.Model): name = models.CharField(max_length=60, unique=True) topping = models.ManyToManyField(Toppings, max_length=60, related_name="toppings") def __str__(self): return (self.name, self.topping) Serializers: class PizzaSerializer(serializers.ModelSerializer): toppings = ToppingsSerializer(read_only=True, many=True) class Meta: model = Pizza fields = "__all__" class ToppingsSerializer(serializers.ModelSerializer): class Meta: model = Toppings fields = "__all__" Pizza.views and Toppings.views are almost the same so I just included Pizza. class PizzaList(generics.ListAPIView): queryset = Pizza.objects.all() serializer_class = PizzaSerializer class PizzaCreate(generics.CreateAPIView): queryset = Pizza.objects.all() serializer_class = PizzaSerializer class PizzaUpdate(generics.UpdateAPIView): queryset = Pizza.objects.all() serializer_class = PizzaSerializer class PizzaDelete(generics.DestroyAPIView): queryset = Pizza.objects.all() serializer_class = PizzaSerializer Please let me know if you need anything else. Thank you. -
Implementing Apple Sign in using django-allauth
I am currently implementing social login using django-allauth. I've had no problems implementing social logins like Google, Facebook and etc. However, when it came to Apple, the package doesn't seem to work properly. I've been testing the logins using https. Also, I've completed settings in Apple Developer and Django Admin. The below is the capture of my login page. when I click on apple icon, it gets redirected to apple page to proceed. When I enter the apple login and complete authentication on apple site, the browser throws Server Error(500). I believe my settings for apple sign-in have been correct. The below is my admin settings for apple sign-in. I tried to search the references on the internet but I couldn't find anyone experienced the same issue. I have no idea on how to resolve this issue nor do I know the way to find where the error is coming from. Could anyone suggest any method on how to implement apple sign-in using django-allauth package? Thanks, -
Query time in django debug toolbar
I see time of query QUERY = 'SELECT COUNT_BIG(*) AS [__count] FROM ... in Django debug toolbar. Is it pure perfomance of database or dirty time that includes handling of query by Django and third-party libraries? -
Unable to change input field text content with javascript
I'm trying to change the text inside an input field to username. The id for the field is is_username. And in my Javascript file I've tried document.getElementById("id_username").innerHTML = "Username"; document.getElementById("id_username").value = "Username"; document.querySelector(".id_username").textContent = "Username"; None are working... This site runs on django. I know with html you can use placeholder to achieve this but these fields are created using django tags. Any ideas? I did try using these methods on a normal html input field and also had no luck.