Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Nonetype object is not iterable
Nonetype object is not iterable [message #1779388] Fri, 05 January 2018 21:33 Go to next message
Jack Gonzales is currently offline Jack GonzalesFriend
Messages: 4
Registered: December 2017
Junior Member
Hi, this is my code and i got an error, it's the next:

TypeError at /admin/products/product/3/change/
'NoneType' object is not iterable
name, ext = get_filename_ext(filename)

*I am working with python 3.6 and django 2.0

*i'm trying change the name to a random name for my files that i want uploading.


import random
import os
from django.db import models

# Create your models here.

def get_filename_ext(filepath):
base_name = os.path.basename(filepath)
name, ext = os.path.splitext(base_name)

def upload_image_path(instance, filename):
new_filename = random.randint(1,3910209312)
name, ext = get_filename_ext(filename)
final_filename = '{new_filename}{ext}'.format(new_filename=new_filename, ext=ext)

return "products/{new_filename}/{final_filename}".format(
new_filename = new_filename,
final_filename = final_filename

class Product(models.Model): #Product_Category
title = models.CharField(max_length=120)
description = models.TextField()
price = models.DecimalField(decimal_places=2, max_digits=20, default=39.99)
image = models.FileField(upload_to=upload_image_path, null=True, blank = True)

def __str__(self):
return self.title

def __unicode__(self):
return self.title
Re: Nonetype object is not iterable [message #1779391 is a reply to message #1779388] Fri, 05 January 2018 22:22 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3071
Registered: July 2009
Senior Member
These forums are for questions relating directly to Eclipse IDEs and/or projects hosted at They are not general programming help forums - I suggest you try or Django support channels.
Previous Topic:Eclipse Oxygen - Error Message "The application "Eclipse" cannot be opened
Next Topic:Can I create an Expression object and set it according to my own idea ?
Goto Forum:

Current Time: Wed Jul 15 08:43:04 GMT 2020

Powered by FUDForum. Page generated in 0.02553 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top