Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can't install django-mailgun
I want to install django-mailgun library. Followed this tutorial https://learnbatta.com/blog/django-send-email-using-mailgun-api-94/ I tried pip install django-mailgun --verbose Log of command: Using pip 21.0.1 from /home/alex/.local/lib/python3.6/site-packages/pip (python 3.6) Defaulting to user installation because normal site-packages is not writeable Created temporary directory: /tmp/pip-ephem-wheel-cache-r4kdc56j Created temporary directory: /tmp/pip-req-tracker-s1r35ye8 Initialized build tracking at /tmp/pip-req-tracker-s1r35ye8 Created build tracker: /tmp/pip-req-tracker-s1r35ye8 Entered build tracker: /tmp/pip-req-tracker-s1r35ye8 Created temporary directory: /tmp/pip-install-14dd83we 1 location(s) to search for versions of django-mailgun: * https://pypi.org/simple/django-mailgun/ Fetching project page and analyzing links: https://pypi.org/simple/django-mailgun/ Getting page https://pypi.org/simple/django-mailgun/ Found index url https://pypi.org/simple Looking up "https://pypi.org/simple/django-mailgun/" in the cache Request header has "max_age" as 0, cache bypassed Starting new HTTPS connection (1): pypi.org:443 https://pypi.org:443 "GET /simple/django-mailgun/ HTTP/1.1" 404 13 Status code 404 not in (200, 203, 300, 301) Could not fetch URL https://pypi.org/simple/django-mailgun/: 404 Client Error: Not Found for url: https://pypi.org/simple/django-mailgun/ - skipping Given no hashes to check 0 links for project 'django-mailgun': discarding no candidates ERROR: Could not find a version that satisfies the requirement django-mailgun ERROR: No matching distribution found for django-mailgun Exception information: Traceback (most recent call last): File "/home/alex/.local/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 171, in _merge_into_criterion crit = self.state.criteria[name] KeyError: 'django-mailgun' OS -- Ubuntu 16.04 LTS -
OperationalError at / no such column: core_book.average_rating
So When I go to my home page route I get OperationalError at / no such column: core_book.average_rating even though I don't think home view mentions that average_rating column in a model. If you want to see the full code it is at https://github.com/ArpitLinux/HostingCode/blob/main/code.txt, Sorry but I cannot put home.html here because of character limit So please consider seeing my github link if you want to see home.html views.py def home(request): category = Category.objects.all() carosel1 = CarouselDisplay1.objects.order_by('-id')[:1] carosel2 = CarouselDisplay2.objects.order_by('-id')[:1] carosel3 = CarouselDisplay3.objects.order_by('-id')[:1] engineering_book = Category.objects.get(name="Engineering") programming_book = Category.objects.get(name="Programming") neuroscience_book = Category.objects.get(name="Neuroscience") physics_book = Category.objects.get(name="Physics") medical_book = Category.objects.get(name="Medical") rocket_book = Category.objects.get(name="Rocket Science") engineering_books1 = Book.objects.filter(category=engineering_book.id)[:3] engineering_books2 = Book.objects.filter(category=engineering_book.id)[3:6] engineering_books3 = Book.objects.filter(category=engineering_book.id)[6:9] programming_books1 = Book.objects.filter(category=programming_book.id)[:3] programming_books2 = Book.objects.filter(category=programming_book.id)[3:6] programming_books3 = Book.objects.filter(category=programming_book.id)[6:9] neuroscience_books1 = Book.objects.filter(category=neuroscience_book.id)[:3] neuroscience_books2 = Book.objects.filter(category=neuroscience_book.id)[3:6] neuroscience_books3 = Book.objects.filter(category=neuroscience_book.id)[6:9] physics_books1 = Book.objects.filter(category=physics_book.id)[:3] physics_books2 = Book.objects.filter(category=physics_book.id)[3:6] physics_books3 = Book.objects.filter(category=physics_book.id)[6:9] medical_books1 = Book.objects.filter(category=medical_book.id)[:3] medical_books2 = Book.objects.filter(category=medical_book.id)[3:6] medical_books3 = Book.objects.filter(category=medical_book.id)[6:9] rocket_books1 = Book.objects.filter(category=rocket_book.id)[:3] rocket_books2 = Book.objects.filter(category=rocket_book.id)[3:6] rocket_books3 = Book.objects.filter(category=rocket_book.id)[6:9] params = {'carosel1':carosel1, 'carosel2':carosel2, 'carosel3':carosel3, 'engineering_books1':engineering_books1, 'engineering_books2':engineering_books2, 'engineering_books3':engineering_books3, 'programming_books1':programming_books1, 'programming_books2':programming_books2, 'programming_books3':programming_books3, 'neuroscience_books1':neuroscience_books1, 'neuroscience_books2':neuroscience_books2, 'neuroscience_books3':neuroscience_books3, 'physics_books1':physics_books1, 'physics_books2':physics_books2, 'physics_books3':physics_books3, 'medical_books1':medical_books1, 'medical_books2':medical_books2, 'medical_books3':medical_books3, 'rocket_books1':rocket_books1, 'rocket_books2':rocket_books2, 'rocket_books3':rocket_books3, 'category':category } if request.user.is_authenticated: oof = CartItem.objects.filter(user=request.user).values_list('book', flat=True) lmao = OrderItem.objects.filter(user=request.user).values_list('book', flat=True) hehe = CartItem.objects.filter(user=request.user) number = 0 fianlprice = 0 … -
django allauth signup page not redirect on email verification page
This started happening yesterday (it was working fine before), I've retraced my steps and reversed any edits and it's still not working. I'm using Allauth with Django and the generic signup form /accounts/signup/ isn't redirecting to verification_sent.html. An email_confirm.html is also not being sent to confirm the account. I've set up an email backend to test on localhost and normally the emails come through fine via the terminal window. Now when I submit the form and request.POST, nothing happens. No emails, no verification_sent.html page redirection. The terminal isn't throwing any errors and says HTTP POST /accounts/signup/ 200 How can I go about debugging this? -
can not send file with Axios to django, It's always empty
I'm using axios and django 3.1.6, the problem is that all axios can not send files via post request and in my views request.FILES is always empty. (while sending it as default html form post, it's not empty) I'm doing it like this my script.js file ... $("#myform").submit(function(event) { event.preventDefault(); }); $("button[type='submit']").click(function() { let form = $("#myform").serialize() axios.post(".", form).then((response) => { if (response.data.status == "success") { myform.reset(); // other codes here } }).catch((error) => { console.error(error); }) }); template.html ... <form method="post", action="." enctype="multipart/form-data" id="myform"> {% csrf_token %} <!-- inputs .. file inputs --> </form> view.py if request.POST.get("add-medical-record"): print(request.POST) # i have my data here print(request.FILES) # it's always empty ... thanks you guys. -
Django MRSS add item into item - using syndication feed framework
I'm using the syndication feed framework to generate an MRSS feed. I was able to add a custom filed media:group inside the item element. I'm looking how I can add media:content element inside media:group, here is the sample I would like to generate: <item> <media:group> <media:content> 1 </media:content> <media:content> 2 </media:content> </media:group> </item> Thanks for any help. -
how to pre-fill a value in django-crispy-form field
I am trying to make a create function using the model class, the forms.py and then using the django-crispy-forms package. The form has been rendered correctly but I am trying to exclude a particular field as well as prefill it with the current user email. I am already able to exclude it in the forme.py but I don't know how to go about adding the current user email to it. models.py class Product(models.Model): name = models.CharField(max_length=36) price = models.PositiveIntegerField() description = models.TextField() quantity = models.PositiveIntegerField() image = models.ImageField() user = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return self.name forms.py from django import forms from .models import * class AddProductForm(forms.ModelForm): class Meta: model = Product fields = '__all__' exclude = ['user'] views.py def Addproduct(request): form = AddProductForm() if request.method == 'POST': form = AddProductForm(request.POST, request.FILES) if form.is_valid(): form.save() messages.success(request, "Products Added Successfully") return redirect('product') context = {"form":form} return render(request, "core/addproduct.html", context) addproduct.html <form method="post"> {% csrf_token %} <div class="form-row"> <div class="form-group col-md-4 mb-0"> {{ form.name|as_crispy_field }} </div> <div class="form-group col-md-4 mb-0"> {{ form.price|as_crispy_field }} </div> <div class="form-group col-md-4 mb-0"> {{ form.quantity|as_crispy_field }} </div> </div> {{ form.description|as_crispy_field }} <div class="form-row"> <div class="form-group col-md-12 mb-0"> {{ form.image|as_crispy_field }} </div> </div> <button class="au-btn au-btn--block au-btn--green m-b-20" … -
How to hide items before filtering in django templates?
i have a simple website and i want to test the filters but i have a problem ! i don't want user to see all results i want him to see only the filtered one before start filtering or searching and here is my CODE (views.py) def Home(request): mobile_filter=MobileFilter(data=request.GET,queryset=MyMobile.objects.all()) my_phone = mobile_filter.qs context={"myphone":my_phone,"myfilter":mobile_filter} return render(request,"mobile_home.html",context) (html) {% for obj in myphone %} {{obj.name}} {{obj.code}} {{obj.date}} {{obj.place}} {{obj.type}} {{obj.mobile}} {% endfor %} -
Fetching data from third party
I have fair bit of experience in handling and playing around with data in Python. However I want to learn how to fetch data from third party applications, APIs, websites etc. I am open to learning new programming tools if needed. Also, I dont have much experience in Django and was wondering if it plays an important role for this. Can someone help with Telling me which courses (if any) I should refer to for this? Which programming languages and Python packages will come handy? Any good websites, blogs or links that can help me in this journey? -
Django Filter results of Table with matching id from another table
I have 3 tables ManagedOrgDocument Entitlements DocumentEntitlementMapping User can upload document and entitlement using different forms, however some entitlements have link with documents and documents have link with entitlement. The 3rd table maps document and entitlement class EntitlementDocumentMapping(models.Model): uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False) managed_org_uuid = models.CharField(max_length=400) document = models.ForeignKey(ManagedOrgDocument, on_delete=models.CASCADE) entitlement = models.ForeignKey(ManagedOrgOraLicenseEntitlement, on_delete=models.CASCADE) managed_org_documents =ManagedOrgDocument.objects.filter(managed_org_uuid=managed_org_uuid).order_by(*sort_order) When I fetch all documents I want records from EntitlementDocumentMapping table as well where Documents.id matches with EntitlementDocumentMapping.document.uuid -
Django ImportExport dynamic fields
I am using Django ImportExport. I would like to export all entries from a model called Room. Each Room can have one to m (upper bound of 20) Tables in it. So I have the following resource: class RoomResource(resources.ModelResource): table1 = Field() table2 = Field() # ... tableM = Field() class Meta: model = Room fields = ('table1', 'table2', 'tableM') @staticmethod def _dehydrate_table(room, table_number): if not room.table_number.count() > number - 1: return '' return getattr(room.table_number.all()[number - 1], 'person_count', '') def dehydrate_table1(self, room): return self._dehydrate_table(room, 1) def dehydrate_table2(self, instance): return self._dehydrate_table(room, 2) def dehydrate_tableM(self, instance): return self._dehydrate_table(room, M) This works fine (because my M has an upper bound of 20) but seems to be much less dynamically solved as it should be. So I think I need to do three things: 1.) Set fields = (...) dynamically 2.) Set the class attribute tableM = Field() dynamically 3.) Set the dehydrate_tableM() dynamically. I tried to do this over the __init__ method, but this adds the fields to the instance dict and not to the class dict, which does not work. So how can I solve this? -
django running in docker container: accessing static folder inside inlinecss
I have moved a django 1.8.6 project in a docker container that is using django-inlinecss==0.1.2 to format emails. I have my static folder defined in the setting.py: # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.7/howto/static-files/ MEDIA_ROOT = "/srv/media/" MEDIA_URL = "/media/" STATIC_ROOT = os.path.join(BASE_DIR, "static") STATIC_URL = "/static/" and this is my template: {% load static %} {% load inlinecss %} {% load email_table %} {% inlinecss "css/email.css" %} {% block content %} {% block preamble %}{% endblock preamble %} {% block table %}{% email_table object_list %}{% endblock table %} {% block postamble %}{% endblock postamble %} {% endblock content %} {% endinlinecss %} If I run my project i get the following error: I believe that the inlinecss is not finding my static file. I have tried the following with no success: {% inlinecss "/static/css/email.css" %} and {% inlinecss "static/css/email.css" %} in other parts of my code I successfully access static using: "{% static 'js/all.min.js' %}" but inside a inlinecss I cannot use this syntax: {% inlinecss {% static 'static/css/email.css' %} %} because of the nested {% %}. Any help is immensely appreciated. -
how to print a result of a calculation in django rest framework
so in my project i am calculating the distance between 1 user and a list of users but for some reason it is not printing nore displaying the result of the calculation below is my api view class Listsellers(generics.ListAPIView): authentication_classes = [SessionAuthentication, BasicAuthentication] queryset = Seller_account.objects.all() serializer_class = SellerAccountSerializer filter_backends = [DjangoFilterBackend] def calc_distance(self, lat_a, long_a, lat_b, long_b): EARTH_RADIUS_IN_MILES = 3958.761 """all angles in degrees, result in miles""" lat_ab = radians(lat_a) lat_b = radians(lat_b) delta_long = radians(long_a - long_b) cos_x = ( sin(lat_ab) * sin(lat_b) + cos(lat_ab) * cos(lat_b) * cos(delta_long) ) return acos(cos_x) * EARTH_RADIUS_IN_MILES def calc_dist(self): user_long = self.request.Users.objects.username.longitude user_lat = self.request.Users.objects.username.latitude seller_lat = Seller_account.objects.latitude seller_long = Seller_account.objects.latitude lat_a = user_lat print(lat_a) long_a = user_long print(long_a) lat_b = seller_lat print(lat_b) long_b = seller_long print(long_b) distance = Users.objects.calc_distance(self, lat_a, long_a, lat_b, long_b) print(distance) is there something i am missing? -
have to to display specific content for each group of user django
i want to display specific content for each group of user. for example i have a course table and an course object belong to one or more MasterGroup and each user can belong to one or more MasterGroup . class MasterGroup(models.Model): title = models.CharField(max_length=200, null=True, blank=True) about = models.TextField(max_length=1000, null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class SolveGroup(models.Model): master_group_id = models.ManyToManyField(MasterGroup ,related_name='fk_solve_master') age_from = models.PositiveSmallIntegerField(default=0, null=False, blank=False) age_to = models.PositiveSmallIntegerField(default=0, null=False, blank=False) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) have_job= models.BooleanField(default=False,null=False,blank=False) do they suggest a specific solution to this problem? -
MultipartParser is not validating data in Django Rest Framework
I am using a multipart/form-data in a form which have a manytomany relation as well as multiple file upload. But the validated data doesn't contains the array data Views.py class ExpenseCreateAPIView(CreateAPIView): permission_classes = (permissions.IsAuthenticated,) parser_classes = ( MultiPartParser,) def post(self, request, *args, **kwargs): owner = request.user.pk d = request.data.copy() d['owner'] = owner serializer = ExpenseSerializer(data=d) print("exp") 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) Serializers.py class ExpenseSerializer(serializers.ModelSerializer): transactions = ExpenseTransactionsSerializer(many=True, required=False) bill = ExpenseFilesSerializer(many=True, required=False) class Meta: model = Expense fields = "__all__" def create(self, validated_data): print("validated data", validated_data) items_objects = validated_data.pop('transactions', None) files_objects = validated_data.pop('bill', None) prdcts = [] files = [] for item in items_objects: i = ExpenseTransactions.objects.create(**item) prdcts.append(i) if files_objects == None: pass else: for item in files_objects: i = ExpenseFiles.objects.create(**item) files.append(i) instance = Expense.objects.create(**validated_data) instance.transactions.set(prdcts) instance.bill.set(files) return instance How else should I use the MultiPartParser class in the views ? I keep getting the error: TypeError: 'NoneType' object is not iterable at for item in items_objects: -
Why are my videos not properlly uploaded and saved in the correct dedicated directory, from the fileField.uploadTo(relative_path)?
I am trying to upload videos to my Django server directory. When i use the coded app in the admin panel, upload succeed at the correct location. However, when dealing with browser form, it will miss a level of the url as : 'media/title.mp4' instead of 'media/videos/title.mp4. I'd like to save the files into 'media/videos/title.mp4'. Currently, front uploaded videos url is computed as 'media/title.mp4. It just fails, no ressources created, even at the wrong location. Here is my urls.py with the upload route : from uploader.views import upload, download from django.conf.urls.static import static from django.conf import settings from django.contrib import admin urlpatterns = [ path('admin/', admin.site.urls), path('upload/', upload, name='upload'), path('download/', download, name='download'), ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) Here is my upload view : from django.shortcuts import render, redirect from .models import VideoItem def upload(request): if request.method == 'POST': title = request.POST['title'] video = request.POST['video'] content = VideoItem(title=title, video=video) content.save() return render(request, 'upload.html') Here is my upload html template : <form action="" method="POST">{% csrf_token %} <input type="text" name="title" placeholder="Enter Video Title here"><br> <input type="file" name="video" accept="video/mp4"> <button type="submit"> Upload New Video </button> </form> And here is my db model : from django.db import models # Create your … -
How can I make a POST-request using Javscript in Django (CSRF-Token)?
This question has been asked before, but those solutions didn't work for me that well: Fetch, set-cookies and csrf Proper Django CSRF validation using fetch post request Right now the content of my post request is correct and being, but the 403 error still shows up. const url = "post/create" let csrftoken = Cookies.get('csrftoken'); //using library const headers = new Headers({ 'X-CSRF-TOKEN': csrftoken }); return fetch(url, { method: 'POST', headers, credentials: 'same-origin', mode: 'same-origin', body: JSON.stringify({ content: content }) }); Do you have any ideas? -
using whois with Django
I am trying to use the external library of whois but i am getting the error [WinError 2] The system cannot find the file specified I have included the package in my settings file. Here is the code for views: class PreviousSearchView(View): def post(self, request): if request.method == 'POST': searchdomain = request.POST['searchdomain'] domain = whois.query(searchdomain) ##### Error on this line date = datetime.datetime.now() print(domain) search = Search( searchdomain = searchdomain, date = date, user = User.objects.get(id = request.user.id) ) search.save() return redirect('/') -
What is the correct way to change FILE_UPLOAD_MAX_MEMORY_SIZE in django?
If I change FILE_UPLOAD_MAX_MEMORY_SIZE, do I have to change DATA_UPLOAD_MAX_MEMORY_SIZE as well? Django default: DATA_UPLOAD_MAX_MEMORY_SIZE = 2.5 Mb FILE_UPLOAD_MAX_MEMORY_SIZE = 2.5 Mb My api expects two files in a json request. Storing these files on disk is not an option. I have to work on these files in memory. Should I just update FILE_UPLOAD_MAX_MEMORY_SIZE to 3Mb? Or should I change DATA_UPLOAD_MAX_MEMORY_SIZE to 7.5 Mb? Or should I change FILE_UPLOAD_MAX_MEMORY_SIZE to 3Mb and DATA_UPLOAD_MAX_MEMORY_SIZE to 7.5 Mb? -
Retrieve card number/expiry date/CVC in Django Stripe
I am trying to integrate the payment gateway system in Django using Stripe gateway. It works fine for on liner input system. I am getting this pictorial output from my code But I want to retrieve all the attributes from the card like Card Number, Expiry date, and CVC. Code i am tried <script src="https://js.stripe.com/v3/"></script> <form action="{% url 'charge' %}" method="post" id="payment-form"> {% csrf_token %} <div class="form-field-12"> <label class="lb" for="card-element"> Credit or Debit card </label> <div id="card-element"> <!-- A Stripe Element will be inserted here. --> </div> <!-- Used to display form errors. --> <div id="card-errors" role="alert"></div> </div> <input class="myButton" type="submit" value="Submit Payment" name=""> </form> <Script> file var stripe = Stripe('Your public key'); var elements = stripe.elements(); var style = { base: { }, invalid: { } }; var card = elements.create('card', {hidePostalCode: true, style: style}); card.mount('#card-element'); card.addEventListener('change', function(event) { var displayError = document.getElementById('card-errors'); if (event.error) { displayError.textContent = event.error.message; } else { displayError.textContent = ''; } }); // Handle form submission. var form = document.getElementById('payment-form'); form.addEventListener('submit', function(event) { event.preventDefault(); stripe.createToken(card).then(function(result) { if (result.error) { // Inform the user if there was an error. var errorElement = document.getElementById('card-errors'); errorElement.textContent = result.error.message; } else { // Send the token to your … -
Django not loading up staticfiles
I have external js file waste.js which want to use in app named waste. I have created static folder within waste with structure static/assets/js and placed my waste.js there Settings: STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' # Extra places for collectstatic to find static files. STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'core/static'), os.path.join(BASE_DIR, 'waste/static'), ) So I expect that http://127.0.0.1:8000/static/assets/js/waste.js will serve my file but this is not the case. What I am missing here? -
How to bring JSON file via URL in Django?
I am new to Django. I have a few independent dropdown boxes. Now I have to get data from the backend in JSON and parse it for each dropdown boxes. How do I do this? How do I bring JSON via URL? how should I make use of Ajax methods here? Basically, I want to use Ajax method calls and JSON bind data to ui. -
Instead of a post request, a get request is executed
I ran into a problem that instead of a POST request, a GET request is executed in general. urls.py. Although I do everything right. And if I remove the lower url, everything will work correctly. file urls.py: urlpatterns = [ path('message-create/<int:id>', MessageAdd.as_view(), name="message-create"), path("chat/members-get/<int:id>", MembersGet.as_view(), name="members-get"), ] file views.py: class MessageAdd(View): success_url = reverse_lazy('chatlist') def post(self, request, id, *args, **kwargs): file = None if request.FILES: file = request.FILES.get('attached_file') chat = Chat.objects.get(id=id) content = request.POST.get('content') user = self.request.user Message(recipient=chat, sender=user, content=content, attached_file=file).save() chat.last_message = datetime.now() chat.save() return HttpResponseRedirect(self.success_url) file .html: <form action="{% url 'message-create' chat.id %}" class="form" enctype="multipart/form-data" method="POST"> {% csrf_token %} <div class="area"> <i class="fas fa-file-upload"></i> <textarea name="content" placeholder="..."></textarea> </div> <input name="attached_file" type="file" class="file_down"> <button><i class="fas fa-paper-plane"></i></button> </form> and my console: "GET /messenger/chat/members-get/3?csrfmiddlewaretoken=3zbUUBC44nvntopZ985NoFPYwAQOTveMaEaAlwv8mLkuOyIHahM0oZqNpkw8cXdC&content=gge&attached_file= HTTP/1.1" 200 141 -
Django order by calculated value
I have 2 models, Player - id: int - name: string Ball - type: string - player_id: int Basically the idea is that a player can have balls. The type of the ball can be BIG or small. Now I would like to sort the players based on a calculated reputation. The formula for reputation is as follows reputation = No of Big balls x 10 + No of balls So for e.g. the reputation of a player with one big and one small ball would be 11. Could someone give an idea on how to order users based on this reputation? Thanks for your help. -
How to query all of the movies that a cast belongs to using its slug in Django?
I have two models: MovieCast and Movie. The MovieCast model includes an actor_slug field and the Movie model includes a cast field which has a many-many relationship with MovieCast model. In the templates, I'm displaying the cast objects that are related to a movie. An example would be something like this: Schindler's List cast: Liam Neeson, Ben Kingsley Each of those actors are the cast objects related to the movie. What I am trying to do is have a link which contains the actor's name as slug (I also have an actor_slug field in the MovieCast model) and when that url is clicked, we get all of the movies that an actor is included in. What I tried to do is as follows: Include a link which will route to something like /movies/cast/{{ actor_slug }} Include a url in urls.py which will direct a link such as above to a view Write a class based view, say MovieCastView, and modify its get_queryset method like this: def get_queryset(self): # the actor_slug will come from the link that I previously mentioned self.actor_slug = self.kwargs['actor_slug'] What I can't figure out is how do I get all of the movies that a cast has … -
Using Django on local network with redundancy server? [closed]
I'm just working on a small project in Django where I want to host a webserver locally with a small number of devices connecting to it. I would like it to be set up that if one of the servers dies the other would continue where it left off. It would be preferable to keep it off the www. How would I do this without it being apparent to any of the devices connected? Thank you.