Right, I have a module called uniqueid.py
in my media
app.
I also have the standard models
file, in the same media
app file.
# models.py
import....
import...
import uniqueid
class NewsArticle(models.Model):
id = models.CharField(max_length=10, default=uniqueid.media_article_id, editable=False)
In my uniqueid.py
file, I have the following:
# uniqueid.py
import random
import string
def media_article_id():
random_string= ''.join(random.choices(string.digits, k=8)) # Generates a random string
return f"{random_string}"
What is the reason behind the fact that Python is not seeing the uniqueid.py
module? Why am I constantly getting the following, despite correctly importing the module?
File "C:UsersxxxOneDrive - xxxxxxxmediamodels.py", line 3, in <module>
import uniqueid
ModuleNotFoundError: No module named 'uniqueid'