Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django rest api: user authentication with multyple databses
I need to developed Django rest API with access to multiple databases and also need to authenticate from multiple databases ex - user1 - authenticate from database1 user table user2 - authenticate from database2 user table router URL ex - http://examle.com/API/auth/{site1}/login - this route should use database1 user table username and password http://example.com/API/auth/{site2)/login - this route should use database2 user table username and password how can I achieve this task? -
Django class-based view processing form and adjusting context accordingly
I'm pretty new to Django and Python in general. I am building a Django app at the moment and am trying to stick to class-based views. I have a form (FormView) that I would like process, meaning take the data, clean it up and store it in the database. When processed I'd simply like to show the form again (so no redirect to another success page) and show the result of the processing above the form. How would I do that? I have played around with get_context_data to add the additional context for the result message but can't figure out how and where to process the data and how to tie it together with updating the context data then. Any help would be appreciated. forms.py: from django import forms class URLsForm(forms.Form): list_of_urls = forms.CharField(label='One URL per line', widget=forms.Textarea) views.py from django.views.generic import FormView from .models import URL from .forms import URLsForm class URLBatchCreateView(FormView): form_class = URLsForm template_name = 'bot/url_batch_create.html' success_url = reverse_lazy('url_batch_create') def form_valid(self, form): return super(URLBatchCreateView, self).form_valid(form) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['created_urls'] = 'The result' return context url_batch_create.html: {% extends 'bot/base.html' %} {% block content %} {% if created_urls %} <div>The following URLs where created:<br>{{ created_urls }}</div> … -
django url pass in context and post.id
views.py class CheongsamViewSet(viewsets.ModelViewSet): def list(self, request): # set context context = { 'url_update': 'item_update', } return Response(context) def update(self, request, pk): profile = get_object_or_404(itemModels, pk=pk) serializer = itemSerializers(profile, data=request.data) if serializer.is_valid(): serializer.save() print('status: status.Item Update') return redirect('item') else: print('status: status.Item Bad Update') urls.py urlpatterns = [ path('item/', cheongsam_router_list, name='item'), path(r'item/product_edit/<str:pk>', cheongsam_router_detail, name='item_update') ] create.html <a href="{% url url_update post.id %}" class="btn btn-success" title="btn btn-success">Edit</a> how do i pass in context variable and pk id at the same time in {% url %} ? both the context variable and object post has positive return so dont worry about it, but how do i put them into gether ? if i just do {% url url_update %} or {% url 'item_update' post.id %} things work just fine. error: Reverse for '' not found. '' is not a valid view function or pattern name. -
How to replace string in django model query
I want to replace a string in a django model query result. my model: class director(models.Model): direction = models.CharField(max_length=100) name = models.CharField(max_length=100) The content of the direction field is either "U", "D", "L" or "R". How do I make a query so that when I select the field direction, I get "Up", "Down", "Left", "Right" respectively. I can achieve this in SQL with: SELECT replace(replace(replace(replace(direction, "U", "Up"),"D", "Down"),"L", "Left"),"R", "Right) as direction from director or using CASE WHEN in in SQL. I know I can achieve this using for loop in python after director.objects.all() but I was hoping that I can do this in the query itself -
How to get the text file which is uploaded from android device and store it in a folder using django?
I want to save the text file or zip file in folder which can be uploaded in mobile devices(Android,IOS) using django framework.How to get the file in request ? Thanks in advance -
Reverse for 'customerdel' with arguments '('',)' not found.1 pattern(s) tried: ['dashboard/records/customerdel/(?P<pk>[0-9]+)$']
I am trying to delete an object from database using simple html button. Also, trying to implement "are you sure" message? BUt I am getting this error everytime and I am not able to crack. This is my view function. def customerdel(request,pk): objs = Customer.objects.filter(id=pk) if request.method == 'POST': objs.delete() # messages.success(request, 'Successfully deleted') return render(request,'records.html') else: content ={ 'items':Customer.objects.all } return render(request,'delete.html', content) This is record.html page <h1>Record's page</h1> {% for abc in Customerdata %} {{abc.name}} {{abc.pk}} <form > <button class="btn btn-danger btn-sm"> <a href="{% url 'customerdel' abc.pk %}">Delete</a></button> </form> {% endfor %} This is delete.html page <h1>Welcome to Delete page</h1> <p>Are you sure want to del {{items.name}} ??</p> <form action="{% url 'customerdel' items.pk %}" method="post"> {% csrf_token %} <a href="{% url 'records' %}">Cancel</a> <input name="confirm" type="submit" > </form> This is my URL. path('dashboard/records/customerdel/<int:pk>', views.customerdel, name='customerdel'), -
Django admin Template Error at admin Template incorrect padding
Default Django Admin not showing Error at /admin/ Incorrect padding Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Django Version: 3.1 Exception Type: Error Exception Value: Incorrect padding Exception Location: C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\base64.py, line 87, in b64decode Python Executable: C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\python.exe -
How to stream the contents of a log file in Django as a web-page
Since Django mainly uses static content served as web pages, how can I write a view that would scroll with the contents of a semi-fast moving log file? I know that redis can cache information as a high speed dictionary, but not sure if I need it for just tailing a log file & rendering the information. Any help here appreciated. -
How to get product id and display its details in django
i followed a youtube tutorial to make e-commerce site and now i'm trying to learn by adding new features to it .i am able to populate different products from the model. i want to display the details of the clicked product on a different page. this is what i have done so far.Thanks models.py class Product(models.Model): name=models.CharField(max_length=200,null=True) price=models.DecimalField(max_digits=7,decimal_places=2) digital=models.BooleanField(default=False,null=False,blank=False) image = models.ImageField(null=True,blank=True) description=models.CharField(max_length=500,null=True) def __str__(self): return self.name views.py def store(request): data=cartData(request) cartItems=data['cartItems'] order=data['order'] items=data['items'] products=Product.objects.all() context={'products':products,'cartItems':cartItems} return render(request,"foodapp/home.html",context) def detail(request): products=Product.objects.get(id=product.id) context={'products':products} return render(request,"foodapp/detail.html",context) urls.py urlpatterns=[ path('',views.store,name='store'), path('cart/',views.cart,name='cart'), path('checkout/',views.checkout,name='checkout'), path('update_item/',views.updateItem,name='update_item'), path('signup/',views.SignUp.as_view(),name='signup'), path('logout/',auth_views.LogoutView.as_view(next_page='login'),name='logout'), path('login/',auth_views.LoginView.as_view(template_name='foodapp/login.html'), name='login'), path('process_order/',views.processOrder,name='process_order'), path('detail/',views.detail,name='detail'), home.html {% for product in products %} <div style="margin-top: 30px;" class="col-md-4"> <div class="box-element product"> <img class="thumbnail" src="{{product.imageURL}}" alt=""> <hr> <h6><strong>{{product.name}}</strong></h6> <hr> <h6>Type:</h6> <button data-product="{{ product.id }}" data-action="add" class="btn btn-outline-secondary add- btn update-cart"> <a href="#"> Add to Cart</a></button>&nbsp; <button data-product="{{ product.id }}" class="btn btn-outline-secondary"> <a href="{% url 'detail' %}">View</a> </button> <h4 style="display: inline-block; float: right;">{{product.price}} </h4> </div> </div> details.html {% for product in products %} <div style="margin-top: 30px;" class="col-md-4"> <div class="box-element product"> <img class="thumbnail" src="{{product.imageURL}}" alt=""> <hr> <h6><strong>{{product.name}}</strong></h6> <hr> <h6>Type:</h6> <button data-product="{{ product.id }}" data-action="add" class="btn btn-outline-secondary add- btn update-cart"> <a href="#"> Add to Cart</a></button>&nbsp; <button data-product="{{ product.id }}" class="btn btn-outline-secondary"> <a href="{% url 'detail' … -
Best way to define reusable blocks for streamfields
I'm planning on building large portions of my page templates with streamfields, using blocks that will be reused across page models. What's the best way to implement this so I can reuse my code across models, and leave only 1 place to update if I want to change the block or the way it renders? I'm envisioning basically building a library of streamfield block definitions, then selecting the applicable ones for a given field in a given model. Should I just go with a generic python library and include it and reference it in my page models, or use abstract Django models or something else? I think trying to make the actual instances of the blocks reusable within the page admin will be overkill (and over my head), but would be open to that as well. -
NoReverseMatch at /posts/list/ Reverse for 'post_detail' not found. 'post_detail' is not a valid view function or pattern name
Well I am working on a simple project and I am stuck on this error. I have tried several way to fix it but non of them work. Maybe you can see and point out my mistake in my code. I am using everything right according to my concept of djnago. But i am new that is my concepts are not so strong i guess. App/urls.py app_name = 'posts' urlpatterns = [ path('about/',views.AboutView.as_view(),name ='about'), path('new/',views.PostCreateView.as_view(),name= 'create'), path('<int:pk>/detail/',views.PostDetailView.as_view(),name ='post_detail'), path('list/',views.PostListView.as_view(),name ='post_list'), path('<int:pk>/remove/',views.PostDeleteView.as_view(),name ='post_remove'), path('<int:pk>/update/',views.PostUpdateView.as_view(),name ='update'), ] App/views.py class PostListView(ListView): model = Post class PostDetailView(DetailView): model = Post class PostCreateView(LoginRequiredMixin,CreateView): form_class = PostForm model = Post class PostUpdateView(LoginRequiredMixin,UpdateView): form_class = PostForm model = Post class PostDeleteView(LoginRequiredMixin,DeleteView): model = Post success_url = reverse_lazy('post_list') post_detail.html {% extends 'base.html' %} {% block content %} <div class='jumbotron'> <h1>Welcome to grabPublic site</h1> <p>Title :{{post.title}}</p> <a class= "btn btn-primary" href="{% url 'posts:post_remove' pk=post.pk %}">del me </a> </div> {% endblock content %} post_list.html {% extends 'base.html' %} {% block content %} <div class="jumbotron"> {% for post in post_list %} <div class="post"> <h1><a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a></h1> <div class="date"> <p> Published on: {{ post.published|date:"D M Y" }} </p> {% endfor %} </div> {% endblock content %} App/models.py … -
How to get a model object using another model object in a template in django
I am trying to get a model object using another model object in my template but i am unable to do so. Please help me to do so. this is my models.py class roomuser(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) date = models.DateTimeField(auto_now_add=True) room = models.ForeignKey(rooms, on_delete=models.CASCADE) class profile(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) name = models.CharField(max_length=100) status = models.TextField(max_length=200, default='Hey, I\'m using twitter') img = models.ImageField(default='default.png', upload_to='profile_pics') private = models.BooleanField(default='False') this is my views.py def room(request, name): myroom = rooms.objects.get(name=name) roomusers = roomuser.objects.filter(room=myroom) myuser = profile.objects.all() return render(request, 'room.html', {'room':myroom, 'users':roomusers, 'myuser':myuser}) this is my template view {% for user in users %} {{user.user}}<br> {{user.user.username.myuser.name}} {% endfor %} i want to access a profile object by using a object of roomuser model as they both have a user class in common. Please help me to do so. Thankyou very much. -
TypeError 'bool' object is not callable in django
I am implementing login function using simple-jwt module in django. At this time, only users who have authenticated their e-mail can log in, and the following error occurs in this conditional sentence. TypeError 'bool' object is not callable in django I don't know why I can't bring in a bool type variable. How can I fix this error? Here is my code. views.py from .models import User from .utils import Util from .serializers import customRegisterSerializer, customLoginSerializer, customTokenRefreshSerializer, userProfileSerializer from rest_framework.permissions import IsAuthenticated from rest_framework.generics import GenericAPIView from rest_framework_simplejwt.tokens import RefreshToken from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView from rest_framework.viewsets import ModelViewSet from rest_framework.response import Response from django.urls import reverse from django.conf import settings from django.contrib.sites.shortcuts import get_current_site import jwt class customSignUpView (GenericAPIView) : serializer_class = customRegisterSerializer def post (self, request) : user = request.data serializer = self.serializer_class(data=user) serializer.is_valid(raise_exception=True) serializer.save() user = User.objects.get(email=serializer.data['email']) token = RefreshToken.for_user(user).access_token current_site = get_current_site(request).domain relativeLink = reverse('emailVerify') absurls = F'http://{current_site}{relativeLink}?token={token}' email_body = F'Hi {user.username} Use link below to verify your email \n{absurls}' data = {'email_body': email_body, 'to_email': user.email, 'email_subject': 'Verify your email'} Util.send_email(data) return Response({'message': '이메일을 확인하세요'}, status=201) class customLoginView (GenericAPIView) : serializer_class = customLoginSerializer def post (self, request) : serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) try : user = … -
django-modeltranslation: how to disable showing objects (e.g. posts) the languages where it is not defined?
I am developing a django multilingual app and using django-modeltranslation to translate the models. It works fine except one thing: when translation is not available in a specific language, it still shows the objects (let's say posts). I have some posts that are available in tajik while not available in russian, and vice versa. My goal is to disable showing the posts in the language which I do not have translation. May be by showing 404 or any other way, but it should not show the posts at all, not partially Here are my settings: settings.py LANGUAGES = [ ('ru', _('Russian')), ('tg', _('Tajik')), # ('en', _('English')), ] EXTRA_LANG_INFO = { 'tg': { 'bidi': False, 'code': 'tg', 'name': 'Tajik', 'name_local': u'Тоҷикӣ', }, } # Add custom languages not provided by Django LANG_INFO = dict(list(django.conf.locale.LANG_INFO.items()) + list(EXTRA_LANG_INFO.items())) django.conf.locale.LANG_INFO = LANG_INFO global_settings.LANGUAGES = global_settings.LANGUAGES + [("tg", 'Tajik')] LANGUAGE_CODE = 'ru' # from modeltranslation.settings import ENABLE_REGISTRATIONS MODELTRANSLATION_LANGUAGES = ('tg','ru') MODELTRANSLATION_DEFAULT_LANGUAGE = ('tg') MODELTRANSLATION_FALLBACK_LANGUAGES = ('ru', 'tg') transation.py from modeltranslation.translator import translator, TranslationOptions from blog.models import Post, Matlab class BlogPostTranslationOptions(TranslationOptions): fields = ('Title', 'ShortDesc', 'Content') translator.register(Post, BlogPostTranslationOptions) models.py: class Post(models.Model): STATUS_CHOICES = ( ('draft', 'Черновик'), ('published', 'Опубликованно'), ) POST_TYPE_CHOICES = ( ('image', 'Image'), ('video', 'Video'), … -
Is there any difference Dockering fullstack Django vs. Django Rest framework application?
There are many instructions for rest framework dockering, but is it similar to normal django with templates (=html pages) ? Also I use mongodb atlas cloud db with djongo. It works locally, but will it work with dockerized django app? Reason why Im dockering is that any app service I have tried doesn´t accept mongo with django the same way as it works locally. -
Django-React/Redux-Apache project: Can't resolve url
first time building a web app. decided to use django/react with redux and django rest framework for api routing and component state. decided to implement apache as a production server and test locally. when I used the django development server everything worked fine but when I switched to apache I hit an issue. I can get the static content to display at the root url "http://localhost" but can't get any further urls to resolve. On the main page of this app there's a component that, when it mounts, calls a url (GET) ".../api/buildings" to populate the component with some data but the server responds with a 404 or 500 but didn't when I used django dev server. I can't figure out what I'm doing wrong and seeing as I'm pretty new to this I'd appreciate some help! here's some code references and lmk if I can provide anything else. thanks in advance! building component that makes the call during mount: export class Buildings extends Component { static propTypes = { buildings: PropTypes.array.isRequired, getBuildings: PropTypes.func.isRequired, deleteBuildings: PropTypes.func.isRequired, }; componentDidMount() { this.props.getBuildings(); }; render() { return ( <Fragment> <h2>Buildings</h2> <table className="table table-striped"> <thead> <tr> <th>Id</th> <th>Name</th> <th>Code</th> <th>Last_Inspection</th> <th /> </tr> </thead> … -
How to set up a Celery Server on AWS for Django
I made a Django project and want to implement async tasks. My Django project is hosted on AWS Elastic Beanstalk with a Postgres DB on AWS RDS. I want to set up a Celery server that can read from my DB periodically and execute tasks. However, I don't know the first thing about how to host my Celery server on AWS. Where should I begin? Thanks! -
cannot unpack non-iterable CustomerPurchaseOrderDetail object
I am getting the correct computation of quantity and price it shown in my terminal, but when i tried to save it to my database i receive this error cannot unpack non-iterable CustomerPurchaseOrderDetail object I have this code in my views.py def addtocart(request): userID = request.POST.get("userID") client = Customer(id=userID) vegetables_id = request.POST.get("id") quantity = request.POST.get("quantity") percentage = request.POST.get("percentage") price = request.POST.get("price") v = Product(id=vegetables_id) total = float(quantity) * float(price) print(total) insert, created = CustomerPurchaseOrderDetail( profile=client, products = v, quantity = quantity, unitprice=price, discount_percentage = percentage, amount = total ) if not created: insert.quantity += 1 insert.save() this is my models.py class CustomerPurchaseOrderDetail(models.Model): profile = models.ForeignKey(Customer,on_delete=models.SET_NULL, null=True, blank=True, verbose_name="Client Account") products = models.ForeignKey(Product,on_delete=models.SET_NULL, null=True, blank=True,verbose_name="Product") quantity = models.IntegerField(null=True, blank=True, default=1) unitquantity = models.FloatField(max_length=500, null=True, blank=True) totalquantity = models.FloatField(max_length=500, null=True, blank=True) unitprice = models.FloatField(max_length=500, null=True, blank=True) discount_percentage = models.FloatField(max_length=500, null=True, blank=True) discounted_unitprice = models.FloatField(max_length=500, null=True, blank=True) discounted_amount = models.FloatField(max_length=500, null=True, blank=True) amount = models.FloatField(max_length=500, null=True, blank=True) this is my traceback Traceback: File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\User\Desktop\LastProject\OnlinePalengke\customAdmin\views.py" in addtocart 926. amount = total Exception Type: TypeError at /addtocart/ Exception … -
Django: How to add to an ArrayField?
I have some questions about the ArrayField mentioned here: https://docs.djangoproject.com/en/3.1/ref/contrib/postgres/fields/#django.contrib.postgres.fields.ArrayField How do you add to an ArrayField? It's clear you can treat it like a regular field and do things like my_array_field = [] my_array_field.save() But what's confusing is I'm seeing everyone mention my_array_field.append("something") in StackOverflow questions. This isn't mentioned in the documentation at all. Moreover, if an arrayfield is .append()ed to, does it still require .save()? -
How to implement such a custom rollback in Django or DRF?
Out system accesses to a middle platform(I do not know how to call it in English, we call it 中台 in Chinese) which is for authentication like logging in, JWT verifying, etc. Then, We have encoutered questions when it is neccessary to rollback actions because of unexpected program errors. Like code below, the program will crash when running at 1 / 0, then AdminPermission.objects.create can be rolled back, but do_user_actions can not, cause it is a RPC function. So, we need to override transaction.atomic or something like this to implement our requirements. But, I do not know how to implement it. Pls give me some suggestions or sample code. Thx a lot. @transaction.atomic # can not rollback remote func call `do_user_actions` def create(self, request, *args, **kwargs): # call a remote func here to create a admin account. user_dict = do_user_actions(query_kwargs=query_kwargs, action='create-admin') user_id = user_dict.get('id') permission_code = 'base_permission' AdminPermission.objects.create(user_id=user_id, permission_code=permission_code) # some unexpected errors, like: 1 / 0 return Response('success') -
How can i make the following video objects using django
How to use django to make the objects in the following video Need model https://www.youtube.com/watch?v=AtS8hlbx3Bc -
Django - how to encode URL parameters with forward slash only once in template?
I am having a very specific issue in my template when creating an anchor tag with the {% url %} templatetag. One of the parameters I pass to it can include a forward slash, and I want to encode that. However, if I use |urlencode:"" as is mentioned in the docs (https://docs.djangoproject.com/en/3.1/ref/templates/builtins), this leads to the variable being double encoded when it arrives in the view. This is what I have in the template: <a href={% url 'myapp:myview' param1=param1 paramWithSlashes=paramWithSlashes|urlencode:"" %}> Then in my view function, the variable paramWithSlashes comes in double encoded. Meaning in order to get back the original string I have to call: import urllib.parse def myView(request, param1, paramWithSlashes): originalStr = urllib.parse.unqoute(urllib.parse.unquote(paramWithSlashes)) This is a really hacky solution and I'm sure double encoding/decoding is unwise in the long run. How can I ensure the url template tag only encodes once, with '/' included in the encoding? -
rest framework django "detail": "Method \"GET\" not allowed."
i am using django rest framework. am getting error "detail": "Method \"GET\" not allowed." i also trying two ways but error is still there. can anybody know how can i solve this error. serializer.py from rest_framework import serializers from .models import Book class BookSerialzer(serializers.ModelSerializer): class Meta: model = Book fields = ['id', 'name', 'price'] views.py 1 class BookCreateView(CreateAPIView): queryset = Book.objects.all() serializer_class = BookSerialzer OR: i am trying two ways for solving this issue but error is still there views.py 2 class BookCreateView(APIView): def post(self, request, format=None): serializer = BookSerialzer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) urls.py from django.urls import path from .views import BookCreateView urlpatterns = [ path('create/', BookCreateView.as_view()), # path('create/', BookCreateView.as_view(), name='create-repo') /// same error with that ] -
Displaying pdf in object tag using HTML5
While displaying the pdf using django's static url, below code works perfectly fine with object tag. <object data="{% static 'v.pdf' %}" type="application/pdf" height="800" width="650"></object> But it does not work with media <object data="{{ media}}/v.pdf" type="application/pdf" height="800" width="650"></object> So, even I tried sending absolute url (http://localhost:8000/v.pdf) in a separate variable {{media_pdf_url}}, but no luck. <object data="{{media_pdf_url}}" type="application/pdf" height="800" width="650"></object> I could see an error in the browser console - Refused to display 'http://localhost:8000/v.pdf' in a frame because it set 'X-Frame-Options' to 'deny'. but could not find any solution, what exactly I need to do to allow 'X-Frame-Options' in the media urls? -
Why do I get "AssertionError: May not set both `read_only` and `required`" in Django Rest Framework?
Why am I getting AssertionError: May not set both 'read_only' and 'required' when I try to access the TestViewSet? Here is the MRE: models.py: class Channel(models.Model): id = models.CharField(max_length=12, primary_key=True) class Test(models.Model): channel = models.ForeignKey(Channel, on_delete=models.PROTECT) foo = models.IntegerField(default=1) class Meta: unique_together = ( ('channel_id', 'foo'), ) views.py: from rest_framework import routers, viewsets, serializers class TestSerializer(serializers.ModelSerializer): class Meta: model = Test fields = [ 'channel_id', 'foo', ] class TestViewSet(viewsets.ModelViewSet): queryset = Test.objects.all() serializer_class = TestSerializer router = routers.DefaultRouter() router.register('test', TestViewSet) If you remove the unique constraint on Test, or set fields='__all__', on the serializer, the view magically starts working again. I'd prefer not to use fields='__all__' for 2 reasons: it will result in a lot of unused data on my real serializer the channel_id column ends up being rendered as channel, which is inconvenient, and will force me to update my frontend code to reference channel, or I will have to append _id to the data. I would just create an alias on the serializer: class TestSerializer(serializers.ModelSerializer): channel_id = serializers.CharField(source='channel_id') ... but doing so results in another error... AssertionError: It is redundant to specify `source='channel_id'` on field 'CharField' in serializer 'OrderSerializer', because it is the same as the field name. …