Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
choice multiple instances from foreignkey django
how to choice multiple instances of a foreignkey for example class Mobile(models.Model): mobile = models.CharField(max_length=20,unique=True) quantity = models.IntegerField() imei = models.ForeignKey(Imei,on_delete=models.CASCADE) class Imei(models.Model): imei = models.CharField(max_length=13,unique=True) each mobile have different Imei in Mobile if mobile =samsung A51 and quantity = 10 then we have 10 unique imei i want to know how to let the user the select 10 imei's (with barcode reader) in the same form ? i appreciate your helps -
Django Stripe payment does not respond after clicking the Submit Payment button
I have an e-commerce application that I'm working on. The app is currently hosted on Heroku free account. At the moment I can select a product, add it on the cart and can get up to the stripe form and type in the card details, but when I click the 'Submit Payment' button nothing happens. I don't even get an error message. I'm using Stripe test keys and 4242 four times as my card number. Can anyone help me to find out what's going on pliz. I have been stuck on it for days. Here is the relevant code below: Settings.py code: from .base import * import dj_database_url DEBUG = (os.environ.get('DEBUG_VALUE') == 'True') ALLOWED_HOSTS = ['.herokuapp.com', '127.0.0.1'] AUTH_PASSWORD_VALIDATORS = [ {'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'}, {'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'}, {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'} ] """ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': config('DB_NAME'), 'USER': config('DB_USER'), 'PASSWORD': config('DB_PASSWORD'), 'HOST': config('DB_HOST'), 'PORT': '' } } """ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } STRIPE_PUBLIC_KEY = os.environ.get('STRIPE_LIVE_PUBLIC_KEY') STRIPE_SECRET_KEY = os.environ.get('STRIPE_LIVE_SECRET_KEY') AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME') AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = None AWS_S3_REGION_NAME = "us-east-2" AWS_S3_SIGNATURE_VERSION = "s3v4" DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = … -
How do I save form response as an object in Django's database?
I am unable to save my form responses to the database as an object in Django. Everytime I click on submit to submit my form, I am just logged out of my website and the object isnt saved in the database either. Can anyone tell me where I am going wrong? This is my models in models.py. class Chain(models.Model): name = models.CharField(max_length=255) user = models.ForeignKey(User, on_delete=models.CASCADE) year = models.CharField(max_length=10, default="20XX") sem = models.CharField(max_length=30, default="Default Semester") code = models.CharField(max_length=10, default="SUB-CODE") slot = models.CharField(max_length=10, default="EX+EX") last_updated = models.DateTimeField(auto_now=True) def __str__(self): return self.name This is my view in views.py file. @login_required(login_url='/') def create_course(request): if request.method == 'GET': return render(request, 'create_course.html', {}) elif request.method == 'POST': name=request.POST['name'] year=request.POST['year'] sem=request.POST['sem'] code=request.POST['code'] slot=request.POST['slot'] newchain = Chain( name=name, year=year, sem=sem, code=code, slot=slot, ) newchain.user = request.user newchain.save() return redirect('success') -
How do I get two auth0 apps written in Django to show one login page and redirect to correct auth 0 app depending on username?
I have two Django apps that authenticate using auth0 pointing to same domain running on different ports - localhost:3000 and localhost:3001. They're both working fine and authenticating users as expected when I go to the respective ports. But going to localhost:3000 authenticates me to app1 and going to localhost:3001 authenticates me to app2 What I want to do is have both the apps running and I want a common login page to show up ( dont want this to be login to a particular app - app1 or app2) and then depending on the username, it redirects me to either app1 or app2. -
Django e-mail doesn't send the pdf generated
I think i didn't really understood about mail sending, but my objective is to send the PDF that my app generate to my real email, i only get the backend mail. I leave a photo of the "runserver", "celery", "rabbitmq" shell tabs, and my github so you guys can see the project if u need to, i think with the code below is what u need to see but just in case. Github: https://github.com/Taiel-Kadar/myshop Photo: shell views.py: import braintree from django.shortcuts import render, redirect, get_object_or_404 from django.conf import settings from orders.models import Order from .tasks import payment_completed # instantiate Braintree payment gateway gateway = braintree.BraintreeGateway(settings.BRAINTREE_CONF) def payment_process(request): order_id = request.session.get('order_id') order = get_object_or_404(Order, id=order_id) total_cost = order.get_total_cost() if request.method == 'POST': # retrieve nonce nonce = request.POST.get('payment_method_nonce', None) # create and submit transaction result = gateway.transaction.sale({ 'amount': f'{total_cost:.2f}', 'payment_method_nonce': nonce, 'options': { 'submit_for_settlement': True } }) if result.is_success: # mark the order as paid order.paid = True # store the unique transaction id order.braintree_id = result.transaction.id order.save() # launch asynchronous task payment_completed(order.id) return redirect('payment:done') else: return redirect('payment:canceled') else: # generate token client_token = gateway.client_token.generate() return render(request, 'payment/process.html', {'order': order, 'client_token': client_token}) def payment_done(request): return render(request, 'payment/done.html') def payment_canceled(request): return render(request, … -
Django: L10N and en-IN
I googled a lot to find solution for my problem related to Django's L10N settings for en-IN and found nothing satisfying which works. So, finally get back here to friends. I'm struggling to format currency as Indian number formatting standard. Which follows NUMBER_GROUPING = (3, 2, 0) and LANGUAGE_CODE = 'en-IN'. My current configurations of settings.py file is: LANGUAGE_CODE = 'en-IN' USE_I18N = False USE_L10N = True USE_THOUSAND_SEPARATOR = True NUMBER_GROUPING = (3, 2, 0) In template file I use: {% load humanize %} {# where object.price value is 524300 #} <p> {{ object.price }} {{ object.price|intcomma }} </p> Hence this outputs: 524,300 instead 5,24,300 What am I doing wrong, which is stopping Django for follow settings of LANGUAGE_CODE, USE_L10N and NUMBER_GROUPING -
Django KeyError after AJAX request
I have a KeyError: 'category_id' after an AJAX request. I know the kwarg is being passed because it says Internal Server Error: /tests/cat-update/1/ My view looks as such: def get_tests_filtered_for_category(request, **kwargs): print('test:', kwargs['category_id']) category = Category.objects.all() quiz = Quiz.objects.filter(category=category) test_list = list(quiz.values('id', 'name')) return HttpResponse(simplejson.dumps(test_list), content_type="application/json") url.py: path('cat-update/<int:pk>/', views.get_tests_filtered_for_category, name='cat-update'), JS: $('select[name=categories]').change(function(){ category_id = $(this).val(); request_url = '/tests/cat-update/' + category_id + '/'; $.ajax({ url: request_url, success: function(data){ $.each(data, function(index, text){ $('select[name=tests]').append( $('<option></option>').val(index).html(text) ); }); } }); }); What is the reason the category_id key does not exist? -
How to not use pylint-django in non Django file?
I'm new to the Django. I am currently use VS code as my code editor. In order to work on the Django project, in the user settings of the VS code, I include the following code to use pylint_django as the default linter. "python.linting.pylintArgs": [ "--load-plugins=pylint_django", "--errors-only" ], However, in another python file, which is just a regular python file, I got an error, saying "Django is not available on the PYTHONPATHpylint(django-not-available)" If I comment the above code in the user setting, the error goes away. I think the problem is pylint-django is used as default linter, even for non-Django python file. My question is I didn't find the solution to solve this problem. Could you please help me on this? Thank you so much. I really appreciate it. -
Ajax with Django mistakenly printing JSON to screen
I'm trying to implement a "like" feature for a Gapper object (people who are on a gap year), and change the "Like" button to "Unlike" when the change is made on the backend. Since I don't want to reload the whole page, I'm using AJAX (have used .fetch in React, which was simple, seamless, and very short--AJAX seems super clunky and outdated--is there no better way for vanilla HTML applications?) and running into some trouble. The JSONResponse that many answers suggest is being printed to the screen, whereas I don't want there to be any reloading/refreshing/change of endpoint at all--that's the whole point. The relevant code is below and I think it's a straightforward problem, and I'm just being silly. Help much appreciated! In views, I tried using serializers.serialize(), but I don't really need any data back from the backend, it just needs to make the change and then on the front end I can swap Like to Unlike and vice versa when a successful ajax response is received. Also tried it with csrf, wasn't working. I also tried is_ajax() which gave False. Importantly, the like and unlike function is working correctly (the list is being added and removed from, … -
How can i style my django filter with bootstrap or CSS
i'm new to django here and still learning. So, i created a filter using django-filter and i didn't know how to style it (bootstrap or CSS) because i really don't like the default styling. Can anyone help me with it? i already googled it but didn't find anything useful. filters.py ` class CompLink_Filter(django_filters.FilterSet): start_date = DateFilter(field_name="date_added", label='Date ajout' ,lookup_expr='gte') company_name = CharFilter(field_name='company_name', label='Nom Entreprise' ,lookup_expr='icontains') sector = CharFilter(field_name='sector',label='Secteur' , lookup_expr='icontains') size = CharFilter(field_name='size', label='Taille' ,lookup_expr='icontains') phone = CharFilter(field_name='phone', label='Téléphone' ,lookup_expr='icontains') employees_on_linkedin = CharFilter(field_name='employees_on_linkedin', label='Employés sur Linkedin :' ,lookup_expr='icontains') type = CharFilter(field_name='type', label='Type' ,lookup_expr='icontains') founded_in = CharFilter(field_name='founded_in', label='Fondée En' ,lookup_expr='icontains') specializations = CharFilter(field_name='specializations', label='Spécialisations' ,lookup_expr='icontains') class Meta: model = Comapny_Profile fields= '__all__' exclude= ['company_link','website','head_office','address']` displaying the filter in my template: <form class="" action="" method="get"> {% for field in myFilter.form %} <div class="fieldWrapper"> {{ field.errors }} {{ field.label_tag }} {{ field }} {% if field.help_text %} <p class="help">{{ field.help_text|safe }}</p> {% endif %} </div> {% endfor %} <button class="btn btn-primary" type="submit" name="button">Recherche</button> </form> -
Django custom user model doesn't show up under Authentication and Authorization in the admin page
I have been trying to figure this out for a few hours and feel lost. I am new to django and have tried to create a custom user model. My struggle is that my user model won't show up under the Authentication and Authorization section of the admin page. Admin page pic Here is my code for the model from django.db import models from django.contrib.auth.models import AbstractUser # Create your models here. class User(AbstractUser): first_name = models.TextField(max_length = 300) last_name = models.TextField(max_length = 300) Here is the code for my admin.py file from django.contrib import admin from django.contrib.auth.admin import UserAdmin from orders.models import User # Register your models here. admin.site.register(User,UserAdmin) here is a snippet of my settings.py file where i added the AUTH_USER_MODEL AUTH_USER_MODEL='orders.User' # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'orders' ] -
Django - Spotify API authorisation
I have developed a simple Django app, using Spotify API and Spotipy Authorisation (authorisation flow). This runs a localhost server where I click a simple button which creates a playlist in Spotify. My issue however is in setting this up for an alternative user to login via their credentials and gain authorisation. Atm, I have set this app up using a hardcoded cid and client secret within the views.py module (in the backend). This uses the following code to gain auth. token = util.prompt_for_user_token(username, scope, client_id= cid, client_secret= secret, redirect_uri=r_uri) My index.html file then links a button to this script so that when clicked, the playlist is created. I expect this index.html needs to be updated to allow the user to login to their own spotify account and to authorise their token. However I am unsure on how to update this or if I am on the right track. Alternatively, I think I may need to restart the project using java to gain authorisation for another user or using Implicit Grant Auth method, if spotipy authorisation cannot be used. -
how can i resize bootstraps cards for a website using django?
I just started in the programming world and i'm currently trying to learn python and some django, so i apologized in advanced if this is a dumb question, now back to the point, i'm trying to add some cards from bootstrap to a website to display images of the products with their prices and the option to add then to the cart but since the image in this card are being retrieved from another website, when i tried to load my page the images are too big and the cards don't resize automatically with the browser window so it shows one on top of another. -
'Cannot add or update a child row: a foreign key constraint fails' While creating a new django model object
I have two models 'inventory_barcodes' and 'transfer_inventory' like: Transfered barcodes: class TranferedBarcode(models.Model): id = models.IntegerField(primary_key=True) barcodes = models.CharField(max_length=45, blank=True, null=True) transfer_lot_id = models.ForeignKey('InventoryTransfer', models.DO_NOTHING, db_column='transfer_lot_id') class Meta: managed = False db_table = 'tranfered_barcode' and Inventory Transfer: class InventoryTransfer(models.Model): id = models.IntegerField(primary_key=True) barcodes = models.TextField() to_warehouse = models.CharField(max_length=255) from_warehouse = models.CharField(max_length=255) total_count = models.IntegerField() approval_flag = models.IntegerField(default=0) current_status = models.CharField(max_length=50, blank=True, null=True) error_message = models.CharField(max_length=255, blank=True, null=True) created_by = models.CharField(max_length=50, blank=True, null=True) created_at = models.DateTimeField(blank=True, null=True, auto_now_add=True) transfer_lot_id = models.IntegerField() class Meta: managed = False db_table = 'transfer_inventory' I'm creating two objects for each model in a view for eg: n = random.randint(1,10000000) InventoryTransfer.objects.create(barcodes=barcodes, to_warehouse=to_warehouse, total_count=barcode_count, created_by=request.user.username, from_warehouse=current_warehouse, current_status="Pending", transfer_lot_id=n) transfer_obj = InventoryTransfer.objects.get(id=36) TranferedBarcode.objects.create(barcodes='SPBA121212',transfer_lot_id=transfer_obj) While doing this I'm getting error as "Cannot add or update a child row: a foreign key constraint fails' While creating a new django model object." I'm stuck here, so any help would be needful. Thanks in advance. -
How to Submit a category form in Django?
I am trying to submit a category form in Django,but it's not saving data in my Database table and it's redirecting me on create category page. I have already created a forms.py file, but that's not working properly, I am working with creating my custom HTML form, Please check my code and let me know where i am Mistaking, and how i can submit this form data in Database table. Here are my Urls.py file... urlpatterns = [ url(r'^category/create/$',views.add_cat, name="catadd"), ] Here are my models.py file code... class Category(models.Model): catType=models.IntegerField(default=None) cat_name=models.CharField(max_length=225) cat_slug=models.SlugField(max_length=225, unique=True) meta_title=models.CharField(max_length=225) meta_desc=models.CharField(max_length=285) meta_keyword=models.CharField(max_length=285) status=models.BooleanField() linkable=models.BooleanField() created_at = models.DateTimeField(auto_now_add=True) update_at = models.DateTimeField(auto_now=True) def __str__(self): return self.cat_name Here are my forms.py file... from django import forms from .models import Category class CategoryForm(forms.ModelForm): class Meta: model=Category fields=('catType','cat_name','cat_slug','meta_title','meta_desc','meta_keyword','status','linkable') Here are my views.py files.. def add_cat(request): if request.method=='POST': form = CategoryForm(request.POST) if form.is_valid(): cate = form.save(commit=False) cate.save() return redirect('dashboard/category') else: form=CategoryForm() return render(request, 'dashboard/category/createcat.html', {'form': form}) here are my createcat.html file.. <form class="form-horizontal m-bottom-30 catForm" id="wizard-arrow" method="POST" action="{% url 'dashboard:catadd' %}" novalidate="novalidate"> {% csrf_token %} <ul class="list-steps"> <li class="col-sm-4 step-item-arrow active"> <a href="#arrow-one" data-toggle="tab"> <i class="fa fa-lock bg-primary"></i> <span>Category Name Section</span> </a> </li> <li class="col-sm-4 step-item-arrow"> <a href="#arrow-two" data-toggle="tab"> <i class="fa fa-gear … -
Change form_field.required inside UpdateView.form_valid
I have a field with blank=True. Inside my UpdateView form_valid method i have an if condition. Is it possible to make it so, if if cond == False, the form will act as if the field is required and throw a prompt to fill-in the field, and not a sever error. -
Different redirect on form submit in a Django view
Is it possible to redirect to a page or another when sending a request.POST in a Django view, depending on which button has been used? Example: <form id="myForm" action='.'> <submit button1> <submit button2> </form> and then in my view: if request.method == "POST": if form_.is_valid() and button1: form.save() return redirect('page1') if form_.is_valid() and button2: form.save() return redirect('page2') -
Showing list of items including item details on same page in Django
In a Django v3.x app I would like to display a list of uploaded file names (e.g. images) in the left hand side of the screen. When a user clicks on one of those, I'd like to display the actual file/image on the right hand side of the screen. I am still new to Django and have used both ListView and DetailView separately, but not in such a combination. I'm not sure how this can be achieved. Using a little Bootstrap magic, I can create a split screen easily. Hence, my template would look somehow like this: <div class="row"> <div class="col-md-5 left"> {% for image in images %} <div class="card"> <h4>{{ image.url }}</h4> <a href="{{ image.url }}">View</a> </div> {% endfor %} </div> <div class="col-md-5 right"> {# TODO: When the user clicks on the View url above, then I'd like to load the actual image here on the right hand side of the screen inside this div-tag. #} </div> </div> Question 1: How can I achieve loading a selected image from a list? Can I still use ListView and DetailView, or do I need to write my own View logic? Question 2: Ideally, I'd like to NOT re-send the whole page … -
How to create model allowing infinite submodels in django?
Im creating a site where you can write down your goals, you should be able to split every goal into subgoals if chosen, and allow those subgoals to be split into subgoals infinitely. This code below shows what i came up with first for the models, the first model is for creating a goal, the second model can either either be a subgoal of the goal or a subgoal of the subgoal. But it seems like a really bad way to go around this problem. Django semi-newbie BTW... from django.db import models from django.contrib.auth.models import User class Goal(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, default=None) title = models.CharField(max_length=70, null=True) content = models.TextField(blank=True) slug = models.SlugField(max_length=50, editable=False) date_created = models.DateTimeField(auto_now_add=True, null=True) class Meta: unique_together = ['user', 'title'] def __str__(self): return self.user.username + " - " + self.title def save(self, *args, **kwargs): self.slug = self.title.replace(' ', '-').lower() super(Goal, self).save(*args, **kwargs) class SubGoal(models.Model): goal = models.ForeignKey( Goal, on_delete=models.CASCADE, null=True, blank=True) parent = models.ForeignKey( "SubGoal", on_delete=models.CASCADE, null=True, blank=True) title = models.CharField(max_length=70) content = models.TextField(blank=True) date_created = models.DateTimeField(auto_now_add=True, null=True) def __str__(self): try: return self.goal.title + " - " + self.title except: return self.parent.title + " - " + self.title -
How to use p5.sound.js library in Django?
I have a problem with p5.sound.js in Django. When I create AudioIn() object in my javascript file I get this error in web browser: "TypeError: arraySequence[0] is undefined2 f1a53862-ad3a-488b-a58a-c9b8c40fa664:75:28 push blob:http://127.0.0.1:8000/f1a53862-ad3a-488b-a58a-c9b8c40fa664:75 process blob:http://127.0.0.1:8000/f1a53862-ad3a-488b-a58a-c9b8c40fa664:170" The only thing I do in my js code is "mic = new p5.AudioIn();" - in this moment the error appears. I have tried to use the library both downloaded and from cdnjs.cloudflare.com. -
relation between models (tables) in dajngo
how to make such relations class Laptop(models.Model): name = models.CharField(max_length=20) class SerialNumber(models.Model): serial_number = models.CharField(max_length=13,unique=True) each single computer has a unique serial number , for example we have 5 MacBook Air (13-inch, 8GB RAM, 256GB SSD Storage) - Space Gray and also we will have 5 unique serial number for MacBook Air as a barcode, i add when quantity selected class Computers(models.Model): serial_number = models.ForeignKey(SerialNumber,on_delete=models.CASCADE) name = models.ForeignKey(Laptop,on_delete=models.CASCADE) quantity = models.IntegerField() when i sell more than one MacBook Air , use their barcodes (serial number) during selling , and sometimes more than one laptop model in one form class LaptopSellingForm(models.Model): name = models.CharField(max_length=20) items = models.ManyToManyField(Computers,through='Laptops') date = models.DateTimeField(auto_now_add=True) i need a connection that allow me after selected Computer Model , then allow me to access serial number , then if quantity=3 then i will choice 3 serial number class LaptopsSelling(models.Model): computer = models.ForeignKey(Computers,on_delete=models.CASCADE) quantity = models.IntegerField() should i add serial_number field to LaptopsSelling as a foreignKey then control the number of serial_number fields with InlineFormset i much appreciate your helps -
Conditional formatting django css
I pretty new to Python and Django. My first Project is a MS Teams Status Call Monitor. Its working so far. But I asked myself if its possible to format the Table different when having a change in my Status. Available = Green Away = Yellow Busy = Red How can I do that with Django / CSS? {% extends "tutorial/layout.html" %} {% block content %} <h1>Teams</h1> <table class="table"> <thead> <tr> <th scope="col">Activity</th> <th scope="col">Availability</th> </tr> </thead> <tbody> <tr> <td>{{ status.status }}</td> <td>{{ status.availability }}</td> </tr> </tbody> </table> {% endblock %} Thanks :) -
I cant update a data object in python. I have a model called choice with 2 object one of the is vote i need to update its valu
enter image description here moodel enter image description here Views.py vote views. -
how to do real time video/audio streaming in django
i want to stream the video and audio (and some real time data which i will get from precessing every fram) from surveillance camera into a django website ... i found this code that help me send frames to the client ''' from django.shortcuts import render from django.http import HttpResponse, StreamingHttpResponse import cv2 import time from django.views.decorators import gzip class VideoCamera(object): def __init__(self): self.video = cv2.VideoCapture('./streaming/video.mp4') def __del__(self): self.video.release() def get_frame(self): ret, image = self.video.read() ret, jpeg = cv2.imencode('.jpg', image) return jpeg.tobytes() def gen(camera): while True: frame = camera.get_frame() yield(b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n') @gzip.gzip_page def index(request): try: return StreamingHttpResponse(gen(VideoCamera()), content_type="multipart/x-mixed-replace;boundary=frame") except HttpResponseServerError as e: print("aborted") but i dont knoow hhow to handle the audio and data and the synchronization . i want to know what technology i have to use and if there any tutorial or ideas about it. i really don't know what to read and how to start (i'm using django). -
Django Migration, Getting User by Username: You can't execute queries until the end of the 'atomic' block
I'm running a data migration that parses a python dictionary and creates objects in a database for every object in the dictionary with their respective fields. The issue is that one of the fields is a user, and the other is a foreign key. When I try and get their objects, I'm met with django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block. I know I can probably put with transaction.atomic() somewhere, and I've looked at similar questions on StackOverflow but I can't seem to figure it out. Here's my migration: def upload_change_data(apps, schema_editor): # Import all required apps Change = apps.get_model('changecontrol', 'Change') Server = apps.get_model('changecontrol', 'Server') User = apps.get_model('auth', 'User') # Iterate over every entry in dictionary and add a new change object # to a list of all changes changes = [] for page in initial_data: for entry in page: # Try and find the user that created this object, otherwise # skip the object try: user = User.objects.get(username=page[entry]['admin']) except User.DoesNotExist: continue # Get the server that this change was for computer = Server.objects.get(name=page[entry]['computer']) # Append the change object to the list of changes changes.append( Change(time=page[entry]['time'], server=computer, summary=page[entry]['summary'], …