Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Make django handle subdomain suffix
We're hosting several dockerized web-apps on our webserver, let's call it group.example.com. Our subdomains are handled via nginx as suffixes though, which translates to something like group.example.com/app1/ group.example.com/app2/ as root urls. When using Django, we run into problems though, as all its urls generated by url in the templates such as <a href="{% url 'index' %}">home</a> will be relative links, so rendered to <a href="/">home</a>. This relative link will not be interpreted correctly, leading to the main, non-app page group.example.com. So the goal is to have an app based prefix such as /app1/ for all links. I can hardcode these for static links, but there has to be a more elegant way. Also this leads to problem for the used forms submitting to the wrong page - redirecting again back to the main, non-app page group.example.com. I tried adding /app1/ to all registered urls as prefix, but that doesn't seem to work either - that way the app is running but user would need to visit group.example.com/app1/app1/ to get to the index, and the relative links still don't work correctly. In the app docker-container we're running the web-app with nginx and uwsgi. It works fine when using correct subdomains such … -
Trying to understand django url namespacing
I was going through the Django docs, here they're talking about removing hardcoding in urls so that its easier to modify urls in the future. This is how a hardcoded url looks like <li><a href="/polls/{{ question.id }}/">{{ question.question_text }}</a></li> After removal of hardcoded string <li><a href="{% url 'detail' question.id %}">{{ question.question_text }}</a></li> This is all well and done. What's confusing me is the namespacing part from django.urls import path from . import views app_name = 'polls' urlpatterns = [ path('', views.index, name='index'), path('<int:question_id>/', views.detail, name='detail'), path('<int:question_id>/results/', views.results, name='results'), path('<int:question_id>/vote/', views.vote, name='vote'), ] Here the app_name variable is introduced to store the app name, polls in this case. But in the view they have gone and specified <li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li> Isn't this the same as before? I mean the hardcoded URL issue is right there... What is the design pattern behind this. Why can't they just look at the app folder and get the app name from there? -
How do I access separate Django-entangled JSONField items in a form with jinja?
does someone have an idea how I get individual entangled_field items into my form? Here's my code, I'll explain further down (in form.html) where I'm having issues. models.py class Project(Model): """Project Data""" eeg = JSONField() meg = JSONField() forms.py class ProjectForm(EntangledModelForm): """HTML form for Project objects https://github.com/jrief/django-entangled""" nosessions = IntegerField(required=False) sessionduration = IntegerField(required=False) hoursrequired = IntegerField(required=False) esthourspermonth = IntegerField(required=False) class Meta: model = Project entangled_fields = { "eeg": [ "nosessions", "sessionduration", "hoursrequired", "esthourspermonth", ], "meg": [ "nosessions", "sessionduration", "hoursrequired", "esthourspermonth", ], } untangled_fields = [..working fields..] Django object proj112 = Project.objects.get(name='112_test') for k,v in proj112.eeg.items(): print(k,v) nosessions 5 hoursrequired 10 sessionduration 2 esthourspermonth 10 for k,v in proj112.meg.items(): print(k,v) nosessions 10 hoursrequired 20 sessionduration 2 esthourspermonth 20 detail.html - I can successfully access/list the keys and values for both 'eeg' and 'meg' once they are created (manually via the api or database). <table> <b>EEG</b> {% for key,value in project.eeg.items %} <tr> <td>{{key}}</td><td>{{value}}</td> </tr> {% endfor %} </table> <table> <b>MEG</b> {% for key,value in project.meg.items %} <tr> <td>{{key}}</td><td>{{value}}</td> </tr> {% endfor %} </table> form.html - This displays the field correctly but inserts data to both 'eeg' and 'meg'. {{ form.nosessions|as_crispy_field }} I want to reference them separately as I have a … -
I am facing a problem while trying to deploy python django app to heroku
-----> Python app detected cp: cannot stat '/tmp/build_f87e66a969d68e5390ddccb6b44523c7/requirements.txt': No such file or directory it constantly gives me this error and the app wont run its getting frustrated now can anyone help?? -
Django taggit with Count: the example from book
I am trying to understand the example from book "Django by Example". There is a blog application with tags. models.py class Post(models.Model): # ... tags = TaggableManager() views.py def post_detail(request, pk): post = get_object_or_404(Post, pk=pk) # List of similar posts post_tags_ids = post.tags.values_list('id', flat=True) similar_posts = Post.published.filter(tags__in=post_tags_ids)\ .exclude(id=post.id) similar_posts = similar_posts.annotate(same_tags=Count('tags'))\ .order_by('-same_tags','-publish')[:4] return render(request, 'blog/post_detail.html', {'post': post, 'similar_posts': similar_posts}) From my point of view, annotate(same_tags=Count('tags')) will count all tags in each post in similar_post Queryset. Why does it pick and sum only the same tags as in my post? Thanks in advance -
How to groupby nested object elements In Django Rest FrameWork
How to use group-by for nested objects class RequirementInfo(models.Model): name = models.ForeignKey(PostJobRequirement, on_delete=models.CASCADE) class CandidataInfo(models.Model): name = models.ForeignKey(CandidateList, on_delete=models.CASCADE) rate = models.FloatField(null=True, blank=True) class SubmittedCandidateInfo(models.Model): requirement = models.ArrayField(model_container=RequirementInfo) candidate = models.ArrayField(model_container=CandidataInfo) def __str__(self): return str(self.requirement[0]) class SubmittedCandidate(CreateModificationDateMixin): submitted_candidate_id = models.IntegerField(default=sub_id, editable=False, primary_key=True) submit_candidate = models.ArrayField(model_container=SubmittedCandidateInfo) def __str__(self): return str(self.submitted_candidate_id) class Meta: verbose_name_plural = "submitted_candidates" db_table = "submitted_candidate" Serializer: class RequirementInfoSerializer(DjongoModelSerializer): class Meta: model = RequirementInfo exclude = ('id', ) depth = 1 class CandidataInfoSerializer(DjongoModelSerializer): class Meta: model = CandidataInfo exclude = ('id', ) depth = 1 class SubmittedCandidateInfoSerializer(DjongoModelSerializer): requirement = RequirementInfoSerializer(many=True, required=False) candidate = CandidataInfoSerializer(many=True, required=False) class Meta: model = SubmittedCandidateInfo fields = ('requirement','candidate') For Submitting candidates Here am generating number of records based on requirment*candidate computation class SubmittedCandidateSerializer(DjongoModelSerializer): class Meta: model = SubmittedCandidate fields = ('submitted_candidate_id','submit_candidate') def create(self, validated_data): submit_candidate = validated_data['submit_candidate'][0] submit_candidate_copy = submit_candidate['candidate'].copy() for _item in submit_candidate['requirement']: for index, _val in enumerate(submit_candidate_copy): validated_data['submit_candidate'][0]['requirement'] = [dict(_item)] validated_data['submit_candidate'][0]['candidate'] = [dict(_val)] message_obj = super().create(validated_data) return message_obj For viewing submitted candidates class ViewSubmittedCandidateSerializer(DjongoModelSerializer): submit_candidate = SubmittedCandidateInfoSerializer(many=True, required=False) class Meta: model = SubmittedCandidate fields = ('submitted_candidate_id','submit_candidate', 'interview_status', 'modification') Views: class SubmittedCandidateViewSet(viewsets.ModelViewSet): permission_classes = (IsAuthenticated,) queryset = SubmittedCandidate.objects.all() serializer_class = SubmittedCandidateSerializer class ViewSubmittedCandidateViewSet(viewsets.ModelViewSet): permission_classes = (IsAuthenticated,) queryset = SubmittedCandidate.objects.all() serializer_class = ViewSubmittedCandidateSerializer My … -
How to fix Page not found (404) error django2.0 for profile pages
How to fix Page not found (404) error django2.0 for profile pages this code views code ''' def profile(request, slug): profile = Profile.objects.get(slug=slug) context = { 'profile':profile, } return render(request, 'registration/profile.html' ,context) ''' and this urls.py ''' from django.urls import path,re_path from . import views from django.contrib.auth.views import LoginView,logout #login app_name='accounts' urlpatterns = [ path(r'', views.home, name ='home'), # path(r'^login/$', login, {'template_name':'registration/login.html'}), path('login/', LoginView.as_view(), name="login"), path(r'^logout/$', logout, name='logout'), # path(r'^signup/$', views.register, name='register'), path('signup/', views.register, name='signup'), path(r'^(?P<slug>[-\w]+)/$', views.profile, name='profile'), # path(r'^(?P<slug>[-\w]+)/edit$', views.edit_profile, name='edit_profile'), ] ''' profile.html page in templates /registration folder -
I do exactly as the tutorial says and my code has no syntax errors - but things still don't work
I do exactly as the tutorial says and my code has no syntax errors - but things still don't work. I need to verify a few things, can someone help with me in a chat please? It shouldn't take more than 5 minutes I'm sure. Would highly appreciate it, thanks! -
(1048, "Column 'cnic' cannot be null" , duplicate entry error, etc value cannot be saved in database through add_ser_save function
here is add_user_save function in managerviews.py def add_user_save(request): if request.method!="POST": return HttpResponse("Method Not Allowed") else: first_name=request.POST.get("first_name") last_name=request.POST.get("last_name") username=request.POST.get("username") email=request.POST.get("email") password=request.POST.get("password") cnic=request.POST.get("cnic") contact_number=request.POST.get("contact_number") gender=request.POST.get("gender") #try: user=CustomUser.objects.create_user(username=username,password=password,email=email,last_name=last_name,first_name=first_name, user_type=3) user.passenger.cnic=cnic user.passenger.first_name=first_name user.passenger.last_name=last_name user.passenger.email=email user.passenger.contact_number=contact_number user.passenger.gender=gender user.passenger.save() user.save() #messages.success(request,"Successfully Added User") #return HttpResponseRedirect(reverse("add_user")) #except: #messages.error(request,"Failed to Add User") #return HttpResponseRedirect(reverse("add_user")) here is my models.py passsenger table class Passenger(models.Model): cnic=models.BigIntegerField(primary_key=True) admin=models.OneToOneField(CustomUser,on_delete=models.CASCADE, blank=False, null=True) manager_id=models.ForeignKey(Manager,on_delete=models.CASCADE, blank=True, null=True) staff_id=models.ForeignKey(Staff,on_delete=models.CASCADE, blank=True, null=True) fisrt_name=models.CharField(max_length=255, default='non') last_name=models.CharField(max_length=255, default='non') email=models.CharField(max_length=255, default='non') contact_number=models.IntegerField( null=True) gender=models.CharField(max_length=255, default='non') created_at=models.DateTimeField(auto_now_add=True) updated_at=models.DateTimeField(auto_now_add=True) def __str__(self): return self.cnic do i have to change in the below function? I dont know what to add here (usertype =3 is passenger user) @receiver(post_save,sender=CustomUser) def create_user_profile(sender,instance,created,**kwargs): if created: if instance.user_type==1: Manager.objects.create(admin=instance) if instance.user_type==2: Staff.objects.create(admin=instance) if instance.user_type==3: Passenger.objects.create(admin=instance) Problem is value is not added in database i trued a lot by adding blank=true, null=true but error changes every time. Sometimes comes on duplicate key on admin and sometimes like cnic cannot be null all that. Is there any issue in models.py? Help kindly so that i can save data from front end template to passenger table. -
Django is-instance is not working properly For UUID [closed]
I have UUID4 value= "2626df07-1854-4ff1-9296-fa43bc896950" for this value am trying import uuid print((isinstance(value, uuid.UUID))) Result is:- False can anyone please explain me the reason behind this. Note:-value is a proper UUId4 -
Python IF Statement using "Or" and "And"
Code Picture def delete(request, id): destroy = Appointment.objects.get(id=id) if destroy.status == "Done" or "Missed" or "Pending" and request.session["userid"] == destroy.user.id: destroy.delete() return redirect('/update/table') So my delete function works. However the code doesn't do what I'm wanting it to exactly. I want to do a triple check of the 3 strings("Done", "Missed" and "Pending") individually with the "and request.session["userid"] == destroy.user.id:" If I put: if destroy.status == "Pending" and request.session["userid"] == destroy.user.id: destroy.delete() Then it will only delete the object on the table I have created which has "Pending" in its status. So that works good. However... If I put: if destroy.status == "Pending" or "Done" and request.session["userid"] == destroy.user.id: destroy.delete() If I click my delete button on what ever has "Pending" it deletes, great. If I click on anything that has "Done", deleted, great. However if I click my delete button on anything that has "Missed" it still deletes it?? So my code is redundant by adding the 3rd string "Missed". I can't wrap my brain right now on why it still deletes the "Missed" if I leave it out. How do I clean this code up so it does what I'm wanting it to do. -
How can I save the django variable in the cookie for further usage?
Following is the output JSON data I'm getting when I hit the API, {'test_1': {'test_name': 'FASTING SUGAR', 'results': '121.00', 'units': 'mg%', 'low_range': 70.0, 'high_range': 110.0}} <tbody> {% for key, value in data.items %} <tr class="gradeX"> <td>{{ value.test_name }}</td> <td>{{ value.results }}</td> <td>{{ value.units }}</td> <td>{{ value.low_range }}</td> <td>{{ value.high_range }}</td> </tr> {% endfor %} </tbody> I'm getting the {{ data }} from the API that I want to save it in the cookie so that I can use the old value of {{ data }} to append it with the new one using jquery. -
Facing issues while converting django-cms into Headless CMS
My company is using django-cms as the CMS. However, recently we need to convert it into headless CMS so that we can have our custom view layer to improve speed and performance. I got a very few articles online but none of them helped Here is what I have understood till now: The core team for django-cms had started development for headless mode but it was not completed or is not supported now (visit article: https://www.django-cms.org/en/blog/2017/03/14/headless-django-cms/ for more details). I found 2 plugins such: djangocms-rest-api which was archived and it recommends using djangocms-spa djangocms-spa which looks like is a good choice but I am not finding any good documentation for the usage. Also, the git repository looks like is not frequently updated. There is django-rest-framework which seems can be integrated and used. Tried integrating it but there were a lot of errors. Requirement: Any plugin which can be easily integrated without frontend developers having the need to learn django/python in detail code wise (I am mainly looking for this option) If django-cms is not the best option then do I have another alternative cms which can easily accommodate this, is secure and performant. My impression is that djangocms-spa and django-rest-framework … -
Relative and Absolute Path in Python Django
I have succesfully, seperated my settings file to Development and Production settings. While trying to import from base (common to the two) I always get path error. When I try to do this in prod.py file from src.psm_website.settings.base import * and try to compile with the IDE, it works well ( I used a print statement to print from a variable from the base file) But when I try to deploy to Heroku, I get the error from src.psm_website.settings.base import * remote: ModuleNotFoundError: No module named 'src' remote: Then when I change the import statement to this from .base import * I get this error when trying to deploy in heroku raise KeyError(key) from None remote: KeyError: 'SECRET_KEY' Secret key is a variable in base file, meaning base was not imported and I get this error when I try to run from the IDE. from .base import * ImportError: attempted relative import with no known parent package I have init.py in all parent directory, making them pakages from what I have read. How can I solve this Python Version: 3.7.7 -
How to remove default delete confirmation message from django admin on overriding delete queryset method?
I want to override the default delete_queryset method in admin to prevent deleting last object. def delete_queryset(self, request, queryset): warehouses = self.model.objects.all() if warehouses.count() == 1: messages.error(request, "Can't delete last object") return False return super(WarehouseModelAdmin, self).delete_queryset(request, queryset) The deletiion is working fine but along with the error message, "Successfully deleted 1 Warehouse.", this message is also being displayed. How can I remove this success message? -
How can I shortcuts request session in Django Python?
Here's my views.py code: def checkout(request): request.session["quantity"] = int(request.POST["quantity"]) request.session["price"] = float(request.POST["price"]) quantity_from_form = request.session["quantity"] price_from_form = request.session["price"] total_charge = quantity_from_form * price_from_form context = { 'quantity_from_form': quantity_from_form, 'price_from_form': price_from_form, 'total_charge': total_charge } print("Charging credit card...") Order.objects.create(quantity_ordered=quantity_from_form, total_price=total_charge) return render(request, "store/checkout.html", context) I want to shortcuts naming request.session[" "] = request.POST[" "]. Is there any way i can shortcut this? -
Setting a Django ForeignKey to multiple models
I have a simple model called WebProfile that stores a webpage URL and its title. This model has a ForeignKey to a Student model, which allows me to store the student's bookmarks. I would like to reuse this model to also store bookmarks saved by teachers. What is the best way to have the owner ForeignKey point to either a Student or Teacher? Note: in my actual use case, the target model classes are conceptually very different and do not share any common fields other than the WebProfile links. class Student(models.Model): ... class Teacher(models.Model): ... class WebProfile(models.Model): title = models.CharField(max_length=50) link = models.URLField() owner = models.ForeignKey('Student', on_delete=models.CASCADE, related_name="bookmarks") -
NoReverseMatch with generic DeleteView
I cannot figure out why I'm getting NoReverseMatch when trying to use this view. I'd like to get generic views to work because it seems like alot less code to do the same task. views.py from django.views.generic import DetailView, ListView, UpdateView, CreateView, DeleteView from django.urls import reverse_lazy from .models import * class ProductDeleteView(DeleteView): model = Product success_url = reverse_lazy('homepage_view') models.py from django.db import models from django.urls import reverse from autoslug import AutoSlugField class Product(models.Model): name = models.CharField(max_length=50) slug = AutoSlugField(null=True, default=None, unique=True, populate_from='name') def get_delete_url(self): return reverse('product_delete_view', args=(self.slug,)) class Meta: verbose_name_plural = "Products" def __str__(self): return self.name urls.py from . import views from django.urls import path, include from django.views.generic import TemplateView app_name = "main" urlpatterns = [ path('product/delete/<slug:slug>/', views.ProductDeleteView.as_view(), name='product_delete_view'), ] template <p> <a class="btn btn-primary" href="{{product.get_delete_url}}">Delete Product</a> </p> -
Apply a condition to a uniqueconstraint to only run on create not update
With a UniqueConstraint on a model it is possible to add a condition. E.g.: class MyModel(models.Model): class Meta: UniqueConstraint(fields=['user'], condition=Q(status='DRAFT'), name='unique_draft_user') ensures that each user only has one draft. Is it possible to use condition to apply the UniqueConstraint only on model create not on update? Do CheckConstraints have the same condition value? It is not in the docs. -
Django Documentation part 4 <Forms and generic views> return HttpResponseRedirect(reverse('polls:results', args=(question.id,))) Not working
This is Working Working But when I use return HttpResponseRedirect(reverse('polls:results', args=(question.id,))) .. Not Working Not Working It shows NoReverseMatch at /polls/3/vote/ Reverse for 'results' not found. 'results' is not a valid view function or pattern name. Request Method: POST Request URL: http://127.0.0.1:8000/polls/3/vote/ Django Version: 3.0.3 Exception Type: NoReverseMatch Exception Value: Reverse for 'results' not found. 'results' is not a valid view function or pattern name. Exception Location: C:\Users\shaff\Anaconda3\envs\First_Django_App\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 677 Python Executable: C:\Users\shaff\Anaconda3\envs\First_Django_App\python.exe Python Version: 3.7.7 Python Path: ['G:\Django_Project\First_Django_App', 'C:\Users\shaff\Anaconda3\envs\First_Django_App\python37.zip', 'C:\Users\shaff\Anaconda3\envs\First_Django_App\DLLs', 'C:\Users\shaff\Anaconda3\envs\First_Django_App\lib', 'C:\Users\shaff\Anaconda3\envs\First_Django_App', 'C:\Users\shaff\Anaconda3\envs\First_Django_App\lib\site-packages'] Server time: Wed, 22 Apr 2020 07:54:46 +0000`` -
Build a one-page website that show results from InfluxDB query (Python? Node js? React?)
I have a InfluxDB database sat on an Ubuntu VM. I've written some basic Python code to run through some dates and pull out summary results from the influx database based on hard-coded (for now) calculations. What i'd like to do is to create a basic one page website (on a new VM) to go out on there on the web, where I can feed variables from pre-canned dropdown boxes (to create the calculations), fire off the script, then display the results on the page. Then ultimately show a graph, but i'd be happy with a table of results for starters. Apart from knowing a small amount of HTML from way back when, I no experience of creating websites. Wordpress doesn't count does it? :) I've seen Flask and Django mentioned from the Python side, but I can't see too much about an Influx client for those or whether they would be suitable? When I look at Node I see a fully fledged Influx API https://github.com/node-influx/node-influx So do I go down the React js route? Its all a bit daunting and unclear what is the best path to take. I'd be learning something from scratch whatever route I take. Any … -
How to change the response structure
I am facing one issue to change the following structure..... THis is the structure I am getting { "labels": [ "List A", "List B", "List C", "List D" ], "data": [ 19, 25, 30, 32 ], "colors": [ "#e15759", "#f28e2b", "#76b7b2", "#4e79a7" ], } But I want to change the following data in to the following method { "category": "List D", "value": 32, "colors": "#e15759" }, { "category": "List C", "value": 25 "colors": "#f28e2b" }, { "category": "List B", "value": 30, "colors": "#76b7b2" }, { "category": "List A", "value": 19, "colors" : "#4e79a7" } Here is my code class AbcListAPI(APIView): def get(self, request, format=None): a = data_fuction() return Response(a) In this code I am getting this response from a function data_fuction that is used in another part of my code.... So I am unable to edit that response from there ..... But in this function I need to format this code .... -
How do I get a url using "requests" in host adapter only? I keep getting HTTPSConnectionPool NewConnectionError
The error I keep getting when I try to run url The code I'm using -
Django Outer Join
I'm creating a small web application to track my orders, i have two models: Order(models.Model) " This model to record the new orders" class Order(models.Model): customer= models.ForeignKey(Customer, null=True, on_delete= models.SET_NULL) product= models.ForeignKey(Product, null=True, on_delete= models.SET_NULL) date_created = models.DateTimeField(auto_now_add=True, null=True) status = models.CharField(max_length=200, null=True, choices=CATEGOTRIES) note = models.CharField(max_length=200, null=True) OrderHistory(models.Model) " This model to record the changes for each order in any field" version_num = models.AutoField(primary_key=True) Order = models.ForeignKey(Order, null=True, on_delete= models.SET_NULL) customer= models.ForeignKey(Customer, null=True, on_delete= models.SET_NULL) product= models.ForeignKey(Product, null=True, on_delete= models.SET_NULL) date_created = models.DateTimeField(auto_now_add=True, null=True) status = models.CharField(max_length=200, null=True) note = models.CharField(max_length=200, null=True) View: def update_orders(request,pk): theOrder = Order.objects.get(id=pk) theHistory = createOrderHistory({ 'Order': theOrder.id, 'customer': theOrder.customer, 'product': theOrder.product, 'date_created': theOrder.date_created, 'status': theOrder.status, 'note': theOrder.note }) print('The History of the order ',theHistory) UpdateForm = createOrder(instance=theOrder) theid = pk if request.method == 'POST': UpdateForm = createOrder(request.POST,instance=theOrder) if theHistory.is_valid(): if UpdateForm.is_valid(): theHistory.save() UpdateForm.save() return redirect('home') else: UpdateForm = createOrder(instance=theOrder) context = {'UpdateForm':UpdateForm} return render(request,'accounts/updateOrder.html',context) In the View update_orders function am taking the current order and save it into OrderHistory and then i save the new changes into Order Model it's working fine but the OrderHistory Model is not including the new change. orderHistory to get the history of the order def orderHistory(request,pk): theHistoryOfTheOrder … -
Mocking django tests - why is this patched function still being called?
I'm trying to test a function in one of my models, and am trying to to mock out the filesytem using mock.patch. No matter what I try, it doesn't seem to intercept the method. Model to test: app/models.py from django.db import models from .utils.storageutils import get_file from .utils.datautils import derive_data Class DataThing(models.Model): #defined here def set_data_from_file(self): data = derive_data(get_file('filepath')) setattr(self, 'derived_data', data) self.save() app/utils/datautils.py import pandas as pd def derive_data(data_from_file): df = pd.DataFrame('...') #do stuff with dataframe return df app/tests/unit_tests/tests_models.py from django.test import TestCase import mock from app.models import DataThing class DataThingModelTest(TestCase): @classmethod def setUpTestData(cls): cls.datathing = DataThing @mock.patch('app.models.derive_data') def test_set_data_from_file(self, mocked_derive_data): mocked_derive_data.return_value=('pretend_dataframe') self.datathing.set_data_from_file() self.assertEquals(self.datathing.derived_data, 'pretend_dataframe') I would expect this to pass. However, I get an error, because datathing.set_data_from_file() is still ultimately calling utils.storageutils.get_file. I've tried patching in app.utils.datautils.derive_data but have the same issue.