Questions tagged [django]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
35 views

Exporting data from PostgreSQL as CSV to S3 bucket

I have a general question regarding DRY. As you can see there are several parts such as io.StringIO(), csv.writer, ...
0
votes
0answers
33 views

Is it a good practice to save media files on the same server in Django? [closed]

I want to release Speedy Net to production soon. Speedy Net uses Django (1.11) and I noticed that if I set the DEBUG settings to ...
-1
votes
0answers
37 views

Django models: retrieving database data in a for loop

This piece of code is grinding my Django project to a halt whenever it is run (but it does do what is expected of it): ...
2
votes
0answers
20 views

Automatically filled multiple forms in one view

I have some question because in my project I have 4 models, and one of models is parent for other 3 and they are connected to parent by foreign key. Then I have view which is used for automatically ...
1
vote
1answer
25 views

Custom model to count user interaction in application

In language dictionary application users can add new words and do other staff with this word such as adding additional information to the word (description, etymology, speech parts, noun class etc.) I'...
0
votes
1answer
41 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
90 views

ProfileForm that collects extra fields on User Signup

I have a signupView that shows 2 forms: SignUpForm and ProfileForm. Basically, ...
1
vote
0answers
19 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
21 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
36 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
58 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
33 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
25 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
21 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
96 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
64 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
57 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
49 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
58 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
68 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
42 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
1answer
103 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
53 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
77 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
649 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
75 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
69 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
69 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....
8
votes
0answers
136 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
81 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
930 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
53 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
58 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
541 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
210 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
53 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
326 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
182 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
120 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
272 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
726 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
102 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
22 views

Click a link to delete targeted content using Ajax

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

Unit tests for os.scandir/scantree a directory

I wrote my first series of test for this simple function: ...
2
votes
0answers
90 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
886 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 ...