Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django model related to self
How to create object to object relation suchwise that when i add this relation to parent and relaton to child added automatically? class Object(models.Model): name = models.CharField(max_length=150) description = models.TextField(blank=True) is_published = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) relation = models.ForeignKey('self', related_name="related", on_delete=models.DO_NOTHING, blank=True, null=True) def __str__(self): return self.name When I appoint some relation in django-admin for example to 'Spider Man' object related to 'Peter Pen' object I don't have relation 'Peter Pen' -> 'Spider Man' when I open 'Peter Pen' object -
Django models: How do I check that a decorartor property exists
I have a Profile model with a decorator property @property def primary_phone(self): When I query for the primary phone for a given id like this it works x = Profile.objects.get(id=3) x.primary_phone outputs Out[3]: '+256771000022' However filtering for the same like this Profile.objects.filter(primary_phone="+256771000022").exists() outputs FieldError: Cannot resolve keyword 'primary_phone' into field. Choices are: _created_at, _modified_at, apierror, business,...) -
django how to create object and add many to many best way or best practice
how can I make this code much more effective or faster def handle(self, *args, **kwargs): shops = MyShop.objects.all() for shop in shops: month_invoice = shop.shop_order.annotate(year=TruncYear('created'), month=TruncMonth('created')).values( 'year', 'month', 'shop_id' ).annotate(total=Sum(ExpressionWrapper( (F('item_comission') / 100.00) * (F('price') * F('quantity')), output_field=DecimalField())), ).order_by('month') for kv in month_invoice: a = ShopInvoice.objects.create(shop_id=kv['shop_id'], year=kv['year'], month=kv['month'], total=kv['total']) test = shop.shop_order.filter(created__month=kv['month'].month, created__year=kv['year'].year) for t in test: a.items.add(t.id) -
I am getting "token_blacklist.0008_migrate_to_bigautofield...Not implemented alter command for SQL ALTER TABLE "token_blacklist_blacklistedtoken"
Anyone please tell me what type of error is it? on django rest_framework I am getting this error after running "python manage.py migrate" I am using simple_jwt library for authentication and the migrations stop here Applying token_blacklist.0008_migrate_to_bigautofield...Not implemented alter command for SQL ALTER TABLE "token_blacklist_blacklistedtoken" ALTER COLUMN "id" TYPE long (env) D:\inductionplan\django-api\backend>python manage.py migrate Operations to perform: Apply all migrations: admin, api, auth, authtoken, contenttypes, sessions, token_blacklist Running migrations: Applying token_blacklist.0008_migrate_to_bigautofield...Not implemented alter command for SQL ALTER TABLE "token_blacklist_blacklistedtoken" ALTER COLUMN "id" TYPE long Traceback (most recent call last): File "D:\inductionplan\django-api\env\lib\site-packages\djongo\cursor.py", line 51, in execute self.result = Query( File "D:\inductionplan\django-api\env\lib\site-packages\djongo\sql2mongo\query.py", line 784, in __init__ self._query = self.parse() File "D:\inductionplan\django-api\env\lib\site-packages\djongo\sql2mongo\query.py", line 876, in parse raise e File "D:\inductionplan\django-api\env\lib\site-packages\djongo\sql2mongo\query.py", line 857, in parse return handler(self, statement) File "D:\inductionplan\django-api\env\lib\site-packages\djongo\sql2mongo\query.py", line 889, in _alter query = AlterQuery(self.db, self.connection_properties, sm, self._params) File "D:\inductionplan\django-api\env\lib\site-packages\djongo\sql2mongo\query.py", line 425, in __init__ super().__init__(*args) File "D:\inductionplan\django-api\env\lib\site-packages\djongo\sql2mongo\query.py", line 84, in __init__ super().__init__(*args) File "D:\inductionplan\django-api\env\lib\site-packages\djongo\sql2mongo\query.py", line 62, in __init__ self.parse() File "D:\inductionplan\django-api\env\lib\site-packages\djongo\sql2mongo\query.py", line 441, in parse self._alter(statement) File "D:\inductionplan\django-api\env\lib\site-packages\djongo\sql2mongo\query.py", line 500, in _alter raise SQLDecodeError(f'Unknown token: {tok}') djongo.exceptions.SQLDecodeError: Keyword: Unknown token: TYPE Sub SQL: None FAILED SQL: ('ALTER TABLE "token_blacklist_blacklistedtoken" ALTER COLUMN "id" TYPE long',) Params: ([],) Version: 1.3.6 The above exception was … -
how do i render text put into a django textfield with a its original format?
im building a site with django and i would like to output some text that I put into a text field from my model but when i do so in the html it loses all the form that i give it (spacing and new lines, etc.) does anyone have a solution?. so instead of coming out as: enter image description here it comes out as just a line without the proper spacing enter image description here -
How to get a user with 'django-microsoft-authentication' code?
I'm using the library django-microsoft-authentication. The application for microsoft was created, all the codes were received by me. I did everything according to the documentation. MICROSOFT = { "app_id": "<my app id>", "app_secret": "my app secret id", "redirect": "http://localhost:8000", "scopes": ["user.read"], "authority": "https://login.microsoftonline.com/common", "valid_email_domains": ["<list_of_valid_domains>"], "logout_uri": "http://localhost:8000/admin/logout" } Add 'microsoft_authentication' to INSTALLED_APPS LOGIN_URL = "/microsoft_authentication/login" LOGIN_REDIRECT_URL = "/admin" and urls.py from django.urls import path, include urlpatterns = [ ..... path('microsoft_authentication/', include('microsoft_authentication.urls')) ] And everything goes well, and without errors. I authenticate and get returned to the home page. But there is no new user in the admin area. Or I need to do create a new user manually? Or is callback not working? In my address bar I get some this: http://localhost:8000/?code=0.Awfwjhey79kyt4fe..........feky5hmj (random code). I understand that this is some kind of user token grant. According to the documentation, I checked the decorator @microsoft_login_required(), and it working when I was logged in, and it did not work when I was NOT logged in. So everything is going well. But I only get the code=..... above. But I don't see the user anywhere. How do I get a user? How do I create and save a user? Please, any help will … -
Django-taggit: how to save after adding tags in save()
def save(self, *args, **kwargs): super(Flow, self).save(*args, **kwargs) if self.pk: self.tags.add(str(date.today().year)) self.save() This doesn't work in my model Flow. How can I save the newly added tag into tags of my flow instance successfully? Thanks. -
making a new table in django for database by user from frontend
I am writing a web application by Django and Reactjs. It should be able that the user creates a new project in application with a specific name and, the project should have its table in the database. I need a tool to create a model and migrate it automatically in the database. -
ValueError: invalid literal for int() with base 10: in Django 3.0
I have updated my project from Django 1.8 to Django 3.0 Here when i am trying display items using autocomplete i am getting this error Here is my views.py def autocomplete_items(request, flag=None): client = request.user.client q = request.GET.get('term') category = request.GET.get('category', '') job_items = JobItems.objects.filter(client_id=client) if category: job_items = job_items.filter(category_id=category) if flag: job_items = job_items.filter(stock='Variety Master') else: if client.horticulture: job_items = job_items.exclude(stock='Variety Master') products = job_items.filter(Q(item_name__icontains=q)|Q(soil_type__icontains=q)|Q(height__icontains=q)|Q(pot_size__icontains=q)|Q(form__contains=q)|Q(unit_price__contains=q)|Q(supplier_one__supplier_name__icontains=q)|Q(part_number__icontains=q)|Q(batch_number__icontains=q),is_deleted=False, is_one_of_item=False) res = [] for c in products: #make dict with the metadatas that jquery-ui.autocomple needs (the documentation is your friend) dict = {'id':c.id, 'label':c.__str__()+ ' ('+ str(c.part_number)+')' if c.part_number else c.__str__() , 'label2':c.__str__()+ ' ('+ str(c.batch_number)+')' if c.part_number else c.__str__(), 'value':c.__str__(), 'partnumber': c.part_number} res.append(dict) return HttpResponse(json.dumps(res[:15])) Here is my models.py class JobItems(models.Model): description = models.TextField(blank=True) item_name = models.CharField(max_length=512) part_number = models.CharField(max_length=32, null=True, blank=True, verbose_name='Stock number') batch_number = models.CharField(max_length=200, blank=True, null=True) client = models.ForeignKey("core.Client", related_name="job_items",on_delete=models.CASCADE) is_deleted = models.BooleanField(default=False, help_text="Deleted tasks will not display in the UI.") is_checked = models.BooleanField(default=False, help_text="Save item into item details") created_at = models.DateTimeField(auto_now_add=True) modified_at = models.DateTimeField(auto_now=True) quantity = models.DecimalField( max_digits=10, decimal_places=2, default=0.00, verbose_name='Quantity In Stock') unit_price = models.DecimalField(null=True, max_digits=10, decimal_places=2, default=0.00, verbose_name='Retail price') def __str__(self): return self.item_name class Meta: ordering = ("quantity", ) here is my error traceback Traceback (most … -
Django: how to search for the most similar entry
There are many ways I can query for information in a database, mine being PostgreSQL, such as __contains, __icontains, unnaccent__icontains, __unaccent__lower__trigram_similar, and so on. Though these are very handy, none of these helped my really reach the goal I have in mind: searching for the most similar entry. Trigram similarity got pretty close, but it no longer worked for longer strings. Is there any operation that can get the closest value, also working for longer strings? -
Django: How to rewrite raw SQL into queryset
The raw SQL was rewritten because the issue time of the following queryset was very slow. # queryset Video.objects.annotate( is_viewed=Exists(History.objects.filter(user=user, video=OuterRef("pk"))), is_favorited=Exists( Favorite.objects.filter(user=user, video=OuterRef("pk")) ), is_wl=Exists( Track.objects.filter( playlist__user=user, playlist__is_wl=True, video=OuterRef("pk") ) ), ).filter( Q(title__contains=value) | Q(tags__name__contains=value), is_public=True, published_at__lte=timezone.now(), ).order_by("-published_at").distinct()[:20] SELECT DISTINCT "videos_video"."id", "videos_video"."title", "videos_video"."thumbnail_url", "videos_video"."preview_url", "videos_video"."embed_url", "videos_video"."duration", "videos_video"."views", "videos_video"."is_public", "videos_video"."published_at", "videos_video"."created_at", "videos_video"."updated_at", EXISTS (SELECT (1) AS "a" FROM "videos_history" U0 WHERE (U0."user_id" IS NULL AND U0."video_id" = "videos_video"."id") LIMIT 1) AS "is_viewed", EXISTS (SELECT (1) AS "a" FROM "videos_favorite" U0 WHERE (U0."user_id" IS NULL AND U0."video_id" = "videos_video"."id") LIMIT 1) AS "is_favorited", EXISTS (SELECT (1) AS "a" FROM "videos_track" U0 INNER JOIN "videos_playlist" U1 ON (U0."playlist_id" = U1."id") WHERE (U1."is_wl" AND U1."user_id" IS NULL AND U0."video_id" = "videos_video"."id") LIMIT 1) AS "is_wl" FROM "videos_video" LEFT OUTER JOIN "videos_video_tags" ON ("videos_video"."id" = "videos_video_tags"."video_id") LEFT OUTER JOIN "videos_tag" ON ("videos_video_tags"."tag_id" = "videos_tag"."id") WHERE ("videos_video"."is_public" AND "videos_video"."published_at" <= '2022-01-03 05:20:16.725884+00:00' AND ("videos_video"."title" LIKE '%word%' OR "videos_tag"."name" LIKE '%word%')) ORDER BY "videos_video"."published_at" DESC LIMIT 20; I have sped up the above query to look like the query below. But how can I reproduce this in Django's querieset? SELECT DISTINCT "t"."id", "t"."title", "t"."thumbnail_url", "t"."preview_url", "t"."embed_url", "t"."duration", "t"."views", "t"."is_public", "t"."published_at", "t"."created_at", "t"."updated_at", EXISTS (SELECT (1) AS … -
Django Session Is not working with Heroku when changing views (but works locally)
The sessions work perfectly while changing views when working locally, but when deployed to Heroku it is as if the session was refreshed and all the information it contains is deleted upon every view change. I am using Heroku's Postgres Database. I have already taken a look at: Django Session Not Working on Heroku but the problem still persists Here is my current settings file. Any help would be appreciated import os from pathlib import Path BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'e488a0185303170daa47fe1de243823fbb3db60f045e6eae' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['127.0.0.1', 'here goes the heroku host'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', '....', '....', ] ASGI_APPLICATION = 'System.asgi.application' MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'System.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [BASE_DIR / 'templates'] , 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'System.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } import dj_database_url db_from_env = dj_database_url.config() DATABASES['default'].update(db_from_env) SESSION_ENGINE= 'django.contrib.sessions.backends.cached_db' AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 'OPTIONS': {'min_length': 8} }, … -
Django Rest Framework - Nested List Inside JSON Response
I'm very new to both Django and the Django Rest Framework, and I'm struggling with building up a particular JSON response. I have two models, like so: class Artist(models.model): artist_id = models.CharField( max_length=256, primary_key=True, ) name = models.CharField( max_length=256, null=False, blank=False, ) birthplace = models.CharField( max_length=256, null=False, blank=False, ) class Album(models.Model): artist = models.ForeignKey( Artist, on_delete=models.DO_NOTHING, db_constraint=False, null=True, ) name = models.CharField( max_length=256, null=False, blank=False, ) label = models.CharField( max_length=256, null=False, blank=False, ) I'm trying to build a JSON response that looks like this, where the albums are nested inside the artist: { "artist_id": "A123", "name": "Bob Dylan", "birtplace": "Duluth, Minnesota", "albums": [ { "id": 123, "name": "Bob Dylan", "label": "Columbia" }, { "id": 123, "name": "The Freewheelin' Bob Dylan", "label": "Columbia" } ] } Is this even possible? I was looking into select_related, but that doesn't seem to work as I feel like I need to 'hit' the Artist table first, and there is no relationship defined in the direction of Artist to Album. Any help would be greatly appreciated. -
I need save info + User.id or username to database in Django
I have some problem with save info about authentificate user with info. I didnt have some id but django have exception. My model.py from django.contrib.auth.models import User from django.db import models from hashlib import md5 from django.conf import settings # Create your models here. class Url(models.Model): long_url = models.CharField(unique=True,max_length=500) short_url = models.CharField(unique=True, max_length=100) user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) id = models.BigAutoField(primary_key=False, null=True) @classmethod def create(self, long_url, user, id): tmp = md5(long_url.encode()).hexdigest()[:6] tmp = '127.0.0.1:8000' + '/' + tmp try: obj = self.objects.create(id=id,long_url=long_url, short_url=tmp, user=user) except: obj = self.objects.get(long_url=long_url, user=user) return obj My views.py from django.contrib.auth.models import User from django.shortcuts import render, redirect from .forms import UserRegistration, UserLogIn from .models import Url from django.http import HttpResponse from django.contrib.auth import authenticate, login # Create your views here. def register(request): if request.method == 'POST': user_form = UserRegistration(request.POST) if user_form.is_valid(): new_user = user_form.save(commit=False) new_user.set_password(user_form.cleaned_data['password']) new_user.save() return render(request, 'register.html', {'new_user': new_user}) else: user_form = UserRegistration() return render(request, 'register.html', {'user_form': user_form}) def shorter(request): if request.method == 'POST': long_url = request.POST.get('long_url') obj = Url.create(long_url, User) return render(request, 'short.html', { 'short_url': request.get_host() + '/' + obj.short_url[-6:]}) return render(request, 'shorter.html') My forms.py from django.contrib.auth.models import User from django import forms class UserRegistration(forms.ModelForm): password = forms.CharField(label='Password', widget=forms.PasswordInput) password2 = forms.CharField(label='Repeat … -
Django: How do I create separate instances of the same model object?
I have two classes that need to relate to each other. an Item class and an Order class. An Item object has several attributes: name, cost, quantity etc. I want the same item to be able to belong to several different Order objects and white doing so, having different attributes inside that Order object. (Like different orders can have different amounts of the same Item on order) Is this possible? Here's what I've got so far: class Item(models.Model): description = models.CharField(max_length=200) cost = models.FloatField() order_quantity = models.IntegerField(null=True, blank=True) def __str__(self): return str(self.description) @property def line_total(self): return self.cost * self.order_quantity class Order(models.Model): STATUS_CHOICES = ( ('draft', 'Draft'), ('issued', 'Issued'), ('closed', 'Closed'), ) reference = models.AutoField(primary_key=True) location = models.ForeignKey( Location, null=True, blank=True, on_delete=models.CASCADE) author = models.ForeignKey(User, on_delete=models.CASCADE) status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft') created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) item = models.ManyToManyField(Item, blank=True) class Meta: ordering = ('location',) def __str__(self): return str(self.reference) This setup allows me to have the same item in different orders, which is great, however I can't figure out how to make some Item attributes 'independent', based on which order they belong to. -
Customized Settings in Django
I am creating an electronic reference library for my school, where I have created a custom admin page (not the Django admin page). And in my requirements there needs to be a specific 'settings' page where I can store small information such as How frequently to create reports How frequently users should change their passwords etc. These kinds of custom settings are not available in Django by default. But is there a way I can implement it in my app? And how should I store this information? Should I create another table to store these information? Please let me know how to tackle such a situation. Thanks! -
Django: Annotate distinct foreign ManyToMany relation
Given the following simplified model setup class Tag(models.Model): name = CharField() class Template(models.Model): name = CharField() tags = ManyToManyField(Tag) class Collection(models.Model): name = CharField() templates = ManyToManyField(Template) class GenericViewSet(viewsets.ModelViewSet): def get_queryset(): ... queryset = Collection.objects.all() queryset = queryset.annotate(tags=models.Distinct('templates__tags')) ... Is there a way similar to the last line above to annotate a Collection queryset with a distinct set of tags originating from its templates? Example (Template): name: History 1 tags: [England, France] (Template): name: History 2 tags: [England, United States) (Collection): name: History of England templates: [History 1, History 2] tags: [England, France, United States] Where the collections tags are derived from its templates. -
Unable to Login to Admin Panel in Django using Custom User Model
I have created a custom user model that overrides the default AUTH_MODEL in settings.py. I am unable to login on the admin panel using python manage.py createsuperuser. The message that the admin throws back at me is: Please enter the correct username and password for a staff account. Note that both fields may be case-sensitive. Below is my code for models.py: from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager from django.db import models from django.contrib.auth.hashers import make_password from phonenumber_field.modelfields import PhoneNumberField class UserAccountManager(BaseUserManager): def create_user(self, email, username, first_name, last_name, phone, password=None): if not email: return ValueError("User must have an email address!") if not username: return ValueError("User must have a username!") if not first_name: return ValueError("User must have a first name!") if not last_name: return ValueError("User must have a last name!") if not phone: return ValueError("User must have a phone number!") user = self.model( email=self.normalize_email(email), username=username, first_name=first_name, last_name=last_name, phone=phone, ) hashed_password = make_password(password) user.set_password(hashed_password) user.save(using=self._db) return user def create_superuser(self, email, username, first_name, last_name, phone, password): user = self.create_user( email=self.normalize_email(email), username=username, first_name=first_name, last_name=last_name, phone=phone, password=password, ) user.is_admin = True user.save(using=self._db) return user class UserAccount(AbstractBaseUser): username = models.CharField(null=False, blank=False, max_length=30, unique=True) first_name = models.CharField(null=False, blank=False, max_length=50) last_name = models.CharField(null=False, blank=False, max_length=50) email = models.EmailField(null=False, blank=False, unique=True) … -
Store JWT tokens in cookies with django-rest-framework-social-oauth2 library
I wanted to securely store my JWT token. Up until now, I have used local storage, but I have read that using local storage is not secure. Hence, I wanted to start using HttpOnly cookies to store my JWT tokens. I was going to use CSRF protection inbuilt into Django to mitigate the security issues with cookies. However, I can't figure out how to use cookies with the Django-rest-framework-social-oauth2 library. There doesn't need to be any other library that has social auth and JWT auth. So my first question, is there a secure storage method that doesn't need cookies. If not, how does use django-rest-framework-social-oauth2 library with cookies? -
How not to skip what follows hashtags in django admin search field?
In Django admin, there is the search bar for list_display page of objects. Lets say there is search_fields = ["name"] for given admin. If there is an object with the name "abc" and the search term is "ab", an object is returned. however, when there is a name "abc#deg" and "ab" is searched for, doesn't return any. Seems like the Django admin search bar perceives # as a special character for setting parameters or something, does anyone know how to avoid this? Any hint would be much appreciated! -
Django/PythonAnywhere -- Getting Error "Something went wrong :-("- Debugging Tips
I am new and learning Full Deployment walkthrough on python Anywhere, But getting the Error. I have tried all possible things which I could do to resolve it but I am stuck here. where supriya25 is my directory name Error is: **Something went wrong :-(** Something went wrong while trying to load this website; please try again later. If it is your site, you should check your logs to determine what the problem is. There was an error loading your PythonAnywhere-hosted site. There may be a bug in your code. Error code: Unhandled Exception **Debugging tips** -The first place to look is at your web app page to ensure that there are no errors indicated there. -Next, check your site's server and error logs for any messages — you can view them here: -supriya25.pythonanywhere.com.error.log -supriya25.pythonanywhere.com.server.log -You can find helpful tips on the PythonAnywhere help site: -There's an ImportError in the logs -"403 Forbidden" error or "Connection Refused" error in logs -Database connection errors -There are many more helpful guides on our Help pages If you get completely stuck, then drop us a line at support@pythonanywhere.com, in the forums, or use the "Send feedback" link on the site, with the relevant … -
Is there a best practice for storing data for a database object (model) that will change or be deleted in the future (Django)?
I am building an order management system for an online store and would like to store information about the product being ordered. Now, if I use a Foreign Key relationship to the product, when someone changes the price of the product or deletes it, the order will be affected as well. I want the order management system to be able to display the state of the product when it was ordered even if it is altered or deleted from the database afterwards. I have thought about it long and hard and have come up with ideas such as storing a JSON string representation of the object; creating a duplicate product whose foreign key I then use for the order etc. However, I was wondering if there is a best practice or what other people use to handle this kind of situation in commercial software? -
Revoke celery task queue based on task id
I have two button in Django View in which the first button starts a celery task. I want to stop the queue when i press the second button. Is it possible to stop the queue simply based on the task id? -
Django makemigrations not working, how can i fix the dependencies?
I'm getting the error at the end of the trace back below. When I run 'python manage.py makemigrations'. I Get similar errors when I run it by 'python manage.py makemigrations accounts' and 'python manage.py makemigrations homedb'. If I run the accounts app, it says I'm missing a dependency in the accounts app and if I run the homedb app, it says I'm missing a dependency in the accounts app. In an effort to fix this, I've deleted my migrations, many pycache_ items, and the database to no avail. I also unstalled then reinstalled django. I would be greatful for any help. This is a portion of my traceback: self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/PyKane/.virtualenvs/django23/lib/python3.9/site-packages/d jango/core/management/base.py", line 373, in run_from_argv self.execute(*args, **cmd_options) File "/home/PyKane/.virtualenvs/django23/lib/python3.9/site-packages/d jango/core/management/base.py", line 417, in execute output = self.handle(*args, **options) File "/home/PyKane/.virtualenvs/django23/lib/python3.9/site-packages/d jango/core/management/base.py", line 90, in wrapped res = handle_func(*args, **kwargs) File "/home/PyKane/.virtualenvs/django23/lib/python3.9/site-packages/d jango/core/management/commands/makemigrations.py", line 88, in handle loader = MigrationLoader(None, ignore_no_migrations=True) File "/home/PyKane/.virtualenvs/django23/lib/python3.9/site-packages/d jango/db/migrations/loader.py", line 53, in __init__ self.build_graph() File "/home/PyKane/.virtualenvs/django23/lib/python3.9/site-packages/d jango/db/migrations/loader.py", line 262, in build_graph self.graph.validate_consistency() File "/home/PyKane/.virtualenvs/django23/lib/python3.9/site-packages/d jango/db/migrations/graph.py", line 195, in validate_consistency [n.raise_error() for n in self.node_map.values() if isinstance(n, Du mmyNode)] File "/home/PyKane/.virtualenvs/django23/lib/python3.9/site-packages/d jango/db/migrations/graph.py", line 195, in <listcomp> [n.raise_error() for n in self.node_map.values() if isinstance(n, Du mmyNode)] File … -
Customize Create funciton in DRF viewset
I want to customize the user viewset i.e. when the user registers the user account was created as well.