Questions tagged [django]

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

Filter by
Sorted by
Tagged with
5 votes
2 answers
3k views

Password generator in Django

I am a system admin, not a developer, so this might be pretty horrible code. This is a password generator. The point of the attempt was to become more familiar with Django at a lower level. I current ...
digitaladdictions's user avatar
4 votes
0 answers
988 views

Working with multiple currencies in Django

I'm working on a project where user adds many products and compare their prices, average price, minimal and many other statistics. There are two currencies for now, EUR and CZK. I'm here to ask ...
Milano's user avatar
  • 191
1 vote
0 answers
2k views

React Redux quiz app

I started learning about React and redux recently and I created a dummy project based on drf-redux project and react-redux-quiz-game This application uses Django rest framework for API and React with ...
fandefee's user avatar
2 votes
1 answer
223 views

Django BaseController

A working example of mine, trying to streamlining my Django views, with absolute inspiration from Laravel: ...
Simon's user avatar
  • 1,012
4 votes
1 answer
8k views

Django query ManyToMany for tagged items

I've got a item inventory that each inventory item is tagged with multiple tags. What I've got is an API that takes a query parameter with multiple comma separated query items and returns a list of ...
koblas's user avatar
  • 193
2 votes
1 answer
307 views

Django Forms and handling

I'm really new with Django and I would like to get your minds, advices, ... in order to improve the first part of my project. For the moment, I created a model form which is named ...
Essex's user avatar
  • 293
5 votes
1 answer
157 views

Civil status database with Django

I'm beginning with Django and I have a Civil Status project. I created my first models.py in order to get a Form, but I had some advices in order to normalize my database. I made this process and I ...
Essex's user avatar
  • 293
1 vote
0 answers
612 views

Django Notification Model with a generic relation

I wanted to implement notifications for my app, so that a user would know if another user, liked, commented on, or followed another user. It works, but I feel like it's very limited which I need to ...
Sebastian Olsen's user avatar
5 votes
2 answers
3k views

Abstracting celery tasks with class based implementations

Background I want to send emails with a rendered template (django template, that is) but I also want to be able to control the QuerySets, and context provided. The goal is to make a task whose ...
theWanderer4865's user avatar
3 votes
1 answer
549 views

Storing database references to files/media

This is an extension of this question due to it not covering an important role of my setup that I think needs more attention. The files are stored on a different server for separation and convenience....
Sebastian Olsen's user avatar
2 votes
0 answers
2k views

Django REST custom methods for generic views

I'm intern and work on a project where I develop DRF API that need to interact with mobile app written by my colleague with Ionic framework. We are creating new user. My view method is following: <...
Ilia_Mochalov's user avatar
3 votes
1 answer
803 views

Backup MySQL database for Django projects

I have a usual Django application with a single MySQL database. The purpose of this shell script is to backup a MySQL database every midnight by crontab and check that everything goes right. The ...
outoftime's user avatar
  • 1,729
9 votes
2 answers
27k views

Generating a unique ID for a filename

This function generates a unique id for my files, which will be stored in the database to reference them. It returns the id if unique, if not, it generates a new one. My separate file server can then ...
Sebastian Olsen's user avatar
3 votes
1 answer
2k 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 ...
Joff's user avatar
  • 263
2 votes
0 answers
69 views

oAuth2 token creation when registering new user

I am working on Django Rest Framework for backend to develop android app. My project is about Food Delivery System. My app has user login and registration feature. I preferred oAuth2 for token based ...
Serenity's user avatar
  • 211
2 votes
2 answers
193 views

Method to return the lowest filename number not being used

I have a Django site where users upload and have the option to delete files. There will be a lot of files that will have the same logical name so I append numbers to them: ...
Joff's user avatar
  • 263
1 vote
1 answer
68 views

Django class based view URL API

I kind of started making an API for my site in a Django class based view because it seemed logical and now it has gotten quite large and unruly and I am starting to wonder if I am doing this correctly....
Joff's user avatar
  • 263
