RE: Possible bug in runserver

2022-11-11 Thread Mike Dewhirst
Try using the inline argument --settings when executing runserver--(Unsigned 
mail from my phone)
 Original message From: Matteo Sani  
Date: 12/11/22  05:38  (GMT+10:00) To: Django users 
 Subject: Possible bug in runserver Hello, I 
wanted to run Django runserver with custom settings defined in 
proj/mysettings.py. So I exported the env variable DJANGO_SETTINGS_MODULE to 
point to the custom settings file and then I ran manage.py runserver … The 
printout was showing that Django was still using the default settings in 
proj/settings.py, it seems it is ignoring DJANGO_SETTINGS_MODULE. Is it an 
intended behavior or a bug ? What is the recommended way to do that ? Below the 
commands I used to reproduce the issue:  $ export 
DJANGO_SETTINGS_MODULE=”proj.mysettings”$ python manage.py runserver 
0.0.0.0:7474November 11, 2022 - 10:22:48Django version 3.2.6, using settings 
'proj.settings'Starting development server at http://0.0.0.0:7474/Quit the 
server with CONTROL-C. Best regards,Matteo



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/821066be-0877-4ab1-a98f-c6a18dd62931n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/636ee2cd.810a0220.4928f.c912SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Apps aren't loaded yet exception when trying to run migrate Django oscar

2022-11-11 Thread Leslie Taffe
I'm trying to get to know django-oscar and this is what happens when i try 
to make migrations : 
Traceback (most recent call last):
  File "C:\Users\Leslie\Desktop\GrandmarketV3\Grandmarket\manage.py", line 
22, in 
main()
  File "C:\Users\Leslie\Desktop\GrandmarketV3\Grandmarket\manage.py", line 
18, in main
execute_from_command_line(sys.argv)
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\core\management\__init__.py",
 
line 419, in execute_from_command_line
utility.execute()
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\core\management\__init__.py",
 
line 363, in execute
settings.INSTALLED_APPS
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\conf\__init__.py",
 
line 82, in __getattr__
self._setup(name)
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\conf\__init__.py",
 
line 69, in _setup
self._wrapped = Settings(settings_module)
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\conf\__init__.py",
 
line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
  File 
"C:\Users\Leslie\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py",
 
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1050, in _gcd_import
  File "", line 1027, in _find_and_load
  File "", line 1006, in 
_find_and_load_unlocked
  File "", line 688, in _load_unlocked
  File "", line 883, in exec_module
  File "", line 241, in 
_call_with_frames_removed
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Grandmarket\Grandmarket\settings.py", 
line 18, in 
from oscar.core.compat import get_user_model
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\oscar\core\compat.py",
 
line 6, in 
from django.contrib.auth.models import User
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\contrib\auth\models.py",
 
line 3, in 
from django.contrib.auth.base_user import AbstractBaseUser, 
BaseUserManager
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\contrib\auth\base_user.py",
 
line 48, in 
class AbstractBaseUser(models.Model):
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\db\models\base.py",
 
line 108, in __new__
app_config = apps.get_containing_app_config(module)
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\apps\registry.py",
 
line 253, in get_containing_app_config
self.check_apps_ready()
  File 
"C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\apps\registry.py",
 
line 136, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

This is my settings.py file:
import os
import oscar

import django
from django.conf import settings
from oscar.core.compat import get_user_model
from oscar.defaults import *
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent



# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',

'Grandmarket.'
'oscar.config.Shop',
'oscar.apps.analytics.apps.AnalyticsConfig',
'oscar.apps.checkout.apps.CheckoutConfig',
'oscar.apps.address.apps.AddressConfig',
'oscar.apps.shipping.apps.ShippingConfig',
'oscar.apps.catalogue.apps.CatalogueConfig',
'oscar.apps.catalogue.reviews.apps.CatalogueReviewsConfig',
'oscar.apps.communication.apps.CommunicationConfig',
'oscar.apps.partner.apps.PartnerConfig',
'oscar.apps.basket.apps.BasketConfig',
'oscar.apps.payment.apps.PaymentConfig',
'oscar.apps.offer.apps.OfferConfig',
'oscar.apps.order.apps.OrderConfig',
'oscar.apps.customer.apps.CustomerConfig',
'oscar.apps.search.apps.SearchConfig',
'oscar.apps.voucher.apps.VoucherConfig',
'oscar.apps.wishlists.apps.WishlistsConfig',
'oscar.apps.dashboard.apps.DashboardConfig',
'oscar.apps.dashboard.reports.apps.ReportsDashboardConfig',
'oscar.apps.dashboard.users.apps.UsersDashboardConfig',
'oscar.apps.dashboard.orders.apps.OrdersDashboardConfig',
'oscar.apps.dashboard.catalogue.apps.CatalogueDashboardConfig',
'oscar.apps.dashboard.offers.apps.OffersDashboardConfig',
'oscar.apps.dashboard.partners.apps.PartnersDashboardConfig',
'oscar.apps.dashboard.pages.apps.PagesDashboardConfig',

