Questions tagged [django]

Django is a Python-based framework for creating web applications.

0
votes
0answers
24 views

Django view of reward points that heavily filters and sorts (many) database results

My page (even when it has no data) takes 10+ seconds to load. That's just too long, considering when you finally get to it there's no data. When it has data, it takes even longer. Here is my view, ...
3
votes
0answers
58 views
+50

ProfileForm that collects extra fields on User Signup

I have a signupView that shows 2 forms: SignUpForm and ProfileForm. Basically, ...
0
votes
0answers
17 views

Language dialects Django model [on hold]

I'm creating the Dictionary app, where you can search for words, click on a word, and show the same word in other dialects of the language. I have now created the following Django model: ...
1
vote
0answers
17 views

Trigger sirens on cameras in remote locations

Web-app summary: I'm a complete beginner in web development and I made a sample web application that can trigger sirens on security cameras located in remote locations. Here's the functionality seen ...
0
votes
0answers
15 views

Django: Better way to combine these two queries?

I combine two query sets (available_tickets_by_event and sold_tickets_by_event. My end goal is to combine it in ...
2
votes
0answers
32 views

Web app that triggers sirens on cameras in remote locations

Web-app summary: I'm a complete beginner in web development and I made a sample web application that can trigger sirens on security cameras located in remote locations. Here's the functionality seen ...
1
vote
1answer
50 views

Sign-up serialization in Python [closed]

I built a small project using Django-Rest-Framework. Please comment on the best practice style for the code below, which will make it simpler. ...
1
vote
1answer
32 views

Django export to xls format

I'm working on a Django project and I'm wondering if there is any way to improve the process time to export my data to xls format. Actually, it takes between 43 seconds and 49 seconds to create the ...
1
vote
0answers
21 views

Putting a multichoicefield under a dropdown button

I am building a web app in Django where one of the form fields is a multiplechoicefield from a many2many object that I use to select users that are allowed to edit the post. In standard form the field ...
0
votes
1answer
43 views

Simplify small pieces of code with Python/Django [closed]

I'm trying to make a code review for an external developer on my project. His code could be improved and I need your advices in order to know if my overwritten parts are better or not. Part 1 ...
1
vote
0answers
15 views

Python Elasticserch DSL integration with Django [closed]

There is a big Pull Request in django-elasticsearch-dsl. Can anyone take some time and review the pull request? We are changing from python MetaClass to a decorator ...
3
votes
0answers
43 views

Simple auction application in Django

I'm learning backend dev and python and django1. My first app is a basic auction site. Users sign up, submit an auction, and other users bid on the auctions. I would highly appreciate any ...
4
votes
1answer
61 views

Django view to display weather measurements for selected location and dates

I'm a crop scientist and am currently building a web app that collects weather data then generates and displays modeled agriculturally relevant output. My question centers around an increasingly ...
3
votes
1answer
56 views

Two cases for indicating consent for a ticket

I have two cases here: the person who ordered a ticket clicks on "Permission" and the OrderConsentUpdate View updates the database. is the attendee him- or herself ...
3
votes
0answers
39 views

Django authentication against Exchange server

I wrote an authentication app for Django and my worry is primarily about the security of my app. My Django authentication app uses exchangelib to authenticate ...
4
votes
1answer
53 views

Django model for real estate

I have built a real estate management system with Django. I want to know if my design database was wrong. Please let me know how to improve it. Should I make the models use more than two tables (...
2
votes
0answers
35 views

Django Restframework: Writable nested serializer with custom behavior

Context I am trying to get some practice with Django and Django REST framework. As a toy example I want to set up a server to which I can POST results of automated test runs. In the simplest version, ...
2
votes
1answer
38 views

Wipe sensitive information from memory in Python

I have come up with the following method to remove sensitive information with the help of the garbage collector: ...
7
votes
0answers
73 views

TDD tests for every view and its permissions in a REST API

I am currently developing a Django Rest Framework API with TDD. I have 15 tests and counting for two views, which doesn't seem right to me. It takes me a lot of time to write the tests and a lot of ...
2
votes
1answer
49 views

Django: Database efficiency - currently accessed twice

I have the following function that is called via signal. 1) check if incluencer exists. 2) Increase discount by +1. Currently, I hit the database twice. Is there a better way to write that? ...
1
vote
1answer
55 views

Django functions to sanitize URL, return welcome message, redirect, compute HMAC, and manage profile picture

I wrote this code to to perform the following: I will remove the "spaces" within the url. Return welcome message. Redirect the user to different url. Compute HMAC for the request. Return and revoke ...
0
votes
1answer
408 views

Django delete user from userprofile [closed]

I'm creating a Django project where users can decide to delete their account and everything we know about them (solved riddles, votes ...). I think you can compress this code but I don't know how. I ...
1
vote
1answer
62 views

Using a form with formsets in Django

I'm learning Django and making my (technically second) project. The project features several apps, including player_interface and manager_interface. Here's the player_interface/models.py: ...
5
votes
1answer
65 views

NHL Stats web app

There is a web app. My first attempt to use NHL API have been reviewed here. I'm interested in any kind of refactoring of this code. But I have some questions that I want to point at specifically. ...
2
votes
0answers
61 views

