Questions tagged [django-custom-field]

django-custom-field refers to an ability to create custom model fields in Django

refers to an ability to create custom model fields in Django.

See documentation.

31 questions
7
votes
4 answers

Adding Javascript to Custom widgets

This question is related to Django: Best Way to Add Javascript to Custom Widgets But is not the same. The original question asks how to add supporting javascript to a custom django widget, and the answer is to use forms.Media, but that solution does…
5xum
  • 5,250
  • 8
  • 36
  • 56
4
votes
1 answer

Django model with a custom field that uses a database default

I am trying to implement a subclass of IntegerField to use a default method on my Postgres database, rather than a django default method (I know this is a hot topic). In order to do so I've modified the following method on my custom field def…
elynch
  • 2,150
  • 1
  • 18
  • 20
4
votes
2 answers

How to store HDF5 (HDF Store) in a Django model field

I am currently working on a project where I generate pandas DataFrames as results of analysis. I am developing in Django and would like to use a "data" field in a "Results" model to store the pandas DataFrame. It appears that HDF5(HDF Store) is the…
Ben Mukasa
  • 63
  • 10
3
votes
1 answer

handling unique constraint for custom field in django admin

Hi I'm new to django and just took my first foray into using a custom field for my model. I have a Char field that I want to always be saved as lower case so I implemented it as a custom field as follows (learned from another Stack Overflow…
3
votes
0 answers

Custom Page fields in Mezzanine not displaying in template

I am building a CMS in Mezzanine, and all in all I am extremely impressed with the system. I can't tell you how many CMS systems I have attempted to customize in the past and given up in total frustration. All in all this has been smooth as silk.…
2
votes
0 answers

How to create a magnifying glass beside a form field in admin change form to run a script

I'd like to put a search icon (like magnifiying glass) beside a field in the admin change form to let the users to trigger a script to fill other fields on demand only. I have to avoid triggering any field event (blur, click, change etc) on this…
Guaracy Lima
  • 91
  • 1
  • 4
2
votes
3 answers

How to store a complex number in Django model

I need to store a complex number in a Django model. For those who forget, that simply means Z=R+jX where R and X are real numbers representing the real and imaginary components of the complex. There will be individual numbers, as well as lists that…
Brian
  • 642
  • 7
  • 18
2
votes
0 answers

django custom field accept and store decimal but return ouput as integer

I have problem statement where I need that my field should store the value as decimal, but while calling it the field should return a rounded Integer value Example mymodel.myfield = 12.61 mymodel.save() Input mymodel.myfield Output 13 and if…
2
votes
0 answers

Changing lookup_type in Django 1.10+

In older versions of Django, you could change the lookup on the fly and have access to the value being looked up. For example, let's assume we're storing country by its ISO 2-letter abbreviation, but we want to allow searching by the name of a…
Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161
1
vote
1 answer

Custom form field class with dynamic widget attributes

I often use Django form fields with various lengths. I would like to create a custom form field class MyFloatField with a dynamic widget attribute so I could set the max_width when defining each form field such as: quantity =…
JamesBear
  • 25
  • 4
1
vote
1 answer

Django: how to filter form field based off foreignkey AND many to many relationship?

Currently, when a user creates a task, they can assign it to all users. I only want them to be able to assign a task based on the members of the project. I feel like the concept I have right now works but I need to replace the ????. Task's assignee…
Bryant Irawan
  • 79
  • 1
  • 6
1
vote
1 answer

Retrieve data from external api and show in django admin panel

How to display data from external service in Django admin?Rather than querying a local database I would like to use an external API to retrieve the data to display in the django admin class Order(models.Model): service = models.ForeignKey('Service',…
1
vote
3 answers

Cannot login a normal user in a django website having a custom user model

I have made a Custom user model for my website. I have used AbstractBaseUser to make the model and also set it up at the settings. The creation of user and superuser is working fine without any problems and also a super user can login from the admin…
1
vote
1 answer

How to get a django field value throw a custom models.Field?

I have a custom field: class MyCustomTextField(models.Field): (...) and use that on my model: class MyModel(): encrypted_password = MyCustomTextField(null=True) password_seed = models.TextField(null=True) I need when I use MyModel to grab …
fh_bash
  • 1,725
  • 4
  • 16
  • 23
1
vote
2 answers

Write not fully displayed Django field

I need to write a Django custom field where the stored value is not fully displayed. For example if the stored value is "079684" I need it to be displayed as "---84". Is it possible to do so ? If yes how should I implement my custom field ?
Akamee
  • 593
  • 1
  • 6
  • 21
1
2 3