writing most common queries as model class method!

2022-11-11 Thread Amir Jamshidi
Hi, 
I tried to write a classmothods/ instance method in a Model in order to run 
most common query from the model but got errors like below :

""AttributeError: Manager isn't accessible via ... instances""

example code:

class Profile(model.Model):
name = model.Charfield(...)
address = model.Charfield(...)


@classmethod
 def count_of_users(cls):
   return cls.objects.all()  #example query

 def all_users(self):
  return self.objects


*My purpose is to have most common and important queries in a method to be 
called within application. (Its a good way for documenting most common 
queries as well).What is the best practice for this case?*


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e58df10a-e5c0-40e8-8e0d-5439c04281d8n%40googlegroups.com.


Possible bug in runserver

2022-11-11 Thread Matteo Sani
Hello, 

I wanted to run Django runserver with custom settings defined in 
proj/mysettings.py. So I exported the env variable DJANGO_SETTINGS_MODULE 
to point to the custom settings file and then I ran manage.py runserver … 

The printout was showing that Django was still using the default settings 
in proj/settings.py, it seems it is ignoring DJANGO_SETTINGS_MODULE. 

Is it an intended behavior or a bug ? 

What is the recommended way to do that ? 

Below the commands I used to reproduce the issue: 

$ export DJANGO_SETTINGS_MODULE=”proj.mysettings”
$ python manage.py runserver 0.0.0.0:7474
November 11, 2022 - 10:22:48
*Django version 3.2.6, using settings 'proj.settings'*
Starting development server at http://0.0.0.0:7474/
Quit the server with CONTROL-C. 

Best regards,
Matteo

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/821066be-0877-4ab1-a98f-c6a18dd62931n%40googlegroups.com.


Re: Can't Load Django Dev Sever

2022-11-11 Thread James
Thanks so much! I thought I was doing something wrong when I deleted the 
cache and cookies and nothing happened. Just needed to restart my computer 
after clearing the cache/cookies; may have been a firefox bug!

Thanks again for you help!

Best Regards,

-James Logan

On Friday, November 11, 2022 at 1:01:56 AM UTC-7 ahmadabd...@gmail.com 
wrote:

> Try clearing cache and cookies for 127.0.0.1
>
> On Fri, Nov 11, 2022, 8:36 AM Mike Dewhirst  wrote:
>
>> Try visiting http://localhost:8000 instead
>>
>> No guarantees and I'm not going to test it myself ;-)
>>
>>
>>
>>
>>
>> --
>> (Unsigned mail from my phone)
>>
>>
>>
>>  Original message 
>> From: James  
>> Date: 11/11/22 16:13 (GMT+10:00) 
>> To: Django users  
>> Subject: Can't Load Django Dev Sever 
>>
>> Hello,
>>
>> I can't connect to my django web server and it's all my fault. I turned 
>> on SECURE_HSTS_SECONDS to 60 by accident in development, in another 
>> project, a few days ago.
>>
>> Now I can not load http://127.0.0.1:8000 on FireFox and I don't know how 
>> to fix it. And yes runserver is set to that port/ip and yes I can connect 
>> in incognito mode and in chrome.
>>
>> I have cleared all caches and cookies.
>>
>> Thanks very much!
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/29a776ee-e840-45ad-885b-3f5752c9466fn%40googlegroups.com
>>  
>> 
>> .
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/636dfb79.050a0220.368b6.8b8fSMTPIN_ADDED_MISSING%40gmr-mx.google.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a1f86756-0bd9-4743-a7fb-8c32d32b709cn%40googlegroups.com.


Re: Can't Load Django Dev Sever

2022-11-11 Thread Ahmad Abdulnasir Shuaib
Try clearing cache and cookies for 127.0.0.1

On Fri, Nov 11, 2022, 8:36 AM Mike Dewhirst  wrote:

> Try visiting http://localhost:8000 instead
>
> No guarantees and I'm not going to test it myself ;-)
>
>
>
>
>
> --
> (Unsigned mail from my phone)
>
>
>
>  Original message 
> From: James 
> Date: 11/11/22 16:13 (GMT+10:00)
> To: Django users 
> Subject: Can't Load Django Dev Sever
>
> Hello,
>
> I can't connect to my django web server and it's all my fault. I turned on
> SECURE_HSTS_SECONDS to 60 by accident in development, in another project, a
> few days ago.
>
> Now I can not load http://127.0.0.1:8000 on FireFox and I don't know how
> to fix it. And yes runserver is set to that port/ip and yes I can connect
> in incognito mode and in chrome.
>
> I have cleared all caches and cookies.
>
> Thanks very much!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/29a776ee-e840-45ad-885b-3f5752c9466fn%40googlegroups.com
> 
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/636dfb79.050a0220.368b6.8b8fSMTPIN_ADDED_MISSING%40gmr-mx.google.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE9AdkY5HCgqgHRMXr_XtnFG_Zhu3s4dBkC6V0py_591_dOQFA%40mail.gmail.com.