Python/Django Class based saving

I'm creating multiple Django apps with vote possibilities, so I made an app vote to handle all this votes. In my templates I'm including an ajax-function named <...
1
vote
1answer
46 views

Python/Django Filter with Datetime and extra options

I'm creating a filter in python/django. I want to make a datetime human-readable. You have multiple options: Plain Datetime ("04. Februar 2018, 18:18") ...
2
votes
0answers
65 views

Generate automatically new groups in a tournament

I'm trying to model a tournament with Python (Django) and I've got a function that assigns teams of the previous stage to the groups of the new one. The teams in the first stage are assigned manually....
7
votes
0answers
119 views

Building Slack message

I have the function which builds and return Slack message with text and attachments. How can I refactor this function to make it ...
4
votes
2answers
80 views

Counting users by the type in their profile

I'm creating a django web application and I would like to know how to shorten this code. I have a model where every user has a typeOfPerson (Student, Teacher, Guest ...) and I want to count these ...
3
votes
0answers
739 views

Sending notifications with Django channels

I have project on Django wich use Django Channels. I use Django Channel for sending notifications to users who are subscribed to articles changes (adding/editing/deleting comments on article). So I'...
3
votes
1answer
43 views

Django module to transform data from database to be displayed in Slickgrid tables

This is a Django tag with 2 classes, but can be viewed as a module: What does the module do? it loads a database, performs some transformations on the data, returns the output as a dictionary of json ...
1
vote
0answers
52 views

Django model and views to summarize and plot an uploaded CSV

I have a simple web application where a user uploads a CSV of some dataset and some summary statistics and box plots are displayed. I heard that it is better to have so called skinny views and fat ...
1
vote
0answers
459 views

React + Django (session) authentication

Is authentication implemented correctly? At the entry point to the app, which is App.js, query the Django server, which responds whether the current user is ...
1
vote
0answers
23 views

Django template for “no more discount codes” and “expired discount code” situations

I have the following code in my Django template. It's a bit repetitive. I wonder if that's good the way I wrote it, or if you would combine these two 'if'-statements into one somehow? ...
3
votes
1answer
133 views

Custom login class based view

I am trying to fight my way trough self learning Django (as this is a beast on its own) and Python (just for coding <3) in combination with nginx, PostgreSQL and gunicorn - I have some limited ...
2
votes
1answer
52 views

Transactionally create something, if allowed

I have been looking over this block of code for hours trying to simplify it. Would there be a better way to check all those conditions before creating a transaction ...
1
vote
1answer
275 views

Isolate a Database Change Within Django Transaction.Atomic

I have been typically adding the @transaction.atomic decorator to my endpoints and appreciate if a request fails at any point the data completely rolls back. However, some of my endpoints will make ...
3
votes
1answer
151 views

Django post function : split method is a good way?

I'm working on my Django project and I'm trying to develop this one with 'Class Based View' (CBV) method in order to keep the code maintainable. I have a class ...
1
vote
2answers
117 views

Let's make this Order nicer

Environment details Python 3.6.5 Django 2.0 (which is not necessarily needed for this review) Class details I have a small class which holds 3 staticmethods (I ...
4
votes
0answers
253 views

Python Class to represent a Pokemon

I have been programming with Python on-and-off for about 2 years now, even now I still find that when I look at other applications I struggle to follow along with their classes/objects. Please help me ...
3
votes
2answers
593 views

JWT authentication between Django and ReactJS

I am currently using Django (2.1) to build an API, and I have added djangorestframework-jwt to manage JWT. Here is the configuration: ...
1
vote
0answers
91 views

Model architecture in Django

I am developing a project with various tables so I can have better understanding of model relation by communicating with the experts. Can anyone look at my code and see if I have designed my models ...
0
votes
1answer
21 views

Click a link to delete targeted content using Ajax

I wrote a glypicon as a link to delete a comment: ...
2
votes
1answer
98 views

Unit tests for os.scandir/scantree a directory

I wrote my first series of test for this simple function: ...
2
votes
0answers
78 views

An asynchronous solution to send validation email [closed]

I intend to send validating message to User's email to complete a registration with the following codes: ...
3
votes
0answers
787 views

Django shopping cart, and testing

For an e-commerce web application I have written a shopping cart, and some tests for it. I have used a course on Lynda.com, on building an e-commerce website, as inspiration on how to build the ...
2
votes
1answer
463 views

Web scraping news articles with Beautiful Soup

It's been nearly a year I've been working with C++ and now I am diving in Python and its libraries and frameworks. I am currently creating a website for my portfolio that gathers news articles from a ...
2
votes
0answers
110 views

Django social network application - database schema

I am writing a simple social media application in Django. I would like to know whether the following model structure is correct, or how can I improve the schema to get better performance. Do I need to ...
0
votes
1answer
7k views

Cleanest way to get list of Django objects that have same foreign key and display them in a view

I am a beginner in Django and would like some advice regarding best practices. I have the following model: ...
7
votes
0answers
441 views

Let's register that Django user

Short intro So, I've been using Django for a while now and thought it would be nice to start a simple application. In an ideal World, each app must have a way of letting its users register and that's ...