Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
JSON Dump a string surrounded by single quotes and containing escaped single quotes
I'm going mad! I'm working on a Django web app and I have a problem. I have a page where i list all the results in a MySQL table, and it works fine. {% for row in db_list %} <tr> <th scope="row">{{ row.description }}</th> <td> <button type="submit" name="instance" value="{{ row }}" class="btn btn-primary" title="OPEN TABLE" id="test"><i class="fas fa-list-ul"></i></button> </td> </tr> {% endfor %} Depending on the selection, I have to show the relations of the chosen table, and it works fine with a workaround, but it's not generalistic. What I'm doing is, as you see, transferring back a single row of the json. The db_list is: { "db_list": [ { "description": "description", "table_name": "table_name", "database_name": "database_name" }, { "description": "description", "table_name": "table_name", "database_name": "database_name" }, { "description": "description", "table_name": "table_name", "database_name": "database_name" } ] } I would expect to transfer a json like this: { "description": "description", "table_name": "table_name", "database_name": "database_name" } In this case, I would treat it with the json.dumps() and retrieving the fields I need to execute the query with a simple command and everything would be fine. But I get an escaped string, surrounded by two quotes.. '{ \'description\': \'description\', \'table_name\': \'table_name\', \'database_name\': \'database_name\' }' This … -
conditionally display columns in Django admin based on filtered queryset
I want to hide some columns in the django admin when all the values in that column are null. I have tried using get_list_display but the queryset returned is the one before being filtered, therefore it's no use. def get_list_display(self, request): result = super().get_list_display(request) # remove some columns when there's no data, to save space if not any(d.node_type for d in super().get_queryset(request)): result = (r for r in result if r not in {'node_type', 'mesh_layer'}) return result It's just occured to me that the value of list_display is probably affecting the final query itself, is there some way to filter the columns shown after the query but before displaying the final result? -
Django Record Locking and Atomic Transactions
I am trying to implement some critical updates in a project that I'm doing. In summary, I need to take information from a work file which does some further processing and then updates it to a final file. This information comes from different sources so it is best to do it on the middle file which then writes it to the final file. My problem is that some of the detail lines data is getting lost among the way. I have duplicated this problem in the below files to eliminate any crud. Simply run the functions in a manage.py shell. This shows up both in Mariadb as well as Postgresql. Is there a better way to achiever this instead of a workaround? The models.py: import random from decimal import Decimal from django.db import models, transaction class Head(models.Model): name = models.CharField(max_length=20, default="") h1_text = models.CharField(max_length=20, default="") def update(self): tmp1 = Tmp1Head() tmp1.name = self.h1_text tmp1.save() for line in self.head_lines.all(): tl1 = Tmp1Line() tl1.head = tmp1 tl1.data_text = line.data_text tl1.t1_data = line.t1_data tl1.t2_data = Decimal(random.random()) tl1.save() with transaction.atomic(): transaction.on_commit(tmp1.update) tmp1.delete() # All fine - remove this work transaction. return True class Line(models.Model): head = models.ForeignKey(Head, on_delete=models.CASCADE, related_name='head_lines') data_text = models.CharField(max_length=20, default="") t1_data … -
Poll is adding multiple votes
I am building a PollApp and I am stuck on a Problem. What i am trying to do :- I am trying to vote only on One choice at a time and if user want to change the voting choice then user can also change the choice. BUT at this time, When user is selecting first choice then it is adding vote again and again and if user is selecting second option then both are adding ( first choice and second choice ). BUT i am trying to add only one choice at a time. views.py def poll_vote(request, poll_id): poll = get_object_or_404(Poll, pk=poll_id) choice_id = request.POST.get('choice') if choice_id: choice = Choice.objects.get(id=choice_id) vote = Vote(user=request.user, poll=poll, choice=choice) vote.save() print(vote) return render(request, 'polls/poll_result.html', {'poll': poll}) else: messages.error( request, "No choice selected") return redirect("polls:polls_detail_view", poll_id) return render(request, 'polls/poll_result.html', {'poll': poll}) I also tried this in poll_vote view if not poll.user_can_vote(request.user): messages.error(request, "You already voted this poll") return redirect("polls:polls_detail_view",poll_id=poll_id) This is working fine like :- When user is voting first choice then it is preventing user from selecting second choice BUT i want, user can change another option after vote. models.py class Poll(models.Model): owner = models.ForeignKey(User,null=True,on_delete=models.CASCADE) text = models.TextField() date = models.DateTimeField(default=timezone.now) def user_can_vote(self, … -
How to solve Javascript template not returning correct value issue in Django,?
I created some values with various operations in my views. Since I am using USE_THOUSAND_SEPARATOR = True in the project, I am going through some operations (otherwise the charts don't work), when I print the final value in the terminal, the value appears correctly. But in the template, it does not take the full value of the integer in javascript, it shows incomplete. For example, in views terminal: print(t1credit) --> 2241825 (Correct) in template: window.alert( ({{ t1credit }}) ) --> 2 (not correct) How can I solve it? views.py top_1_country = Customer.objects.values( 'country__country_name' ).annotate(Count('country'), Sum('credit_limit')).order_by('-country__count')[:1] t1country = "" t1count = 0 t1credit = 0 counter = 0 for top in top_1_country: for q,w in top.items(): if counter == 0: t1country = w elif counter == 1: t1count = w else: t1credit = w counter += 1 sep = '.' t1credit = str(t1credit) t1credit = t1credit.split(sep, 1)[0] t1credit = t1credit.replace(',', '') t1credit = int(t1credit) -
How to check if the form is edit/view/create form in a template for Django admin
I want to customize the view only template in Django admin and want to add custom CSS class if the user opens the view only form (for example class="test_class"). I tried this to change the class for edit form so I can use the default one for add and change templates: Can I tell if a form is an 'edit' form in a template? but it doesn't work. I don't see my custom class when I inspect the form. I want to know if there is a more "cleaner" solutions than this: How to add css class to Django admin form For example (this is a pure guess) something like this in change_form.html: <form {% if form.is_change_form %} class="test_class" {% endif %} -
Faking http-host headers with pytest (and potential security issues)?
I am running a django app with a REST API and I am protecting my API endpoint with a custom permission. It looks like this: class MyPermission(permissions.BasePermission): def has_permission(self, request, view): host = request.META.get('HTTP_HOST', None) return host == "myhost.de" ) The idea is that my API is only accessible via "myhost.de". My question with this approach is twofold: I would like to test this now with pytest. But pytest does not provide host-headers. So I am wondering if I can add (or fake) my headers with pytest. I tried setting the headers but I still get a permission denied 401 status code: @pytest.fixture() def request_unauth(self, client): result = client.get( "myurl", headers={'Host', 'myhost.de'}, content_type="application/json", ) return result def test_host(request_unauth): assert request_unauth.status_code == 200 Assuming I can fake my headers with pytest, is it then also possible for other applications to easily "fake" headers, rendering my permission obsolete? How can MyPermission be evaluated from a security perspective? Thanks so much for any help and hints. Very much appreciated. -
Changing status when Boolean field change value django
I want to change the status of a project automatically when checklist is checked. models.py class Projets(models.Model): id = models.BigAutoField(primary_key=True) date_debut_projets = models.DateField(default=timezone.now) date_fin_provisoire = models.DateField(default=None, blank=True, null=True) description_projets = models.CharField(max_length=255) nom_projets = models.CharField(max_length=100, null=True, blank=True) adresse_projets = models.CharField(max_length=255) code_postal_projets = models.IntegerField() ville_projets = models.CharField(max_length=100) departement_projets = models.CharField(max_length=100) projet_clients = models.ForeignKey(Clients, on_delete=models.CASCADE, default=None) ATTENTE = 'En attente' A_PLANIFIE = 'A planifie' PLANIFIE = 'Planifie' REALISES = 'Realises' ETAT_PROJET = [ (ATTENTE, 'En attente'), (A_PLANIFIE, 'A planifie'), (PLANIFIE, 'Planifie'), (REALISES, 'Realises') ] projet_status_projets = models.CharField( max_length=25, choices=ETAT_PROJET, default=A_PLANIFIE ) entites_projets = models.ForeignKey(Entites, on_delete=models.CASCADE, default=None) starter = models.ForeignKey(User, on_delete=models.CASCADE, related_name='+', default=None) def __str__(self): return self.nom_projets class Checkpoints(models.Model): projet_checks = models.OneToOneField(Projets, on_delete=models.CASCADE, primary_key=True, parent_link=True) check1 = models.BooleanField(default='', blank=True, null=True) check2 = models.BooleanField(default='', blank=True, null=True) check3 = models.BooleanField(default='', blank=True, null=True) check4 = models.BooleanField(default='', blank=True, null=True) check5 = models.BooleanField(default='', blank=True, null=True) check6 = models.BooleanField(default='', blank=True, null=True) check7 = models.BooleanField(default='', blank=True, null=True) OUI = 'oui' NON = 'non' REPONSE = [ (OUI, 'Oui'), (NON, 'Non') ] check8 = models.CharField( max_length=3, choices=REPONSE, default='', blank=True, null=True) check9 = models.BooleanField(default='', blank=True, null=True) check10 = models.BooleanField(default='', blank=True, null=True) check11 = models.BooleanField(default='', blank=True, null=True) check12 = models.BooleanField(default='', blank=True, null=True) check13 = models.BooleanField(default='', blank=True, null=True) check14 = models.BooleanField(default='', blank=True, null=True) pub_date = … -
How can i fetch my data from database to django template?
Whenever I run this, Exception Value: name 'current_user' is not defined; error is raised. I am not getting where i am doing the mistake as I m new in django programming. Please help me fetch the data # To add a new product in the database def AddNewProduct(request): if request.method == "POST": current_user = request.user product_title =request.POST['product_title'] uid = request.POST['uid'] specification =request.POST['specification'] sale_price = request.POST['sale_price'] discount = request.POST['discount'] img1 = request.FILES['img1'] img2 = request.FILES['img2'] promote_method = request.POST['promote_method'] terms_conditions = request.POST['terms_conditions'] newproduct = AffProduct(user_id=current_user.id, product_title=product_title, uid=uid, specification=specification, sale_price=sale_price, discount=discount, img1=request.FILES.get('img1'), img2=request.FILES.get('img2'), promote_method=promote_method, terms_conditions=terms_conditions) newproduct.save() # Status message messages.success(request, 'Product added successfully') return render(request, 'blink_network.html') else: return render(request, 'blink_network.html') #Here i m trying to fetch my data. def showproduct(request): if request.user.is_authenticated: result = AffProduct.objects.filter(user_id=current_user.id) else: result = AffProduct.objects.all() return render(request, 'blink_viewproduct.html', {'result': result}) -
How to use Django URL field?
I have an URL field in Django to which I am adding the URL of a photo, how can I render this image to the frontend of my website. This is my: Models.py file reference This is my: templete.html file reference This is my: Admin file reference Showing 5 images to the frontend: frontend part of the website Problem part : Not showing URL part image I am new to Django, so if I am doing any mistake then please help me out. I would be really appreciable -
How can I use custom filters inside ViewSet views? Django DRF
I have made a custom filter # filters.py class CustomFilter(filters.BaseFilterBackend): def filter_queryset(self, request, queryset, view): if view.action == 'list': # here's additional filtering of queryset return queryset And now I don't understand, how to apply this filter to my queryset inside the view? # views.py class EventViewSet(ViewSet): filter_backends = [CustomFilter] serializer_class = MySerializer def list(self, request): raw_queryset = MyModel.objects.all() filtered_queryset = # here's should be called filter from filter_backends serializer = MySerializer(filtered_queryset , many=True) return Response(serializer.data) -
In python Django I want to run two statements on if else that is if email is taken show it or if username is taken show it
I have a html registration page where I am displaying if any username or email exists or not so if it exists then display username is taken and if email exists it will display email is taken but the problem is even if I give email in the email field in the html form it says username is taken but not email I tried elif statement it didn't worked the username is taken is working perfectly but not email. I mean both statements should run individually If anyone knows please help This is my views.py def Register(request): try: if request.method == 'POST': username = request.POST.get('username') email = request.POST.get('email') password = request.POST.get('password') try: if User.objects.filter(username = username).first(): messages.success(request, 'Username is taken.') return redirect('/register/') if User.objects.filter(email = email).first(): messages.success(request, 'Email is taken.') return redirect('/register/') user_obj = User(username = username , email = email) user_obj.set_password(password) user_obj.save() profile_obj = Profile.objects.create(user = user_obj ) profile_obj.save() return redirect('/login/') except Exception as e: print(e) except Exception as e: print(e) return render(request , 'register.html') -
Django cannot use order_by when annotating
Am using TrucDate to get count by date for the last 1000 records: test_data = RequestModel.objects.filter(user_id=info.context.user.id).order_by('-id')[:1000] .annotate(date=TruncDate('date_created')).values('date').annotate(c=Count('id')).values('date', 'c') The issue is that it is not counting correctly, am having only 1 as count Output: <QuerySet [{'date': datetime.date(2021, 5, 28), 'c': 1}, {'date': datetime.date(2021, 5, 2), 'c': 1}, {'date': datetime.date(2021, 5, 2), 'c': 1}, {'date': datetime.date(2021, 4, 27), 'c': 1}, {'date': datetime.date(2021, 4, 27), 'c': 1}, {'date': datetime.date(2021, 4, 27), 'c': 1}, {'date': datetime.date(2021, 5, 8), 'c': 1}, {'date': datetime.date(2021, 4, 18), 'c': 1}, {'date': datetime.date(2021, 4, 28), 'c': 1}, {'date': datetime.date(2021, 5, 8), 'c': 1}, {'date': datetime.date(2021, 5, 8), 'c': 1}, {'date': datetime.date(2021, 5, 2), 'c': 1}, {'date': datetime.date(2021, 1, 1), 'c': 1}]> However if I remove the order_by('-id')[:1000] from the query I get the count correctly, but, I want to have last 1000 not whole querySet test_data = RequestModel.objects.filter(user_id=info.context.user.id).annotate(date=TruncDate('date_created')).values( 'date').annotate(c=Count('id')).values('date', 'c') Output: <QuerySet [{'date': datetime.date(2021, 1, 1), 'c': 1}, {'date': datetime.date(2021, 4, 18), 'c': 1}, {'date': datetime.date(2021, 4, 27), 'c': 3}, {'date': datetime.date(2021, 4, 28), 'c': 1}, {'date': datetime.date(2021, 5, 2), 'c': 3}, {'date': datetime.date(2021, 5, 8), 'c': 3}, {'date': datetime.date(2021, 5, 28), 'c': 1}]> How can I count by date for the last 1000 records? -
DRF SerializerMethodField not getting called
This is my serializer: class MetaDataSerializer(serializers.Serializer): bg_colors = ColorSerializer(Color.objects.all(), many=True) button_choices = serializers.SerializerMethodField() class Meta: fields = ('bg_colors', 'button_choices') def get_button_choices(self, obj): return { 'save': 1, 'continue': 2, 'cancel': 3, 'back': 4 } I'm calling this serializer from my view like this: class MetaDataView(RetrieveAPIView): serializer_class = MetaDataSerializer def get(self, request, *args, **kwargs): return Response(self.get_serializer().data) In the response I'm getting only the bg_colors field. The other field is absent from response, and its get_field method is also not called. What am I doing wrong here? -
How to generate Qrcode from data and make all Qrcode images to single PDF within one view in Django?
I need to generate Qrcode images from database objects and make all QRcode images as single pdf in one view in Django. Thanks in advance. -
How to add multiple number of module in one cart (Django)
I'm using PostgresSQL as DB, Django as backend and HTML, CSS, Javascript as Frontend. I have Multiple number of product Modules and I want to add all those module in one cart. So, I had Successfully add One of the module in cart. But I want to add different products like Refrigerator, Fans, Washing Machine, ... etc. in one cart So, how it will work? The Codes goes here: models.py class Customer(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) full_name = models.CharField(max_length=200) joined_on = models.DateTimeField(auto_now_add=True) def __str__(self): return self.full_name class Regrigeratior(models.Model): image_src = models.URLField(max_length=300,null=True, blank=True) name = models.CharField(max_length=200, db_index=True, verbose_name="processor name") brand = models.CharField(max_length = 300, null=True, blank=True) .... def __str__(self): return self.name class Fans(models.Model): image_src = models.URLField(max_length=300,null=True, blank=True) name = models.CharField(max_length=200, db_index=True, verbose_name="processor name") brand = models.CharField(max_length = 300, null=True, blank=True) .... def __str__(self): return self.name . . . class Cart(models.Model): customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, null=True, blank=True) total = models.PositiveIntegerField(default=0) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return "Cart: " + str(self.id) # class CartProduct(models.Model): cart = models.ForeignKey(Cart, on_delete=models.CASCADE) refrigerator = models.ForeignKey(Refrigerator, on_delete=models.CASCADE) rate = models.PositiveIntegerField() quantity = models.PositiveIntegerField() subtotal = models.PositiveIntegerField() def __str__(self): return "Cart: " + str(self.cart.id) + " CartProduct: " + str(self.id) I have succesfully add Refrigerator Module in the cart … -
Atomic transaction to update pair of related objects at once
I have a simple task - mark all User's and its Profiles as "is_active", and I do it like this: users = User.objects.all().select_related('profile') for user in users: user_profile = user.profile user.is_active = True user_profile.is_active = True user.save() user_profile.save() Sometimes it corrupts data, so user's is_active and user.profile's is_active not always synced And the best plan I can think of is to wrap both .save()s into atomic transaction from django.db import transaction users = User.objects.all().select_related('profile') for user in users: user_profile = user.profile user.is_active = True user_profile.is_active = True with transaction.atomic(): user.save() user_profile.save() So, should it work?) The concern is - maybe whole block, including users = User.objects.all().select_related('profile') should be wrapped P.S. I can not use .update() due to complex logic inside -
I am just wondering if I can change primery key in django
I know django set primery key for the object automatically even if I don't do anything... it starts from 1 for first object created. I would like to have primery key start from 100, not 1. is it possible? if so, how could i set this up? -
Django dependent dropdown
So i want to get data from dependent dropdown but i get only the id value not the actual value of data. class Service(models.Model): customer = models.ForeignKey(Customer, on_delete=models.CASCADE) serv_type = models.ForeignKey(Servicetype,on_delete=models.CASCADE) serv_job_card_no = models.CharField(max_length=100) serv_job_loc = models.CharField(max_length=100,default='') serv_cost = models.CharField(max_length=100) serv_exp_date = models.CharField(max_length=100) class Servicetype(models.Model): serv_type = models.CharField(max_length=100) -
django async ORM sync_to_async executor swap out concurrent.futures.ThreadPoolExecutor when using gevent
The third kwarg that can be passed to asgiref's sync_to_async is an executor the executor is a type of concurrent.futures.ThreadPoolExecutor According to the documentation gevent.threadpool.ThreadPoolExecutor more or less inherits and wraps concurrent.futures.ThreadPoolExecutor Say for example I want to use a werkzeug DispatcherMiddleware, and wrap an ASGI app. Think FastAPI mounted to the inside of an older monolithic django WSGI app ( using eventlet / gevent / monkey patching ) Here's my attempt at doing it. https://github.com/rednaks/django-async-orm/pull/7/files Basically, how to get django async-ish ORM? try: from gevent.threadpool import ThreadPoolExecutor as GThreadPoolExecutor from django.conf import settings if settings.GEVENT_DJANGO_ASYNC_ORM: from gevent import monkey monkey.patch_all() def monkey_patch_the_monkey_patchers(ex): from .patch_gevent import _FutureProxy def submit(ex, fn, *args, **kwargs): # pylint:disable=arguments-differ print(fn, *args, **kwargs) with ex._shutdown_lock: # pylint:disable=not-context-manager if ex._shutdown: raise RuntimeError('cannot schedule new futures after shutdown') future = ex._threadpool.spawn(fn, *args, **kwargs) proxy_future = _FutureProxy(future) proxy_future.__class__ = concurrent.futures.Future return proxy_future ex.submit = submit return ex MonkeyPoolExecutor = monkey_patch_the_monkey_patchers(GThreadPoolExecutor) conf = {"thread_sensitive": False, "executor": MonkeyPoolExecutor(max_workers=1)} executor_ = MonkeyPoolExecutor except Exception as e: print(e) print('defaulting django_async_orm') pass And then called like: await sync_to_async(SomeModel.objects.all, **conf)() https://github.com/rednaks/django-async-orm/discussions/9 https://github.com/abersheeran/a2wsgi related: django 3.0 async orm with concurrent.futures.ThreadPoolExecutor() as executor: ... does not wait -
AttributeError: 'UserViewSet' object has no attribute 'user'
I've currently got an API endpoint that works as I would expect it when I send a request to it manually via Postman. I am now trying to setup unit tests using factory-boy but I'm not able to get it to work due to an error. So far, the important files with regards to the unit tests that I have are: urls.py from django.urls import include, path from rest_framework import routers from rest_framework.schemas import get_schema_view import views router = routers.DefaultRouter() router.register(r"user", views.UserViewSet, basename='user') urlpatterns = [ path('user', views.UserViewSet.as_view({'get': user}), name='user') ] test_user.py import factory from django.test import Client, TestCase from django.urls import reverse from factory import DjangoModelFactory, Faker from models.user import User class UserFactory(DjangoModelFactory): class Meta: model = User class UserViewSetTest(TestCase): def setUp(self): client = Client() def test_user_list(self): response = self.client.get(reverse('user'), format='json') self.assertEqual(response.status_code, 200) When running pytestusing the above, I get an error: AttributeError: 'UserViewSet' object has no attribute 'user' As I mentioned, I've been able to send a request via Postman to the API so I'm not sure it's useful to show my complete code (i.e. the ViewSet, models and serializers). For what it's worth, the viewset currently just returns a list of users in Json format. -
Unable to access uploaded image from aws S3 bucket through Django
I have successfully done the configuration of uploading images to s3 bucket through django settings.py file. this is my config: AWS_ACCESS_KEY_ID = '######################' AWS_SECRET_ACCESS_KEY = '###########################' AWS_STORAGE_BUCKET_NAME = 'divytrust-image' AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = None DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' I am using Nginx+gunicorn on server. I am successfully able to upload image to s3bucket/pics But when I try to view the image from django admin panel, I get error: This XML file does not appear to have any style information associated with it. The document tree is shown below. <Error> <Code>InvalidRequest</Code> <Message>The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.</Message> <RequestId>1F51EJV41QT73FSV</RequestId> <HostId>ZL9W4GqDXDbPluBsX+aC4FvRzVy0CLLjy6mXEPL8U/zAWSFzNi1tAQQixGIhbLgeADS1DV0Mv8c= </HostId> -
Check if a file exist in Django
I have created a newclaim.html and editclaims.html. newclaims.html allows me to upload a file while editclaims.html allows me to retrieve the file. Currently, I am able to retrieve the uploaded file but I want to do an if-else. I want to do an if-else that will delete the old file if a new file is uploaded This is my views.py **# Submit a new Claim** def newclaim(request): context = initialize_context(request) user = context['user'] if request.method == 'POST': receipt = request.FILES['receipt_field'] ins = SaveClaimForm(receipt=receipt) ins.save() print("The Data has been written") return render(request, 'Login/newclaim.html/', {'user':user}) # Edit a claim def editclaims(request,id): context = initialize_context(request) user = context['user'] # get original object claims = SaveClaimForm.objects.get(id=id) if request.method == 'POST': # update original object claims.receipt = request.FILES.get('receipt') # save it with original `ID` claims.save() return render(request, "Login/editclaims.html", {'claims':claims, 'user':user}) -
How can i use AWS SNS Https Endpoint i.e API of my backend server which running in Django?
I want to use my Backend API endpoint in AWS SNS Https endpoint but my backend API Development done in Django Restrframework and it's verifying access token also with the help of aws cognito . If i'll call my API from SNS Endpoint then my backend required access token which is authenticate by user pool of cognito in backend but how i can call my backend endpoint without verifying access token because i'm calling internal server api thatt will not call by user. Actually it will call by SNS Endpont. -
channels_presence.Presence.user: (fields.E300) Field defines a relation with model 'auth.User', which is either not installed, or is abstract
I am trying to use django channels_presence in my project but my user model is present in another project(microservice architechure) named auth which gives me the error: channels_presence.Presence.user: (fields.E300) Field defines a relation with model 'auth.User', which is either not installed, or is abstract. channels_presence.Presence.user: (fields.E307) The field channels_presence.Presence.user was declared with a lazy reference to 'auth.user', but app 'auth' isn't installed. How do I use channels_presence without User model in the same project?