Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Use production media files in development - Django
I have a blog made with Django (and Django-CMS). Some times, when working in development, I make some changes and it would be nice to see how those changes that I'm doing look like with the actual media files that I have in production. So today I tried to set the MEDIA_URL and the MEDIA_ROOT settings to be the actual media URL of my production site. i.e: MEDIA_URL = 'https://example.com/media/' MEDIA_ROOT = 'https://example.com/media/' I was naively hoping to see the media files of production in development after doing this, but nope, it didn't work. Aditional info: My site is hosted by PythonAnywhere, and they (pythonanywhere) serve the media files as well. The files are all public. I use django-filer as my file manager. One sample of my media files: media file Anyway, is this possible to achieve? If so, what am I missing? -
build a function helper for dynamically upload file
before all , I hope you guys are in the very good and healthy conditions ! hi, I want to make all the uploaded files will be uploaded to the dynamically named file that's related to the name of it's model name this is the functions I've created to be put on the upload_to= arguments in imageField def get_random_alphanumeric_string(length): letters_and_digits = string.ascii_letters + string.digits result_str = ''.join((random.choice(letters_and_digits) for i in range(length))) return result_str def namefile_profile_picture(instance, filename): ext = filename.split('.')[-1] get_random_1 = get_random_alphanumeric_string(10) get_random_2 = get_random_alphanumeric_string(10) name_of_file = "{}{}{}".format(get_random_1,str(instance.id),get_random_2) filename = "%s.%s" % (name_of_file, ext) return 'user_{}/{}/{}'.format(instance.user.username,'profile_picture',filename) def namefile_poster_picture(instance, filename): ext = filename.split('.')[-1] get_random_1 = get_random_alphanumeric_string(10) get_random_2 = get_random_alphanumeric_string(10) name_of_file = "{}{}{}".format(get_random_1,str(instance.id),get_random_2) filename = "%s.%s" % (name_of_file, ext) return 'user_{}/{}/{}'.format(instance.user.username,'poster_picture',filename) def namefile_photo(instance, filename): ext = filename.split('.')[-1] get_random_1 = get_random_alphanumeric_string(10) get_random_2 = get_random_alphanumeric_string(10) name_of_file = "{}{}{}".format(get_random_1,str(instance.id),get_random_2) filename = "%s.%s" % (name_of_file, ext) return 'user_{}/{}/{}'.format(instance.user.username,'photo',filename) so instead of manually using these functions for every different imageField such as class Photo(models.Model)`: ... image = models.ImageField(upload_to=namefile_photo) ... class Profile(models.Model): ... image = models.ImageField(upload_to=namefile_profile_picture) ... I wish there is a way to create such a one function or class that can perform such example above the way which I can just easily pass some name file … -
Django RuntimeError when using models for unittests
I'm using multiple models for running tests like this one on a django-2.2 project: class Person(models.Model): name = models.CharField(max_length=200) Running a simple test: class TestRegistration(SimpleTestCase): def setUp(self): self.site = admin.AdminSite() def test_bare_registration(self): self.site.register(Person) self.assertIsInstance(self.site._registry[Person], admin.ModelAdmin) But always getting the same kind of RuntimeError, with this one as with other models (the model raised changes but the RuntimeError persists): "INSTALLED_APPS." % (module, name) RuntimeError: Model class tests.models.Person doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. I've already tried: Deleting the init.py Deleting the content of the init.py Explicit import the model from the init.py importing the model from inside the function as this article suggessts ( https://medium.com/@michal.bock/fix-weird-exceptions-when-running-django-tests-f58def71b59a ) Running the tests with django-nose Declaring the model from the same test Setting a test-env with the same settings but adding the models Running the tests not only with -c"python manage.py test", also with a "python runtest.py" as suggessts in ( https://docs.djangoproject.com/en/3.1/topics/testing/advanced/ ) Here is the complete message error: Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/home/codea/Workspace/venv3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/home/codea/Workspace/venv3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/codea/Workspace/venv3.6/lib/python3.6/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv super().run_from_argv(argv) File "/home/codea/Workspace/venv3.6/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, … -
How to send error messages from Django ModelForm clean_<name> method to view?
I have the following ModelForm: class AddObjForm(forms.ModelForm): # stuff ... def clean_performed_by(self): # validation for performed_by if not valid: e = "Error message I want to send back to view" raise forms.ValidationError(e) return performed_by I have the following view: class AddObject(LoginRequiredMixin, CreateView): # stuff ... def post(self, request, *args, **kwargs): form = AddObjForm(request.POST) if form.is_valid(): messages.success(request, f"New obj created: {new_obj}") return HttpResponseREdirect("whatever") else: messages.error("?") # How do I get my error message from my form into my view? return(request, template, context) My question is how do I get the error message I raised in my ModelForm into my view so that I can put it into the messages.error() method? I found code resembling this, but I can't find how to access/update form.error_messages in the documentation: for msg in form.error_messages: messages.error(request, f"{msg}: {form.error_messages[msg]}") -
Beginner Django / Python / Postgres dev struggling with no model data output to html file
I have been working through some basic online Youtube tutorials for Django, which have been great, but I've been struggling the last few days with my Test-table app, being unable to display table data on my example Postgresql table placed on my index.html file. When I created the Postgres model (local hosted), it appears correctly with data in the admin page, and my index page loads successfully from my url and view file configurations, but is missing the table data specifically and I'm hoping for some guidance on what I am doing incorrectly. I understand there are more dynamic configurations for the URL and views, but I was attempting to get a basic one working first... models.py file: from django.db import models class products(models.Model): Phone = models.TextField(primary_key=True) Version = models.TextField(max_length=100) Price = models.FloatField() Sales = models.IntegerField() class Meta: db_table = "productlist" Url file: from django.contrib import admin from django.urls import path from . import views app_name = 'Test_table' urlpatterns = [ path('admin/', admin.site.urls), path('', views.sales), ] views.py from django.shortcuts import render from Test_table.models import products # from django.http import HttpResponse def sales(request): ph_data = products.objects.all(), return render(request, 'Test_table/index.html', {'ph_data': ph_data}) html file: <table border='3'> <tr> <th>Phone</th> <th>Version</th> <th>Price</th> <th>Sales</th> </tr> … -
Proper way to insert DJANGO tag into tag?
I want to write an href call passing the parameters through a DJANGO tag, something like : <a href="{% url 'incid:vercosas' filtro='cerradas' vista={{ vista }} %}" to replace this: <a href="{% url 'incid:vercosas' filtro='activas' vista='tabla' %}" when {{vista}} holds the value 'tabla, but I only get this message: Reverse for 'vercosas' with keyword arguments '{'filtro': 'cerradas', 'vista': '{{ vista }}'}' not found. 1 pattern(s) tried: ['incid/vercosas/(?P\w+)/(?P\w+)/$'] from PyCharm. What would be the proper way to do this? -
Django: Is there a way to use admin to add image files to an app's static DIR?
So I'm not sure if this is a terrible setup, but here it is. I created a basic portfolio app in Django with the help of a tutorial. However I wanted to be able to add the portfolio entries in admin. I use the following function in "projects/models.py" class Project(models.Model): title = models.CharField(max_length=100) description = models.TextField() technology = models.CharField(max_length=100) image = models.ImageField(upload_to='**PATH**') If I use the string projects/static/img/ as the PATH, the files go where I want. However, then I cannot access them in the template with either "{{project.image.url}}" or "{% static project.image.url%}" If I use MEDIA_ROOT and then img/ as the PATH, the files (obviously) go to media/img/, then I can access them with "{{project.image.url}}". However, then this does not collect in staticfiles using collectstatic and thus is unsuitable for production. Is there a way to add my files directly to projects/static/img/ in admin while still allowing me to access them in the html template? -
How to recover from Django Channels connection limit?
I'm running a server on heroku where I have intermittent channel layer communications between instances of asyncConsumers. Running heroku locally, I have no problem with redis channel connection since I can have as many of them as I want, but once I upload my server to heroku, it gives me a 20 redis connection limit. If I use more than that my server errors out, so I try to lower the expiry time so inactive redis connections would close. BUT, if a redis connection expires and I try to use the channel name with self.channel_layer.send(), I'll get the error below, how do I recover from this error without having to have external calls to create another asyncConsumer instance? ERROR Exception inside application: Reader at end of file File "/app/.heroku/python/lib/python3.6/site-packages/channels/consumer.py", line 59, in __call__ [receive, self.channel_receive], self.dispatch File "/app/.heroku/python/lib/python3.6/site-packages/channels/utils.py", line 51, in await_many_dispatch await dispatch(result) File "/app/.heroku/python/lib/python3.6/site-packages/channels/consumer.py", line 73, in dispatch await handler(message) File "./myapp/webhook.py", line 133, in http_request await self.channel_layer.send(userDB.backEndChannelName,{"type": "device.query"}) File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 296, in send if await connection.llen(channel_key) >= self.get_capacity(channel): File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/commands/list.py", line 70, in llen return self.execute(b'LLEN', key) File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/commands/__init__.py", line 51, in execute return self._pool_or_conn.execute(command, *args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/connection.py", line 322, in execute raise ConnectionClosedError(msg) Reader … -
Override Field Option on Inherited Modl in Django
I've found similar questions and answers, but none seems exactly right. I've got an abstract base model like so: class BaseModel(models.Model): timestamp = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) description = models.CharField(max_length=512, blank=True, null=True, help_text='Help') class Meta: abstract = True And then I'm inheriting from it: class AnotherModel(BaseModel): field1 = models.CharField(max_length=512) But I want this model's help_text on the description field to be something else, like help_text='Some other help text' What's the best way to do this? Can I override options on fields from inherited models? -
Why am I losing access to context after invalid form submission?
So, I have a URL pattern: path('<int:pk>/<slug:slug>/', PostDetailView.as_view(), name='detail') I have a view: class PostCommentView(CustomLoginRequiredMixin,CreateView): template_name = 'blog/comment.html' model = Comment form_class = CommentForm def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['page'] = get_object_or_404(Post, pk = self.kwargs.get('pk')) return context def post(self, request,pk,slug): if request.method == "POST": form = self.form_class(request.POST) post = get_object_or_404(Post, pk=pk) if form.is_valid(): comment = form.save(commit=False) comment.post = post comment.author = request.user comment.save() messages.success(request, (request, 'blog/post_detail.html', {'form': form, 'slug': post.slug, 'pk': post.id, 'username': post.author})) return redirect('/' + str(post.id) +'/' + str(post.slug) + '/' +'#comment') return render(request, 'blog/comment.html', {'form': form}) I have a comment model: class Comment(models.Model): title = models.CharField(max_length = 49,) body = models.CharField(max_length = 250) post = models.ForeignKey(Post,on_delete=models.CASCADE) comment_date = models.DateTimeField(default = timezone.now) author = models.ForeignKey(User, on_delete= models.CASCADE) class Meta: ordering = ["comment_date"] def __str__(self): return self.title The default User model and the Post model: class Post(models.Model): title = models.CharField(max_length = 49) content = models.TextField() date_posted = models.DateTimeField(default = timezone.now) author = models.ForeignKey(User, on_delete= models.CASCADE, default = 'NicholasPolino') slug = models.SlugField(max_length = 250, null = True, blank = False) category = models.ForeignKey(Category, default= 'programming', on_delete=models.PROTECT) def __str__(self): return self.title def get_absolute_url(self): return reverse('detail', kwargs ={ 'slug': self.slug, 'pk':self.pk}) I have a comment form: class CommentForm(forms.ModelForm): body = forms.CharField() … -
Hiding Postgresql credentials in django
I'm new to programming and I'm having a hard time with something. I've been able to be somewhat make this work. I've created an .env file with this info DATABASE_NAME=db_name DATABASE_USER=db_user DATABASE_PASSWORD=password DATABASE_HOST=localhost DATABASE_PORT=5432 and added this to my settings.py import environ env = environ.Env() environ.Env.read_env() DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': env("DATABASE_NAME"), 'USER': env("DATABASE_USER"), 'PASSWORD': env("DATABASE_PASSWORD"), 'HOST': env("DATABASE_HOST"), 'PORT': env("DATABASE_PORT"), } } and it works finest first, I can start the server and migrate files however after I git init and add my .env file to my .gitignore file, Django isn't able to read the file or something and I'm no longer able to start the server.... Also i've tried every other thing you could think of. I've tried decouple i've tried importing from os with credentials put in a .bash_profile file. I've tried literally everything you can find when you google how to hide database credentials using environmental variables. Does anyone know what else could be happening that I am unaware of? -
Is there a way to delete the File from FileField without removing it from S3 with Django Storages?
I have a Django application that is strictly the backend to my frontend application. I use a FileField to upload files that can be downloaded later. I use django-storages to upload to AWS S3. Currently, it saves to the media/ folder while also uploading to S3. To save on disk space, I would like to just have the S3 link. Is there a way to remove just the file from the local hard disk and just have the S3 link? -
Frontend vs Backend as a NOOB Django aspiring Developer
I'm learning Django and aspire to work as a web developer someday, started out 7 months ago. I also like frontend designing but I start to realize its taking a lot of my time that could be put into learning Django. I know intermediate HTML and CSS only. No Javascript or SQL. Is it ok to use "free templates" for the frontend from a site called "Colorlib"? I want to sharpen my Django backend skills but don't want to spend time making a full frontend from scratch in the future when I get my first jobs or even right now that I want to master Django the most I can. I'm a total noob in web development. Is it ok to use "free templates"? I know how to make a navigation bar, animation using CSS, but I peak at some level and the site is not as "cool" as these "already made" templates. One day I will want to be able to make a full awesome frontend and backend all by myself. If this question is not written ok, I apologize, just searching for a pro opinion that can guide me. thanks. -
How to pass a url parameter to the url tag in a template
I am using Django 3.1 I have URLs configured so that I can corretly use the following in my template: <li><a href="{% url 'sitemember:profile' 'bobby' %}">{{ user.username }}&nbsp;&nbsp;</a></li> Where user.username resolves to 'bobby' How do I pass the variable user.username to the url() tag, so that the URL resolves correctly as: https://localhost:/user/bobby (as an example) -
NoReverseMatch Error, even though everything should be set
https://pastebin.com/EBfq1SRL Getting this error, Even though this is how my views and URL's are setup: class MyProfile(generic.TemplateView): template_name = 'profiletabs/user-profile.html' extra_context = {'profile': 'active-page'} from django.urls import path, include from . import views from rest_framework.routers import DefaultRouter router = DefaultRouter() router.register('tags', views.TagViewSet) router.register('bots', views.BotViewSet) app_name = 'profile' urlpatterns = [ path('', views.MyProfile.as_view(), name='my_profile'), path('settings/', include(router.urls)), ] -
Django two models on one form
Thanks in advance. This is my first question on StackOverflow. I am a newbie to Django and I'm trying to create an inventory checklist for someone to quickly look at the inventory and place a number in the count column. What I am missing is how to link the count field to the item_name (iterate the count field with the item_name. When I type in values and submit it makes each count field equal to the first count field. Here is my models.py class InventoryItem(models.Model): item_name = models.CharField(max_length=200, null=True) class InventoryChecklist(models.Model): count = models.CharField(max_length=10, null=True) date_posted = models.DateTimeField(default=timezone.now) item = models.ForeignKey(InventoryItem, on_delete=models.CASCADE) forms.py class InventoryCheck(ModelForm): class Meta: model = InventoryChecklist fields = '__all__' views.py def DailyCount(request): items = InventoryItem.objects.all() form = InventoryCheck if request.method == 'POST': form = InventoryCheck(request.POST) if form.is_valid(): form.save() return redirect('/') context = {'items':items, 'form':form} return render(request, 'checklist/dailycount.html', context) template <table class="table table-sm"> <tr> <th>Item Name</th> <th>Count</th> <th>Date</th> </tr> <form action="" method='POST'> {% csrf_token %} {% for item in items %} <tr> <td>{{ item.item_name }}</td> <td>{{ form.count }}</td> </tr> {% endfor %} <input type="submit" name="Save" /> </form> </table> -
Django: Pass a list of dates to JavaScript in template for Chart.js
I'm using Django as backend and want to draw a line plot using Chart.js with dates on the x-axis. I'm trying to pass the dates as datetime.dates from my view: def eval_time_series(request): context = { 'dates': [datetime.date.today() + datetime.timedelta(days=i) for i in range(1, 8)] } return render(request, 'app/eval_time_series.html', context) Now the question is how to process and use these dates in the JavaScript code generating the line plot. This is what I currently have: div id="container"> <canvas id="myChart"></canvas> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js"></script> <script> // trying to convert to JS dates here var labels = []; {% for d in dates %} labels.push(new Date("{{ d.isoformat }}")); {% endfor %} var config = { type: 'line', data: { labels: labels, datasets: [{ label: "Car Speed", data: [0, 59, 75, 20, 20, 55, 40], }] }, options: { scales: { xAxes: [{ type: 'time' }] } } }; window.onload = function () { var ctx = document.getElementById('myChart').getContext('2d'); window.myChart = new Chart(ctx, config); } </script> So basically, I am trying to apply the suggestion here to an array of dates by iterating over all dates, converting them, and adding them to the JS array. Unfortunately, it doesn't work: No chart is displayed and the console … -
Ajax post request is not working with django view
I am trying to do an add to cart anchor tag and when the user presses the anchor tag the product id is sent to a view where I can create and instance of a new product object inside my cart model but it doesn't seem to work. here is my code : Models.py : class CartModel(models.Model): customer = models.ForeignKey(User, on_delete= models.CASCADE) products = models.ManyToManyField(ProductModel) anchor tag: <a class="aa-add-card-btn" data-href="{% url 'home:cart_add' product.id %}" href="#" id="sendproduct"><span class="fa fa-shopping-cart"></span>Add To Cart</a> ajax : $(document).ready(function(){ $("#sendproduct").click(function(){ var postData = {csrfmiddlewaretoken: '{{ csrf_token }}'} $.ajax({ type: "POST", url: $(this).attr("data-href"), data: postData, success: function(data) }) }) }) urls.py: app_name="home" urlpatterns = [ path('cart/add/<int:id>/', cart_add, name='cart_add'), ] views.py: def cart_add(request, id): if request.is_ajax() and request.method == 'POST': product = get_object_or_404(ProductModel, pk=id) current_user = request.user cart_product = CartModel(customer=current_user, products=product) cart_product.save() return JsonResponse({}) -
How can I use a customizable queryset as dropdown choices in a form?
Something like this ideally: forms.py class SelectCar(Form): def __init__(self, custom_queryset): choices = custom_queryset self.fields['choices'] = forms.ModelMultipleChoiceField(choices=choices) views.py def index(request): queryset = Car.objects.filter(brand=brand).all() form = SelectCar(queryset) context['form'] = form return render(request, 'form.html', context) The queryset here depends on some other object as filter to what should be shown in the dropdown list. Is there a way to do this neatly? -
Select first item of an ID
I have a table which consists of multiple items which shares the same stuff_id and I am trying to get the price of the FIRST item per each stuff_id. From the table below, I would want to print: 55 and 85 for example. My table id price stuff_id 1 55 505 2 85 402 3 84 402 4 56 505 5 56.4 505 My views.py for id in MyTable.objects.values_list('stuff_id'): first = MyTable.objects.values('price').filter(stuff_id=id).first() This code sort of works, but it prints for example 55 three times since there are three stuff_id=505. Any suggestions how I could just get the first value per stuff_id? Feels like I have the wrong approach. -
Django: Crispy Forms Validation Error in Template
I'm using django-crispy-forms for nicely rendered forms. For one of my forms, I had to make some custom adjustments and am now wondering how to properly validation errors that don't belong to a specific field but to the whole form. Specifically, my form contains a start and end date: # forms.py class PlotForm(forms.Form): start_date = forms.DateField(initial=last_month, widget=forms.widgets.DateInput(attrs={'type': 'date'})) end_date = forms.DateField(initial=datetime.date.today, widget=forms.widgets.DateInput(attrs={'type': 'date'})) def clean(self): cleaned_data = super().clean() start_date = cleaned_data.get('start_date') end_date = cleaned_data.get('end_date') if start_date > end_date: raise forms.ValidationError("Start date must not be before end date.") return start_date To check that the end date is not before the start date, I use clean(self). However, the error is never displayed. <form method="post"> {% csrf_token %} <div class="row"> <div class="col-6"> {{ form.start_date|as_crispy_field }} </div> <div class="col-6"> {{ form.end_date|as_crispy_field }} </div> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> I can fix this by adding {{ form.errors }} but that looks really ugly. Is there any simple way to nicely render form-related validation errors with crispy? The field-related errors are shown nicely. -
Using AJAX to pull data and render updated contents in select2 drop-down using Django
I have two forms (one text and select2 dropdown). My text form will read in an ID and pull data from a website using an API. Each ID contains different data so my select2 drop-down form will need to render the updated contents to match that ID. As of now my forms need to be submitted and refreshed for the contents in my select2 to be updated/changed. I wanted to use AJAX to create a faster more dynamic web page. As of now I am using AJAX to pull in data and check if the ID is valid or not. I am stuck on how to make the two forms dependent of one another. So when I input an ID it should pull the data in the background while updating the select2 contents. I am working with JSON data. I am doing this with django so what is the best way to accomplish this? I don't know what to search for and looking for guidance because whatever resources I find either don't make sense or are unrelated to what I am looking for. -
Django Rest Framework - Unique field, but still allows multiple objects with the same value
I'm trying to make the field "mollie_cid" unique, such that when there exists an account with a certain mollie_cid, another account can not sign up with the same mollie_cid. This is not the case currently, I can make multiple accounts with the same mollie_cid currently. I added "unique=True", but I can still register multiple accounts with the same mollie_cid Does anyone know how to make it truly unique? Model class CustomUser(AbstractBaseUser): ... email = models.EmailField(verbose_name='email address', max_length=255, unique=True) mollie_cid = models.CharField(max_length=255, blank=False, null=False, unique=True) ... Serializer class CustomRegisterSerializer(RegisterSerializer): ... is_admin = serializers.BooleanField(default=True) mollie_cid = serializers.CharField(max_length=255, default=None) # Set default when its not required on signup def get_cleaned_data(self): data_dict = super().get_cleaned_data() ... data_dict['is_admin'] = self.validated_data.get('is_admin', False) data_dict['mollie_cid'] = self.validated_data.get('mollie_cid', None) return data_dict -
Django models column behaviour
I added a column to a model. Then I accidentally deleted some migrations and did some random stuff. I got make migrations to work again but a column which I had deleted the migration file for is still in my database. I can't get rid of it. My model: class Campaign(models.Model): title = models.CharField(max_length=1000) campaignType = models.CharField(max_length=50, default="FC") slug = models.SlugField() url = models.TextField() The database still has a column called imageUrl which I don't have in the model anymore. If I try adding imageUrl again it says duplicate column. -
TypeError: float() argument must be a string or a number, not 'Profile'
Problem: I'm trying to get the latest value from my model called Profile. But I've encountered a problem, when I try to save it to a variable as a float value I get this error TypeError: float() argument must be a string or a number, not 'Profile'. I need this so, I can make calculations with the datas. Models.py file: class Profile(models.Model): weight = models.FloatField() height = models.FloatField() bmi = models.FloatField(null=True) date = models.DateField(auto_now_add=True) user = models.ForeignKey(User, default=None, on_delete=models.CASCADE) def __str__(self): return self.user.username Views.py file (relevant parts): weight = float(Profile.objects.latest('weight')) height = float(Profile.objects.latest('height')) bmi = (weight/(height**2)) I searched up this error code here, but I didn't find any, where ppl wanted to convert from obj to float