Questions tagged [django]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
44 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
30 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
712 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
69 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 ...
2
votes
0answers
106 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
79 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
545 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
54 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
155 views

Database modeling for products and store

I am planning to develop a virtual shopping mall where stores of any kind can be registered, such as in a physical shopping mall. First I want to develop an efficient and effective database modeling ...
2
votes
1answer
65 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
204 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 ...
1
vote
1answer
72 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") ...
0
votes
1answer
2k 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
242 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
115 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
62 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 <...
5
votes
0answers
506 views

Django blog application - views, urls, models, forms

I want to learn how to create websites and I have started learning Django web framework. I think Django is very good alternative for PHP and it isn't too complex as JEE. I'm very satisfied learning ...
2
votes
0answers
80 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....
4
votes
2answers
83 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
1answer
76 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 ...
4
votes
1answer
53 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 ...
1
vote
0answers
86 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
872 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
24 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? ...
5
votes
1answer
98 views

Preventing code duplication in Django

I have these 2 functions that are almost the same: ...
8
votes
1answer
4k views

CreateView set foreign key from URL parameter

I want to be able to create a lorum, using a ipsum_id (ForeignKey) that has been supplied in the URL. Using Django's class based views. Given the following URL: ...
15
votes
0answers
7k views

Django Rest Framework - add/remove to a list

I have a model Collection which has a many to many relation to a model Item. I want to be able to add or remove items to this collection using Django Rest Framework. Option1 - make an action: ...
2
votes
1answer
55 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 ...
3
votes
3answers
4k views

Storing values from checkboxes in database

I'm getting values from 2 checkboxes and save those values to a database. I don't like these if statements. How is it possible to simplify the code? ...
1
vote
1answer
530 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
340 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
121 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 ...
3
votes
2answers
1k 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: ...
4
votes
0answers
345 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 ...
0
votes
1answer
23 views
1
vote
0answers
114 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 ...
2
votes
1answer
129 views

Unit tests for os.scandir/scantree a directory

I wrote my first series of test for this simple function: ...
2
votes
0answers
114 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
1k 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
413 views

Authenticate users in Django

I'm writing a social networking site in Django. I created an account application which is part of site project. I implemented an authentication mechanism in the project. Every user has different ...
0
votes
1answer
15k 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: ...
2
votes
0answers
163 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 ...
7
votes
0answers
587 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 ...
1
vote
2answers
66 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, ...
2
votes
0answers
37 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 ...
3
votes
1answer
933 views

Using mocking to test that a Django view renders as expected

I have a Django view that ends with this... return render(request, 'define/see_all.html', context) I have mocked the render function and ...
6
votes
1answer
33k views

Django query_set filtering in the template

Can I make my template syntax simpler? I'm hoping to eliminate the if and maybe also the for block. This worked in the shell ...
5
votes
3answers
406 views

Todo app for displaying a list of tasks

The main view in my (toy!) Todo app is, of course, to display the list of tasks. These are grouped by some criterion, and the tasks structure below is actually a ...
1
vote
1answer
58 views
16
votes
1answer
10k views

Django Rest Framework - ManyToMany relationship through intermediate model

I'm new to Django and have just started to learn the basics. I have some questions about how to structure the code, how relationships should be written, and where the business logic should live. I ...