5 votes
2 answers
7k views

Model design for Online Food order app

I have been trying to develop online food order application. I have taken the concept of zomato.com where a user or say owner registers his/her restaurant. After adding the restaurant, an executive ...
pythonBeginner's user avatar
2 votes
1 answer
70 views

Dynamic Official Receipt increment algorithm

I made a function that would automatically generate official receipt for POS. it is able to accept format such as xxx, xxx-xxx, xx-xx. But my code is really messy and horrible and it needs review. I ...
Binsoi's user avatar
  • 123
3 votes
1 answer
61 views

Profile creation

I was creating a view with Django that would create a user profile for a website and this is what I came up with: ...
Woody1193's user avatar
  • 133
3 votes
0 answers
82 views

One user profile for company and person

I'm creating a web page which has two types of users with very similar permissions: Person and Company. The main difference is ...
Milano's user avatar
  • 191
6 votes
2 answers
120 views

Django controller method to list the top characters, guilds, and killers

I've been reading the Chapter 8 of this book. Here's the view I'm currently coding. It list all characters/guilds according to the type of URL. ...
Bruno's user avatar
  • 61
3 votes
1 answer
3k views

simple form validation

i've just started to learn python /django .. im coming from php world ...i mostly struggle with None values which are new to me .. in php i mostly did my boll checking with true/false but in python ...
max's user avatar
  • 133
0 votes
1 answer
2k views

Idiomatic Django conditional filter queryset

