Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django and post request to an external API in different views
So i want to create a Django App where my users can post data through a form and make a post request to an external API, but getting the response in the same page/view For example, i have my view class Home(TemplateView): template_name: 'home/index.html' And i have my index.html: <form id="formdata" > <select id="options"> <option id="sku">Option 1</option> <option id="sku2">Option 2</option> </select> <input name="number" type="text" id="number"> <select id="price"> <option id="price1">$5</option> <option id="price2">%10</option> </select> <button type="button" data-loading-text="enviando..." onclick="submitInfo()">Send</button> </form> Let's ignore the fact HTML may be wrong, it is a basic structure of a form with selects and input field, but note that i need to pass "product", "number" and "price" as parameters in the post request. The thing is that when the user clics on the submit button, they make a post request to an external api, i know i can do int with JavaScript using fetch, but the thing is that i need to pass my personal Token Key in the body params, also i'd like to hide the real api url hiding it with an url of my website, for example: www.myurl.com/my-api-call So i'm thinking about creating a "external_api_view" with post request, something like this: import requests import time … -
Vuejs axios.post method gives wbs disconnected error in console
I keep getting this error [WDS] disconnected! in the console when I try to run axios.post. I have done my research so I know that the The problem seems to be that I have not included the port number in url webpack-dev-server/client?http://127.0.0.0/ However I do not know how to make this change. -
Need help on checking/unchecking a checkbox based on the passed data
I am creating a website that a patient can manually insert their data and save into a database. Then, the data can be accessed and be modified like an “edit view”. I am using django. I need help on displaying the saved data on the html. I was able to figure out how to display the original data of the patient on the input that are text or integers. However, I can’t find a way to display the original data on the checkbox. First, I will search the patient’s name After searching the patient’s name, I would like the checkbox to be checked based on the data Before and After Could you help me on coding for the html? users = patient’s data form = form field to get an input Any help will be greatly appreciated. Thank you in advance. **** Need to modify {form.q1}} and {{form.q2}} to be checked or unchecked based on user.q1 and user.q2**** *user.q1 is MultipleChoiceField (this is the most troubled one) * *user.q2 is a true/false data * modify_patient.html <style> table { table-layout: fixed; font-family: arial, sans-serif; border-collapse: collapse; width: 80%; } th.one, th.three, { width: 15%; background-color: #dddddd; } th.two, th.four { width: … -
Baffling error filtering Django objects of derived class by values in foreign key linked class
An app I am converting from Django 1.10 to 3.0 contains classes defined as follows (including only relevant fields) : class DataSet(models.Model): ::: class SurveyRunDataSet(DataSet): survey_run = models.ForeignKey('survey.SurveyRun', null=True, on_delete=models.CASCADE, ..) ::: But the following call, which worked fine at Django 1.10, now fails at Django 3.0 : survey_run_id = .. report_ids = (SurveyRunDataSet.objects. filter(survey_run_id=survey_run_id,report__report_type=AnalysisReport.SUMMARY). values_list('report_id', flat=True).distinct()) The error is : Cannot resolve keyword 'survey_run_id' into field. Choices are: aggregatedataset, filtereddataset, flush_date, id, materalised_source_data_set, materialiseddataset, name, primary_dataset, psession_source_data_set, psessiondataset, report, report_id, source_data_set, surveyrundataset Most of the above choices are other classes that inherit from "DataSet". So Django goes delving upwards in a bizarre wrong direction in the class structure, while missing a field item which is right in front of its nose, in the very model the objects.filter() is being applied to. It makes absolutely no sense! The model tables in postgres are exactly as expected : # \d dataset_surveyrundataset dataset_ptr_id | integer | not null status | character varying(10) | not null base_dataset | boolean | not null schema_mapping | text | not null survey_run_id | integer | "dataset_surveyrundat_survey_run_id_8e235a8a_fk_survey_su" FOREIGN KEY (survey_run_id) REFERENCES survey_surveyrun(id) DEFERRABLE INITIALLY DEFERRED # \d survey_surveyrun id | integer | not null default nextval('survey_surveyrun_id_seq'::regclass) ::: … -
i stack over and over in djjango
i watched few videos to learn how to use Django. a lot of them coming older version of Django and because im a beginner in Django so it makes it harder. the problem is that in urls.py file they are showing how to make it with "url" way and i have the newer version of Django which is showing me with "path" way. what i did wrong here that it does not showing me: from django.contrib import admin from django.urls import path from adoptions import views urlpatterns = [ path('admin/', admin.site.urls), path("", views.home, name = "home"), path("adoptions/(\d+)/", views.pet_detail, name = "pet_detail"), ] cause what i actually did, i looked on the tutorial and implemented on the path. maybe i did it wrong i dont know. and this is not the first time that i stack on the same place. -
After validation error, keep user input using django
After validation errors appear - Django form, how do I retain the inputs that the user had entered? I didn't use {{form}} , {{form.as_p}}, {{form.as_table}} but manually outputed the form. -
How to upload and display videos on django
I have been trying to add a view that uploades videos and displays them in the main template, well while adding code, I realized that the view that uploades the file isn't being rendered while the view that shows the uploded file in the template gets rendered but it doesnt show anything because nothing is being uploded. I dont know where the error might be but I think it is on the views.py, maybe the urls.py. views.py def upload(request): if request.method == 'POST': form = PostForm(request.POST, request.FILES) if form.is_valid(): instance = form.save(commit=False) instance.user = request.user instance.save() return redirect('home') print('succesfully uploded') else: form = PostForm() print('didnt upload') return render(request, 'home.html', {'form': form}) def home(request): contents = Post.objects.all() context = { "contents": contents, } print("nice") return render(request, 'home.html', context) urls.py urlpatterns = [ path('', views.home, name='home'), path('upload', views.upload, name='upload'), ] models.py class Post(models.Model): text = models.CharField(max_length=200) video = models.FileField(upload_to='clips', null=True, blank="True") user = models.ForeignKey(User, related_name='imageuser', on_delete=models.CASCADE, default='username') def __str__(self): return str(self.text) forms.py class PostForm(forms.ModelForm): class Meta: model = Post fields = ('text', 'video') exclude = ['user'] home.html (uplodes the content and displays it) <div class="user-content"> {% for content in contents %} <li class="">{{ content.text }} {% if content.video %} <video class="video" width='400'> … -
How to import AbstractUser correctly
I am building an API by using DRF, and while I try to register an User django-registeration, I realized that I did not name my custom User differently, I have entries in my database, so if I can save my saved objects it will be better for my members. This is my model: class User(AbstractUser): bio = models.TextField() I have added to settings and set my forms # settings.py AUTH_USER_MODEL = "profiles.User" # forms.py from yogavidya.apps.profiles.models import User from django_registration.forms import RegistrationForm class UserForm(RegistrationForm): class Meta(RegistrationForm.Meta): model = User # urls.py path('accounts/register/', RegistrationView.as_view( form_class=UserForm, success_url="/" ), name="django_registration_register"), path('accounts/', include('django_registration.backends.one_step.urls')), path('accounts/', include('django.contrib.auth.urls')), now I get an error: You are attempting to use the registration view <class 'django_registration.backends.one_step.views.RegistrationView'> with the form class <class 'yogavidya.apps.profiles.forms.UserForm'>, but the model used by that form (<class 'django.contrib.auth.models.User'>) is not your Django installation's user model (<class 'yogavidya.apps.profiles.models.User'>). why does my UserForm uses User model different than I have imported ? How can I fix it ? Thanks -
Unable to display parent table with child table in a for loop with template tagging in Django
I want to display an unordered list of NBA teams from my teams table database. Within each team, I want an ordered list of players on that team. So basically I want to produce a list of all objects from my parent table and for each object from the parent table I want a list of all objects from the child table related the parent table. I understand that the problem is methods are not allowed in template tagging, so 'team.players_set.all()' would not be allowed. How else can I get the results that I want? class Teams(models.Model): name = models.CharField(max_length=20, unique=True) num_of_plyrs = models.IntegerField() def __str__(self): return f"{self.name} have {self.num_of_plyrs} players." class Meta: verbose_name_plural = "Teams" class Players(models.Model): name = models.CharField(max_length=20) team = models.ForeignKey(Teams, on_delete=models.CASCADE) def __str__(self): return f"{self.name} plays for {self.team}" class Meta: verbose_name_plural = 'Players' __________________________________________________________________________________ def teams(request): teams = Teams.objects.all() context = {'teams': teams} return render(request, 'one_app/teams.html', context) __________________________________________________________________________________ <h3>NBA Teams</h3> <ul> {% for team in teams %} <li> <p>Team: {{ team.name }}</p> <p>Number of players: {{ team.num_of_plyrs }}</p> <ol> {% for plyr in team.players_set.all() %} <li>{{ plyr.name }}</li> {% endfor %} </ol> </li> {% empty %} <li>There are no teams listed.</li> {% endfor %} </ul> -
why is it showing "type object 'CourseInstructor' has no attribute 'objects' "
i'm using class based views because classes can't be defined in function based views. i have two tables (Course, CourseInstructor) when i created the first table and checked it there was no such error but when i created the second it displayed that error from django.shortcuts import HttpResponse, render from django.views import View from .models import Course, CourseInstructor class Course(View): def get(self, request): courses = Course.objects.all() return render(request, 'examscheduling.html', {'courses': courses}) class CourseInstructor(View): def get(self, request): coursesInstructor = CourseInstructor.objects.all() return render(request, 'examscheduling.html', {'coursesInstructor': coursesInstructor}) -
How can I get this Django CreateView to call my Django-FSM transition?
I'm working on an application that allows logged in users to submit news articles to the database where they can be reviewed and editing before being published. Their submissions could also be rejected. I'm using the cool django-fsm package to manage the state changes and django-bootstrap-modal-forms to display the news submission form and submit it via Ajax. I'm having trouble getting my class-based view to trigger the django-fsm transition in my model. The data is saved to the database, but the receive() method never gets called, so I don't get the confirmation email, for example. I can call receive() manually from the command line and generate the email, so I know that part is working. Here's the code: # views.py class NewsSubmitView(LoginRequiredMixin, BSModalCreateView): template_name = "modals/submit_news.html" form_class = NewsSubmitForm success_message = "Success: News submitted." def form_valid(self, form): response = super(NewsSubmitView, self).form_valid(form) user = self.request.user form.instance.submitted_by = user form.instance.slug = slugify(form.instance.headline) return response def save(self, commit=True): instance = super().save(commit=False) instance.receive(activity_slug=self.kwargs.get("slug")) instance.save() return instance def get_success_url(self): return reverse_lazy("news", kwargs={"slug": self.kwargs["slug"]}) # models.py @transition(field=state, source=ArticleState.RECEIVED, target=ArticleState.RECEIVED) def receive(self, activity_slug, by=None): """Receive the submission""" self.slug = slugify(self.headline) self.activity = Activity.objects.get(slug=activity_slug) self.send_article_received_email() def send_article_received_email(self): context = { "submitter": self.submitted_by, "headline": self.headline, } msg_to_submitter = render_to_string( … -
Part of celery-beat periodic task not triggered
I have two celery-beat periodic tasks are configured with the same crontab schedule to run in the system. But at the start of month, one of them is not sending due task to celery worker. From the django admin panel, one task last_run_time is None, which indicates that it is not triggered. I tried to configure the crontab schedule to '''15 * * * *''' and it runs successfully at minute 15. -
Django Admin with Django debug toolbar same table being queried multiple times for each column?
I am using django-debug-toolbar and loading a large table with no foreignkeys. The table size is about 20,000 rows - 15mb - however the django list page is taking extremely long to load, 10s+ to load. When i remove columns from the list_display it seems to load faster. When I am querying the entire dataset however using Ref_ICD.objects.all() via get_queryset it doesn't seem to take that long to query, sub 3s - which is as expected because its a linear query. Can anyone tell me whats wrong with my code? Am i reading the django-debug-toolbar wrong? Either way the page loads really slow. class TimeLimitedPaginator(Paginator): def _get_count(self): if not hasattr(self, "_count"): self._count = None if self._count is None: try: key = "adm:{0}:count".format(hash(self.object_list.query.__str__())) self._count = cache.get(key, -1) if self._count == -1: self._count = super().count cache.set(key, self._count, 3600) except: self._count = len(self.object_list) return self._count count = property(_get_count) @admin.register(Ref_ICD) class ICDAdmin(admin.ModelAdmin, WYSIWYG): def get_queryset(self, request): con = get_redis_connection("default") qs = Ref_ICD.objects.filter(FullCode="J449") # qs = Ref_ICD.objects.all() # pickled_object = pickle.dumps(qs) # con.set('ref_icd', pickled_object) unpacked_object = pickle.loads(con.get('ref_icd')) # qs == unpacked_object return qs paginator = TimeLimitedPaginator show_full_result_count = False list_per_page = 10 search_fields = ['FullCode'] list_filter = ( 'CategoryCode', 'DiagnosisCode', 'FullCode', 'AbbreviatedDescription', 'FullDescription', 'CategoryTitle' ) … -
Django/HTML - How to stay on the same page after a search
I'm working on a Django project and i have a problem with URL pattern when i'm using form. So i have a search bar on the home page but also on the search page doing the same search : /home/ and /home/search/ When I search for the first time it redirects me to search wich is normal from home to home/search/. But when i want to search again i want to stay to this /home/search/ but it redirects me to another search like below /home/search/search/ It says error because obviously it's not in the url pattern mentioned in urls.py Actually what i've done is the following (i know it's dirty programming) : if url contains search then <form method="post" action=""> else <form method="post" action="search/"> If it is in home page then go to search page but if it is in search page stay here. I'm wondering if there is a better way to resolve this problem ? Thanks for reading guys and i hope you will help me. -
choice multiple instances from foreignkey django
how to choice multiple instances of a foreignkey for example class Mobile(models.Model): mobile = models.CharField(max_length=20,unique=True) quantity = models.IntegerField() imei = models.ForeignKey(Imei,on_delete=models.CASCADE) class Imei(models.Model): imei = models.CharField(max_length=13,unique=True) each mobile have different Imei in Mobile if mobile =samsung A51 and quantity = 10 then we have 10 unique imei i want to know how to let the user the select 10 imei's (with barcode reader) in the same form ? i appreciate your helps -
Django Stripe payment does not respond after clicking the Submit Payment button
I have an e-commerce application that I'm working on. The app is currently hosted on Heroku free account. At the moment I can select a product, add it on the cart and can get up to the stripe form and type in the card details, but when I click the 'Submit Payment' button nothing happens. I don't even get an error message. I'm using Stripe test keys and 4242 four times as my card number. Can anyone help me to find out what's going on pliz. I have been stuck on it for days. Here is the relevant code below: Settings.py code: from .base import * import dj_database_url DEBUG = (os.environ.get('DEBUG_VALUE') == 'True') ALLOWED_HOSTS = ['.herokuapp.com', '127.0.0.1'] AUTH_PASSWORD_VALIDATORS = [ {'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'}, {'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'}, {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'} ] """ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': config('DB_NAME'), 'USER': config('DB_USER'), 'PASSWORD': config('DB_PASSWORD'), 'HOST': config('DB_HOST'), 'PORT': '' } } """ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } STRIPE_PUBLIC_KEY = os.environ.get('STRIPE_LIVE_PUBLIC_KEY') STRIPE_SECRET_KEY = os.environ.get('STRIPE_LIVE_SECRET_KEY') AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME') AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = None AWS_S3_REGION_NAME = "us-east-2" AWS_S3_SIGNATURE_VERSION = "s3v4" DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = … -
How do I save form response as an object in Django's database?
I am unable to save my form responses to the database as an object in Django. Everytime I click on submit to submit my form, I am just logged out of my website and the object isnt saved in the database either. Can anyone tell me where I am going wrong? This is my models in models.py. class Chain(models.Model): name = models.CharField(max_length=255) user = models.ForeignKey(User, on_delete=models.CASCADE) year = models.CharField(max_length=10, default="20XX") sem = models.CharField(max_length=30, default="Default Semester") code = models.CharField(max_length=10, default="SUB-CODE") slot = models.CharField(max_length=10, default="EX+EX") last_updated = models.DateTimeField(auto_now=True) def __str__(self): return self.name This is my view in views.py file. @login_required(login_url='/') def create_course(request): if request.method == 'GET': return render(request, 'create_course.html', {}) elif request.method == 'POST': name=request.POST['name'] year=request.POST['year'] sem=request.POST['sem'] code=request.POST['code'] slot=request.POST['slot'] newchain = Chain( name=name, year=year, sem=sem, code=code, slot=slot, ) newchain.user = request.user newchain.save() return redirect('success') -
How do I get two auth0 apps written in Django to show one login page and redirect to correct auth 0 app depending on username?
I have two Django apps that authenticate using auth0 pointing to same domain running on different ports - localhost:3000 and localhost:3001. They're both working fine and authenticating users as expected when I go to the respective ports. But going to localhost:3000 authenticates me to app1 and going to localhost:3001 authenticates me to app2 What I want to do is have both the apps running and I want a common login page to show up ( dont want this to be login to a particular app - app1 or app2) and then depending on the username, it redirects me to either app1 or app2. -
Django e-mail doesn't send the pdf generated
I think i didn't really understood about mail sending, but my objective is to send the PDF that my app generate to my real email, i only get the backend mail. I leave a photo of the "runserver", "celery", "rabbitmq" shell tabs, and my github so you guys can see the project if u need to, i think with the code below is what u need to see but just in case. Github: https://github.com/Taiel-Kadar/myshop Photo: shell views.py: import braintree from django.shortcuts import render, redirect, get_object_or_404 from django.conf import settings from orders.models import Order from .tasks import payment_completed # instantiate Braintree payment gateway gateway = braintree.BraintreeGateway(settings.BRAINTREE_CONF) def payment_process(request): order_id = request.session.get('order_id') order = get_object_or_404(Order, id=order_id) total_cost = order.get_total_cost() if request.method == 'POST': # retrieve nonce nonce = request.POST.get('payment_method_nonce', None) # create and submit transaction result = gateway.transaction.sale({ 'amount': f'{total_cost:.2f}', 'payment_method_nonce': nonce, 'options': { 'submit_for_settlement': True } }) if result.is_success: # mark the order as paid order.paid = True # store the unique transaction id order.braintree_id = result.transaction.id order.save() # launch asynchronous task payment_completed(order.id) return redirect('payment:done') else: return redirect('payment:canceled') else: # generate token client_token = gateway.client_token.generate() return render(request, 'payment/process.html', {'order': order, 'client_token': client_token}) def payment_done(request): return render(request, 'payment/done.html') def payment_canceled(request): return render(request, … -
Django: L10N and en-IN
I googled a lot to find solution for my problem related to Django's L10N settings for en-IN and found nothing satisfying which works. So, finally get back here to friends. I'm struggling to format currency as Indian number formatting standard. Which follows NUMBER_GROUPING = (3, 2, 0) and LANGUAGE_CODE = 'en-IN'. My current configurations of settings.py file is: LANGUAGE_CODE = 'en-IN' USE_I18N = False USE_L10N = True USE_THOUSAND_SEPARATOR = True NUMBER_GROUPING = (3, 2, 0) In template file I use: {% load humanize %} {# where object.price value is 524300 #} <p> {{ object.price }} {{ object.price|intcomma }} </p> Hence this outputs: 524,300 instead 5,24,300 What am I doing wrong, which is stopping Django for follow settings of LANGUAGE_CODE, USE_L10N and NUMBER_GROUPING -
Django KeyError after AJAX request
I have a KeyError: 'category_id' after an AJAX request. I know the kwarg is being passed because it says Internal Server Error: /tests/cat-update/1/ My view looks as such: def get_tests_filtered_for_category(request, **kwargs): print('test:', kwargs['category_id']) category = Category.objects.all() quiz = Quiz.objects.filter(category=category) test_list = list(quiz.values('id', 'name')) return HttpResponse(simplejson.dumps(test_list), content_type="application/json") url.py: path('cat-update/<int:pk>/', views.get_tests_filtered_for_category, name='cat-update'), JS: $('select[name=categories]').change(function(){ category_id = $(this).val(); request_url = '/tests/cat-update/' + category_id + '/'; $.ajax({ url: request_url, success: function(data){ $.each(data, function(index, text){ $('select[name=tests]').append( $('<option></option>').val(index).html(text) ); }); } }); }); What is the reason the category_id key does not exist? -
How to not use pylint-django in non Django file?
I'm new to the Django. I am currently use VS code as my code editor. In order to work on the Django project, in the user settings of the VS code, I include the following code to use pylint_django as the default linter. "python.linting.pylintArgs": [ "--load-plugins=pylint_django", "--errors-only" ], However, in another python file, which is just a regular python file, I got an error, saying "Django is not available on the PYTHONPATHpylint(django-not-available)" If I comment the above code in the user setting, the error goes away. I think the problem is pylint-django is used as default linter, even for non-Django python file. My question is I didn't find the solution to solve this problem. Could you please help me on this? Thank you so much. I really appreciate it. -
Ajax with Django mistakenly printing JSON to screen
I'm trying to implement a "like" feature for a Gapper object (people who are on a gap year), and change the "Like" button to "Unlike" when the change is made on the backend. Since I don't want to reload the whole page, I'm using AJAX (have used .fetch in React, which was simple, seamless, and very short--AJAX seems super clunky and outdated--is there no better way for vanilla HTML applications?) and running into some trouble. The JSONResponse that many answers suggest is being printed to the screen, whereas I don't want there to be any reloading/refreshing/change of endpoint at all--that's the whole point. The relevant code is below and I think it's a straightforward problem, and I'm just being silly. Help much appreciated! In views, I tried using serializers.serialize(), but I don't really need any data back from the backend, it just needs to make the change and then on the front end I can swap Like to Unlike and vice versa when a successful ajax response is received. Also tried it with csrf, wasn't working. I also tried is_ajax() which gave False. Importantly, the like and unlike function is working correctly (the list is being added and removed from, … -
How can i style my django filter with bootstrap or CSS
i'm new to django here and still learning. So, i created a filter using django-filter and i didn't know how to style it (bootstrap or CSS) because i really don't like the default styling. Can anyone help me with it? i already googled it but didn't find anything useful. filters.py ` class CompLink_Filter(django_filters.FilterSet): start_date = DateFilter(field_name="date_added", label='Date ajout' ,lookup_expr='gte') company_name = CharFilter(field_name='company_name', label='Nom Entreprise' ,lookup_expr='icontains') sector = CharFilter(field_name='sector',label='Secteur' , lookup_expr='icontains') size = CharFilter(field_name='size', label='Taille' ,lookup_expr='icontains') phone = CharFilter(field_name='phone', label='Téléphone' ,lookup_expr='icontains') employees_on_linkedin = CharFilter(field_name='employees_on_linkedin', label='Employés sur Linkedin :' ,lookup_expr='icontains') type = CharFilter(field_name='type', label='Type' ,lookup_expr='icontains') founded_in = CharFilter(field_name='founded_in', label='Fondée En' ,lookup_expr='icontains') specializations = CharFilter(field_name='specializations', label='Spécialisations' ,lookup_expr='icontains') class Meta: model = Comapny_Profile fields= '__all__' exclude= ['company_link','website','head_office','address']` displaying the filter in my template: <form class="" action="" method="get"> {% for field in myFilter.form %} <div class="fieldWrapper"> {{ field.errors }} {{ field.label_tag }} {{ field }} {% if field.help_text %} <p class="help">{{ field.help_text|safe }}</p> {% endif %} </div> {% endfor %} <button class="btn btn-primary" type="submit" name="button">Recherche</button> </form> -
Django custom user model doesn't show up under Authentication and Authorization in the admin page
I have been trying to figure this out for a few hours and feel lost. I am new to django and have tried to create a custom user model. My struggle is that my user model won't show up under the Authentication and Authorization section of the admin page. Admin page pic Here is my code for the model from django.db import models from django.contrib.auth.models import AbstractUser # Create your models here. class User(AbstractUser): first_name = models.TextField(max_length = 300) last_name = models.TextField(max_length = 300) Here is the code for my admin.py file from django.contrib import admin from django.contrib.auth.admin import UserAdmin from orders.models import User # Register your models here. admin.site.register(User,UserAdmin) here is a snippet of my settings.py file where i added the AUTH_USER_MODEL AUTH_USER_MODEL='orders.User' # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'orders' ]