Questions tagged [django]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
49 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 ...
Essex's user avatar
  • 293
1 vote
0 answers
640 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 ...
Bruno Vermeulen's user avatar
0 votes
1 answer
51 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 ...
Essex's user avatar
  • 293
3 votes
0 answers
3k 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 ...
user1849962's user avatar
4 votes
1 answer
85 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 ...
Dodge's user avatar
  • 143
3 votes
1 answer
75 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 ...
Joey Coder's user avatar
2 votes
0 answers
236 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 ...
Greg Schmit's user avatar
4 votes
1 answer
208 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 (...
namo 's user avatar
  • 69
2 votes
0 answers
2k 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, ...
dudenr33's user avatar
  • 281
2 votes
1 answer
200 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: ...
volingas's user avatar
  • 121
8 votes
1 answer
795 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 ...
 DJN's user avatar
  • 81
2 votes
1 answer
105 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? ...
Joey Coder's user avatar
1 vote
2 answers
1k 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 ...
PythonLearner's user avatar
0 votes
1 answer
7k 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 ...
Myzel394's user avatar
  • 296
1 vote
1 answer
705 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: ...
art-solopov's user avatar
6 votes
1 answer
202 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. ...
edvard_munch's user avatar
4 votes
1 answer
101 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 <...
Myzel394's user avatar
  • 296
1 vote
1 answer
534 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") ...
Myzel394's user avatar
  • 296
2 votes
0 answers
102 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....
Lorenzo Fiamingo's user avatar
14 votes
2 answers
278 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 ...
ryche's user avatar
  • 253
4 votes
2 answers
103 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 ...
Myzel394's user avatar
  • 296
11 votes
0 answers
3k 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'...
KIN1991's user avatar
  • 211
3 votes
1 answer
153 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 ...
Claudiu Creanga's user avatar
2 votes
0 answers
166 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 ...
awcot's user avatar
  • 21
1 vote
1 answer
1k 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 ...
M3RS's user avatar
  • 373
3 votes
1 answer
3k 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 ...
Hookoha's user avatar
  • 31
2 votes
1 answer
63 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 ...
KeykoYume's user avatar
  • 203
1 vote
1 answer
903 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 ...
Jonathan Veit's user avatar
3 votes
1 answer
749 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 ...
Essex's user avatar
  • 293
1 vote
2 answers
135 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 ...
Grajdeanu Alex's user avatar
5 votes
1 answer
1k 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 ...
CHBresser's user avatar
3 votes
2 answers
2k 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: ...
Baiello's user avatar
  • 33
1 vote
2 answers
91 views

Click a link to delete targeted content using Ajax

I used a glyphicon as a link to delete a comment: ...
Wizard's user avatar
  • 449
2 votes
1 answer
209 views

Unit tests for os.scandir/scantree a directory

I wrote my first series of test for this simple function: ...
John Doe's user avatar
  • 123
2 votes
0 answers
130 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: ...
Wizard's user avatar
  • 449
8 votes
1 answer
3k 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 ...
Rik Schoonbeek's user avatar
3 votes
1 answer
909 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 ...
maufcost's user avatar
  • 379
2 votes
0 answers
230 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 ...
Arun's user avatar
  • 121
1 vote
1 answer
34k 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: ...
pavlos163's user avatar
  • 265
14 votes
0 answers
826 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 ...
Grajdeanu Alex's user avatar
1 vote
2 answers
174 views

Middleware Django statistics

I have this middleware to log the number of queries, the time spent on each view and some errors and tracebacks. This will be called on each request, so I had to put a 75ms timeout. I don't like it, ...
Marcos Aguayo's user avatar
2 votes
0 answers
40 views

Making zip file with custom content per user

What I tried to do: In my main project folder I have directory downloadable_app with these files/folders inside: index.html js/app.f54b97d7097bcf4226c0.js I need ...
paul's user avatar
  • 121
4 votes
1 answer
537 views

Tournament Management model

I'm creating tournament management web-app using wagtail and after searching for different solutions on the Internet came to the following: ...
khashashin's user avatar
1 vote
1 answer
63 views

Clear data-model layer in Django MVC

I have a Django model User ...
Denny's user avatar
  • 141
5 votes
0 answers
1k views

Django Project for creating events

Before I continue developing this project, I just wanted to make sure I'm going about creating the views and tests in a "proper manner" or if I am completely fudging this up. Also, is it better to use ...
doughboy's user avatar
4 votes
1 answer
67 views

Show furnitures in a different way considering django principle

I want in my homepage to show the furnitures items in a following way: Newly Arrived Furnitures(upto 10) Featured Furnitures Free shipping Furnitures (upto 10) For this I tried to go ...
beginner boy's user avatar
5 votes
1 answer
128 views

Preventing code duplication in Django

I have these 2 functions that are almost the same: ...
kambi's user avatar
  • 153
2 votes
0 answers
768 views

Django Rest Framework ListAPIView - many if-s in get_queryset()

Please review my DRF ListAPIView code. There are a lot of if statements. I wonder if it's a good approach to put these if-s in <...
user3115655's user avatar
1 vote
0 answers
4k views

Django model for an inventory management system

The usecase of my app I am trying to build is about Inventory Management System for a single company. I have attached a layout depicting what table or model should look like. I have designed the model ...
Priyanka's user avatar
  • 219
5 votes
2 answers
185 views

Django model to do accounting for a Litecoin miner pool

I'm coming from Java so I am used to performing calculations I require in separate functions. I would like to know if the below code makes sense in my Django model especially the loop and calling ...
Josh's user avatar
  • 153

1 2
3
4 5
7