I am sharing a viewset between two types of routes in Django: one is a nested route (/users/:id/comments/:id/), and a regular route (...
user1152226's user avatar
1 vote
1 answer
139 views

Validating Email Addresses without DB

I wanted to put this out here and see if there were any security vulnerabilities that I'm not seeing. Also, if I can improve performance without sacrificing security, that's always a plus. Thanks in ...
VertigoRay's user avatar
1 vote
1 answer
14k views

Django query filter on count in one to many relation

I have the following models: ...
nobe4's user avatar
  • 141
1 vote
1 answer
3k views

Get time slots based on multiple workshops

I have a list of Workshops, each having open days (Monday, Tuesday etc.) and open time and close time (which will be same for each day). Now, Based on the current time, I need to find out next 7 days ...
Anuj's user avatar
  • 121
1 vote
1 answer
5k views

Loading data from a text file into the database as fast as possible

I'm building a Django (1.8.12) application that parses a .bc3 file (Standard Interchange Format for Databases of Construction and Real State) and loads all the data into the database (PostgreSQL 9.3.9)...
oubiga's user avatar
  • 13
2 votes
1 answer
2k views

Auto registering class registry

I built this auto registering registry to look into a package and import all modules and register any classes that are a subclass of a base class. I use it as a registry for a model's choices in ...
Jared Mackey's user avatar
2 votes
1 answer
46 views

improvement of a database register function

Here is a function in a django rest api, that takes data in json and registers a category for a given website. I'd like to merge two try...except parts that check <...
PHA's user avatar
  • 175
5 votes
1 answer
1k views

LRU caching decorator that caches in the instance and in a shared cache

I needed a caching decorator, that could be used with methods and functions, that could take typed args and kwargs, and that was Python 2.7 compatible. Therefore I started with a backport of the <...
mjbrams's user avatar
  • 53
4 votes
1 answer
2k views

Selecting all posts created by user that actual user follows

I have a view that displays posts created by users that actual logged in user follows. It works, by I think the way I've done it isn't good. BTW, UserProfile is my default user model. UserFollower ...
Paweł Kosiński's user avatar
2 votes
1 answer
139 views

Registration in Django

Can you say, is this a bad code for registration in Django? Do I need to fix something or use a pip instead? (I am learning) ...
TheDeadMays's user avatar
5 votes
1 answer
2k views

FIFO inventory allocation method

I am an owner of a small industrial business startup and I am learning to write software in order to efficiently keep track of our inventory and finances, as our needs have outgrown the capabilities ...
Adam Starrh's user avatar
6 votes
1 answer
151 views

Handling SMS replies to register/unregister phone numbers

I'm working on a Django Twilio app, and I believe it's coming along well. I just want to improve my code writing skills. How can I improve the below code? ...
joshlsullivan's user avatar
3 votes
2 answers
230 views

Object oriented architecture with an image processing code

This code is python 3X code (in django). It takes an instance of user entry, and process images: it creates a resized version of original image, 2 thumbs, saves all, and update instance fields to ...
Benj's user avatar
  • 63
4 votes
2 answers
2k views

Django views for banking operations

How can I Pythonize/Djangoize/DRY my Django code? views.py ...
Vassily's user avatar
  • 215
7 votes
2 answers
4k views

Bank account model implementation in Django

There is a draft of my models.py. What can I do for code quality and readability increase? ...
Vassily's user avatar
  • 215
7 votes
1 answer
6k views

Model classes for a quiz app in Django

I am creating simple quiz app in Django. It works, but I think that way I've done it is not the best. I have Exam detail view, which display questions related to that exam and answers for these ...
Paweł Kosiński's user avatar
3 votes
1 answer
105 views

Mapping different classes to the same database table

I have several very similar subclasses that I (think I) want to be stored in the same database table. Most of the fields are identical, with each subclass adding 1 or 2 custom fields. My code is using ...
Felipe's user avatar
  • 131
2 votes
1 answer
83 views

Ad filtering in Angular factory

I'm an 'old school' programmer (C, C++), and I have step-by-step, algorithmic thinking. I'm writing some code in Angular + Django and I know that this code is ugly but I don't have any idea how to ...
Hegol99's user avatar
  • 21
4 votes
2 answers
787 views

SOAP request in a while loop

I am developing a service where the user need to sign the seller agreement with Mobile BankID (Swedish e-sign service). To make this work I need to make SOAP request to get the progress status of the ...
Spindel's user avatar
  • 43
1 vote
2 answers
484 views

Django search method

I have done this small piece of code used to search for a given word across several fields of a Django model. Goal was to have first entries equals to the word, then entries starting by the world ...
trnsnt's user avatar
  • 111
3 votes
1 answer
2k views

Serving a growing audio file with Django

I would like to serve a growing audio file (raw PCM audio for now) with the possibility of seeking. I tried to manage it with Apache, but in the end wasn't able to achieve what I wanted. Now I ...
basilikum's user avatar
  • 224
2 votes
0 answers
50 views

Platform to buy services, where you can receive notifications

I am developing a website, where people can buy services, also it has a notification system; I do this in views to show log in and sign up, on index.html. views.py ...
Alfredhb.q's user avatar
2 votes
0 answers
2k views

A web crawler for scraping images from stock photo websites

I created a web crawler that uses beautiful soup to crawl images from a website and scrape them to a database. in order to use it you have to create a class that inherits from Crawler and implements 4 ...
davegri's user avatar
  • 153
-1 votes
2 answers
120 views

How should I arrange my imports? [closed]

I inherited a project that has many imports. Is there any way to refactor it so that we don't have this many imports? ...
Niklas Rosencrantz's user avatar
2 votes
2 answers
174 views

Excluding an element from a dictionary

I was asked to change code that I maintain (but didn't write) for a learning management system that previously listed an examed course both under examed courses and other courses and now my task was ...
Niklas Rosencrantz's user avatar
1 vote
1 answer
495 views

Changing attributes in Django Objects outside of iteration

I'm adding three attributes to a Django QuerySet that represents a hierarchical tree structure: a display_name which is added to all objects the id of the object's ...
BarFooBar's user avatar
  • 251
3 votes
1 answer
41 views

Updating multiple membership plan expiration dates at once

I have model action in RequestAdmin like this: ...
vijay's user avatar
  • 133

1
3 4
5
6 7