Bohdan
Hello, whenever I put installed module to INSTALLED_APPS and runserver I got "ModuleNotFoundError: No module named". I installed by pip, pip3, python -m pip install but it's not work
Bohdan
I installed only "rest_framework" but used a lot of ways and they don't work already
Bohdan
missing ','?
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # Added 'social_login', 'rest_framework', "rest_framework.authtoken", "django.contrib.sites", "corsheaders", # 'allauth', # "dj_rest_auth", # "dj_rest_auth.registration", # "allauth", # "allauth.account", # "allauth.socialaccount", # "allauth.socialaccount.providers.google", ]
Bohdan
Error with corsheaders
Bohdan
does pip freeze shows this module?
django-cors-headers==3.13.0
Alex
django-cors-headers==3.13.0
have you added Middleware?
Bohdan
have you added Middleware?
MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', # Added 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', ]
Alex
share entire error message, use pastebin.com or something.
Alex
Error with corsheaders
but nowhere in error is mentioned?
Bohdan
but nowhere in error is mentioned?
Oh, I forgot last string ModuleNotFoundError: No module named 'corsheaders'
Bohdan
And this error is the same for allauth and dj_rest_auth too. So I thought that it is strange
Bohdan
I can even share github
Bohdan
Link?
On repository, 2 minutes please
Bohdan
Link?
https://github.com/websorokinweb/auth-nuxtjs-django
Bohdan
But how?
Bohdan
Could it be problem that I have virtualenv in parent folder but start server in api?
Bohdan
I just start virtualenv and then use "cd api"
Alex
create new virtual env
AmirHossein
how to read a total number of N records from multiple tables? can anyone give me a keyword pls?
AmirHossein
imagine we have three tables: A, B, C now the question is, how do I query these three tables, so at the end, I have a total number of N (for example, 10) records together (each of these records could be from table A, B or C)
AmirHossein
imagine we have three tables: A, B, C now the question is, how do I query these three tables, so at the end, I have a total number of N (for example, 10) records together (each of these records could be from table A, B or C)
basically, it's for feed generation for a home page api, with three types of posts and also, I'm not allowed to use inheritance here. (read about paradigm mismatch, if you wanna ask why)
Bohdan
create new virtual env
I tried, only one module installed and then the same errors
Alex
I tried, only one module installed and then the same errors
did you install all the required packages after activating the new virtual env?
Bohdan
did you install all the required packages after activating the new virtual env?
What do you mean? I installed Django and only restframework and each of this packages INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # Added 'social_login', 'rest_framework', "rest_framework.authtoken", "django.contrib.sites", "corsheaders", # 'allauth', # "dj_rest_auth", # "dj_rest_auth.registration", # "allauth", # "allauth.account", # "allauth.socialaccount", # "allauth.socialaccount.providers.google", ]
Bohdan
I mean pip install one
Yes, by pip, pip3 but every time "no modules" error, but i see this modules in venv/Library and in pip freeze
Bohdan
pastebin.com/Cc7YqvuF this is my pip freeze
I installed backports.zoneinfo but nothing has changed(
Bohdan
Maybe I should reinstall python
D
Please tell me how to process the payment correctly so that after payment I get is_paid = True in the database. I don't understand what needs to be fixed in views.py http://linkode.org/#oupH03AytXjDL36JRVzw94
karakurt
I've built category tree with django-mptt. What is the best way to get url for a specific product in a category like cat/subcat/subsubcat/product-name? And how to register that pattern in urls.py?
karakurt
Why you want to do that?
It's my goal. I need it on my site
karakurt
I've found different solutions, but I want to come to a common and best way of doing it
Morteza
Actually you could get the product directly and get the products that are related to the specefic category hierarchies
karakurt
Actually you could get the product directly and get the products that are related to the specefic category hierarchies
I think you misunderstood me. I need to be able to go to links like /cat/subcat/ and view products of "subcat" category OR to go to link like /cat/subcat/product-name and view product with slug "product-name" that is in "subcat" category
karakurt
for getting this to work you should use re_path in urls.py
But I saw solutions with regex in "path" function. Why do I need "re_path"?
karakurt
for getting this to work you should use re_path in urls.py
path(r"^catalog/(?P<hierarchy>.+)/", views.catalog, name="catalog") And then in my view I need to split hierarchy by slash?
karakurt
yes
Ok, bro. I'll try. Thank you
karakurt
for getting this to work you should use re_path in urls.py
I found another path converter in the docs - path. We can write this: path("catalog/<path:categories>/", ...)
Faraaz
can anyone sort out the problem why my submit button isnt working in django forms
Faraaz
these are the files views.py https://linkode.org/#kUXtZ501e2etU5FYQbraC4
Faraaz
html https://linkode.org/#F4c1wG5oecOoaGxVmHawm2
Faraaz
forms.py https://linkode.org/#ObwNRVbkOdRzXzOFELhGH
Faraaz
models.py https://linkode.org/#QPcYXFWqJvZxNhhNAAz9O2
Umar
Change button type to submit
button type="submit"
Faraaz
Change button type to submit
now i changed it to submit , now when i submit this error comes up "UnboundLocalError at / local variable 'instance' referenced before assignment"
Faraaz
please go through the code and help me out
Umar
instance
https://www.pythonpool.com/local-variable-referenced-before-assignment/
Umar
Instance= form.save(commit.......)
Umar
instance
Try this
Faraaz
Try this
It worked thanks.... and one more thing when i submit my form and again refresh it i get the same details i filled earlier why
Lone wolf
I'm not being able to host my django website at heroku tried many time, tried to resolve through google but getting error Failed to push some refs
Lone wolf
Can anyone please help
Vikas
How i learn rest api in django interview purpose please guide me any resources or YouTube or pdf please available me
Vikas
Thanks
Aditya
Excuse me, how to create/insert db when the condition is running ? if period == 'daily': if status == True: if times == currentTimes: send_email_func(id_job) Shcedule.objects.filter(pk = id_job).update(terakhir_eksekusi = today) job = Shcedule.objects.last() log = Log.objects.create(id_job = job, status = True) log.save()
Rudraksh
My django site is live on heroku. When I open admin page and deleted few entries from database. After some time entries come back again. I deleted many times using admin section but after 2,3 hrs they come back in the database. Anyone help me why this happening