Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
y-a t-il un moyen de lier un champ d'un formulaire a un autre? [closed]
bonjour , je m'interesse à django depuis peu! et aujourdhui suis dans la creation de mon apps, et jaimerai avoir un formulaire dans lequel on pourra saisir par exemple l'username d'un membre et directement on obtient un deuxieme champ qui repete les données entrees. j'ai pu voir ce que notre collegue a fait et j'avoue que je comprend pas tres bien -
'BasicAuthentication' object has no attribute 'has_permission' Django
Good day. how do i solve this problem? 'BasicAuthentication' object has no attribute 'has_permission' views.py from rest_framework import routers, viewsets class EducationLevelViewSet(viewsets.ModelViewSet): model = EducationLevel field = ('Sequence', 'Description', 'Status') serializers.py class EducationLevelSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = EducationLevel field = ('Sequence', 'Description', 'Status') urls.py router = routers.DefaultRouter() router.register(r'EducationLevel', views.EducationLevelViewSet, basename='MyModel') from Homepage.views import ArticleListView urlpatterns = [ path('', include(router.urls)), path('api-auth/', include('rest_framework.urls', namespace='rest_framework')), ] error -
Multiple domains with Nginx, Varnish and Django all returns the same cached page
I am trying to configure a second domain for an existing project which was previously just using one. But Varnish always returns the cached page from the first domain. So when I visit the second domain I see the content of the first domain. I tried: Changed NGINX: proxy_set_header Host existingdomain.com; to proxy_set_header Host $host; Changed NGINX: 2 server configurations listing to port 8000 for both domains Changed VARNISH: 2 backend configurations for both domains Note: 99% of the configuration was already there I changed the domain names and removed some SLL configurations for this post to be more clear. Both domains use the same html page but slightly difference content. I am noob regarding nginx and varnish. What do I want: Eventually I want 2 different domains and several subdomains who all need its own varnish cache. NGINX server_tokens off; resolver 127.0.0.53 ipv6=off; upstream django_app_server { server unix:/home/test/run/gunicorn.sock fail_timeout=0; } #http redirect too https. server { listen 80 default_server; server_name _; return 301 https://$host$request_uri; } server { server_name existingdomain.com newdomain.com; listen 443 ssl default deferred; # match with actual application server client_max_body_size 10M; keepalive_timeout 60s; # proxy the request through varnish before sending it to gunicorn. location / { … -
Django Backward lookup from other apps
i have models in galery apps class Galery(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='galery') tour = models.ForeignKey('tour.Tour', on_delete=models.CASCADE, blank=True, null=True) # users_customuser = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) users_customuser = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) judul = models.CharField(max_length=127, blank=True, null=True) fotografer = models.ForeignKey(Fotografer, on_delete=models.CASCADE) tanggal = models.DateField(blank=True, null=True) deskripsi = models.TextField(blank=True, null=True) foto_file = models.ImageField(upload_to='images/', null=True) and other models in tour app class TourManager(models.Manager): def home(self): last3 = super().get_queryset().order_by('-id').prefetch_related('plan', 'buget','galery.galery') tournew = last3 return tournew class Tour(models.Model): # users_customuser = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) users_customuser = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) nama_tour = models.CharField(max_length=127, blank=True, null=True) deskripsi_tour = models.TextField(blank=True, null=True) tanggal_mulai = models.DateField(blank=True, null=True) hari = models.SmallIntegerField(blank=True, null=True) malam = models.SmallIntegerField(blank=True, null=True) TourList = TourManager() how i load Galery from Tour i have this error AttributeError at /tour/ Cannot find 'galery.galery' on Tour object, 'galery.galery' is an invalid parameter to prefetch_related() Request Method: GET Request URL: http://127.0.0.1:8000/tour/ Django Version: 3.0.7 Exception Type: AttributeError Exception Value: Cannot find 'galery.galery' on Tour object, 'galery.galery' is an invalid parameter to prefetch_related() Exception Location: D:_Project\TourGaleryProject.venv\lib\site-packages\django\db\models\query.py in prefetch_related_objects, line 1638 Python Executable: D:_Project\TourGaleryProject.venv\Scripts\python.exe Python Version: 3.8.3 -
Can we use multiple OneToOneFields in single User Model? Any performance issue happen?
I'm new to django, I'm working on a project. I have define User model with multiple parts. User --> default property like username, email, password, date_joined, is_staff, is_superadmin... UserProfile --> OneToOneField(User), first_name, last_name, gender, avatar, dob. UserPhoneAuth --> OneToOneField(User), otp_code, etc.. UserEmailAuth --> OneToOneField(User), secret_key, etc... UserCard --> OneToOneField(User), card_name, card_no, etc.. UserWallet --> OneToOneField(User), chips, tokens. Is this best practice to split multiple models?. Any one can please help me on this. Advanced Thanks. -
How to store the data files of a django project
I am developing a feature in which the user can download some specific files. I am using Django Rest Framework and I want to create some endpoints for downloading those files, and being able to modify them from the script. I don't want to store the files inside the repository as they are a bit heavy and contain a lot of rows (millions). Is there any way I can store the files outside my project and still being able to access/modify them from the script of my project? -
Getting current user in blocks class in Wagtail
Using Wagtail 2.9, I am trying to create a block that has a function that generates URL. To generate the URL I need the current logged in user. class Look(blocks.StructBlock): title = blocks.CharBlock(required=True, help_text='Add your look title') id = blocks.CharBlock(required=True, help_text='Enter the Id') class Meta: template = "looker/looker_block.html" value_class = LookStructValue the value class has the get_url() definition which looks like: class LookStructValue(blocks.StructValue): def url(self): id = self.get('id') user = User(15, first_name='This is where is need the current user First name', last_name='and last name', permissions=['some_permission'], models=['some_model'], group_ids=[2], external_group_id='awesome_engineers', user_attributes={"test": "test", "test_count": "1"}, access_filters={}) url_path = "/embed/looks/" + id url = URL(user,url_path, force_logout_login=True) return "https://" + url.to_string() Can i get the current user inside the LookStructValue class? -
field id expected a number but got 'ashu'
I keep getting the following error while trying to print the level: field id expected a number but got 'ashu' And here's my code: class User(models.Model): user_name=models.CharField(max_length=20) class Sport(models.Model): sport=models.CharField(max_length=20) class Intrest(models.Model): sport_name=models.ForeignKey(Sport,on_delete=models.CASCADE) user=models.ForeignKey(User,on_delete=models.CASCADE) LEVEL=(('1','Beginner'), ('2','Mediate'), ('3','Advance'), ) level=models.CharField(max_length=20,choices=LEVEL) # code sample A=Intrest.objects.get(user=uder.Host.user_name) print(a.level) -
"PermissionError: [Errno 13] Permission denied: '/dev/core' "
Get this error when building django container - PermissionError: [Errno 13] Permission denied: '/dev/core' I have seen similar questions here, but couldn't find the solution. Thanks in advance for help. This is traceback Traceback (most recent call last): django_1 | File "/app/manage.py", line 31, in <module> django_1 | execute_from_command_line(sys.argv) django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line django_1 | utility.execute() django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute django_1 | self.fetch_command(subcommand).run_from_argv(self.argv) django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv django_1 | self.execute(*args, **cmd_options) django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute django_1 | output = self.handle(*args, **options) django_1 | File "/usr/local/lib/python3.8/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle django_1 | collected = self.collect() django_1 | File "/usr/local/lib/python3.8/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 113, in collect django_1 | handler(path, prefixed_path, storage) django_1 | File "/usr/local/lib/python3.8/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 347, in copy_file django_1 | with source_storage.open(path) as source_file: django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/files/storage.py", line 36, in open django_1 | return self._open(name, mode) django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/files/storage.py", line 231, in _open django_1 | return File(open(self.path(name), mode)) django_1 | PermissionError: [Errno 13] Permission denied: '/dev/core' This is my Dockerfile FROM python:3.8-slim-buster ENV PYTHONUNBUFFERED 1 RUN apt-get update \ && apt-get install -y build-essential \ && apt-get install -y libpq-dev \ && apt-get install -y … -
django print value of query set
simple problem (i think). I have following query: hostname = Host.objects.get(pk=(host_id)) env = Host.objects.filter(cfthostname=hostname).values('cftos') print(env) what i get from print is: <QuerySet [{'cftos': 'unix'}]> how to make it: unix -
Where to initialize a GraphQL Client inside Django App
I'm building an API with Django, I want to query the Github GraphQL API, and I found this GraphQL client for python that suits my needs. But now, I'm wondering, where is the proper place to initialize such a client inside my Django App? inside the request? in the apps.py? in views.py? any guidelines will be appreciated! here is my current Django Project folder structure: . ├── LICENSE ├── README.md ├── api │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ ├── urls.py │ └── views.py ├── db.sqlite3 ├── manage.py ├── portfolio │ ├── __init__.py │ ├── asgi.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── requirements.txt └── setup.py Thanks in advance! -
Why does an axios post request to django get empty data?
Returns a 404 error Here is a request with react const addItemToBasket = (item) => { dispatch({type: ADD_ITEM_TO_BASKET, payload: item}) console.log(item.id, store.get('email')) axios.defaults.xsrfCookieName = 'csrftoken' axios.defaults.xsrfHeaderName = 'X-CSRFToken' axios.post("http://localhost:8000/cart/add", { uid: item.id, amount: 1, email: store.get('email') }) .then((response) => { console.log(response.data) }) .catch((error) => { console.log(error); }); } Here is the django function -
How exactly should I be linking in NPM modules?
I'm updating all of my CSS and JS libraries, but I want to make sure I do it the right way this time. Let's take jQuery for example. First, I install with NPM. $ npm i jquery # from project root Then, I create symlinks to be included in my static directory. $ cd home/static/lib/js # also from project root $ ln -s ../../../../node_modules/jquery/dist/jquery.js $ ln -s ../../../../node_modules/jquery/dist/jquery.min.js Next, in that same js directory, I generate hashsums. $ openssl dgst -sha384 -binary jquery.js | openssl base64 /LjQZzcpTzaYn7qWqRIWYC5l8FWEZ2bIHIz0D73Uzba4pShEcdLdZyZkI4Kv676E $ openssl dgst -sha384 -binary jquery.min.js | openssl base64 ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2 Finally, I add to the head of my Django template (HTML). <head> <!-- jQuery JS (compressed) --> <script src="{% static 'lib/js/jquery.min.js' %}" integrity="sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2" ></script> <!-- jQuery JS (uncompressed) --> <!-- <script src="{% static 'lib/js/jquery.js' %}" integrity="sha384-/LjQZzcpTzaYn7qWqRIWYC5l8FWEZ2bIHIz0D73Uzba4pShEcdLdZyZkI4Kv676E" ></script> --> </head> I comment out the uncompressed file to make page loading faster, but I leave the static URL for developers to see. It's hosted on the server, but it's not included in the head tag. Are there any steps I'm missing? Should I include an external link to a CDN? Should I actually include the compressed file instead of just a comment of it? Any … -
update formset with class based view
i've created web blog with django 2.2 each post has multiple images , but when i try to update the post images wont updated i use class based view class Post(models.Model): user= models.ForeignKey(Account,on_delete=models.CASCADE) title= models.CharField(max_length=100) #others class PostImage(models.Model): post= models.ForeignKey(Post,on_delete=models.CASCADE,related_name='images') media_files = models.FileField(upload_to=random_url) and this my forms.py class PostImageForm(forms.ModelForm): class Meta: model = PostImage fields = [ 'media_files' ] class PostUpdateForm(forms.ModelForm): class Meta: model = Post fields = [ 'title','description',#and others ] my views.py PostImageFormSet = inlineformset_factory( Post,PostImage,form=PostImageForm,extra=1,can_delete=True,can_order=False ) class PostUpdateView(LoginRequiredMixin,UserPassesTestMixin,UpdateView): model = Post form_class = PostUpdateForm template_name = 'posts/update_post.html' def get_context_data(self,**kwargs): data = super().get_context_data(**kwargs) if self.request.POST: data['images'] = PostImageFormSet(self.request.POST or None,self.request.FILES,instance=self.object) else: data['images'] = PostImageFormSet(instance=self.object) return data def form_valid(self,form): context = self.get_context_data() images = context['images'] with transaction.atomic(): if form.is_valid() and images.is_valid(): self.object = form.save() images.instance = self.object images.save() return super().form_valid(form) def test_func(self): post = self.get_object() if self.request.user.username == post.user.username: return True return False def get_success_url(self): return reverse_lazy('post:post-detail',kwargs={'slug':self.object.slug}) my templates <form enctype="multipart/form-data" method="post" action=""> {% csrf_token %} {{images.management_form }} {{ form|crispy }} {% for img in images %} <label>{{img.media_files.label}}</label> {{img.media_files}} {% endfor %} <button type="submit" class="btn btn-block btn-primary">update</button> </form> i'm wondering why didnt update the posts image !? thanks for replay .. -
Python and django: how to set a filter value with a form
I have created the following model that give me the possibility to get all daily income: class Ricavi(models.Model): quantita=models.DecimalField() data_contabile=models.DateField() After that I have created a views.py that give me the possibility to collect my data in yearly and monthly view as following: ricavi = dict() total_ricavi=dict() for year, month, totale in(Ricavi.objects.values_list( 'data_contabile__year', 'data_contabile__month'). annotate(totale=ExpressionWrapper(Sum(F('quantita') * F('ricavo')*(1+F('iva'))), output_field=FloatField())).values_list('data_contabile__year', 'data_contabile__month', 'totale')).filter(data_contabile__year=2019): if id not in ricavi.keys() : ricavi[id]=list(defaults) index=month-1 ricavi[id][index]=totale total_ricavi={'Ricavi Lordi': [sum(t) for t in zip(*ricavi.values())],} Now I have fixed the data_contabile__year equal to 2019 ad example. But I want to have the possibility to choose the year (ad example using a selection form). How could I get this result? -
django-private-chat /dialogs is empty
I followed the steps in guide in https://django-private-chat.readthedocs.io/en/latest/readme.html: base.html: {% block extra_js %}{% endblock extra_js %} settings.py: INSTALLED_APPS = ( ... 'django_private_chat', ... ) CHAT_WS_SERVER_HOST = 'localhost' CHAT_WS_SERVER_PORT = 5002 CHAT_WS_SERVER_PROTOCOL = 'ws' urlpatterns = [ "other urls" url(r'^', include('django_private_chat.urls')), ] After starting the server I go to http://127.0.0.1:8000/dialogs/some-of-the-users and there is no result whatsoever, the page is empty. The console displaying: Uncaught ReferenceError: $ is not defined at username:128 django version= 3.0.6 python version= 3.7.6 and the latest version of django-private-messaging It's my first time implementing a chat app so I hope I'm not missing anything fundamental. Have a nice day! -
comparing DateField with timezone.now().date()
I am trying to compare DateFIeld with timezone.now().date() but its not giving the desired output: models.py: class Holiday_List(models.Model): name=models.CharField(max_length=30) holi_day=models.DateField(default=timezone.now()) def __str__(self): return '{}---{}'.format(self.name, self.holi_day) admin.py: def refresh(): flag=0 din=Holiday_List.objects.all() for aaj in din: if aaj.holi_day==timezone.now().date(): flag=1 break; if(flag==0): # some code to be executed I have objects with today's date in the Holiday_List but still the flag value is not being set to 1 and the code gets executed after calling the function. -
How to create a custom log middleware in django?
I want to keep track of every records which are done by the user in my system. For this I used the django admin LogEntry model and created log like this. It works but in my app there are hundreds of view for create,update, delete so this process will be very long so I think writing the middleware will be better idea but I got no idea how can i write logic in middleware for this? Any small help will be greatful. views if form.is_valid(): form.save() # creating log LogEntry.objects.log_action(user_id=request.user.pk, content_type_id=ContentType.objects.get_for_model(Category).pk, object_id=category.pk, object_repr=force_text(category), change_message='Category updated.', action_flag=2 ) return redirect('list_categories') middleware class LogMiddleware(object): def __init__(self, get_response): self.get_response = get_response # One-time configuration and initialization. def __call__(self, request): # Code to be executed for each request before # the view (and later middleware) are called. response = self.get_response(request) # Code to be executed for each request/response after # the view is called. return response -
I am new to django. I tried using django-taggit-autosuggest but autosuggestion doesn't show up in template. Please help me. Thank you
IN http://127.0.0.1:8000/taggit_autosuggest/list/ -> I am able to see list of tags In my installed apps: INSTALLED_APPS = [ 'taggit', 'taggit_autosuggest', ] urlpatterns = [ url(r'^taggit_autosuggest/', include('taggit_autosuggest.urls')), ] base.html <head> <link href="{% static 'jquery-autosuggest/css/autoSuggest-upshot.css'%}"> <script src="{% static 'jquery-autosuggest/js/jquery.autoSuggest.minified.js'%}"> </script> </head> models.py from taggit_autosuggest.managers import TaggableManager class Discussions(models.Model): txt = models.TextField(blank=True, null=True) tags = TaggableManager() def __str__(self): return self.txt forms.py class DiscussionsForm(forms.ModelForm): class Meta: model = Discussions fields = ('txt', 'tags') def __init__(self, *args, **kwargs): super(forms.ModelForm, self).__init__(*args, **kwargs) self.fields['txt'].widget.attrs['class'] = 'form-control' self.fields['tags'].widget.attrs['class'] = 'form-control' -
Are both the raw queries same for left join?
While working with left join I wanted to have a search string - which would be dynamic. So, I had two queries Query 1: songs = Song.objects.raw(initial_query_string + ''' as sinpl left join songs on sinpl.song_id=id ) as songs left join (select song_id, votes, bool_or(thirdpartyuser_id=%s) as is_requested from (select * from core_priorityrequests where client_id=%s and is_played=False ) as clpr left join core_priorityrequests_third_party_user on clpr.id=priorityrequests_id group by priorityrequests_id, song_id, votes ) as cpr on songs.id=cpr.song_id left join (select core_blocksong.song_id from core_blocksong where core_blocksong.unblock_flag = 'f' and core_blocksong.client_id=%s) as c on c.song_id = songs.id where c.song_id is null and songs.name ilike %s or songs.artist ilike %s limit %s offset %s''', [request.anon_user.id, restaurant.client.id,restaurant.client.id,search_string,search_string,limit,offset,]) Query 2: songs = Song.objects.raw(initial_query_string + ''' as sinpl left join songs on sinpl.song_id=id where explicit=False ) as songs left join (select song_id, votes, bool_or(thirdpartyuser_id=%s) as is_requested from (select * from core_priorityrequests where client_id=%s and is_played=False ) as clpr left join core_priorityrequests_third_party_user on clpr.id=priorityrequests_id group by priorityrequests_id, song_id, votes ) as cpr on songs.id=cpr.song_id where songs.name ilike %s or songs.artist ilike %s limit %s offset %s left join (select core_blocksong.song_id from core_blocksong where core_blocksong.unblock_flag = 'f' and core_blocksong.client_id=%s) as c on c.song_id = songs.id where c.song_id is null''', [request.anon_user.id, restaurant.client.id,search_string,search_string,limit,offset,restaurant.client.id,]) … -
"Cannot read property 'product' of undefined". how to get rid of that problem in javaScript
Want to add products to cart but displaying product is undefined. How to fetch values from data-property and i've also tried $(this).data('data-product) but this one is also not working <button data-product = {{product.id}} data-action="add" class="btn btn-outline-secondary add-btn update-cart">Add to Cart</button> var updateBtns = document.getElementsByClassName('update-cart'); for (var i = 0; i < updateBtns.length; i++) { updateBtns[i]=addEventListener('click',function(){ var productId = this.dataset.product var action = this.dataset.action console.log('productId:', productId, 'Action:', action) }) } -
Is it possible to create a Model that creates sub models in Django?
Please excuse my way of asking the question, but what I mean is this: Is there a way to create a Model in Django, that acts as a "Mother Model" in which I can create sub models.? In my particular example, I am working on a sales website portal in Django, in which I want to create a class called Sales_Process as the "Mother Model" and then Negotiation, Deal and Quote as "Sub Models" that get created using Sales_Process. The user should be able to add more "Steps" to its Sales Process on the admin panel. Thank you so much in advance. -
GeoDjango setup issue
Error: OSError: /usr/local/lib/libgdal.so: caanot open shared object file: No such file or directory unable to load app 0 (mountpoint='') (callable not found or import error) As i see many solutions for this problem but nothings Works for me, From last 2 days i am trying to set up the GeoDjango Project. but did'nt succeed GDAL VERSION: gdal-3.1.0 PROJ VERSION: proj-7.0.1 GEOS VERSION: geos-3.8.1 here below is my django setting library Path:- GDAL_LIBRARY_PATH="/usr/local/lib/libgdal.so" GEOS_LIBRARY_PATH="/usr/local/lib/libgeos_c.so" my Ubuntu Version is 18.04, as When I check this Path, there will be the file present by the name of libgdal.so, libgeos_c.so . But while compile time it will always show the error , No such file or directory According to the Below link Solution I set the Path of inside ld.so.conf , But nOthings works for me GeoDjango - GDAL library giving error As i set the library Path also , in the /etc/ld.so.conf/ , See below :- include /etc/ld.so.conf.d/*.conf /usr/local/lib And After that sudo ldconfig But it will again Show me the Error when I do my docker-compose up Any help will be Highly Appreciated , as I am stuck in this problem from last two days -
Getting rid of useless digits like the 0 in 7.0 or 10.0 in python
I am working with Django and I have a project where I define a Student object that has the fields of grade 1 and grade 2, in this class, I build a function that gives back the grade of the student in question although I encountered a problem, the useless digit when I've got an integer number. That is because I am adding and dividing two float numbers but I want to make the function so that it returns an integer if the result is also one but I don't know how. This is what I've got so far: PS. The class Student inherits from Person, a class that contains credentials about a person like name email and so on but I don't think that really matters here. class Student(Person): grade_1 = models.FloatField(validators=[validate_grade], null=True, blank=True) grade_2 = models.FloatField(validators=[validate_grade], null=True, blank=True) study_field = models.CharField(max_length=50) year = models.PositiveIntegerField(validators=[validate_year], blank=True, null=True) remarks = models.TextField(max_length=300, blank=True, null=True) def get_grade(self): if self.grade_1 is None and self.grade_2 is None: return "No grades yet" elif self.grade_2 is None: return self.grade_1 elif self.grade_1 is None: return self.grade_2 else: return (self.grade_1 + self.grade_2)/2 -
Date detail view error " NoReverse match at orderlist "
I have two models Order and Date. I'm trying to create a view function where a user can click on view URL and will able to see the date details of a specific order.But I'm keep on getting this error "Reverse for 'date-detail' with arguments '('',)' not found. 1 pattern(s) tried: ['dates/(?P[0-9]+)/$']" from order_list.html view URL tag Models: from django.db import models from django.conf import settings from django.contrib.auth.models import User class Order(models.Model): user = models.ForeignKey(User, null=True, on_delete=models.CASCADE) date = models.ForeignKey('Date', null=True, on_delete=models.CASCADE) quote_choices = ( ('Movie', 'Movie'), ('Inspiration', 'Inspiration'), ('Language', 'Language'), ) quote = models.CharField(max_length =100, choices = quote_choices) box_choices = (('Colors', 'Colors'), ('Crossover', 'Crossover'), ) box = models.CharField(max_length = 100, choices = box_choices) pill_choice = models.CharField(max_length=30) shipping_tracking = models.CharField(max_length=30) memo = models.CharField(max_length=100) status_choices = (('Received', 'Received'), ('Scheduled', 'Scheduled'), ('Processing/Manufacturing', 'Processing/Manufacturing'), ) status = models.CharField(max_length = 100, choices = status_choices) def __str__(self): return f"{self.user_id}-{self.pk}" class Date(models.Model): date_added = models.DateField(max_length=100) scheduled_date = models.DateField(max_length=100) service_period = models.DateField(max_length=100) modified_date = models.DateField(max_length=100) finish_date = models.DateField(max_length=100) URLS: from django.urls import path,include from django.contrib.auth import views as auth_views from .views import order_list,create_order,update_order,delete_order,login_page,logout_page, simple_upload, upload_ingredients, update_profile,dateDetailView app_name = 'accounts' urlpatterns = [ path('dates/<int:pk>/', dateDetailView, name='date-detail') ] Views: def dateDetailView(request, pk): date = Date.objects.get(pk=pk) orders = Order.objects.filter(date = …