Re: AttributeError at /auth/users/

2023-07-02 Thread s.alaoui youssef
Hi
you have to create class User(AbstractUser) 

class User(AbstractUser):
   ...
objects = UserManager()

and add objects with your UserManager
Le samedi 1 juillet 2023 à 18:14:53 UTC+1, arun n a écrit :

> Hello, 
>
> I am new to Django.  I am getting the below error. Can someone help.
>
> from django.db import models
> from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, 
> BaseUserManager, UserManager
>
>
> class UserAccountManager(BaseUserManager):
> def create_user(self, email, name, password=None):
> if not email:
> raise ValueError('Email address required')
>
> email = self.normalize_email(email)
> user = self.model(email=email, name=name)
> user.set_password(password)
>     user.save()
> return user
>
> AttributeError at /auth/users/'Manager' object has no attribute 
> 'create_user'
> Request Method:
> POST
> Request URL:
> http://127.0.0.1:8000/auth/users/
> Django Version:
> 4.2.2
> Exception Type:
> AttributeError
> Exception Value:
> 'Manager' object has no attribute 'create_user'
> Exception Location:
>
> C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Lib\site-packages\djoser\serializers.py,
>  
> line 48, in perform_create
> Raised during:
> djoser.views.UserViewSet
> Python Executable:
> C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Scripts\python.exe
> Python Version:
> 3.11.4
> Python Path:
> ['C:\\Users\\Arun\\Documents\\GitHub\\nc-backend', 
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip',
>  
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311', 
> 'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE', 
> 'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE\\Lib\\site-packages']
> Server time:
> Fri, 30 Jun 2023 18:48:41 +
>

-- 
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/ce27af5f-fb17-4347-8496-9c973577a7cdn%40googlegroups.com.


Re: AttributeError at /auth/users/

2023-07-02 Thread s.alaoui youssef
class User(AbstractUser):

   .

objects = UserManager()

we have to create User class and specify as objects your UserManager

Le dimanche 2 juillet 2023 à 02:10:58 UTC+1, Muhammad Juwaini Abdul Rahman 
a écrit :

> What's your code in urls.py for `/auth/user`?
>
> On Sunday, 2 July 2023 at 01:14:53 UTC+8 arun n wrote:
>
>> Hello, 
>>
>> I am new to Django.  I am getting the below error. Can someone help.
>>
>> from django.db import models
>> from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
>> , BaseUserManager, UserManager
>>
>>
>> class UserAccountManager(BaseUserManager):
>> def create_user(self, email, name, password=None):
>> if not email:
>> raise ValueError('Email address required')
>>
>> email = self.normalize_email(email)
>> user = self.model(email=email, name=name)
>> user.set_password(password)
>> user.save()
>> return user
>>
>> AttributeError at /auth/users/'Manager' object has no attribute 
>> 'create_user'
>> Request Method:
>> POST
>> Request URL:
>> http://127.0.0.1:8000/auth/users/
>> Django Version:
>> 4.2.2
>> Exception Type:
>> AttributeError
>> Exception Value:
>> 'Manager' object has no attribute 'create_user'
>> Exception Location:
>>
>> C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Lib\site-packages\djoser\serializers.py,
>>  
>> line 48, in perform_create
>> Raised during:
>> djoser.views.UserViewSet
>> Python Executable:
>> C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Scripts\python.exe
>> Python Version:
>> 3.11.4
>> Python Path:
>> ['C:\\Users\\Arun\\Documents\\GitHub\\nc-backend', 
>> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip',
>>  
>> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 
>> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 
>> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311', 
>> 'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE', 
>> 'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE\\Lib\\site-packages']
>> Server time:
>> Fri, 30 Jun 2023 18:48:41 +
>>
>

-- 
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/c5956e09-fc25-4661-8306-7c958044090an%40googlegroups.com.


Re: AttributeError at /auth/users/

2023-07-01 Thread Muhammad Juwaini Abdul Rahman
What's your code in urls.py for `/auth/user`?

On Sunday, 2 July 2023 at 01:14:53 UTC+8 arun n wrote:

> Hello, 
>
> I am new to Django.  I am getting the below error. Can someone help.
>
> from django.db import models
> from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, 
> BaseUserManager, UserManager
>
>
> class UserAccountManager(BaseUserManager):
> def create_user(self, email, name, password=None):
> if not email:
> raise ValueError('Email address required')
>
> email = self.normalize_email(email)
> user = self.model(email=email, name=name)
> user.set_password(password)
>     user.save()
> return user
>
> AttributeError at /auth/users/'Manager' object has no attribute 
> 'create_user'
> Request Method:
> POST
> Request URL:
> http://127.0.0.1:8000/auth/users/
> Django Version:
> 4.2.2
> Exception Type:
> AttributeError
> Exception Value:
> 'Manager' object has no attribute 'create_user'
> Exception Location:
>
> C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Lib\site-packages\djoser\serializers.py,
>  
> line 48, in perform_create
> Raised during:
> djoser.views.UserViewSet
> Python Executable:
> C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Scripts\python.exe
> Python Version:
> 3.11.4
> Python Path:
> ['C:\\Users\\Arun\\Documents\\GitHub\\nc-backend', 
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip',
>  
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311', 
> 'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE', 
> 'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE\\Lib\\site-packages']
> Server time:
> Fri, 30 Jun 2023 18:48:41 +
>

-- 
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/280c8a92-940c-48f2-9e89-b47351e3d79fn%40googlegroups.com.


Re: AttributeError at /auth/users/

2023-07-01 Thread Fikayo Soetan
Good day,
I'm also still learning but I think the name of the function should be 
"_create_user"
Fikayo.
On Saturday, July 1, 2023 at 6:14:53 PM UTC+1 arun n wrote:

> Hello, 
>
> I am new to Django.  I am getting the below error. Can someone help.
>
> from django.db import models
> from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, 
> BaseUserManager, UserManager
>
>
> class UserAccountManager(BaseUserManager):
> def create_user(self, email, name, password=None):
> if not email:
> raise ValueError('Email address required')
>
> email = self.normalize_email(email)
> user = self.model(email=email, name=name)
> user.set_password(password)
> user.save()
> return user
>
> AttributeError at /auth/users/'Manager' object has no attribute 
> 'create_user'
> Request Method:
> POST
> Request URL:
> http://127.0.0.1:8000/auth/users/
> Django Version:
> 4.2.2
> Exception Type:
> AttributeError
> Exception Value:
> 'Manager' object has no attribute 'create_user'
> Exception Location:
>
> C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Lib\site-packages\djoser\serializers.py,
>  
> line 48, in perform_create
> Raised during:
> djoser.views.UserViewSet
> Python Executable:
> C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Scripts\python.exe
> Python Version:
> 3.11.4
> Python Path:
> ['C:\\Users\\Arun\\Documents\\GitHub\\nc-backend', 
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip',
>  
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 
> 'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311', 
> 'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE', 
> 'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE\\Lib\\site-packages']
> Server time:
> Fri, 30 Jun 2023 18:48:41 +
>

-- 
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/b554889b-b0ef-4856-baaf-6c45b8a96e5an%40googlegroups.com.


AttributeError at /auth/users/

2023-07-01 Thread arun n
Hello, 

I am new to Django.  I am getting the below error. Can someone help.

from django.db import models
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, 
BaseUserManager, UserManager


class UserAccountManager(BaseUserManager):
def create_user(self, email, name, password=None):
if not email:
raise ValueError('Email address required')

email = self.normalize_email(email)
user = self.model(email=email, name=name)
user.set_password(password)
user.save()
return user

AttributeError at /auth/users/'Manager' object has no attribute 
'create_user'
Request Method:
POST
Request URL:
http://127.0.0.1:8000/auth/users/
Django Version:
4.2.2
Exception Type:
AttributeError
Exception Value:
'Manager' object has no attribute 'create_user'
Exception Location:
C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Lib\site-packages\djoser\serializers.py,
 
line 48, in perform_create
Raised during:
djoser.views.UserViewSet
Python Executable:
C:\Users\Arun\.virtualenvs\nc-backend-zDgCjJYE\Scripts\python.exe
Python Version:
3.11.4
Python Path:
['C:\\Users\\Arun\\Documents\\GitHub\\nc-backend', 
'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip', 
'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 
'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 
'C:\\Users\\Arun\\AppData\\Local\\Programs\\Python\\Python311', 
'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE', 
'C:\\Users\\Arun\\.virtualenvs\\nc-backend-zDgCjJYE\\Lib\\site-packages']
Server time:
Fri, 30 Jun 2023 18:48:41 +

-- 
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/8bf54dc0-21f0-4dab-a76f-a9c70470cc8en%40googlegroups.com.


Re: python manage.py commonds: AttributeError: 'PosixPath' object has no attribute 'startswith'

2023-05-14 Thread David Du
py", line 
>>> 3234, in _call_aside
>>> f(*args, **kwargs)
>>>   File 
>>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
>>> 3272, in _initialize_master_working_set
>>> working_set = WorkingSet._build_master()
>>>   File 
>>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
>>> 572, in _build_master
>>> ws = cls()
>>>   File 
>>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
>>> 565, in __init__
>>> self.add_entry(entry)
>>>   File 
>>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
>>> 621, in add_entry
>>> for dist in find_distributions(entry, True):
>>>   File 
>>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
>>> 1988, in find_distributions
>>> importer = get_importer(path_item)
>>>   File "/usr/local/python/lib/python3.10/pkgutil.py", line 421, in 
>>> get_importer
>>> importer = path_hook(path_item)
>>>   File "", line 1632, in 
>>> path_hook_for_FileFinder
>>>   File "", line 1504, in __init__
>>>   File "", line 182, in _path_isabs
>>> AttributeError: 'PosixPath' object has no attribute 'startswith'
>>>
>>> I must midify settings.py, change BASE_DIR, it can run
>>> # BASE_DIR = Path(__file__).resolve().parent.parent 
>>> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))
>>>
>>>
>>> -- 
>>> 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/033f2f50-b073-4a97-9d66-6cc7f8a18049n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/033f2f50-b073-4a97-9d66-6cc7f8a18049n%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> -- 
>> 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/CAE5VhgVp2UiGc_Dh0jzcg4hTijXtKk8f0PE8axDpLKbky1xo_g%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-users/CAE5VhgVp2UiGc_Dh0jzcg4hTijXtKk8f0PE8axDpLKbky1xo_g%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/879d1244-daea-4baf-8800-f701051566e1n%40googlegroups.com.


Re: python manage.py commonds: AttributeError: 'PosixPath' object has no attribute 'startswith'

2023-04-26 Thread Julius Chesoni
You must be a very good Django programmer.

Thank you on behalf of Django community, for such a great answer that even
novices like me are able to understand.

 I had no idea that there were other non default configurations of the
variable BASE_DIR.


Julius.

On Wed, Apr 26, 2023 at 1:15 AM David Nugent  wrote:

> This error is being triggered by an outdated and badly behaved module
> that contains the run_cmdb_worker management command.
>
> Anything that relies on the presence of BASE_DIR in settings is bad
> behaviour. This is an entirely arbitrary variable name that might not even
> be present in a non-default configuration, and it effectively a "private"
> variable.
>
> There are better ways to determine the Django base directory (although
> reliance on same is also questionable as it probably assumes a specific
> Django layout, which is also poor behaviour).
>
> If you insist on using it, then simply wrap BASE_DIR def with a str()
> cast, or use .as_posix() member, i.e.
>
> BASE_DIR = str(Path(__file__).resolve().parent.parent)
>
> This may invalidate other uses in your settings module though, for example:
>
> BASE_DIR / 'someothervalue'
>
> If your change does not trigger an error otherwise, then you are probably
> fine.
>
> Regards,
> David
>
>
> On Mon, Apr 24, 2023 at 2:21 AM DL  wrote:
>
>> Django 4.2
>> Python 3.10.10
>>
>> # python manage.py run_cmdb_worker
>> Traceback (most recent call last):
>>   File "/usr/local/python/lib/python3.10/pkgutil.py", line 417, in
>> get_importer
>> importer = sys.path_importer_cache[path_item]
>> KeyError: PosixPath('/www/cloudadmin')
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File "/www/cloudadmin/manage.py", line 22, in 
>> main()
>>   File "/www/cloudadmin/manage.py", line 18, in main
>> execute_from_command_line(sys.argv)
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py",
>> line 442, in execute_from_command_line
>> utility.execute()
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py",
>> line 436, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py",
>> line 275, in fetch_command
>> klass = load_command_class(app_name, subcommand)
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py",
>> line 48, in load_command_class
>> module = import_module("%s.management.commands.%s" % (app_name, name))
>>   File "/usr/local/python/lib/python3.10/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
>> "/www/cloudadmin/apps/cmdb/management/commands/run_cmdb_worker.py", line 2,
>> in 
>> from cmdb.scheduler import Scheduler
>>   File "/www/cloudadmin/apps/cmdb/scheduler.py", line 3, in 
>> from apscheduler.schedulers.background import BackgroundScheduler
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/apscheduler/__init__.py", line
>> 1, in 
>> from pkg_resources import get_distribution, DistributionNotFound
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
>> 3260, in 
>> def _initialize_master_working_set():
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
>> 3234, in _call_aside
>> f(*args, **kwargs)
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
>> 3272, in _initialize_master_working_set
>> working_set = WorkingSet._build_master()
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
>> 572, in _build_master
>> ws = cls()
>>   File
>> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
>> 565, in __init__
>> 

Re: python manage.py commonds: AttributeError: 'PosixPath' object has no attribute 'startswith'

2023-04-25 Thread David Nugent
This error is being triggered by an outdated and badly behaved module
that contains the run_cmdb_worker management command.

Anything that relies on the presence of BASE_DIR in settings is bad
behaviour. This is an entirely arbitrary variable name that might not even
be present in a non-default configuration, and it effectively a "private"
variable.

There are better ways to determine the Django base directory (although
reliance on same is also questionable as it probably assumes a specific
Django layout, which is also poor behaviour).

If you insist on using it, then simply wrap BASE_DIR def with a str() cast,
or use .as_posix() member, i.e.

BASE_DIR = str(Path(__file__).resolve().parent.parent)

This may invalidate other uses in your settings module though, for example:

BASE_DIR / 'someothervalue'

If your change does not trigger an error otherwise, then you are probably
fine.

Regards,
David


On Mon, Apr 24, 2023 at 2:21 AM DL  wrote:

> Django 4.2
> Python 3.10.10
>
> # python manage.py run_cmdb_worker
> Traceback (most recent call last):
>   File "/usr/local/python/lib/python3.10/pkgutil.py", line 417, in
> get_importer
> importer = sys.path_importer_cache[path_item]
> KeyError: PosixPath('/www/cloudadmin')
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "/www/cloudadmin/manage.py", line 22, in 
> main()
>   File "/www/cloudadmin/manage.py", line 18, in main
> execute_from_command_line(sys.argv)
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py",
> line 442, in execute_from_command_line
> utility.execute()
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py",
> line 436, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py",
> line 275, in fetch_command
> klass = load_command_class(app_name, subcommand)
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py",
> line 48, in load_command_class
> module = import_module("%s.management.commands.%s" % (app_name, name))
>   File "/usr/local/python/lib/python3.10/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 "/www/cloudadmin/apps/cmdb/management/commands/run_cmdb_worker.py",
> line 2, in 
> from cmdb.scheduler import Scheduler
>   File "/www/cloudadmin/apps/cmdb/scheduler.py", line 3, in 
> from apscheduler.schedulers.background import BackgroundScheduler
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/apscheduler/__init__.py", line
> 1, in 
> from pkg_resources import get_distribution, DistributionNotFound
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
> 3260, in 
> def _initialize_master_working_set():
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
> 3234, in _call_aside
> f(*args, **kwargs)
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
> 3272, in _initialize_master_working_set
> working_set = WorkingSet._build_master()
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
> 572, in _build_master
> ws = cls()
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
> 565, in __init__
> self.add_entry(entry)
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
> 621, in add_entry
> for dist in find_distributions(entry, True):
>   File
> "/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line
> 1988, in find_distributions
> importer = get_importer(path_item)
>   File "/usr/local/python/lib/python3.10/pkgutil.py", line 421, in
> get_importer
> importer = path_hook(path_item)
>   File "", line 1632, in
> path_hook_for_FileFinder
>   File "", line 1504, in __init__
>   File "", line 182, in _path_isabs
> AttributeError: 'PosixPath' object has no attribute

python manage.py commonds: AttributeError: 'PosixPath' object has no attribute 'startswith'

2023-04-23 Thread DL
Django 4.2
Python 3.10.10

# python manage.py run_cmdb_worker
Traceback (most recent call last):
  File "/usr/local/python/lib/python3.10/pkgutil.py", line 417, in 
get_importer
importer = sys.path_importer_cache[path_item]
KeyError: PosixPath('/www/cloudadmin')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/www/cloudadmin/manage.py", line 22, in 
main()
  File "/www/cloudadmin/manage.py", line 18, in main
execute_from_command_line(sys.argv)
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py", 
line 442, in execute_from_command_line
utility.execute()
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py", 
line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py", 
line 275, in fetch_command
klass = load_command_class(app_name, subcommand)
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/django/core/management/__init__.py", 
line 48, in load_command_class
module = import_module("%s.management.commands.%s" % (app_name, name))
  File "/usr/local/python/lib/python3.10/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 "/www/cloudadmin/apps/cmdb/management/commands/run_cmdb_worker.py", 
line 2, in 
from cmdb.scheduler import Scheduler
  File "/www/cloudadmin/apps/cmdb/scheduler.py", line 3, in 
from apscheduler.schedulers.background import BackgroundScheduler
  File "/opt/.pyvenv/lib/python3.10/site-packages/apscheduler/__init__.py", 
line 1, in 
from pkg_resources import get_distribution, DistributionNotFound
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
3260, in 
def _initialize_master_working_set():
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
3234, in _call_aside
f(*args, **kwargs)
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
3272, in _initialize_master_working_set
working_set = WorkingSet._build_master()
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
572, in _build_master
ws = cls()
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
565, in __init__
self.add_entry(entry)
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
621, in add_entry
for dist in find_distributions(entry, True):
  File 
"/opt/.pyvenv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 
1988, in find_distributions
importer = get_importer(path_item)
  File "/usr/local/python/lib/python3.10/pkgutil.py", line 421, in 
get_importer
importer = path_hook(path_item)
  File "", line 1632, in 
path_hook_for_FileFinder
  File "", line 1504, in __init__
  File "", line 182, in _path_isabs
AttributeError: 'PosixPath' object has no attribute 'startswith'

I must midify settings.py, change BASE_DIR, it can run
# BASE_DIR = Path(__file__).resolve().parent.parent 
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))


-- 
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/033f2f50-b073-4a97-9d66-6cc7f8a18049n%40googlegroups.com.


Re: AttributeError: 'QuerySet' object has no attribute 'mime_type'

2023-01-19 Thread Jason
is `content` a queryset? 

On Thursday, January 19, 2023 at 8:21:39 AM UTC-5 monisha.s...@ideas2it.com 
wrote:

> @staticmethod
> def post(request, *args, **kwargs):
> constant = utils.send_grid_key
> sg = SendGridAPIClient(constant)
> subject = get_subject()
> content = get_content()
> message = Mail(
> from_email=From((utils.sender_mail, 'Hello')),
> to_emails=To('man...@gmail.com'),
> # to_emails=To(get_email()),
> subject=subject,
> html_content=content)
> response = sg.send(message)
> print(response.status_code)
> print(response.body)
> print(response.headers)
> return Response(response)
>
>
> Traceback (most recent call last):
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\exception.py",
>  
> line 55, in inner
> response = get_response(request)
>^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\base.py",
>  
> line 197, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\decorators\csrf.py",
>  
> line 54, in wrapped_view
> return view_func(*args, **kwargs)
>^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\generic\base.py",
>  
> line 103, in view
> return self.dispatch(request, *args, **kwargs)
>^^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 509, in dispatch
> response = self.handle_exception(exc)
>^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 469, in handle_exception
> self.raise_uncaught_exception(exc)
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 480, in raise_uncaught_exception
> raise exc
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 506, in dispatch
> response = handler(request, *args, **kwargs)
>^
>   File "C:\Users\Lenovo\marketautomation\automation\user\views.py", line 
> 140, in post
> message = Mail(
>   ^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
>  
> line 80, in __init__
> self.add_content(html_content, MimeType.html)
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
>  
> line 734, in add_content
> if content.mime_type == MimeType.text:
>^
> AttributeError: 'QuerySet' object has no attribute 'mime_type'
> [19/Jan/2023 17:54:52] ERROR - Internal Server Error: /automation/user/mail
> Traceback (most recent call last):
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\exception.py",
>  
> line 55, in inner
> response = get_response(request)
>^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\base.py",
>  
> line 197, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\decorators\csrf.py",
>  
> line 54, in wrapped_view
> return view_func(*args, **kwargs)
>^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\generic\base.py",
>  
> line 103, in view
> return self.dispatch(request, *args, **kwargs)
>^^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 509, in dispatch
> response = self.handle_exception(exc)
>^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 469, in handle_exception
> self.raise_uncaught_exception(exc)
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.p

AttributeError: 'QuerySet' object has no attribute 'mime_type'

2023-01-19 Thread Monisha Sivanathan
@staticmethod
def post(request, *args, **kwargs):
constant = utils.send_grid_key
sg = SendGridAPIClient(constant)
subject = get_subject()
content = get_content()
message = Mail(
from_email=From((utils.sender_mail, 'Hello')),
to_emails=To('mani...@gmail.com'),
# to_emails=To(get_email()),
subject=subject,
html_content=content)
response = sg.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
return Response(response)


Traceback (most recent call last):
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\exception.py",
 
line 55, in inner
response = get_response(request)
   ^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\base.py",
 
line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
   
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\decorators\csrf.py",
 
line 54, in wrapped_view
return view_func(*args, **kwargs)
   ^^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\generic\base.py",
 
line 103, in view
return self.dispatch(request, *args, **kwargs)
   ^^^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
 
line 509, in dispatch
response = self.handle_exception(exc)
   ^^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
 
line 469, in handle_exception
self.raise_uncaught_exception(exc)
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
 
line 480, in raise_uncaught_exception
raise exc
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
 
line 506, in dispatch
response = handler(request, *args, **kwargs)
   ^
  File "C:\Users\Lenovo\marketautomation\automation\user\views.py", line 
140, in post
message = Mail(
  ^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
 
line 80, in __init__
self.add_content(html_content, MimeType.html)
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
 
line 734, in add_content
if content.mime_type == MimeType.text:
   ^
AttributeError: 'QuerySet' object has no attribute 'mime_type'
[19/Jan/2023 17:54:52] ERROR - Internal Server Error: /automation/user/mail
Traceback (most recent call last):
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\exception.py",
 
line 55, in inner
response = get_response(request)
   ^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\base.py",
 
line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
   
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\decorators\csrf.py",
 
line 54, in wrapped_view
return view_func(*args, **kwargs)
   ^^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\generic\base.py",
 
line 103, in view
return self.dispatch(request, *args, **kwargs)
   ^^^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
 
line 509, in dispatch
response = self.handle_exception(exc)
   ^^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
 
line 469, in handle_exception
self.raise_uncaught_exception(exc)
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
 
line 480, in raise_uncaught_exception
raise exc
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
 
line 506, in dispatch
response = handler(request, *args, **kwargs)
   ^
  File "C:\Users\Lenovo\marketautomation\automation\user\views.py", line 
140, in post
message = Mail(
  ^
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
 
line 80, in __init__
self.add_content(html_content, MimeType.html)
  File 
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
 
li

Re: AttributeError at /form/

2022-12-18 Thread 'Kasper Laudrup' via Django users

Reading something like this:

https://betterprogramming.pub/how-to-ask-questions-about-programming-dcd948fcd2bd

should help guide you in the right direction.

Kind regards,
Kasper Laudrup

--
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/00319842-092e-3210-43b1-c1152672968a%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


AttributeError at /form/

2022-12-17 Thread Aravind
AttributeError at /form/'AssetForm' object has no attribute 'save'
Request Method:
POST
Request URL:
http://127.0.0.1:8000/form/
Django Version:
4.1.2
Exception Type:
AttributeError
Exception Value:
'AssetForm' object has no attribute 'save'
Exception Location:
D:\Core Py\django\projects\VSPL\Test\AssetV2\calsofnav1\capp\views.py, line 
28, in insert_view
Raised during:
capp.views.insert_view
Python Executable:
C:\Users\aravi\AppData\Local\Programs\Python\Python311\python.exe
Python Version:
3.11.0
Python Path:
['D:\\Core Py\\django\\projects\\VSPL\\Test\\AssetV2\\calsofnav1', 
'C:\\Users\\aravi\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip', 
'C:\\Users\\aravi\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 
'C:\\Users\\aravi\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 
'C:\\Users\\aravi\\AppData\\Local\\Programs\\Python\\Python311', 
'C:\\Users\\aravi\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages']
Server time:
Sat, 17 Dec 2022 13:08:47 +

-- 
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/30ee2a15-4517-43a7-96f1-a7e7533a3e24n%40googlegroups.com.


Re: AttributeError: module 'django.db.models' has no attribute 'PointField'

2022-11-27 Thread Larry Martell
On Sun, Nov 27, 2022 at 2:40 PM Ilyas Modni  wrote:
>
> AttributeError: module 'django.db.models' has no attribute 'PointField'

Are you importing:

from django.contrib.gis.db import models

-- 
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/CACwCsY6VyNv5RdQ5UbA2N2j9W2OKN0B0vg0gjS_kuphmAmd8xg%40mail.gmail.com.


Re: AttributeError: module 'django.db.models' has no attribute 'PointField'

2022-11-27 Thread Karen Tracey
On Sun, Nov 27, 2022 at 2:41 PM Ilyas Modni  wrote:

> AttributeError: module 'django.db.models' has no attribute 'PointField'
>
> PointField is in django.contrib.gis.db.models:
https://docs.djangoproject.com/en/4.1/ref/contrib/gis/model-api/#pointfield

-- 
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/CACS9raddif%3DiWrMUHUqEoK%2BTBxDoTYeXQ-mW0D_OZPyfoZqnpg%40mail.gmail.com.


AttributeError: module 'django.db.models' has no attribute 'PointField'

2022-11-27 Thread Ilyas Modni
AttributeError: module 'django.db.models' has no attribute 'PointField'

-- 
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/84040dbe-1512-43ca-a9be-996839f4f527n%40googlegroups.com.


psycopg 3 - getting attributeError

2022-11-04 Thread Brian Nabusiu
[image: attribute_error.png]Hello, 

I wanted to migrate my app to using psycopg 3. However, I got an error that 
insists using psycopg2, even when it was not installed in venv. So I 
decided to ammend some django code as illustrated by the inventor of 
psycopg3. However, 

   1. django complained of not knowing how to import Text from 
   django.db.utils. So I inspected the utils.py, there was class Text. I 
   created one and the error went away. I know I am very much likely wrong 
   doing that
   2. django started but I could not connect to querry relations with 
   attribute error that objects do not have status attribute as shown in the 
   image attached

Anyone using django 4.1, python 3.11.0 and psycopg3 to help?


-- 
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/7189f73f-d2ce-4cbf-9a72-350202158ec0n%40googlegroups.com.


AttributeError at /invoice/add_invoice/ 'int' object has no attribute '_meta' while using in_bulk

2022-07-10 Thread Kiran Chavan
I want to convert the model instances into a JSON object and then pass it 
to the HTML file. However, I get an AttributeError at this line:
`data = serializers.serialize("json", Inventory.objects.in_bulk())`

The full `views.py`:

def add_invoice(request):
  form = InvoiceForm(request.POST or None)
  data = serializers.serialize("json", Inventory.objects.in_bulk())
  total_invoices = Invoice.objects.count()
  queryset = Invoice.objects.order_by('-invoice_date')[:6]

  if form.is_valid():
form.save()
messages.success(request, 'Successfully Saved')
return redirect('/invoice/list_invoice')
  context = {
"form": form,
"title": "New Invoice",
"total_invoices": total_invoices,
"queryset": queryset,
"data": data,
  }
return render(request, "entry.html", context)

The Javascript code:

{{ data|json_script:"hello-data" }}

const data = 
JSON.parse(document.getElementById('hello-data').textContent);

document.getElementById('id_line_one').onchange = function(event){
document.getElementById('id_line_one_unit_price').value = 
data[event.target.value].fields.amount;
};



`models.py`:



class Inventory(models.Model):
  product_number = models.IntegerField(primary_key=True)
  product = models.TextField(max_length=3000, default='', blank=True, 
null=True)
  title = models.CharField('Title', max_length=120, default='', 
blank=True, unique=True)
  amount = models.IntegerField('Unit Price', default=0, blank=True, 
null=True)
  
  def __str__(self):
return self.title

How can I pass that JSON object and assign the amount value to the text 
field according to the object selected in the dropdown? Thanks
[image: Screenshot 2022-07-09 232808.jpg]

-- 
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/6176f7fe-9f50-4380-b044-3e46f2219c8fn%40googlegroups.com.


Re: AttributeError at /api/courses/

2021-12-22 Thread Kasper Laudrup
If you want someone to help you then spend the minimum effort and ask a 
proper question.


That's the least you can do if you expect someone to take the time to 
help you.


Kind regards,

Kasper Laudrup

--
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/d7d05e8a-9fa1-82db-1f7f-fa29df1273a7%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: AttributeError: 'Values' object has no attribute 'link_base' in building sphinx documentation.

2021-12-10 Thread Sencer Hamarat
I think the same way.
I will upgrade to 2.2.25 soon. Then I'll open a ticket asap.

On Thu, Dec 9, 2021 at 7:04 PM Jason  wrote:

> you could raise a bug report on the django tracker at
> https://code.djangoproject.com/query but I'm doubtful that this will gain
> any traction
>
> Those versions of django you specified are very out of date.  1.10 was EOL
> in 2017, 1.11 EOL'd April 2020 and 2.0 EOLd Aug 2018
>
> If you don't have any issues with currently supported versions (2.2, 3.2
> and 4.0),  then its likely that any PRs won't be applied.
>
> On Thursday, December 9, 2021 at 10:15:03 AM UTC-5 sencer...@gmail.com
> wrote:
>
>> Hello everyone,
>>
>> If 'sphinx.ext.autodoc' extension enabled in conf.py of sphinx, when I
>> try to run 'make html' I'm ending up with AttributeError exception:
>>
>> Exception occurred:
>>   File
>> /env/lib/python3.6/site-packages/django/contrib/admindocs/utils.py", line
>> 121, in _role
>> inliner.document.settings.link_base,
>> AttributeError: 'Values' object has no attribute 'link_base'
>>
>> I tried it with combinations of some django and sphinx versions.
>>
>> Here is the no luck list:
>> django 1.10, django 1.11 and sphinx 3.5
>> django 2.0.13 and sphinx 3.5 , sphinx 4.0, sphinx 4.2.0, sphinx 4.3.1
>>
>> I also opened an issue at sphinx github but they said this has to do with
>> django admindocs instead of  sphinx.
>>
>> Is there anybody who has resolved the AttributeError exception thrown
>> while building documents via sphinx?
>>
>> Regards,
>> Sencer HAMARAT
>>
>> --
> 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/d684ad8e-3001-4d36-8b13-33ce0029cb32n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d684ad8e-3001-4d36-8b13-33ce0029cb32n%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CACp8TZg5PRgxn6HwMpk3rN%3DHqu35%3DYvojoQgeMUSyOgC%3DuXy1A%40mail.gmail.com.


Re: AttributeError: 'Values' object has no attribute 'link_base' in building sphinx documentation.

2021-12-09 Thread Jason
you could raise a bug report on the django tracker 
at https://code.djangoproject.com/query but I'm doubtful that this will 
gain any traction

Those versions of django you specified are very out of date.  1.10 was EOL 
in 2017, 1.11 EOL'd April 2020 and 2.0 EOLd Aug 2018

If you don't have any issues with currently supported versions (2.2, 3.2 
and 4.0),  then its likely that any PRs won't be applied. 

On Thursday, December 9, 2021 at 10:15:03 AM UTC-5 sencer...@gmail.com 
wrote:

> Hello everyone,
>
> If 'sphinx.ext.autodoc' extension enabled in conf.py of sphinx, when I try 
> to run 'make html' I'm ending up with AttributeError exception:
>
> Exception occurred:
>   File 
> /env/lib/python3.6/site-packages/django/contrib/admindocs/utils.py", line 
> 121, in _role
> inliner.document.settings.link_base,
> AttributeError: 'Values' object has no attribute 'link_base'
>
> I tried it with combinations of some django and sphinx versions.
>
> Here is the no luck list:
> django 1.10, django 1.11 and sphinx 3.5
> django 2.0.13 and sphinx 3.5 , sphinx 4.0, sphinx 4.2.0, sphinx 4.3.1
>
> I also opened an issue at sphinx github but they said this has to do with 
> django admindocs instead of  sphinx.
>
> Is there anybody who has resolved the AttributeError exception thrown 
> while building documents via sphinx?
>
> Regards,
> Sencer HAMARAT
>
>

-- 
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/d684ad8e-3001-4d36-8b13-33ce0029cb32n%40googlegroups.com.


AttributeError: 'Values' object has no attribute 'link_base' in building sphinx documentation.

2021-12-09 Thread Sencer Hamarat
Hello everyone,

If 'sphinx.ext.autodoc' extension enabled in conf.py of sphinx, when I try
to run 'make html' I'm ending up with AttributeError exception:

Exception occurred:
  File /env/lib/python3.6/site-packages/django/contrib/admindocs/utils.py",
line 121, in _role
inliner.document.settings.link_base,
AttributeError: 'Values' object has no attribute 'link_base'

I tried it with combinations of some django and sphinx versions.

Here is the no luck list:
django 1.10, django 1.11 and sphinx 3.5
django 2.0.13 and sphinx 3.5 , sphinx 4.0, sphinx 4.2.0, sphinx 4.3.1

I also opened an issue at sphinx github but they said this has to do with
django admindocs instead of  sphinx.

Is there anybody who has resolved the AttributeError exception thrown while
building documents via sphinx?

Regards,
Sencer HAMARAT

-- 
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/CACp8TZgkaogKXkfonu%3DacRwfN%3D_yG5UzW85i1BSAThR-H0qCZA%40mail.gmail.com.


Re: AttributeError: module 'polls.views' has no attribute 'index'

2021-07-26 Thread DJANGO DEVELOPER
as you mentioned that you're using django 3.2 but your urls.py file is
following the pattern of django 1.7.
use your urls.py this way : path('your polls url here', views.index,
name='index')

On Mon, Jul 26, 2021 at 6:45 PM Zain  wrote:

> Had the same issue.
>
> Solved, make sure you run each edited python file during the tutorial.
> I guess it needs to update. All I know is this fixed the issue.
>
> On Monday, April 19, 2021 at 2:07:34 AM UTC+10 avi.me...@gmail.com wrote:
>
>> I followed the same tutorial on 17th April 2021 with Python 3.9.2 and
>> Django 3.2 and have exactly the same problems as mentioned above.
>>
>>     path('', views.index, name='index'),
>>
>> AttributeError: module 'polls.views' has no attribute 'index'
>>
>> any help on how can I debug this? I am a django noob
>>
>> On Wednesday, 19 April 2017 at 16:31:59 UTC+2 lce...@gmail.com wrote:
>>
>>> Thanks for your reploy.
>>>
>>> Actually I followed the tutorial exactly.
>>>
>>> My polls/views.py has:
>>>
>>> from django.http import HttpResponse
>>>
>>>
>>> def index(request):
>>> return HttpResponse("Hello, world. You're at the polls index.")
>>>
>>> My polls/urls.py has:
>>>
>>> from django.conf.urls import url
>>>
>>> from . import views
>>>
>>> urlpatterns = [
>>> url(r'^$', views.index, name='index'),
>>> ]
>>>
>>>
>>> On Wednesday, 19 April 2017 15:43:57 UTC+2, m712 - Developer wrote:
>>>
>>>> You didn't give us enough info, but I am thinking that you don't have
>>>> an index() function in your polls/views.py. Start the tutorial from the
>>>> beginning and follow it closely.
>>>> On Apr 19, 2017 4:17 PM, Billy Lin  wrote:
>>>>
>>>> I'm following the getting started tutorial 01 and running into issues
>>>> after creating the polls app. Can someone please help?
>>>>
>>>> I'm using Python 3.6.1 and Django 1.11.
>>>>
>>>> Here's the detailed trace:
>>>>
>>>> Performing system checks...
>>>> Unhandled exception in thread started by >>> check_errors..wrapper at 0x04222810>
>>>> Traceback (most recent call last):
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py",
>>>> line
>>>> 227, in wrapper
>>>> fn(*args, **kwargs)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
>>>> nserver.py", line 125, in inner_run
>>>> self.check(display_num_errors=True)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>>> l
>>>> ine 359, in check
>>>> include_deployment_checks=include_deployment_checks,
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>>> l
>>>> ine 346, in _run_checks
>>>> return checks.run_checks(**kwargs)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py",
>>>> l
>>>> ine 81, in run_checks
>>>> new_errors = check(app_configs=app_configs)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>>> line
>>>> 16, in check_url_config
>>>> return check_resolver(resolver)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>>> line
>>>> 26, in check_resolver
>>>> return check_method()
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>>> line 25
>>>> 4, in check
>>>> for pattern in self.url_patterns:
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>>>> line
>>>> 35, in __get__
>>>> res = instance.__dict__[self.na

Re: AttributeError: module 'polls.views' has no attribute 'index'

2021-07-26 Thread Zain
Had the same issue. 

Solved, make sure you run each edited python file during the tutorial. 
I guess it needs to update. All I know is this fixed the issue.

On Monday, April 19, 2021 at 2:07:34 AM UTC+10 avi.me...@gmail.com wrote:

> I followed the same tutorial on 17th April 2021 with Python 3.9.2 and 
> Django 3.2 and have exactly the same problems as mentioned above.
>
> path('', views.index, name='index'),
>
> AttributeError: module 'polls.views' has no attribute 'index'
>
> any help on how can I debug this? I am a django noob
>
> On Wednesday, 19 April 2017 at 16:31:59 UTC+2 lce...@gmail.com wrote:
>
>> Thanks for your reploy.
>>
>> Actually I followed the tutorial exactly.
>>
>> My polls/views.py has:
>>
>> from django.http import HttpResponse
>>
>>
>> def index(request):
>> return HttpResponse("Hello, world. You're at the polls index.")
>>
>> My polls/urls.py has:
>>
>> from django.conf.urls import url
>>
>> from . import views
>>
>> urlpatterns = [
>> url(r'^$', views.index, name='index'),
>> ]
>>
>>
>> On Wednesday, 19 April 2017 15:43:57 UTC+2, m712 - Developer wrote:
>>
>>> You didn't give us enough info, but I am thinking that you don't have an 
>>> index() function in your polls/views.py. Start the tutorial from the 
>>> beginning and follow it closely.
>>> On Apr 19, 2017 4:17 PM, Billy Lin  wrote:
>>>
>>> I'm following the getting started tutorial 01 and running into issues 
>>> after creating the polls app. Can someone please help?
>>>
>>> I'm using Python 3.6.1 and Django 1.11.
>>>
>>> Here's the detailed trace:
>>>
>>> Performing system checks...
>>> Unhandled exception in thread started by >> check_errors..wrapper at 0x04222810>
>>> Traceback (most recent call last):
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py",
>>>  
>>> line
>>> 227, in wrapper
>>> fn(*args, **kwargs)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
>>> nserver.py", line 125, in inner_run
>>> self.check(display_num_errors=True)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>>  
>>> l
>>> ine 359, in check
>>> include_deployment_checks=include_deployment_checks,
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>>  
>>> l
>>> ine 346, in _run_checks
>>> return checks.run_checks(**kwargs)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py",
>>>  
>>> l
>>> ine 81, in run_checks
>>> new_errors = check(app_configs=app_configs)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>>  
>>> line
>>> 16, in check_url_config
>>> return check_resolver(resolver)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>>  
>>> line
>>> 26, in check_resolver
>>> return check_method()
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>>  
>>> line 25
>>> 4, in check
>>> for pattern in self.url_patterns:
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>>>  
>>> line
>>> 35, in __get__
>>> res = instance.__dict__[self.name] = self.func(instance)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>>  
>>> line 40
>>> 5, in url_patterns
>>> patterns = getattr(self.urlconf_module, "urlpatterns", 
>>> self.urlconf_module)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",

Re: AttributeError: module 'polls.views' has no attribute 'index'

2021-04-22 Thread David Nugent
On Mon, Apr 19, 2021 at 2:07 AM Avi Mehenwal  wrote:

> I followed the same tutorial on 17th April 2021 with Python 3.9.2 and
> Django 3.2 and have exactly the same problems as mentioned above.
>
> path('', views.index, name='index'),
> AttributeError: module 'polls.views' has no attribute 'index'
>
> any help on how can I debug this? I am a django noob
>

We all started out that way.

>From the error message, assuming views it is defined as:

from . import views

or, maybe

from polls import views

it means that python cannot find the function index() in the views module.

Regards

-- 
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/CAE5VhgUckZZtR%2BVBmW6ungOQ8uBowyE%2BSLG%3DVg%3DuqZVZmw275w%40mail.gmail.com.


Re: AttributeError: module 'polls.views' has no attribute 'index'

2021-04-18 Thread Avi Mehenwal
I followed the same tutorial on 17th April 2021 with Python 3.9.2 and 
Django 3.2 and have exactly the same problems as mentioned above.

path('', views.index, name='index'),
AttributeError: module 'polls.views' has no attribute 'index'

any help on how can I debug this? I am a django noob

On Wednesday, 19 April 2017 at 16:31:59 UTC+2 lce...@gmail.com wrote:

> Thanks for your reploy.
>
> Actually I followed the tutorial exactly.
>
> My polls/views.py has:
>
> from django.http import HttpResponse
>
>
> def index(request):
> return HttpResponse("Hello, world. You're at the polls index.")
>
> My polls/urls.py has:
>
> from django.conf.urls import url
>
> from . import views
>
> urlpatterns = [
> url(r'^$', views.index, name='index'),
> ]
>
>
> On Wednesday, 19 April 2017 15:43:57 UTC+2, m712 - Developer wrote:
>
>> You didn't give us enough info, but I am thinking that you don't have an 
>> index() function in your polls/views.py. Start the tutorial from the 
>> beginning and follow it closely.
>> On Apr 19, 2017 4:17 PM, Billy Lin  wrote:
>>
>> I'm following the getting started tutorial 01 and running into issues 
>> after creating the polls app. Can someone please help?
>>
>> I'm using Python 3.6.1 and Django 1.11.
>>
>> Here's the detailed trace:
>>
>> Performing system checks...
>> Unhandled exception in thread started by > check_errors..wrapper at 0x04222810>
>> Traceback (most recent call last):
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py",
>>  
>> line
>> 227, in wrapper
>> fn(*args, **kwargs)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
>> nserver.py", line 125, in inner_run
>> self.check(display_num_errors=True)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>  
>> l
>> ine 359, in check
>> include_deployment_checks=include_deployment_checks,
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>  
>> l
>> ine 346, in _run_checks
>> return checks.run_checks(**kwargs)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py",
>>  
>> l
>> ine 81, in run_checks
>> new_errors = check(app_configs=app_configs)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>  
>> line
>> 16, in check_url_config
>> return check_resolver(resolver)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>  
>> line
>> 26, in check_resolver
>> return check_method()
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>  
>> line 25
>> 4, in check
>> for pattern in self.url_patterns:
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>>  
>> line
>> 35, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>  
>> line 40
>> 5, in url_patterns
>> patterns = getattr(self.urlconf_module, "urlpatterns", 
>> self.urlconf_module)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>>  
>> line
>> 35, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>  
>> line 39
>> 8, in urlconf_module
>> return import_module(self.urlconf_name)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py",
>>  
>> line 126, in import_modu
>> le
>> return _bootstrap._gcd_import(name[level:], package, level)
>>   File "", line 978, in _gcd_import
>>

Django 3.2 AttributeError: 'TextField' object has no attribute 'db_collation'

2021-04-07 Thread Asaduzzaman Sohel
I've an existing project on Django 3.1 and I upgraded my project to Django 
3.2. I created an app called payment on my project. But When I make 
migrations. It trow an error 
```AttributeError: 'TextField' object has no attribute 'db_collation'```
```
from django.db import models
from django.conf import settings
from django.utils.translation import gettext_lazy as _
# Create your models here.
from simple_history.models import HistoricalRecords


class TransactionType(models.TextChoices):
CASH_IN = 'IN', _('Cash In')
CASH_OUT = 'OUT', _('Cash Out')


class TransactionMethod(models.TextChoices):
STUDENT_TR = 'STT', _('Student Transaction')
BANK_TR = 'BKT', _('Bank Transaction')
SCHOOL_TR = 'SLT', _('School Transaction')
Teacher_TR = 'TRT', _('Teacher Transaction')
DONATE_TR = 'DET', _('Donate Transaction')


class Payment(models.Model):
id = models.AutoField(primary_key=True)
created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
   on_delete=models.PROTECT,
   related_name="created_by")
updated_by = models.ForeignKey(settings.AUTH_USER_MODEL,
   on_delete=models.PROTECT,
   related_name="updated_by")
transaction_amount = models.FloatField("Transaction amount")
transaction_type = models.CharField(max_length=3, 
choices=TransactionType.choices, default=TransactionType.CASH_IN,)
transaction_method = models.CharField(max_length=3, 
choices=TransactionMethod.choices, default=TransactionMethod.STUDENT_TR,)
transaction_note = models.CharField(null=True, blank=True, 
max_length=200)
is_approved = models.BooleanField(default=False)
is_approved_by_user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.PROTECT,
related_name="approved_by",
null=True,
blank=True)
created_at = models.DateTimeField(auto_now=True, blank=True, null=True)
updated_at = models.DateTimeField(auto_now_add=True, blank=True, 
null=True)
history = HistoricalRecords()


```

Full error message 
```Traceback (most recent call last):
  File "manage.py", line 22, in 
main()
  File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 419, in execute_from_command_line
utility.execute()
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 354, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 398, in execute
output = self.handle(*args, **options)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 89, in wrapped
res = handle_func(*args, **kwargs)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py",
 
line 150, in handle
ProjectState.from_apps(apps),
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/db/migrations/state.py",
 
line 220, in from_apps
model_state = ModelState.from_model(model)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/db/migrations/state.py",
 
line 407, in from_model
fields.append((name, field.clone()))
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
 
line 512, in clone
name, path, args, kwargs = self.deconstruct()
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
 
line 2173, in deconstruct
if self.db_collation:
AttributeError: 'TextField' object has no attribute 'db_collation'
```
stackoverflowlink: 
https://stackoverflow.com/questions/66981658/django-3-2-attributeerror-textfield-object-has-no-attribute-db-collation

-- 
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/1c70a09d-e14f-4a38-bcf5-90dd4ac327fen%40googlegroups.com.


Re: AttributeError: 'customer' object has no attribute 'is_authenticated'

2021-04-01 Thread Gabriel Araya Garcia
Why you don't explain better your problem ? When appear that

Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos




El jue, 1 abr 2021 a las 15:43, Mahendra ()
escribió:

> I think given name is wrong Hlo do you have any idea posting form data?
>
> Mahendra Yadav
>
> On Thu, 1 Apr 2021, 22:32 Salima Begum, 
> wrote:
>
>> Hi all,
>>
>> How to solve this errors
>> ```
>> AttributeError: 'customer' object has no attribute 'is_authenticated'
>> ```
>>
>> ```
>>   AttributeError: 'customer' object has no attribute 'is_anonymous'
>> ```
>>
>> How can I solve this above errors. Help me.
>>
>> Thanks
>> ~Salima
>>
>> --
>> 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/CAMSz6bkcDZeFhhStQeTOeLAst1kNA1xa%2BuVsd0sva1JA0P8kMw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMSz6bkcDZeFhhStQeTOeLAst1kNA1xa%2BuVsd0sva1JA0P8kMw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/CAN-6G3x_vyJcBsfQ-pfN3AgK1-V_SVPSt3Fk6h%2ByLnU4iKorkg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAN-6G3x_vyJcBsfQ-pfN3AgK1-V_SVPSt3Fk6h%2ByLnU4iKorkg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAKVvSDCxW%3DcKpko_oxduQkZyCO00t1tRjbJ55fBTf%3DhjZj6-3g%40mail.gmail.com.


Re: AttributeError: 'customer' object has no attribute 'is_authenticated'

2021-04-01 Thread sebasti...@gmail.com
I think this must be wrong. Only User instance have a method 
is_authenticated. Here a example for views:

if request.user.is_authenticated:
   pass

sali...@rohteksolutions.com schrieb am Donnerstag, 1. April 2021 um 
19:03:36 UTC+2:

> Hi all,
>
> How to solve this errors
> ```
> AttributeError: 'customer' object has no attribute 'is_authenticated'
> ```
>
> ```
>   AttributeError: 'customer' object has no attribute 'is_anonymous'  
> ```
>
> How can I solve this above errors. Help me.
>
> Thanks
> ~Salima
>

-- 
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/3e9ee7e0-0616-4150-a778-75e9660b5fb1n%40googlegroups.com.


Re: AttributeError: 'customer' object has no attribute 'is_authenticated'

2021-04-01 Thread Mahendra
I think given name is wrong Hlo do you have any idea posting form data?

Mahendra Yadav

On Thu, 1 Apr 2021, 22:32 Salima Begum, 
wrote:

> Hi all,
>
> How to solve this errors
> ```
> AttributeError: 'customer' object has no attribute 'is_authenticated'
> ```
>
> ```
>   AttributeError: 'customer' object has no attribute 'is_anonymous'
> ```
>
> How can I solve this above errors. Help me.
>
> Thanks
> ~Salima
>
> --
> 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/CAMSz6bkcDZeFhhStQeTOeLAst1kNA1xa%2BuVsd0sva1JA0P8kMw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMSz6bkcDZeFhhStQeTOeLAst1kNA1xa%2BuVsd0sva1JA0P8kMw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAN-6G3x_vyJcBsfQ-pfN3AgK1-V_SVPSt3Fk6h%2ByLnU4iKorkg%40mail.gmail.com.


AttributeError: 'customer' object has no attribute 'is_authenticated'

2021-04-01 Thread Salima Begum
Hi all,

How to solve this errors
```
AttributeError: 'customer' object has no attribute 'is_authenticated'
```

```
  AttributeError: 'customer' object has no attribute 'is_anonymous'
```

How can I solve this above errors. Help me.

Thanks
~Salima

-- 
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/CAMSz6bkcDZeFhhStQeTOeLAst1kNA1xa%2BuVsd0sva1JA0P8kMw%40mail.gmail.com.


Re: AttributeError: 'NoneType' object has no attribute 'replace'

2021-02-23 Thread Kasper Laudrup

On 23/02/2021 17.56, Abnilson Rafael wrote:

Hi,
I'm getting error above when I try to this program:


The get_language() member function/method of your "translation" 
object/variable doesn't return anything and you most likely expect it to 
return a string.


Try to figure out how that could happen and you'll most likely have the 
solution.


Hard to help you any further without knowing anything about what you are 
trying to achieve.


Kind regards,

Kasper Laudrup

--
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/b8f083f9-5640-c8d0-7043-88a7a646ce85%40stacktrace.dk.


Re: AttributeError: type object 'User' has no attribute 'objects'

2021-02-22 Thread georgia...@gmail.com
Sorry I have the same similar problem, please help, thank you!!
I put the question on stackoverflow, there are questions and reference 
materials attached.

So you can click the link to enter : 
https://stackoverflow.com/questions/66310704/attributeerror-type-object-product-has-no-attribute-objects

for
File "C:\Users\georgiawang\PycharmProjects\libshopapp\store\views.py", line 
195, in updateItem** product = Product.objects.get(id=productId) 
AttributeError: type object 'Product' has no attribute 'objects'**
sagar ninave 在 2020年4月27日 星期一下午11:10:21 [UTC+8] 的信中寫道:

> i got answer 
>
> i was doing this:
> from .models import User
> user = User.objects.filter(pk=user_id) 
>
> instead i do this:
> from .models import MyUser
> user =  MyUser.objects.filter(pk=user_id) 
>
>
> error gone
>
>
>
>
> On Mon, Apr 27, 2020 at 6:57 AM Kasper Laudrup  
> wrote:
>
>> Hi Sagar,
>>
>> On 27/04/2020 14.25, sagar ninave wrote:
>> > i am getting this error
>> > 
>>
>> It's hard to guess since you don't show where your User class comes
>> from, but it doesn't seem like its inheriting from the Django model class.
>>
>> The error message is quite clear. Look at your User model.
>>
>> Btw. just a hint: please try to "return early". It is quite difficult to
>> see which else branches are connected to which if statements in the code
>> following the one throwing the exception.
>>
>> Kind regards,
>>
>> Kasper Laudrup
>>
>> -- 
>> 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/96eba188-98e9-4284-cbab-a3aa3c909c05%40stacktrace.dk
>> .
>>
>
>
> -- 
>
> <https://about.me/sagarninave?promo=email_sig_source=product_medium=email_sig_campaign=gmail_api_content=thumb>
>  
> sagar ninave
> about.me/sagarninave 
> <https://about.me/sagarninave?promo=email_sig_source=product_medium=email_sig_campaign=gmail_api_content=thumb>
>  
>

-- 
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/6c631cbb-2294-4350-b136-e6ef38d9f022n%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-15 Thread Mislav Jurić
Thank you for your suggestion. I will use the username, as it is unique as 
well.

Best,
Mislav

Dana ponedjeljak, 14. rujna 2020. u 19:45:36 UTC+2 korisnik coolguy napisao 
je:

> If i had to stick to your code then i would save the file with 
> instance.username. username is available and folder would be readable as 
> well.
>
> However, as i mentioned in my last reply and seems you agreed, 
> save/register the employee and then have employee upload the picture.
>
> On Monday, September 14, 2020 at 8:20:21 AM UTC-4 mislav@gmail.com 
> wrote:
>
>> What I can do is first register the employee via a register form, then 
>> once he logs in ask him/her for the profile picture. *Can I do that this 
>> way? *
>>
>> If I do it this way, I don't have to change my model in any way.
>>
>> Dana nedjelja, 13. rujna 2020. u 18:11:18 UTC+2 korisnik coolguy napisao 
>> je:
>>
>>> not sure about the purpose of showing that example in Django 
>>> documentation while its comments are clear that "object will not have been 
>>> saved to the database yet, so if it uses the default AutoField, *it 
>>> might not yet have a value for its primary key field*."
>>>
>>> so that's the reason for having None with file path.
>>>
>>> In this approach what i can see is to save the employee first without 
>>> file and then edit and select the file.
>>>
>>> I would not use this approach and rather keep it simple as followed:
>>>
>>> photo = models.ImageField(upload_to='employee/%Y/%m/%d/', blank=True)
>>>
>>> On Sunday, September 13, 2020 at 5:41:18 AM UTC-4 mislav@gmail.com 
>>> wrote:
>>>
>>>> Hey coolguy,
>>>>
>>>> thanks for responding. After I changed that line as you suggested that 
>>>> error is solved, *but when I add the user through the admin interface, 
>>>> I get None as the ID* (the folder that gets created in the 
>>>> */media/users* is titled *None*). I'm not sure if this is expected 
>>>> behavior.
>>>>
>>>> I haven't added the registration or the login yet, so maybe the ID gets 
>>>> a value when someone is actually registering.
>>>>
>>>> Let me know.
>>>>
>>>> Best,
>>>> Mislav
>>>>
>>>> Dana subota, 12. rujna 2020. u 21:57:21 UTC+2 korisnik coolguy napisao 
>>>> je:
>>>>
>>>>> I wanted to see your model to understand but i realized after my last 
>>>>> post that you are using "instance.user.id" while your employee 
>>>>> instance does not have user field. (had to go somewhere urgently) >>> 
>>>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>>>> instance.user.id, extension)  
>>>>>
>>>>> change it as follow and remove user from it.
>>>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>>>> instance.id <http://instance.user.id/>, extension)  
>>>>>
>>>>> It should work...
>>>>>
>>>>> On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 
>>>>> mislav@gmail.com wrote:
>>>>>
>>>>>> coolguy here is the complete Employee model:
>>>>>>
>>>>>> class Employee(models.Model): #TODO: Double-check this
>>>>>> username = models.CharField(max_length=50, unique=True)
>>>>>> email = models.EmailField()
>>>>>> password = models.CharField(max_length=50)
>>>>>> first_name = models.CharField(max_length=150)
>>>>>> last_name = models.CharField(max_length=100)
>>>>>> website = models.URLField(max_length=200, blank=True)
>>>>>>
>>>>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>>>>> blank=True, null=True)
>>>>>> 
>>>>>> def __str__(self):
>>>>>> return str(self.first_name) + str(self.last_name)
>>>>>>
>>>>>> *Why do I need the foreign key to User in the first place?* I don't 
>>>>>> recall seing the foreign key to User in any one of the tutorials.
>>>>>> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy 
>>>>>> napisao je:
>>>>>>
>>>>>>> Please share the complete employee model. It seems you are 

Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-14 Thread coolguy
If i had to stick to your code then i would save the file with 
instance.username. username is available and folder would be readable as 
well.

However, as i mentioned in my last reply and seems you agreed, 
save/register the employee and then have employee upload the picture.

On Monday, September 14, 2020 at 8:20:21 AM UTC-4 mislav@gmail.com 
wrote:

> What I can do is first register the employee via a register form, then 
> once he logs in ask him/her for the profile picture. *Can I do that this 
> way? *
>
> If I do it this way, I don't have to change my model in any way.
>
> Dana nedjelja, 13. rujna 2020. u 18:11:18 UTC+2 korisnik coolguy napisao 
> je:
>
>> not sure about the purpose of showing that example in Django 
>> documentation while its comments are clear that "object will not have been 
>> saved to the database yet, so if it uses the default AutoField, *it 
>> might not yet have a value for its primary key field*."
>>
>> so that's the reason for having None with file path.
>>
>> In this approach what i can see is to save the employee first without 
>> file and then edit and select the file.
>>
>> I would not use this approach and rather keep it simple as followed:
>>
>> photo = models.ImageField(upload_to='employee/%Y/%m/%d/', blank=True)
>>
>> On Sunday, September 13, 2020 at 5:41:18 AM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> Hey coolguy,
>>>
>>> thanks for responding. After I changed that line as you suggested that 
>>> error is solved, *but when I add the user through the admin interface, 
>>> I get None as the ID* (the folder that gets created in the 
>>> */media/users* is titled *None*). I'm not sure if this is expected 
>>> behavior.
>>>
>>> I haven't added the registration or the login yet, so maybe the ID gets 
>>> a value when someone is actually registering.
>>>
>>> Let me know.
>>>
>>> Best,
>>> Mislav
>>>
>>> Dana subota, 12. rujna 2020. u 21:57:21 UTC+2 korisnik coolguy napisao 
>>> je:
>>>
>>>> I wanted to see your model to understand but i realized after my last 
>>>> post that you are using "instance.user.id" while your employee 
>>>> instance does not have user field. (had to go somewhere urgently) >>> 
>>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>>> instance.user.id, extension)  
>>>>
>>>> change it as follow and remove user from it.
>>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>>> instance.id <http://instance.user.id/>, extension)  
>>>>
>>>> It should work...
>>>>
>>>> On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 
>>>> mislav@gmail.com wrote:
>>>>
>>>>> coolguy here is the complete Employee model:
>>>>>
>>>>> class Employee(models.Model): #TODO: Double-check this
>>>>> username = models.CharField(max_length=50, unique=True)
>>>>> email = models.EmailField()
>>>>> password = models.CharField(max_length=50)
>>>>> first_name = models.CharField(max_length=150)
>>>>> last_name = models.CharField(max_length=100)
>>>>> website = models.URLField(max_length=200, blank=True)
>>>>>
>>>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>>>> blank=True, null=True)
>>>>> 
>>>>> def __str__(self):
>>>>> return str(self.first_name) + str(self.last_name)
>>>>>
>>>>> *Why do I need the foreign key to User in the first place?* I don't 
>>>>> recall seing the foreign key to User in any one of the tutorials.
>>>>> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao 
>>>>> je:
>>>>>
>>>>>> Please share the complete employee model. It seems you are missing 
>>>>>> User foreign key in it.
>>>>>>
>>>>>> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 
>>>>>> mislav@gmail.com wrote:
>>>>>>
>>>>>>> Hey guys,
>>>>>>>
>>>>>>> I have the following code in models.py file in one of my apps:
>>>>>>>
>>>>>>> def get_upload_path(instance, filename):
>>>>>>> extension = filename.spl

Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-14 Thread Mislav Jurić
What I can do is first register the employee via a register form, then once 
he logs in ask him/her for the profile picture. *Can I do that this way? *

If I do it this way, I don't have to change my model in any way.

Dana nedjelja, 13. rujna 2020. u 18:11:18 UTC+2 korisnik coolguy napisao je:

> not sure about the purpose of showing that example in Django documentation 
> while its comments are clear that "object will not have been saved to the 
> database yet, so if it uses the default AutoField, *it might not yet have 
> a value for its primary key field*."
>
> so that's the reason for having None with file path.
>
> In this approach what i can see is to save the employee first without file 
> and then edit and select the file.
>
> I would not use this approach and rather keep it simple as followed:
>
> photo = models.ImageField(upload_to='employee/%Y/%m/%d/', blank=True)
>
> On Sunday, September 13, 2020 at 5:41:18 AM UTC-4 mislav@gmail.com 
> wrote:
>
>> Hey coolguy,
>>
>> thanks for responding. After I changed that line as you suggested that 
>> error is solved, *but when I add the user through the admin interface, I 
>> get None as the ID* (the folder that gets created in the */media/users* 
>> is titled *None*). I'm not sure if this is expected behavior.
>>
>> I haven't added the registration or the login yet, so maybe the ID gets a 
>> value when someone is actually registering.
>>
>> Let me know.
>>
>> Best,
>> Mislav
>>
>> Dana subota, 12. rujna 2020. u 21:57:21 UTC+2 korisnik coolguy napisao je:
>>
>>> I wanted to see your model to understand but i realized after my last 
>>> post that you are using "instance.user.id" while your employee instance 
>>> does not have user field. (had to go somewhere urgently) >>> return 
>>> "employees/media/users/{0}/profile_picture.{1}".format(instance.user.id, 
>>> extension)  
>>>
>>> change it as follow and remove user from it.
>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>> instance.id <http://instance.user.id/>, extension)  
>>>
>>> It should work...
>>>
>>> On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 mislav@gmail.com 
>>> wrote:
>>>
>>>> coolguy here is the complete Employee model:
>>>>
>>>> class Employee(models.Model): #TODO: Double-check this
>>>> username = models.CharField(max_length=50, unique=True)
>>>> email = models.EmailField()
>>>> password = models.CharField(max_length=50)
>>>> first_name = models.CharField(max_length=150)
>>>> last_name = models.CharField(max_length=100)
>>>> website = models.URLField(max_length=200, blank=True)
>>>>
>>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>>> blank=True, null=True)
>>>> 
>>>> def __str__(self):
>>>> return str(self.first_name) + str(self.last_name)
>>>>
>>>> *Why do I need the foreign key to User in the first place?* I don't 
>>>> recall seing the foreign key to User in any one of the tutorials.
>>>> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao 
>>>> je:
>>>>
>>>>> Please share the complete employee model. It seems you are missing 
>>>>> User foreign key in it.
>>>>>
>>>>> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 
>>>>> mislav@gmail.com wrote:
>>>>>
>>>>>> Hey guys,
>>>>>>
>>>>>> I have the following code in models.py file in one of my apps:
>>>>>>
>>>>>> def get_upload_path(instance, filename):
>>>>>> extension = filename.split('.')[-1]
>>>>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>>>>> instance.user.id, extension)
>>>>>>
>>>>>> class Employee(models.Model):
>>>>>> # some attributes here
>>>>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>>>>> blank=True, null=True)
>>>>>>
>>>>>> I am getting the following error when I try to add an Employee via 
>>>>>> the admin interface:
>>>>>>
>>>>>> AttributeError at /admin/employees/employee/add/
>>>>>>
>>>>>> 'Employee' object has no attribute 'user'
>>>>>>
>>>>>> *I don't know where this error is stemming from.* I took the 
>>>>>> get_upload_path function from the official Django FIleField 
>>>>>> documentation 
>>>>>> <https://docs.djangoproject.com/en/3.1/ref/models/fields/#filefield>.
>>>>>>
>>>>>> Any ideas as to what is going on here?
>>>>>>
>>>>>> Best,
>>>>>> Mislav
>>>>>>
>>>>>

-- 
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/428c96ea-d71b-4174-a8e7-ff5ad45f5ec3n%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-13 Thread coolguy
not sure about the purpose of showing that example in Django documentation 
while its comments are clear that "object will not have been saved to the 
database yet, so if it uses the default AutoField, *it might not yet have a 
value for its primary key field*."

so that's the reason for having None with file path.

In this approach what i can see is to save the employee first without file 
and then edit and select the file.

I would not use this approach and rather keep it simple as followed:

photo = models.ImageField(upload_to='employee/%Y/%m/%d/', blank=True)

On Sunday, September 13, 2020 at 5:41:18 AM UTC-4 mislav@gmail.com 
wrote:

> Hey coolguy,
>
> thanks for responding. After I changed that line as you suggested that 
> error is solved, *but when I add the user through the admin interface, I 
> get None as the ID* (the folder that gets created in the */media/users* 
> is titled *None*). I'm not sure if this is expected behavior.
>
> I haven't added the registration or the login yet, so maybe the ID gets a 
> value when someone is actually registering.
>
> Let me know.
>
> Best,
> Mislav
>
> Dana subota, 12. rujna 2020. u 21:57:21 UTC+2 korisnik coolguy napisao je:
>
>> I wanted to see your model to understand but i realized after my last 
>> post that you are using "instance.user.id" while your employee instance 
>> does not have user field. (had to go somewhere urgently) >>> return 
>> "employees/media/users/{0}/profile_picture.{1}".format(instance.user.id, 
>> extension)  
>>
>> change it as follow and remove user from it.
>> return "employees/media/users/{0}/profile_picture.{1}".format(instance.id 
>> <http://instance.user.id/>, extension)  
>>
>> It should work...
>>
>> On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> coolguy here is the complete Employee model:
>>>
>>> class Employee(models.Model): #TODO: Double-check this
>>> username = models.CharField(max_length=50, unique=True)
>>> email = models.EmailField()
>>> password = models.CharField(max_length=50)
>>> first_name = models.CharField(max_length=150)
>>> last_name = models.CharField(max_length=100)
>>> website = models.URLField(max_length=200, blank=True)
>>>
>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>> blank=True, null=True)
>>> 
>>> def __str__(self):
>>> return str(self.first_name) + str(self.last_name)
>>>
>>> *Why do I need the foreign key to User in the first place?* I don't 
>>> recall seing the foreign key to User in any one of the tutorials.
>>> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao 
>>> je:
>>>
>>>> Please share the complete employee model. It seems you are missing User 
>>>> foreign key in it.
>>>>
>>>> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 
>>>> mislav@gmail.com wrote:
>>>>
>>>>> Hey guys,
>>>>>
>>>>> I have the following code in models.py file in one of my apps:
>>>>>
>>>>> def get_upload_path(instance, filename):
>>>>> extension = filename.split('.')[-1]
>>>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>>>> instance.user.id, extension)
>>>>>
>>>>> class Employee(models.Model):
>>>>> # some attributes here
>>>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>>>> blank=True, null=True)
>>>>>
>>>>> I am getting the following error when I try to add an Employee via the 
>>>>> admin interface:
>>>>>
>>>>> AttributeError at /admin/employees/employee/add/
>>>>>
>>>>> 'Employee' object has no attribute 'user'
>>>>>
>>>>> *I don't know where this error is stemming from.* I took the 
>>>>> get_upload_path function from the official Django FIleField 
>>>>> documentation 
>>>>> <https://docs.djangoproject.com/en/3.1/ref/models/fields/#filefield>.
>>>>>
>>>>> Any ideas as to what is going on here?
>>>>>
>>>>> Best,
>>>>> Mislav
>>>>>
>>>>

-- 
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/7daceb0e-c1d5-4b9a-b64b-7dbabec6118fn%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-13 Thread coolguy
May the purpose of showing that example in Django documentation is 
something else. If you read the comments there , there is a potential issue 
that the instance that they suggest to use mostly would have not been 
persisted in the database if AutoField has been used. so there will be 'no' 
id as yet resulting None is being saved with file path.

In this approach what i can see is to save the employee first without file 
and then edit and select the file.

I would not use this approach and rather keep it simple as followed:

photo = models.ImageField(upload_to='employee/%Y/%m/%d/', blank=True)

On Sunday, September 13, 2020 at 5:41:18 AM UTC-4 mislav@gmail.com 
wrote:

> Hey coolguy,
>
> thanks for responding. After I changed that line as you suggested that 
> error is solved, *but when I add the user through the admin interface, I 
> get None as the ID* (the folder that gets created in the */media/users* 
> is titled *None*). I'm not sure if this is expected behavior.
>
> I haven't added the registration or the login yet, so maybe the ID gets a 
> value when someone is actually registering.
>
> Let me know.
>
> Best,
> Mislav
>
> Dana subota, 12. rujna 2020. u 21:57:21 UTC+2 korisnik coolguy napisao je:
>
>> I wanted to see your model to understand but i realized after my last 
>> post that you are using "instance.user.id" while your employee instance 
>> does not have user field. (had to go somewhere urgently) >>> return 
>> "employees/media/users/{0}/profile_picture.{1}".format(instance.user.id, 
>> extension)  
>>
>> change it as follow and remove user from it.
>> return "employees/media/users/{0}/profile_picture.{1}".format(instance.id 
>> <http://instance.user.id/>, extension)  
>>
>> It should work...
>>
>> On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> coolguy here is the complete Employee model:
>>>
>>> class Employee(models.Model): #TODO: Double-check this
>>> username = models.CharField(max_length=50, unique=True)
>>> email = models.EmailField()
>>> password = models.CharField(max_length=50)
>>> first_name = models.CharField(max_length=150)
>>> last_name = models.CharField(max_length=100)
>>> website = models.URLField(max_length=200, blank=True)
>>>
>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>> blank=True, null=True)
>>> 
>>> def __str__(self):
>>> return str(self.first_name) + str(self.last_name)
>>>
>>> *Why do I need the foreign key to User in the first place?* I don't 
>>> recall seing the foreign key to User in any one of the tutorials.
>>> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao 
>>> je:
>>>
>>>> Please share the complete employee model. It seems you are missing User 
>>>> foreign key in it.
>>>>
>>>> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 
>>>> mislav@gmail.com wrote:
>>>>
>>>>> Hey guys,
>>>>>
>>>>> I have the following code in models.py file in one of my apps:
>>>>>
>>>>> def get_upload_path(instance, filename):
>>>>> extension = filename.split('.')[-1]
>>>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>>>> instance.user.id, extension)
>>>>>
>>>>> class Employee(models.Model):
>>>>> # some attributes here
>>>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>>>> blank=True, null=True)
>>>>>
>>>>> I am getting the following error when I try to add an Employee via the 
>>>>> admin interface:
>>>>>
>>>>> AttributeError at /admin/employees/employee/add/
>>>>>
>>>>> 'Employee' object has no attribute 'user'
>>>>>
>>>>> *I don't know where this error is stemming from.* I took the 
>>>>> get_upload_path function from the official Django FIleField 
>>>>> documentation 
>>>>> <https://docs.djangoproject.com/en/3.1/ref/models/fields/#filefield>.
>>>>>
>>>>> Any ideas as to what is going on here?
>>>>>
>>>>> Best,
>>>>> Mislav
>>>>>
>>>>

-- 
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/e8aa1e36-8364-4d0a-b325-f79974763c02n%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-13 Thread Mislav Jurić
Hey coolguy,

thanks for responding. After I changed that line as you suggested that 
error is solved, *but when I add the user through the admin interface, I 
get None as the ID* (the folder that gets created in the */media/users* is 
titled *None*). I'm not sure if this is expected behavior.

I haven't added the registration or the login yet, so maybe the ID gets a 
value when someone is actually registering.

Let me know.

Best,
Mislav

Dana subota, 12. rujna 2020. u 21:57:21 UTC+2 korisnik coolguy napisao je:

> I wanted to see your model to understand but i realized after my last post 
> that you are using "instance.user.id" while your employee instance does 
> not have user field. (had to go somewhere urgently) >>> return 
> "employees/media/users/{0}/profile_picture.{1}".format(instance.user.id, 
> extension)  
>
> change it as follow and remove user from it.
> return "employees/media/users/{0}/profile_picture.{1}".format(instance.id 
> <http://instance.user.id/>, extension)  
>
> It should work...
>
> On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 mislav@gmail.com 
> wrote:
>
>> coolguy here is the complete Employee model:
>>
>> class Employee(models.Model): #TODO: Double-check this
>> username = models.CharField(max_length=50, unique=True)
>> email = models.EmailField()
>> password = models.CharField(max_length=50)
>> first_name = models.CharField(max_length=150)
>> last_name = models.CharField(max_length=100)
>> website = models.URLField(max_length=200, blank=True)
>>
>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>> blank=True, null=True)
>> 
>> def __str__(self):
>> return str(self.first_name) + str(self.last_name)
>>
>> *Why do I need the foreign key to User in the first place?* I don't 
>> recall seing the foreign key to User in any one of the tutorials.
>> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao je:
>>
>>> Please share the complete employee model. It seems you are missing User 
>>> foreign key in it.
>>>
>>> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 mislav@gmail.com 
>>> wrote:
>>>
>>>> Hey guys,
>>>>
>>>> I have the following code in models.py file in one of my apps:
>>>>
>>>> def get_upload_path(instance, filename):
>>>> extension = filename.split('.')[-1]
>>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>>> instance.user.id, extension)
>>>>
>>>> class Employee(models.Model):
>>>> # some attributes here
>>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>>> blank=True, null=True)
>>>>
>>>> I am getting the following error when I try to add an Employee via the 
>>>> admin interface:
>>>>
>>>> AttributeError at /admin/employees/employee/add/
>>>>
>>>> 'Employee' object has no attribute 'user'
>>>>
>>>> *I don't know where this error is stemming from.* I took the 
>>>> get_upload_path function from the official Django FIleField 
>>>> documentation 
>>>> <https://docs.djangoproject.com/en/3.1/ref/models/fields/#filefield>.
>>>>
>>>> Any ideas as to what is going on here?
>>>>
>>>> Best,
>>>> Mislav
>>>>
>>>

-- 
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/f8662343-2ae8-40f9-a37f-d49bcc8c58c8n%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread coolguy
I wanted to see your model to understand but i realized after my last post 
that you are using "instance.user.id" while your employee instance does not 
have user field. (had to go somewhere urgently) >>> return 
"employees/media/users/{0}/profile_picture.{1}".format(instance.user.id, 
extension)  

change it as follow and remove user from it.
return "employees/media/users/{0}/profile_picture.{1}".format(instance.id 
<http://instance.user.id/>, extension)  

It should work...

On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 mislav@gmail.com 
wrote:

> coolguy here is the complete Employee model:
>
> class Employee(models.Model): #TODO: Double-check this
> username = models.CharField(max_length=50, unique=True)
> email = models.EmailField()
> password = models.CharField(max_length=50)
> first_name = models.CharField(max_length=150)
> last_name = models.CharField(max_length=100)
> website = models.URLField(max_length=200, blank=True)
>
> profile_picture = models.ImageField(upload_to=get_upload_path, 
> blank=True, null=True)
> 
> def __str__(self):
> return str(self.first_name) + str(self.last_name)
>
> *Why do I need the foreign key to User in the first place?* I don't 
> recall seing the foreign key to User in any one of the tutorials.
> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao je:
>
>> Please share the complete employee model. It seems you are missing User 
>> foreign key in it.
>>
>> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> Hey guys,
>>>
>>> I have the following code in models.py file in one of my apps:
>>>
>>> def get_upload_path(instance, filename):
>>> extension = filename.split('.')[-1]
>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>> instance.user.id, extension)
>>>
>>> class Employee(models.Model):
>>> # some attributes here
>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>> blank=True, null=True)
>>>
>>> I am getting the following error when I try to add an Employee via the 
>>> admin interface:
>>>
>>> AttributeError at /admin/employees/employee/add/
>>>
>>> 'Employee' object has no attribute 'user'
>>>
>>> *I don't know where this error is stemming from.* I took the 
>>> get_upload_path function from the official Django FIleField 
>>> documentation 
>>> <https://docs.djangoproject.com/en/3.1/ref/models/fields/#filefield>.
>>>
>>> Any ideas as to what is going on here?
>>>
>>> Best,
>>> Mislav
>>>
>>

-- 
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/8f08f03a-9617-48b9-bfdb-d00e44652cf1n%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread Mislav Jurić
coolguy here is the complete Employee model:

class Employee(models.Model): #TODO: Double-check this
username = models.CharField(max_length=50, unique=True)
email = models.EmailField()
password = models.CharField(max_length=50)
first_name = models.CharField(max_length=150)
last_name = models.CharField(max_length=100)
website = models.URLField(max_length=200, blank=True)
profile_picture = models.ImageField(upload_to=get_upload_path, 
blank=True, null=True)

def __str__(self):
return str(self.first_name) + str(self.last_name)

*Why do I need the foreign key to User in the first place?* I don't recall 
seing the foreign key to User in any one of the tutorials.
Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao je:

> Please share the complete employee model. It seems you are missing User 
> foreign key in it.
>
> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 mislav@gmail.com 
> wrote:
>
>> Hey guys,
>>
>> I have the following code in models.py file in one of my apps:
>>
>> def get_upload_path(instance, filename):
>> extension = filename.split('.')[-1]
>> return "employees/media/users/{0}/profile_picture.{1}".format(
>> instance.user.id, extension)
>>
>> class Employee(models.Model):
>> # some attributes here
>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>> blank=True, null=True)
>>
>> I am getting the following error when I try to add an Employee via the 
>> admin interface:
>>
>> AttributeError at /admin/employees/employee/add/
>>
>> 'Employee' object has no attribute 'user'
>>
>> *I don't know where this error is stemming from.* I took the 
>> get_upload_path function from the official Django FIleField documentation 
>> <https://docs.djangoproject.com/en/3.1/ref/models/fields/#filefield>.
>>
>> Any ideas as to what is going on here?
>>
>> Best,
>> Mislav
>>
>

-- 
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/c0e9382d-62d2-4c49-bb83-e3a985d26749n%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread coolguy
Please share the complete employee model. It seems you are missing User 
foreign key in it.

On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 mislav@gmail.com 
wrote:

> Hey guys,
>
> I have the following code in models.py file in one of my apps:
>
> def get_upload_path(instance, filename):
> extension = filename.split('.')[-1]
> return "employees/media/users/{0}/profile_picture.{1}".format(
> instance.user.id, extension)
>
> class Employee(models.Model):
> # some attributes here
> profile_picture = models.ImageField(upload_to=get_upload_path, 
> blank=True, null=True)
>
> I am getting the following error when I try to add an Employee via the 
> admin interface:
>
> AttributeError at /admin/employees/employee/add/
>
> 'Employee' object has no attribute 'user'
>
> *I don't know where this error is stemming from.* I took the 
> get_upload_path function from the official Django FIleField documentation 
> <https://docs.djangoproject.com/en/3.1/ref/models/fields/#filefield>.
>
> Any ideas as to what is going on here?
>
> Best,
> Mislav
>

-- 
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/7f3940db-9144-4b68-bd83-095322b51af2n%40googlegroups.com.


AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread Mislav Jurić
Hey guys,

I have the following code in models.py file in one of my apps:

def get_upload_path(instance, filename):
extension = filename.split('.')[-1]
return "employees/media/users/{0}/profile_picture.{1}".format(
instance.user.id, extension)

class Employee(models.Model):
# some attributes here
profile_picture = models.ImageField(upload_to=get_upload_path,
blank=True, null=True)

I am getting the following error when I try to add an Employee via the
admin interface:

AttributeError at /admin/employees/employee/add/

'Employee' object has no attribute 'user'

*I don't know where this error is stemming from.* I took the
get_upload_path function from the official Django FIleField documentation
<https://docs.djangoproject.com/en/3.1/ref/models/fields/#filefield>.

Any ideas as to what is going on here?

Best,
Mislav

-- 
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/CABTqP_FcyzEXhtyBM--khtnsdHhfszi9vtmt-bY3TUsU0KWmLg%40mail.gmail.com.


Re: AttributeError when returning post.title in a comment model

2020-05-31 Thread Julio Cojom
Try '{0}-{1}'.format(var1, var2)

Check in the console in what line it's throwing the attribute error

Rewards

El vie., 29 de mayo de 2020 5:10 p. m., Ahmed Khairy <
ahmed.heshamel...@gmail.com> escribió:

> I was working on a comment section for post and was getting an
> AttributeError when I return return '{}-{}'.format(self.post.title,
> str(self.user.username)) in the comment model
>
> I am trying to link users and posts to the comment I am getting the same
> error
>
> Here is the Models.py
>
> class Comment(models.Model):
> post = models.ForeignKey(Post, on_delete=models.CASCADE)
> user = models.ForeignKey(User, on_delete=models.CASCADE)
> content = models.TextField(max_length=160)
> timestamp = models.DateTimeField(auto_now_add=True)
>
> def __str__(self):
> return '{}-{}'.format(self.post.title, str(self.user.username))
>
> Here is the views.py:
>
> class PostDetailView(DetailView):
> model = Post
> template_name = "post_detail.html"
>
> def get_context_data(self, *args, **kwargs):
> context = super(PostDetailView, self).get_context_data()
> post = get_object_or_404(Post, slug=self.kwargs['slug'])
> comments = Comment.objects.filter(post=post).order_by('-id')
> total_likes = post.total_likes()
> liked = False
> if post.likes.filter(id=self.request.user.id).exists():
> liked = True
>
> if self.request.method == 'POST':
> comment_form = CommentForm(self.request.POST or None)
> if comment_form.is_valid():
> content = self.request.POST.get('content')
> comment = Comment.objects.create(
> post=post, user=request.user, content=content)
> comment.save()
> return HttpResponseRedirect("post_detail.html")
> else:
> comment_form = CommentForm()
>
> context["total_likes"] = total_likes
> context["liked"] = liked
> context["comments"] = comments
> context["comment_form"] = comment_form
> return context
>
>
> class PostCommentCreateView(LoginRequiredMixin, CreateView):
> model = Comment
> form_class = CommentForm
>
>
> --
> 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/9e84bb03-ca66-4517-ab34-8d723a457b9f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9e84bb03-ca66-4517-ab34-8d723a457b9f%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAHRQUHki1Fk2s1a9ws4vB7yhfaLFhyboOVwvPSSVG87BSo0%3DtA%40mail.gmail.com.


Re: Possible Bug? AttributeError: 'HttpResponse' object has no attribute '_resource_closers'

2020-05-30 Thread Tim Allen
Thanks for the reply, my friend. Unfortunately, no new middleware has been 
added. Some folks have said clearing the Django cache(s) worked, but it 
hasn't for me.

I've long been a mod_wsgi user, but I think it is time to move on to 
gunicorn, so I've started moving in that direction rather than sinking a 
lot more time here.

On Saturday, May 16, 2020 at 5:02:32 PM UTC-4, jlgimeno71 wrote:
>
>
>
> On Sat, May 16, 2020 at 12:06 PM Tim Allen  > wrote:
>
>> I posted this to Stack Overflow first, thinking it might be a problem 
>> with `mod_wsgi`, but people using Gunicorn have seen the issue too. Here's 
>> a link to the question on Stack Overflow:
>>
>>
>> https://stackoverflow.com/questions/61295971/django-3-0-5-with-mod-wsgi-attributeerror-httpresponse-object-has-no-attribu
>>
>> Unfortunately, purging my cache hasn't fixed the problem like it did for 
>> a commenter on the question, so I'm asking here for amplification. Here's 
>> the text of the post:
>>
>> I'm getting an error when I deploy Django 3.0.5 under mod_wsgi:  
>> AttributeError: 
>> 'HttpResponse' object has no attribute '_resource_closers'. I'm running:
>>
>>- Python: 3.6.8
>>- Django: 3.0.5
>>- Apache: 2.4.6
>>- mod_wsgi: 4.6.2
>>
>> Here's the basics of the view causing the error; nothing too exotic (I've 
>> simplified the code around meetings_struct):
>>
>>
>> class MeetingsAPIView(MeetingsBaseView):
>> def get(self, request, *args, **kwargs):
>> meetings = self.get_meetings()
>> meetings_struct = []
>>
>> for meeting in meetings:
>> meetings_struct.append({
>> "id": meeting.id,
>> "name": meeting.title,
>> "slug": meeting.slug,
>> })
>>
>> return HttpResponse(meetings_struct, content_type="application/json")
>>
>>
>> If I activate the venv and use runserver manually on the server on port 
>> 80, the same view does not give an error. When the same code and venv are 
>> running under Apache, here's the error from Apache's logs:
>>
>>
>> [Sat Apr 18 16:11:30.683980 2020] [wsgi:error] [pid 4154] [remote 
>> 100.19.146.139:54397] mod_wsgi (pid=4154): Exception occurred processing 
>> WSGI script '/var/django/sites/mysite-prod/config/wsgi.py'.[Sat Apr 18 
>> 16:11:30.684834 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] 
>> Traceback (most recent call last):[Sat Apr 18 16:11:30.684891 2020] 
>> [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]   File 
>> "/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/wsgi.py",
>>  line 133, in __call__[Sat Apr 18 16:11:30.684903 2020] [wsgi:error] [pid 
>> 4154] [remote 100.19.146.139:54397] response = 
>> self.get_response(request)[Sat Apr 18 16:11:30.684925 2020] [wsgi:error] 
>> [pid 4154] [remote 100.19.146.139:54397]   File 
>> "/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
>>  line 76, in get_response[Sat Apr 18 16:11:30.684933 2020] [wsgi:error] [pid 
>> 4154] [remote 100.19.146.139:54397] 
>> response._resource_closers.append(request.close)[Sat Apr 18 16:11:30.684964 
>> 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] AttributeError: 
>> 'HttpResponse' object has no attribute '_resource_closers'
>>
>>
>> I've rolled back to a previous version that works, running Django 2.2; 
>> the rest of the stack is the same. This one has me puzzled, as using the 
>> same deployed code with the same venv that Apache is configured to use 
>> works fine under runserver, but errors with mod_wsgi. I've tried 
>> stopping and starting Apache, running the publish process again for a fresh 
>> venv and code base, and even rebooting the server. The same error 
>> occurs, but only under Apache / mod_wsgi.
>>
>>
>> Any ideas? I'm puzzled!
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/0381e998-321e-489f-abe1-853b6997930f%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/0381e998-321e-489f-abe1-853b6997930f%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>
> Tim,
>
> Shot in the dark:  Did you add any middleware by chance?
>
> -Jorge
>

-- 
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/f80c3888-eaac-48da-adaf-1862e1d4be5f%40googlegroups.com.


AttributeError when returning post.title in a comment model

2020-05-29 Thread Ahmed Khairy


I was working on a comment section for post and was getting an 
AttributeError when I return return '{}-{}'.format(self.post.title, 
str(self.user.username)) in the comment model

I am trying to link users and posts to the comment I am getting the same 
error

Here is the Models.py

class Comment(models.Model):
post = models.ForeignKey(Post, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
content = models.TextField(max_length=160)
timestamp = models.DateTimeField(auto_now_add=True)

def __str__(self):
return '{}-{}'.format(self.post.title, str(self.user.username))

Here is the views.py:

class PostDetailView(DetailView):
model = Post
template_name = "post_detail.html"

def get_context_data(self, *args, **kwargs):
context = super(PostDetailView, self).get_context_data()
post = get_object_or_404(Post, slug=self.kwargs['slug'])
comments = Comment.objects.filter(post=post).order_by('-id')
total_likes = post.total_likes()
liked = False
if post.likes.filter(id=self.request.user.id).exists():
liked = True

if self.request.method == 'POST':
comment_form = CommentForm(self.request.POST or None)
if comment_form.is_valid():
content = self.request.POST.get('content')
comment = Comment.objects.create(
post=post, user=request.user, content=content)
comment.save()
return HttpResponseRedirect("post_detail.html")
else:
comment_form = CommentForm()

context["total_likes"] = total_likes
context["liked"] = liked
context["comments"] = comments
context["comment_form"] = comment_form
return context


class PostCommentCreateView(LoginRequiredMixin, CreateView):
model = Comment
form_class = CommentForm


-- 
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/9e84bb03-ca66-4517-ab34-8d723a457b9f%40googlegroups.com.


Re: " AttributeError at /register/ " facing problem in implementing user registration

2020-05-24 Thread Kasper Laudrup

Hi Madhav,

On 24/05/2020 13.08, Madhav Nandan wrote:

I'm creating a register page.

see the screenshot below., I'm following lectures and doing as 
instructed but still stuck.




I don't see how the screenshots are related to the issue you are having. 
Please explain.


here is the source code of my course: 
https://github.com/codingforentrepreneurs/eCommerce/tree/master/src/ecommerce




Great. How is that relevant?


Please help me get run the code.



I *am* trying to help you. I asked you some questions related to the 
problem you were facing. You could start by answering those.


Feel free to ask any further questions related to that if something's 
not clear.


Kind regards,

Kasper Laudrup

--
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/4d98054b-983b-4db7-bdfd-344e80cc07e1%40stacktrace.dk.


Re: " AttributeError at /register/ " facing problem in implementing user registration

2020-05-24 Thread Kasper Laudrup

Hi Madhav,

On 24/05/2020 04.54, Madhav Nandan wrote:

Hi,
I need help here. I did the required changes in forms.py as well as in 
view.py but my user registration still not working.




Once again, try to make sense from the error messages. They are actually 
pointing to your problem quite clearly.


In this case, what is your "User" object in your forms.py file?

It is hard to tell since you've only provided some screenshots, but this 
line:


User = get_user_model()

in your views.py file looks very suspicious.

Why are you creating a global User variable?

Did you do the same in forms.py for some reason and why?

Kind regards,

Kasper Laudrup

--
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/1e2d5ba7-09f1-0b70-69bf-f136598b7989%40stacktrace.dk.


Re: Possible Bug? AttributeError: 'HttpResponse' object has no attribute '_resource_closers'

2020-05-16 Thread Jorge Gimeno
On Sat, May 16, 2020 at 12:06 PM Tim Allen 
wrote:

> I posted this to Stack Overflow first, thinking it might be a problem with
> `mod_wsgi`, but people using Gunicorn have seen the issue too. Here's a
> link to the question on Stack Overflow:
>
>
> https://stackoverflow.com/questions/61295971/django-3-0-5-with-mod-wsgi-attributeerror-httpresponse-object-has-no-attribu
>
> Unfortunately, purging my cache hasn't fixed the problem like it did for a
> commenter on the question, so I'm asking here for amplification. Here's the
> text of the post:
>
> I'm getting an error when I deploy Django 3.0.5 under mod_wsgi:  
> AttributeError:
> 'HttpResponse' object has no attribute '_resource_closers'. I'm running:
>
>- Python: 3.6.8
>- Django: 3.0.5
>- Apache: 2.4.6
>- mod_wsgi: 4.6.2
>
> Here's the basics of the view causing the error; nothing too exotic (I've
> simplified the code around meetings_struct):
>
>
> class MeetingsAPIView(MeetingsBaseView):
> def get(self, request, *args, **kwargs):
> meetings = self.get_meetings()
> meetings_struct = []
>
> for meeting in meetings:
> meetings_struct.append({
> "id": meeting.id,
> "name": meeting.title,
> "slug": meeting.slug,
> })
>
> return HttpResponse(meetings_struct, content_type="application/json")
>
>
> If I activate the venv and use runserver manually on the server on port
> 80, the same view does not give an error. When the same code and venv are
> running under Apache, here's the error from Apache's logs:
>
>
> [Sat Apr 18 16:11:30.683980 2020] [wsgi:error] [pid 4154] [remote 
> 100.19.146.139:54397] mod_wsgi (pid=4154): Exception occurred processing WSGI 
> script '/var/django/sites/mysite-prod/config/wsgi.py'.[Sat Apr 18 
> 16:11:30.684834 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] 
> Traceback (most recent call last):[Sat Apr 18 16:11:30.684891 2020] 
> [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]   File 
> "/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/wsgi.py",
>  line 133, in __call__[Sat Apr 18 16:11:30.684903 2020] [wsgi:error] [pid 
> 4154] [remote 100.19.146.139:54397] response = 
> self.get_response(request)[Sat Apr 18 16:11:30.684925 2020] [wsgi:error] [pid 
> 4154] [remote 100.19.146.139:54397]   File 
> "/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
>  line 76, in get_response[Sat Apr 18 16:11:30.684933 2020] [wsgi:error] [pid 
> 4154] [remote 100.19.146.139:54397] 
> response._resource_closers.append(request.close)[Sat Apr 18 16:11:30.684964 
> 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] AttributeError: 
> 'HttpResponse' object has no attribute '_resource_closers'
>
>
> I've rolled back to a previous version that works, running Django 2.2; the
> rest of the stack is the same. This one has me puzzled, as using the same
> deployed code with the same venv that Apache is configured to use works
> fine under runserver, but errors with mod_wsgi. I've tried stopping and
> starting Apache, running the publish process again for a fresh venv and
> code base, and even rebooting the server. The same error occurs, but only
> under Apache / mod_wsgi.
>
>
> Any ideas? I'm puzzled!
>
> --
> 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/0381e998-321e-489f-abe1-853b6997930f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0381e998-321e-489f-abe1-853b6997930f%40googlegroups.com?utm_medium=email_source=footer>
> .
>

Tim,

Shot in the dark:  Did you add any middleware by chance?

-Jorge

-- 
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/CANfN%3DK_bLzkR2TZdk-gMkzq%2BCGeUyairDupU5FAqK4wNntr2-Q%40mail.gmail.com.


Possible Bug? AttributeError: 'HttpResponse' object has no attribute '_resource_closers'

2020-05-16 Thread Tim Allen
I posted this to Stack Overflow first, thinking it might be a problem with 
`mod_wsgi`, but people using Gunicorn have seen the issue too. Here's a 
link to the question on Stack Overflow:

https://stackoverflow.com/questions/61295971/django-3-0-5-with-mod-wsgi-attributeerror-httpresponse-object-has-no-attribu

Unfortunately, purging my cache hasn't fixed the problem like it did for a 
commenter on the question, so I'm asking here for amplification. Here's the 
text of the post:

I'm getting an error when I deploy Django 3.0.5 under mod_wsgi:  
AttributeError: 
'HttpResponse' object has no attribute '_resource_closers'. I'm running:

   - Python: 3.6.8
   - Django: 3.0.5
   - Apache: 2.4.6
   - mod_wsgi: 4.6.2

Here's the basics of the view causing the error; nothing too exotic (I've 
simplified the code around meetings_struct):


class MeetingsAPIView(MeetingsBaseView):
def get(self, request, *args, **kwargs):
meetings = self.get_meetings()
meetings_struct = []

for meeting in meetings:
meetings_struct.append({
"id": meeting.id,
"name": meeting.title,
"slug": meeting.slug,
})

return HttpResponse(meetings_struct, content_type="application/json")


If I activate the venv and use runserver manually on the server on port 80, 
the same view does not give an error. When the same code and venv are 
running under Apache, here's the error from Apache's logs:


[Sat Apr 18 16:11:30.683980 2020] [wsgi:error] [pid 4154] [remote 
100.19.146.139:54397] mod_wsgi (pid=4154): Exception occurred processing WSGI 
script '/var/django/sites/mysite-prod/config/wsgi.py'.[Sat Apr 18 
16:11:30.684834 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] 
Traceback (most recent call last):[Sat Apr 18 16:11:30.684891 2020] 
[wsgi:error] [pid 4154] [remote 100.19.146.139:54397]   File 
"/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/wsgi.py",
 line 133, in __call__[Sat Apr 18 16:11:30.684903 2020] [wsgi:error] [pid 4154] 
[remote 100.19.146.139:54397] response = self.get_response(request)[Sat Apr 
18 16:11:30.684925 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]  
 File 
"/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
 line 76, in get_response[Sat Apr 18 16:11:30.684933 2020] [wsgi:error] [pid 
4154] [remote 100.19.146.139:54397] 
response._resource_closers.append(request.close)[Sat Apr 18 16:11:30.684964 
2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] AttributeError: 
'HttpResponse' object has no attribute '_resource_closers'


I've rolled back to a previous version that works, running Django 2.2; the 
rest of the stack is the same. This one has me puzzled, as using the same 
deployed code with the same venv that Apache is configured to use works 
fine under runserver, but errors with mod_wsgi. I've tried stopping and 
starting Apache, running the publish process again for a fresh venv and 
code base, and even rebooting the server. The same error occurs, but only 
under Apache / mod_wsgi.


Any ideas? I'm puzzled!

-- 
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/0381e998-321e-489f-abe1-853b6997930f%40googlegroups.com.


Re: AttributeError

2020-04-27 Thread 'Amitesh Sahay' via Django users
Do you have a "date" field in your models.py.? Please share models.py, and 
views.py as well

Sent from Yahoo Mail on Android 
 
  On Mon, 27 Apr 2020 at 22:44, Phako Perez<13.phak...@gmail.com> wrote:   I 
think issue is how you are trying to access the attributeThis is a form and 
must be accessed through a post call.
Can you share your html form???

Sent from my iPhone

On 27 Apr 2020, at 10:29, DimGo  wrote:



from django import forms
from django.core.exceptions import ValidationError

class SearchProduct(forms.Form):
 text=forms.CharField(label='Search ')
 date=forms.DateField(required=False)
 
t = SearchProduct()
print(t.date)

Error: 

AttributeError: 'SearchProduct' object has no attribute 'date'



why is there this error? How to fix it? 

ff


-- 
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/445e0ffb-03e7-4a32-9d83-b48795a9866c%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/6FEB0B14-73FF-4A74-80B4-ED982F95D01F%40gmail.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/37640327.684638.1588012361686%40mail.yahoo.com.


Re: AttributeError with forms

2020-04-27 Thread 'Amitesh Sahay' via Django users
I couldn't open the screenshot . But to work with the django forms you need to 
perform below tasks.
1) create model of your choice in models.py.2).  Python manage.py 
makemigrations3) python manage py migrate.4 create a python file called 
forms.py inside your app.5) import your models there ( from .models import 
model_name6) create class to extend forms module.7) in views.py you either need 
to define class based views or function based views. 
I hope that helps.

Sent from Yahoo Mail on Android 
 
  On Mon, 27 Apr 2020 at 20:59, DimGo wrote:   Why 
is this this strange error? 


-- 
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/7a2089af-344a-479d-bf7c-8a943973159b%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/407015029.685337.1588012209457%40mail.yahoo.com.


Re: AttributeError with forms

2020-04-27 Thread Ethem Güner
It's not strange. You can't access to an attribute of a form class
directly. Remember how do you define the form in a view. You're passing
arguments such as *data=request.POST*. You're trying to access an undefined
attribute. Because It's a form class and needs input.

Try to print *t.__dict__  *you'll get a dictionary of that class. But If
you really need to access to the attribute like this, use* t['date']*

DimGo , 27 Nis 2020 Pzt, 18:29 tarihinde şunu
yazdı:

> Why is this this strange error?
>
> --
> 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/7a2089af-344a-479d-bf7c-8a943973159b%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/CAMsyPm_ck-hhC-P_FGz3vwk_fgKQWAy9rx6WpAh7AE1Gr08iqg%40mail.gmail.com.


Re: AttributeError with forms

2020-04-27 Thread Phako Perez
In addition, you must define your model in models.py

And to get this attributes on your views.py from a post request, you could use 
like {{ form.attribute }}

Regards

Sent from my iPhone

> On 27 Apr 2020, at 10:29, DimGo  wrote:
> 
> 
> Why is this this strange error? 
> -- 
> 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/7a2089af-344a-479d-bf7c-8a943973159b%40googlegroups.com.
> <Снимок экрана от 2020-04-27 18-06-28.png>

-- 
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/A6EAD9A6-59B3-4986-8338-DF0A5DFDF2F7%40gmail.com.


Re: AttributeError

2020-04-27 Thread Phako Perez
I think issue is how you are trying to access the attribute
This is a form and must be accessed through a post call.

Can you share your html form???

Sent from my iPhone

> On 27 Apr 2020, at 10:29, DimGo  wrote:
> 
> 
> from django import forms
> from django.core.exceptions import ValidationError
> 
> class SearchProduct(forms.Form):
>  text=forms.CharField(label='Search ')
>  date=forms.DateField(required=False)
>  
> t = SearchProduct()
> print(t.date)
> 
> Error: 
> 
> AttributeError: 'SearchProduct' object has no attribute 'date'
> 
> 
> 
> why is there this error? How to fix it? 
> 
> ff
> -- 
> 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/445e0ffb-03e7-4a32-9d83-b48795a9866c%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/6FEB0B14-73FF-4A74-80B4-ED982F95D01F%40gmail.com.


AttributeError

2020-04-27 Thread DimGo
from django import forms
from django.core.exceptions import ValidationError

class SearchProduct(forms.Form):
 text=forms.CharField(label='Search ')
 date=forms.DateField(required=False)
 
t = SearchProduct()
print(t.date)

Error: 

AttributeError: 'SearchProduct' object has no attribute 'date'



why is there this error? How to fix it? 

ff

-- 
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/445e0ffb-03e7-4a32-9d83-b48795a9866c%40googlegroups.com.


Re: AttributeError: type object 'User' has no attribute 'objects'

2020-04-27 Thread sagar ninave
i got answer

i was doing this:
from .models import User
user = User.objects.filter(pk=user_id)

instead i do this:
from .models import MyUser
user =  MyUser.objects.filter(pk=user_id)


error gone




On Mon, Apr 27, 2020 at 6:57 AM Kasper Laudrup 
wrote:

> Hi Sagar,
>
> On 27/04/2020 14.25, sagar ninave wrote:
> > i am getting this error
> >
>
> It's hard to guess since you don't show where your User class comes
> from, but it doesn't seem like its inheriting from the Django model class.
>
> The error message is quite clear. Look at your User model.
>
> Btw. just a hint: please try to "return early". It is quite difficult to
> see which else branches are connected to which if statements in the code
> following the one throwing the exception.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> 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/96eba188-98e9-4284-cbab-a3aa3c909c05%40stacktrace.dk
> .
>


-- 

sagar ninave
about.me/sagarninave


-- 
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/CAA6pdZ818Ju8uHr%3DdDayJr3NKwE%2B%2BJ%2BQQZk1iOHqG1EL4yjO1g%40mail.gmail.com.


Re: AttributeError: type object 'User' has no attribute 'objects'

2020-04-27 Thread Kasper Laudrup

Hi Sagar,

On 27/04/2020 14.25, sagar ninave wrote:

i am getting this error



It's hard to guess since you don't show where your User class comes
from, but it doesn't seem like its inheriting from the Django model class.

The error message is quite clear. Look at your User model.

Btw. just a hint: please try to "return early". It is quite difficult to
see which else branches are connected to which if statements in the code
following the one throwing the exception.

Kind regards,

Kasper Laudrup

--
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/96eba188-98e9-4284-cbab-a3aa3c909c05%40stacktrace.dk.


Error in formatting: AttributeError: 'UUID' object has no attribute 'int'

2020-04-03 Thread aetar
When trying to render my content_detail.html template (printed below), I am 
receiving the following error: 

   - 
   - /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/uuid.py
in __init__
   1. 
  
  raise ValueError('badly formed hexadecimal UUID string')
  
  …
   ▼ Local vars <http://127.0.0.1:8000/posts/2/#>
   VariableValue
   bytes 
   
   None
   
   bytes_le 
   
   None
   
   fields 
   
   None
   
   hex 
   
   '2'
   
   int 
   
   None
   
   is_safe 
   
   
   
   self 
   
   Error in formatting: AttributeError: 'UUID' object has no attribute 'int'
   
   version 
   
   None
   
   

*archive/urls.py:*
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('posts/', include('posts.urls')),
path('admin/', admin.site.urls),
path('', RedirectView.as_view(url='posts/', permanent=True)),] + 
static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

*archive/posts/urls.py:*
from django.urls import path

from . import views

app_name = 'posts'

urlpatterns = [
path('', views.index, name='index'),
path('/', views.ContentDetailView.as_view(), 
name='content-detail'),
]

*archive/posts/models.py:*
import datetime

from django.db import models
from django.utils import timezone
import uuid
from django.urls import reverse

# Create your models here.

class Content(models.Model):
title = models.CharField(max_length=200)
pub_date = models.DateTimeField(null=True, blank=True)

def __str__(self):
return self.title

def get_absolute_url(self):
return reverse('content-detail', args=[str(self.id)])

class ContentInstance(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, 
editable=False)
content = models.ForeignKey(Content, on_delete=models.SET_NULL, 
null=True)
text = models.TextField()

def __str__(self):
return '{0} ({1})'.format(self.id, self.content.title)

*archive/posts/views.py:*
from django.shortcuts import render

# Create your views here.

from .models import Content, ContentInstance
from django.views import generic

def index(request):
archive_list = Content.objects.order_by('-pub_date')
context = {'archive_list': archive_list}
return render(request, 'index.html', context)

class ContentDetailView(generic.DetailView):
model = Content

*archive/posts/templates/posts/content_detail.py:*

{% extends "base_generic.html" %}

{% block content %}
  Heading
  {{ content.title }}
  {{ content.pub_date }}
  
  {% for copy in content.contentinstance_set.all %} 
  <{{ copy.text }}>
  {% endfor %}
  
{% endblock %}


-- 
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/a55a7579-1cd1-4003-bb4e-2398ace9ed0a%40googlegroups.com.


Re: AttributeError: 'NoneType' object has no attribute 'app_name'

2020-03-13 Thread Sencer Hamarat
Thank you for your suggestion. And sorry fro delayed answer.

My hunch is saying same thing but I want to be sure about it.

Kind Regards,
Sencer Hamarat

3 Mart 2020 Salı 12:24:34 UTC+3 tarihinde Naveen Arora yazdı:
>
> Hi, 
>
> Can't the error be resolved ? Still, if error has to occur then you can 
> put conditions instead of try blocks for better functioning.
>
> Regards
> Naveen Arora
>
>
> On Monday, 2 March 2020 18:25:15 UTC+5:30, Sencer Hamarat wrote:
>>
>> Hello, 
>>
>> The project I'm working on has it's custom template context_processor.
>> And when unavailable URL request arrives to Django (Eg. "/wp-login.php"), 
>> the context_processor is throwing AttributeError.
>>
>> Which way should I use to prevent from context processor from throwing 
>> errors?
>> Is it ok to wrapping return with try block and returning empty dictionary 
>> if AttributeError raised?
>>
>> def resolver_context_processor(request):
>> return {
>> 'app_name': request.resolver_match.app_name,
>> 'namespace': request.resolver_match.namespace,
>> 'url_name': request.resolver_match.url_name
>> }
>>
>>
>>
>>

-- 
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/4c876117-f16b-4603-8d7b-d3609420093a%40googlegroups.com.


Re: AttributeError: 'NoneType' object has no attribute 'app_name'

2020-03-03 Thread Naveen Arora
Hi, 

Can't the error be resolved ? Still, if error has to occur then you can put 
conditions instead of try blocks for better functioning.

Regards
Naveen Arora


On Monday, 2 March 2020 18:25:15 UTC+5:30, Sencer Hamarat wrote:
>
> Hello, 
>
> The project I'm working on has it's custom template context_processor.
> And when unavailable URL request arrives to Django (Eg. "/wp-login.php"), 
> the context_processor is throwing AttributeError.
>
> Which way should I use to prevent from context processor from throwing 
> errors?
> Is it ok to wrapping return with try block and returning empty dictionary 
> if AttributeError raised?
>
> def resolver_context_processor(request):
> return {
> 'app_name': request.resolver_match.app_name,
> 'namespace': request.resolver_match.namespace,
> 'url_name': request.resolver_match.url_name
> }
>
>
>
>

-- 
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/77b25608-b663-440c-977c-4fedfd808c8c%40googlegroups.com.


AttributeError: 'NoneType' object has no attribute 'app_name'

2020-03-02 Thread Sencer Hamarat
Hello, 

The project I'm working on has it's custom template context_processor.
And when unavailable URL request arrives to Django (Eg. "/wp-login.php"), 
the context_processor is throwing AttributeError.

Which way should I use to prevent from context processor from throwing 
errors?
Is it ok to wrapping return with try block and returning empty dictionary 
if AttributeError raised?

def resolver_context_processor(request):
return {
'app_name': request.resolver_match.app_name,
'namespace': request.resolver_match.namespace,
'url_name': request.resolver_match.url_name
}



-- 
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/556e8f34-ecd4-45b8-bd39-21504459efc3%40googlegroups.com.


Re: Getting ```AttributeError: 'str' object has no attribute 'state_forwards'``` when running a migrations, Down there is the migrations file. please help

2019-10-22 Thread Jorge Gimeno
Can you post your models.py files, please?

-Jorge

On Tue, Oct 22, 2019, 6:07 PM fils-aime walnes andre <
walnesfilsa...@gmail.com> wrote:

> Merci freo
>
> Le lundi 21 octobre 2019, adonis simo  a écrit :
>
>>
>> # Generated by Django 2.2.3 on 2019-10-21 22:00
>>
>>
>>
>> from django.db import migrations, models
>>
>> import django.db.models.deletion
>>
>> import django_extensions.db.fields
>>
>>
>>
>>
>>
>> class Migration(migrations.Migration):
>>
>>
>>
>> dependencies = [
>>
>> ('restaurant_app', '0002_auto_20191017_1650'),
>>
>> ('hotel', '0001_initial'),
>>
>> ]
>>
>>
>>
>> operations = [
>>
>>
>>
>> migrations.CreateModel(
>>
>> name='Action',
>>
>> fields=[
>>
>> ('id', models.AutoField(auto_created=True, primary_key=
>> True, serialize=False, verbose_name='ID')),
>>
>> ('created', django_extensions.db.fields.
>> CreationDateTimeField(auto_now_add=True, verbose_name='created')),
>>
>> ('modified', django_extensions.db.fields.
>> ModificationDateTimeField(auto_now=True, verbose_name='modified')),
>>
>> ('name', models.CharField(max_length=100)),
>>
>> ('deleted', models.BooleanField(default=False)),
>>
>> ],
>>
>> options={
>>
>> 'ordering': ('-modified', '-created'),
>>
>> 'get_latest_by': 'modified',
>>
>> 'abstract': False,
>>
>> },
>>
>> ),
>>
>> ,
>>
>> migrations.CreateModel(
>>
>> name='TypeDeService',
>>
>> fields=[
>>
>> ('id', models.AutoField(auto_created=True, primary_key=
>> True, serialize=False, verbose_name='ID')),
>>
>> ('created', django_extensions.db.fields.
>> CreationDateTimeField(auto_now_add=True, verbose_name='created')),
>>
>> ('modified', django_extensions.db.fields.
>> ModificationDateTimeField(auto_now=True, verbose_name='modified')),
>>
>> ('nomservice', models.CharField(default='Tout les
>> services', max_length=50, verbose_name='Nom de service')),
>>
>> ('sigle', models.CharField(default='TS', max_length=50,
>> verbose_name='Sigle')),
>>
>> ('deleted', models.BooleanField(default=False,
>> verbose_name='produit effacee')),
>>
>> ],
>>
>> options={
>>
>> 'verbose_name': 'Type de service',
>>
>> },
>>
>> ),
>>
>> migrations.RemoveField(
>>
>> model_name='payementhotel',
>>
>> name='mode_payement_hotel',
>>
>> ),
>>
>> migrations.RemoveField(
>>
>> model_name='payementhotel',
>>
>> name='montant_paye',
>>
>> ),
>>
>> migrations.RemoveField(
>>
>> model_name='payementhotel',
>>
>> name='montant_restant',
>>
>> ),
>>
>> migrations.RemoveField(
>>
>> model_name='payementservice',
>>
>> name='mode_payement',
>>
>> ),
>>
>> migrations.RemoveField(
>>
>> model_name='payementservice',
>>
>> name='montant_paye',
>>
>> ),
>>
>> migrations.RemoveField(
>>
>> model_name='payementservice',
>>
>> name='montant_restant',
>>
>> ),
>>
>> migrations.RemoveField(
>>
>> model_name='taches',
>>
>> name='status',
>>
>> ),
>>
>> migrations.AddField(
>>
>> model_name='agent',
>>
>> name='deleted',
>>
>> field=models.BooleanField(default=False),
>>
>> ),
>>
>> migrations.AddField(
>>
>> model_name='agent',
>>
>> name='role',
>>
>> field=models.CharField(blank=True, max_length=100, null=True,
>> verbose_name='Role'),
>>
>> ),
>>
>> migrations.AddField(
>>
>> model_name='etages',
>>
>> name='deleted',
>>
>> field=models.BooleanField(default=False, verbose_name='produit
>> effacee'),
>>
>> ),
>>
>> migrations.AddField(
>>
>> model_name='factservice',
>>
>> name='montant_paye',
>>
>> field=models.IntegerField(default=0, verbose_name='Montant
>> payé'),
>>
>> ),
>>
>> migrations.AddField(
>>
>> model_name='factservice',
>>
>> name='montant_restant',
>>
>> field=models.IntegerField(default=0, verbose_name='Montant
>> restant'),
>>
>> ),
>>
>> migrations.AddField(
>>
>> model_name='facturationreservation',
>>
>> name='montant_paye',
>>
>> field=models.IntegerField(default=0, verbose_name='Montant
>> payé'),
>>
>> ),
>>
>> migrations.AddField(
>>
>> model_name='facturationreservation',
>>
>> name='montant_restant',
>>
>> field=models.IntegerField(default=0, 

Re: Getting ```AttributeError: 'str' object has no attribute 'state_forwards'``` when running a migrations, Down there is the migrations file. please help

2019-10-22 Thread fils-aime walnes andre
Merci freo

Le lundi 21 octobre 2019, adonis simo  a écrit :

>
> # Generated by Django 2.2.3 on 2019-10-21 22:00
>
>
>
> from django.db import migrations, models
>
> import django.db.models.deletion
>
> import django_extensions.db.fields
>
>
>
>
>
> class Migration(migrations.Migration):
>
>
>
> dependencies = [
>
> ('restaurant_app', '0002_auto_20191017_1650'),
>
> ('hotel', '0001_initial'),
>
> ]
>
>
>
> operations = [
>
>
>
> migrations.CreateModel(
>
> name='Action',
>
> fields=[
>
> ('id', models.AutoField(auto_created=True, primary_key=
> True, serialize=False, verbose_name='ID')),
>
> ('created', django_extensions.db.fields.Cr
> eationDateTimeField(auto_now_add=True, verbose_name='created')),
>
> ('modified', django_extensions.db.fields.Mo
> dificationDateTimeField(auto_now=True, verbose_name='modified')),
>
> ('name', models.CharField(max_length=100)),
>
> ('deleted', models.BooleanField(default=False)),
>
> ],
>
> options={
>
> 'ordering': ('-modified', '-created'),
>
> 'get_latest_by': 'modified',
>
> 'abstract': False,
>
> },
>
> ),
>
> ,
>
> migrations.CreateModel(
>
> name='TypeDeService',
>
> fields=[
>
> ('id', models.AutoField(auto_created=True, primary_key=
> True, serialize=False, verbose_name='ID')),
>
> ('created', django_extensions.db.fields.Cr
> eationDateTimeField(auto_now_add=True, verbose_name='created')),
>
> ('modified', django_extensions.db.fields.Mo
> dificationDateTimeField(auto_now=True, verbose_name='modified')),
>
> ('nomservice', models.CharField(default='Tout les
> services', max_length=50, verbose_name='Nom de service')),
>
> ('sigle', models.CharField(default='TS', max_length=50,
> verbose_name='Sigle')),
>
> ('deleted', models.BooleanField(default=False,
> verbose_name='produit effacee')),
>
> ],
>
> options={
>
> 'verbose_name': 'Type de service',
>
> },
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementhotel',
>
> name='mode_payement_hotel',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementhotel',
>
> name='montant_paye',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementhotel',
>
> name='montant_restant',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementservice',
>
> name='mode_payement',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementservice',
>
> name='montant_paye',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementservice',
>
> name='montant_restant',
>
> ),
>
> migrations.RemoveField(
>
> model_name='taches',
>
> name='status',
>
> ),
>
> migrations.AddField(
>
> model_name='agent',
>
> name='deleted',
>
> field=models.BooleanField(default=False),
>
> ),
>
> migrations.AddField(
>
> model_name='agent',
>
> name='role',
>
> field=models.CharField(blank=True, max_length=100, null=True,
> verbose_name='Role'),
>
> ),
>
> migrations.AddField(
>
> model_name='etages',
>
> name='deleted',
>
> field=models.BooleanField(default=False, verbose_name='produit
> effacee'),
>
> ),
>
> migrations.AddField(
>
> model_name='factservice',
>
> name='montant_paye',
>
> field=models.IntegerField(default=0, verbose_name='Montant
> payé'),
>
> ),
>
> migrations.AddField(
>
> model_name='factservice',
>
> name='montant_restant',
>
> field=models.IntegerField(default=0, verbose_name='Montant
> restant'),
>
> ),
>
> migrations.AddField(
>
> model_name='facturationreservation',
>
> name='montant_paye',
>
> field=models.IntegerField(default=0, verbose_name='Montant
> payé'),
>
> ),
>
> migrations.AddField(
>
> model_name='facturationreservation',
>
> name='montant_restant',
>
> field=models.IntegerField(default=0, verbose_name='Montant
> restant'),
>
> ),
>
> migrations.AddField(
>
> model_name='reservation',
>
> name='arrival_hour',
>
> field=models.TimeField(blank=True, null=True, verbose_name='Heure
> arrivee'),
>
> ),
>
> migrations.AddField(
>
> model_name='reservation',
>
> 

Re: Getting ```AttributeError: 'str' object has no attribute 'state_forwards'``` when running a migrations, Down there is the migrations file. please help

2019-10-22 Thread fils-aime walnes andre
Merci freo

Le lundi 21 octobre 2019, adonis simo  a écrit :

>
> # Generated by Django 2.2.3 on 2019-10-21 22:00
>
>
>
> from django.db import migrations, models
>
> import django.db.models.deletion
>
> import django_extensions.db.fields
>
>
>
>
>
> class Migration(migrations.Migration):
>
>
>
> dependencies = [
>
> ('restaurant_app', '0002_auto_20191017_1650'),
>
> ('hotel', '0001_initial'),
>
> ]
>
>
>
> operations = [
>
>
>
> migrations.CreateModel(
>
> name='Action',
>
> fields=[
>
> ('id', models.AutoField(auto_created=True, primary_key=
> True, serialize=False, verbose_name='ID')),
>
> ('created', django_extensions.db.fields.Cr
> eationDateTimeField(auto_now_add=True, verbose_name='created')),
>
> ('modified', django_extensions.db.fields.Mo
> dificationDateTimeField(auto_now=True, verbose_name='modified')),
>
> ('name', models.CharField(max_length=100)),
>
> ('deleted', models.BooleanField(default=False)),
>
> ],
>
> options={
>
> 'ordering': ('-modified', '-created'),
>
> 'get_latest_by': 'modified',
>
> 'abstract': False,
>
> },
>
> ),
>
> ,
>
> migrations.CreateModel(
>
> name='TypeDeService',
>
> fields=[
>
> ('id', models.AutoField(auto_created=True, primary_key=
> True, serialize=False, verbose_name='ID')),
>
> ('created', django_extensions.db.fields.Cr
> eationDateTimeField(auto_now_add=True, verbose_name='created')),
>
> ('modified', django_extensions.db.fields.Mo
> dificationDateTimeField(auto_now=True, verbose_name='modified')),
>
> ('nomservice', models.CharField(default='Tout les
> services', max_length=50, verbose_name='Nom de service')),
>
> ('sigle', models.CharField(default='TS', max_length=50,
> verbose_name='Sigle')),
>
> ('deleted', models.BooleanField(default=False,
> verbose_name='produit effacee')),
>
> ],
>
> options={
>
> 'verbose_name': 'Type de service',
>
> },
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementhotel',
>
> name='mode_payement_hotel',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementhotel',
>
> name='montant_paye',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementhotel',
>
> name='montant_restant',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementservice',
>
> name='mode_payement',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementservice',
>
> name='montant_paye',
>
> ),
>
> migrations.RemoveField(
>
> model_name='payementservice',
>
> name='montant_restant',
>
> ),
>
> migrations.RemoveField(
>
> model_name='taches',
>
> name='status',
>
> ),
>
> migrations.AddField(
>
> model_name='agent',
>
> name='deleted',
>
> field=models.BooleanField(default=False),
>
> ),
>
> migrations.AddField(
>
> model_name='agent',
>
> name='role',
>
> field=models.CharField(blank=True, max_length=100, null=True,
> verbose_name='Role'),
>
> ),
>
> migrations.AddField(
>
> model_name='etages',
>
> name='deleted',
>
> field=models.BooleanField(default=False, verbose_name='produit
> effacee'),
>
> ),
>
> migrations.AddField(
>
> model_name='factservice',
>
> name='montant_paye',
>
> field=models.IntegerField(default=0, verbose_name='Montant
> payé'),
>
> ),
>
> migrations.AddField(
>
> model_name='factservice',
>
> name='montant_restant',
>
> field=models.IntegerField(default=0, verbose_name='Montant
> restant'),
>
> ),
>
> migrations.AddField(
>
> model_name='facturationreservation',
>
> name='montant_paye',
>
> field=models.IntegerField(default=0, verbose_name='Montant
> payé'),
>
> ),
>
> migrations.AddField(
>
> model_name='facturationreservation',
>
> name='montant_restant',
>
> field=models.IntegerField(default=0, verbose_name='Montant
> restant'),
>
> ),
>
> migrations.AddField(
>
> model_name='reservation',
>
> name='arrival_hour',
>
> field=models.TimeField(blank=True, null=True, verbose_name='Heure
> arrivee'),
>
> ),
>
> migrations.AddField(
>
> model_name='reservation',
>
> 

Re: AttributeError: cffi library '_constant_time' has no function, constant or global variable named '__spec__'

2019-10-21 Thread Jorge Gimeno
Searches to both of your error messages suggested a mismatch in .so
objects. I would uninstall and reinstall Django and see if that helps.


-Jorge

On Sun, Oct 20, 2019 at 7:59 AM 'Abhishek Sharma' via Django users <
django-users@googlegroups.com> wrote:

> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File "C:\Python35\lib\site-packages\django\core\management\__init__.py",
> line 381, in execute_from_command_line
> utility.execute()
>   File "C:\Python35\lib\site-packages\django\core\management\__init__.py",
> line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\Python35\lib\site-packages\django\core\management\base.py",
> line 323, in run_from_argv
> self.execute(*args, **cmd_options)
>   File
> "C:\Python35\lib\site-packages\django\core\management\commands\runserver.py",
> line 60, in execute
> super().execute(*args, **options)
>   File "C:\Python35\lib\site-packages\django\core\management\base.py",
> line 364, in execute
> output = self.handle(*args, **options)
>   File
> "C:\Python35\lib\site-packages\django\core\management\commands\runserver.py",
> line 95, in handle
> self.run(**options)
>   File
> "C:\Python35\lib\site-packages\django\core\management\commands\runserver.py",
> line 102, in run
> autoreload.run_with_reloader(self.inner_run, **options)
>   File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line
> 598, in run_with_reloader
> start_django(reloader, main_func, *args, **kwargs)
>   File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line
> 583, in start_django
> reloader.run(django_main_thread)
>   File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line
> 301, in run
> self.run_loop()
>   File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line
> 307, in run_loop
> next(ticker)
>   File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line
> 347, in tick
> for filepath, mtime in self.snapshot_files():
>   File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line
> 363, in snapshot_files
> for file in self.watched_files():
>   File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line
> 262, in watched_files
> yield from iter_all_python_module_files()
>   File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line
> 103, in iter_all_python_module_files
> return iter_modules_and_files(modules, frozenset(_error_files))
>   File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line
> 124, in iter_modules_and_files
> if getattr(module, '__spec__', None) is None:
> SystemError:  returned a result with an error
> set
>
>
>
> On Sunday, October 20, 2019 at 8:27:48 PM UTC+5:30, Abhishek Sharma wrote:
>>
>> I'm using Django and while run code getting below error, please help out
>> on it
>>
>> AttributeError: cffi library '_constant_time' has no function, constant
>> or global variable named '__spec__'
>>
>
>
>
> --
>
> The information in this e-mail and any attachments is confidential and may
> be legally privileged. It is intended solely for the addressee or
> addressee's. If you are not an intended recipient, please delete the
> message and any attachments and notify the sender of nondelivery. Any use
> or disclosure of the contents of either is unauthorised and may be
> unlawful. All liability for viruses is excluded to the fullest extent
> permitted by law. Any views expressed in this message are those of the
> individual sender, except where the sender states them, with requisite
> authority, to be those of the organisation.
>
> --
> 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/e98263bd-05b9-4d7c-bbc7-bd1ebf9a4a83%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e98263bd-05b9-4d7c-bbc7-bd1ebf9a4a83%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CANfN%3DK-%2BD8R9pDc23RXYGJoE4wVpzx23BGK48qy8rw-RFD8EtQ%40mail.gmail.com.


Re: AttributeError: cffi library '_constant_time' has no function, constant or global variable named '__spec__'

2019-10-20 Thread 'Abhishek Sharma' via Django users
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in 
main()
  File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
  File "C:\Python35\lib\site-packages\django\core\management\__init__.py", 
line 381, in execute_from_command_line
utility.execute()
  File "C:\Python35\lib\site-packages\django\core\management\__init__.py", 
line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python35\lib\site-packages\django\core\management\base.py", line 
323, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"C:\Python35\lib\site-packages\django\core\management\commands\runserver.py", 
line 60, in execute
super().execute(*args, **options)
  File "C:\Python35\lib\site-packages\django\core\management\base.py", line 
364, in execute
output = self.handle(*args, **options)
  File 
"C:\Python35\lib\site-packages\django\core\management\commands\runserver.py", 
line 95, in handle
self.run(**options)
  File 
"C:\Python35\lib\site-packages\django\core\management\commands\runserver.py", 
line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 
598, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 
583, in start_django
reloader.run(django_main_thread)
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 
301, in run
self.run_loop()
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 
307, in run_loop
next(ticker)
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 
347, in tick
for filepath, mtime in self.snapshot_files():
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 
363, in snapshot_files
for file in self.watched_files():
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 
262, in watched_files
yield from iter_all_python_module_files()
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 
103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 
124, in iter_modules_and_files
if getattr(module, '__spec__', None) is None:
SystemError:  returned a result with an error set



On Sunday, October 20, 2019 at 8:27:48 PM UTC+5:30, Abhishek Sharma wrote:
>
> I'm using Django and while run code getting below error, please help out 
> on it
>
> AttributeError: cffi library '_constant_time' has no function, constant or 
> global variable named '__spec__'
>

-- 

















The information in this
e-mail and any attachments is 
confidential and may be legally privileged. It is
intended solely for the 
addressee or addressee's. If you are not an intended
recipient, please 
delete the message and any attachments and notify the sender
of 
nondelivery. Any use or disclosure of the contents of either is 
unauthorised
and may be unlawful. All liability for viruses is excluded to 
the fullest
extent permitted by law. Any views expressed in this message 
are those of the
individual sender, except where the sender states them, 
with requisite
authority, to be those of the organisation.

-- 
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/e98263bd-05b9-4d7c-bbc7-bd1ebf9a4a83%40googlegroups.com.


AttributeError: cffi library '_constant_time' has no function, constant or global variable named '__spec__'

2019-10-20 Thread 'Abhishek Sharma' via Django users
I'm using Django and while run code getting below error, please help out on 
it

AttributeError: cffi library '_constant_time' has no function, constant or 
global variable named '__spec__'

-- 

















The information in this
e-mail and any attachments is 
confidential and may be legally privileged. It is
intended solely for the 
addressee or addressee's. If you are not an intended
recipient, please 
delete the message and any attachments and notify the sender
of 
nondelivery. Any use or disclosure of the contents of either is 
unauthorised
and may be unlawful. All liability for viruses is excluded to 
the fullest
extent permitted by law. Any views expressed in this message 
are those of the
individual sender, except where the sender states them, 
with requisite
authority, to be those of the organisation.

-- 
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/f6cfbeac-cf93-4d4c-b1bc-50a2cc01dd7b%40googlegroups.com.


Re: AttributeError

2019-10-02 Thread Daniel Hepper
You have a typo in your details view:

question=Question.object.get(

Should be:

question=Question.objects.get(

Cheers,
Daniel

> Am 02.10.2019 um 06:38 schrieb Jorge Gimeno :
> 
> 
> 
> 
>> On Tue, Oct 1, 2019 at 9:24 PM yasar arafath Kajamydeen  
>> wrote:
>> Hi ,
>> 
>> While try to execute  it showing AttributeError, Can some one help me on 
>> this.
>> 
>> 
>> My views.py
>> 
>> 
>> 
>> from django.shortcuts import render
>> from django.http import Http404
>> from django.http import HttpResponse
>> from .models import Question
>> 
>> 
>> def index(request):
>> latest_question_list=Question.objects.order_by('pub_date')[:3]
>> context={'latest_question_list':latest_question_list}
>> return render(request,'polls/index.html',context)
>> 
>> def detail(request, question_id):
>> try:
>> question=Question.object.get(pk=question_id)
>> except Question.DoesNotExist:
>> raise Http404("Question does not exist")
>> return render(request, 'polls/detail.html', {'question':question})
>> 
>> 
>> def results(request, question_id):
>> response = "You're looking at the results of question %s."
>> return HttpResponse(response%question_id)
>> 
>> 
>> def vote(request, question_id):
>> return HttpResponse("You're voting on question %s."%question_id)
>> 
>> 
>> 
>> 
>> 
>> 
>> My detail.html
>> 
>> 
>>   {{question}}
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> My polls/urls.py
>> 
>> 
>> 
>> from django.urls import path
>> 
>> from . import views
>> 
>> urlpatterns = [
>> # ex: /polls/
>> path('', views.index, name='index'),
>> # ex: /polls/5/
>> path('/', views.detail, name='detail'),
>> # ex: /polls/5/results/
>> path('/results/', views.results, name='results'),
>> # ex: /polls/5/vote/
>> path('/vote/', views.vote, name='vote'),
>> 
>> ]
>> -- 
>> 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/9918df61-41fd-40bd-8ca3-79ee3be12ec3%40googlegroups.com.
> 
> Can you please post the traceback?  Copy and paste, please. Without that we 
> won't know where the exception is raised.
> 
> -Jorge
> -- 
> 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/CANfN%3DK_EVDfucXrk490XeumWyf2_u0QOfitfbQ0jFQOJyKkAjg%40mail.gmail.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/69313C94-61A3-4670-96C1-35253FEFDB31%40gmail.com.


Re: AttributeError

2019-10-01 Thread Jorge Gimeno
On Tue, Oct 1, 2019 at 9:24 PM yasar arafath Kajamydeen 
wrote:

> Hi ,
>
> While try to execute  it showing AttributeError, Can some one help me on
> this.
>
>
> *My views.py*
>
>
>
> from django.shortcuts import render
> from django.http import Http404
> from django.http import HttpResponse
> from .models import Question
>
>
> def index(request):
> latest_question_list=Question.objects.order_by('pub_date')[:3]
> context={'latest_question_list':latest_question_list}
> return render(request,'polls/index.html',context)
>
> def detail(request, question_id):
> try:
> question=Question.object.get(pk=question_id)
> except Question.DoesNotExist:
> raise Http404("Question does not exist")
> return render(request, 'polls/detail.html', {'question':question})
>
>
> def results(request, question_id):
> response = "You're looking at the results of question %s."
> return HttpResponse(response%question_id)
>
>
> def vote(request, question_id):
> return HttpResponse("You're voting on question %s."%question_id)
>
>
>
>
>
>
>
> *My detail.html*
>
>
>
>   {{question}}
>
>
>
>
>
>
>
>
>
> *My polls/urls.py*
>
>
>
>
> from django.urls import path
>
> from . import views
>
> urlpatterns = [
> # ex: /polls/
> path('', views.index, name='index'),
> # ex: /polls/5/
> path('/', views.detail, name='detail'),
> # ex: /polls/5/results/
> path('/results/', views.results, name='results'),
> # ex: /polls/5/vote/
> path('/vote/', views.vote, name='vote'),
>
> ]
>
> --
> 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/9918df61-41fd-40bd-8ca3-79ee3be12ec3%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9918df61-41fd-40bd-8ca3-79ee3be12ec3%40googlegroups.com?utm_medium=email_source=footer>
> .
>

Can you please post the traceback?  Copy and paste, please. Without that we
won't know where the exception is raised.

-Jorge

-- 
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/CANfN%3DK_EVDfucXrk490XeumWyf2_u0QOfitfbQ0jFQOJyKkAjg%40mail.gmail.com.


AttributeError

2019-10-01 Thread yasar arafath Kajamydeen
Hi ,

While try to execute  it showing AttributeError, Can some one help me on 
this.


*My views.py*



from django.shortcuts import render
from django.http import Http404
from django.http import HttpResponse
from .models import Question


def index(request):
latest_question_list=Question.objects.order_by('pub_date')[:3]
context={'latest_question_list':latest_question_list}
return render(request,'polls/index.html',context)

def detail(request, question_id):
try:
question=Question.object.get(pk=question_id)
except Question.DoesNotExist:
raise Http404("Question does not exist")
return render(request, 'polls/detail.html', {'question':question})


def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response%question_id)


def vote(request, question_id):
return HttpResponse("You're voting on question %s."%question_id)







*My detail.html*



  {{question}}









*My polls/urls.py*




from django.urls import path

from . import views

urlpatterns = [
# ex: /polls/
path('', views.index, name='index'),
# ex: /polls/5/
path('/', views.detail, name='detail'),
# ex: /polls/5/results/
path('/results/', views.results, name='results'),
# ex: /polls/5/vote/
path('/vote/', views.vote, name='vote'),

]

-- 
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/9918df61-41fd-40bd-8ca3-79ee3be12ec3%40googlegroups.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-07 Thread Kean
Hi,

removing did, not work, still getting same error.
Welcome any other help from the wider community in reference to this issue.
best,

Kean

On 6 Sep 2019, at 22:26, Bhoopesh sisoudiya  wrote:

> Try after removing related_name='expenses' from Expenses model.
> 
> On Sat, Sep 7, 2019, 2:28 AM Kean  wrote:
> Hi Bhoopesh,
> 
> If this is a simple issue to resolve, please provide code which works.
> Reading an abstract reference, is welcome, but is not really helping to solve 
> as one can always reference a source. 
> 
> Please advise solution that works, and then reference a learning resource, so 
> user knows where to go for learning, but with solution in hand.
> 
> Best,
> 
> Kean
> 
> On 6 Sep 2019, at 21:54, Bhoopesh sisoudiya  wrote:
> 
>> https://stackoverflow.com/questions/31237042/whats-the-difference-between-select-related-and-prefetch-related-in-django-orm
>> 
>> 
>> On Sat, Sep 7, 2019, 2:20 AM Kean  wrote:
>> Don’t understand?
>> 
>> On 6 Sep 2019, at 21:41, Bhoopesh sisoudiya  wrote:
>> 
>>> 'project' inside select_related() is foreign key in Expenses modal of 
>>> Project modal.
>>> 
>>> On Sat, Sep 7, 2019, 2:07 AM Kean  wrote:
>>> Ok,
>>> 
>>> Updated to below, and am still getting the same error:
>>> 
>>> def projectdetail(request):
>>> projectList = Project.objects.all()
>>> projectExpenseDetails = Expense.objects.select_related('project').all()
>>> return render(request, 'busprojectdetail.html', {'project': project, 
>>> 'expense_list': projectExpenseDetails})
>>> 
>>> Exception Type: NameError
>>> Exception Value:
>>> name 'project' is not defined
>>> Exception Location: 
>>> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
>>> line 239
>>> Best,
>>> Kean
>>> 
>>> 
>>> On 6 Sep 2019, at 21:32, Bhoopesh sisoudiya  wrote:
>>> 
 Sorry my mistake
 
 
 def projectdetail(request):
 projectList = Project.objects.all()
 projectExpenseDetails = Expense.objects.select_related('project').all()
 return render(request, 'busprojectdetail.html', {'project': 
 projectList, 'expense_list': projectExpenseDetails})
 
 
 On Sat, Sep 7, 2019, 1:55 AM Kean  wrote:
 Hi Ok,
 
 I updated as advised.
 
 views.py
 
 def projectdetail(request):
 projectExpenseDetails = Expense.objects.select_related('project').all()
 return render(request, 'busprojectdetail.html', {'project': project, 
 'expense_list': projectExpenseDetails})
 
 I get new error
 Exception Type:NameError
 Exception Value:   
 name 'project' is not defined
 Exception Location:
 /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in 
 projectdetail, line 238
 
 
 Please advise?
 
 Best,
 
 Kean
 On 6 Sep 2019, at 21:19, Bhoopesh sisoudiya  wrote:
 
> projectExpnseDetails
 
>>> 
>> 
> 

-- 
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/43C89EFD-1D4C-4B03-962E-898124A8D96D%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Ok,

Updated to below, and am still getting the same error:

def projectdetail(request):
projectList = Project.objects.all()
projectExpenseDetails = Expense.objects.select_related('project').all()
return render(request, 'busprojectdetail.html', {'project': project, 
'expense_list': projectExpenseDetails})

Exception Type: NameError
Exception Value:
name 'project' is not defined
Exception Location: 
/Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
line 239
Best,
Kean


On 6 Sep 2019, at 21:32, Bhoopesh sisoudiya  wrote:

> Sorry my mistake
> 
> 
> def projectdetail(request):
> projectList = Project.objects.all()
> projectExpenseDetails = Expense.objects.select_related('project').all()
> return render(request, 'busprojectdetail.html', {'project': projectList, 
> 'expense_list': projectExpenseDetails})
> 
> 
> On Sat, Sep 7, 2019, 1:55 AM Kean  wrote:
> Hi Ok,
> 
> I updated as advised.
> 
> views.py
> 
> def projectdetail(request):
> projectExpenseDetails = Expense.objects.select_related('project').all()
> return render(request, 'busprojectdetail.html', {'project': project, 
> 'expense_list': projectExpenseDetails})
> 
> I get new error
> Exception Type:   NameError
> Exception Value:  
> name 'project' is not defined
> Exception Location:   
> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
> line 238
> 
> 
> Please advise?
> 
> Best,
> 
> Kean
> On 6 Sep 2019, at 21:19, Bhoopesh sisoudiya  wrote:
> 
>> projectExpnseDetails
> 

-- 
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/20716649-508A-4E8C-8134-8DD8EECADF7C%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Hi Ok,

I updated as advised.

views.py

def projectdetail(request):
projectExpenseDetails = Expense.objects.select_related('project').all()
return render(request, 'busprojectdetail.html', {'project': project, 
'expense_list': projectExpenseDetails})

I get new error
Exception Type: NameError
Exception Value:
name 'project' is not defined
Exception Location: 
/Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
line 238


Please advise?

Best,

Kean
On 6 Sep 2019, at 21:19, Bhoopesh sisoudiya  wrote:

> projectExpnseDetails

-- 
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/86E3CF35-2148-4C36-A503-5413BE568F95%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
Thanks
>>>> Bhoopesh Kumar
>>>>
>>>>
>>>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
>>>> wrote:
>>>>
>>>>> Hi kean,
>>>>> Please check Expenses Class is not Manager
>>>>> Please make Manager Class.
>>>>>
>>>>>
>>>>> Thanks
>>>>> Bhoopesh sisoudiya
>>>>>
>>>>> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> New to Django. when navigating to the reqired view, I get the error
>>>>>> above.
>>>>>>
>>>>>> urls.py
>>>>>>
>>>>>> path('businesslogin/businessadmin/busproject', views.projectdetail,
>>>>>> name='projectdetail'),
>>>>>>
>>>>>> views.py
>>>>>>
>>>>>> def projectdetail(request):
>>>>>> project = Project.objects.all()
>>>>>> return render(request, 'busprojectdetail.html', {'project':
>>>>>> project, 'expense_list': project.expenses.all()})
>>>>>>
>>>>>> models.py
>>>>>>
>>>>>> # Project model
>>>>>>
>>>>>> class Project(models.Model):
>>>>>> name = models.CharField(max_length=100)
>>>>>> budget = IntegerField()
>>>>>>
>>>>>> def save(self, *args, **kwargs):
>>>>>> self.name
>>>>>> super(Project, self).save(*args, **kwargs)
>>>>>>
>>>>>> # Category manager model
>>>>>>
>>>>>>
>>>>>> class Category(models.Model):
>>>>>> project = models.ForeignKey(
>>>>>> Project, on_delete=models.CASCADE)
>>>>>> name = models.CharField(max_length=150)
>>>>>>
>>>>>>
>>>>>> # Expenses manager model
>>>>>>
>>>>>> class Expense(models.Model):
>>>>>> project = models.ForeignKey(
>>>>>> Project, on_delete=models.CASCADE, related_name='expenses')
>>>>>> title = models.CharField(max_length=100)
>>>>>> amount = models.DecimalField(max_digits=8, decimal_places=2)
>>>>>> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>>>>>>
>>>>>> the error is as follows:
>>>>>>
>>>>>>
>>>>>> Exception Type: AttributeError
>>>>>> Exception Value:
>>>>>>
>>>>>> 'QuerySet' object has no attribute 'expenses'
>>>>>>
>>>>>> Exception Location: 
>>>>>> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py
>>>>>> in projectdetail, line 238
>>>>>>
>>>>>> Please can anyone help?
>>>>>>
>>>>>> Best
>>>>>>
>>>>>> K
>>>>>>
>>>>>>
>>>>>> --
>>>>>> 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/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/django-users/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com?utm_medium=email_source=footer>
>>>>>> .
>>>>>>
>>>>>
>>>> --
>>>> 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/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmai

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
>>> Bhoopesh sisoudiya
>>>> 
>>>> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
>>>> Hi, 
>>>> 
>>>> New to Django. when navigating to the reqired view, I get the error above.
>>>> 
>>>> urls.py
>>>> 
>>>> path('businesslogin/businessadmin/busproject', views.projectdetail, 
>>>> name='projectdetail'),
>>>> 
>>>> views.py
>>>> 
>>>> def projectdetail(request):
>>>> project = Project.objects.all()
>>>> return render(request, 'busprojectdetail.html', {'project': project, 
>>>> 'expense_list': project.expenses.all()})
>>>> 
>>>> models.py
>>>> 
>>>> # Project model
>>>> 
>>>> class Project(models.Model):
>>>> name = models.CharField(max_length=100)
>>>> budget = IntegerField()
>>>> 
>>>> def save(self, *args, **kwargs):
>>>> self.name
>>>> super(Project, self).save(*args, **kwargs)
>>>> 
>>>> # Category manager model
>>>> 
>>>> 
>>>> class Category(models.Model):
>>>> project = models.ForeignKey(
>>>> Project, on_delete=models.CASCADE)
>>>> name = models.CharField(max_length=150)
>>>> 
>>>> 
>>>> # Expenses manager model
>>>> 
>>>> class Expense(models.Model):
>>>> project = models.ForeignKey(
>>>> Project, on_delete=models.CASCADE, related_name='expenses')
>>>> title = models.CharField(max_length=100)
>>>> amount = models.DecimalField(max_digits=8, decimal_places=2)
>>>> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>>>> 
>>>> the error is as follows:
>>>> 
>>>> 
>>>> Exception Type:AttributeError
>>>> Exception Value:   
>>>> 'QuerySet' object has no attribute 'expenses'
>>>> Exception Location:
>>>> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in 
>>>> projectdetail, line 238
>>>> 
>>>> Please can anyone help?
>>>> 
>>>> Best 
>>>> 
>>>> K
>>>> 
>>>> 
>>>> -- 
>>>> 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/024bc998-b683-41ae-90e2-d33f4527913a%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/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmail.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/52D49AAA-5E17-4F6C-92DE-E1576F305927%40gmail.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/CAAk3c1PtFX7oNie8qZKF%3Dm7jFrCEMwTZfn%2BcvWBFSqc9FT0h4A%40mail.gmail.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/06BE184B-33E5-4B84-A723-5C7075048349%40gmail.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/CAAk3c1OiCB0YW_5%2B2CcjFGJzBytRpOmKCw%3D3f_C2w-0JuESnvA%40mail.gmail.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/79DB1D00-AF66-4584-B635-7C22F9673733%40gmail.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/CAAk3c1OmNHiqVgvQMHj16wiMPr23hy%3DfU%2BE4WFH8sDixpiVx5w%40mail.gmail.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/751F6019-D299-44CE-AA95-CAC95D953A1E%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
projectdetail'),
>>>>>
>>>>> views.py
>>>>>
>>>>> def projectdetail(request):
>>>>> project = Project.objects.all()
>>>>> return render(request, 'busprojectdetail.html', {'project':
>>>>> project, 'expense_list': project.expenses.all()})
>>>>>
>>>>> models.py
>>>>>
>>>>> # Project model
>>>>>
>>>>> class Project(models.Model):
>>>>> name = models.CharField(max_length=100)
>>>>> budget = IntegerField()
>>>>>
>>>>> def save(self, *args, **kwargs):
>>>>> self.name
>>>>> super(Project, self).save(*args, **kwargs)
>>>>>
>>>>> # Category manager model
>>>>>
>>>>>
>>>>> class Category(models.Model):
>>>>> project = models.ForeignKey(
>>>>> Project, on_delete=models.CASCADE)
>>>>> name = models.CharField(max_length=150)
>>>>>
>>>>>
>>>>> # Expenses manager model
>>>>>
>>>>> class Expense(models.Model):
>>>>> project = models.ForeignKey(
>>>>> Project, on_delete=models.CASCADE, related_name='expenses')
>>>>> title = models.CharField(max_length=100)
>>>>> amount = models.DecimalField(max_digits=8, decimal_places=2)
>>>>> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>>>>>
>>>>> the error is as follows:
>>>>>
>>>>>
>>>>> Exception Type: AttributeError
>>>>> Exception Value:
>>>>>
>>>>> 'QuerySet' object has no attribute 'expenses'
>>>>>
>>>>> Exception Location: 
>>>>> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py
>>>>> in projectdetail, line 238
>>>>>
>>>>> Please can anyone help?
>>>>>
>>>>> Best
>>>>>
>>>>> K
>>>>>
>>>>>
>>>>> --
>>>>> 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/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>>
>>> --
>>> 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/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>>>
>>>
>>> --
>>> 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/52D49AAA-5E17-4F6C-92DE-E1576F305927%40gmail.com
>>> <https://groups.google.com/d/msgid/django-users/52D49AAA-5E17-4F6C-92DE-E1576F305927%40gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>>
>> --
>> 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/CAAk3c1PtFX7oNie8qZKF%3Dm7jFrCEMwTZfn%2BcvWBFSqc9FT0h4A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAAk3c1PtFX7oNie8qZKF%3Dm7jFrCEMwTZfn%2BcvWBFSqc9FT0h4A%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>>
>>
>> --
>> 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/06BE184B-33E5-4B84-A723-5C7075048349%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/06BE184B-33E5-4B84-A723-5C7075048349%40gmail.com?utm_medium=email_source=footer>
>> .
>>
>
> --
> 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/CAAk3c1OiCB0YW_5%2B2CcjFGJzBytRpOmKCw%3D3f_C2w-0JuESnvA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAk3c1OiCB0YW_5%2B2CcjFGJzBytRpOmKCw%3D3f_C2w-0JuESnvA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
>
> --
> 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/79DB1D00-AF66-4584-B635-7C22F9673733%40gmail.com
> <https://groups.google.com/d/msgid/django-users/79DB1D00-AF66-4584-B635-7C22F9673733%40gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAAk3c1OmNHiqVgvQMHj16wiMPr23hy%3DfU%2BE4WFH8sDixpiVx5w%40mail.gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Thanks,

I updated the view, and now I am getting syntax error.
Please see below.

views.py

def projectdetail(request):
project = Project.objects.all()
return render(request, 'busprojectdetail.html', {'project': project, 
'expense_list': project.expenses.all()})

projectDetails = Project.objects.select_related(Project).values(select 
column).all()

please advise how to correct?

Best,

Kean

On 6 Sep 2019, at 21:01, Bhoopesh sisoudiya  wrote:

> def projectdetail(request):
> project = Project.objects.all()
> return render(request, 'busprojectdetail.html', {'project': project, 
> 'expense_list': project.expenses.all()})
> 
> According to me by this archive you want expense details of each project
> 
> Then you write
> 
> projectDetails = Project.objects.select_related(your foreign key).values 
> (select column).all()
> 
> Thanks
> Bhoopesh sisoudiya
> 
> 
> On Sat, Sep 7, 2019, 1:22 AM Kean  wrote:
> Hi,
> 
> please ignore the manager it is just a naming convention ignore, it if for me 
> to identify tables, if i have 50 table, I want to be able to know which model 
> is holding which object information and for what I need it.
> 
> Please use below, I have removed the # information to reduce confusion.
> 
> models.py
> 
> class Project(models.Model):
> name = models.CharField(max_length=100)
> budget = IntegerField()
> 
> def save(self, *args, **kwargs):
> self.name
> super(Project, self).save(*args, **kwargs)
> 
> class Category(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
> 
> class Expense(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE, related_name='expenses')
> title = models.CharField(max_length=100)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
> On 6 Sep 2019, at 20:45, Bhoopesh sisoudiya  wrote:
> 
> Best wishes,
> Kean
> 
>> Ok No problem but 
>> why you want Manager?
>> 
>> Please send me answer
>> 
>> Thanks
>> Bhoopesh sisoudiya
>> 
>> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
>> Hi Bhoopesh
>> Thanks for this, please can you put it into the context of my specific model 
>> setup, so I get it right and understand.
>> This will be easier for me as this approach is causing me some other errors, 
>> when i try to apply it.
>> 
>> Best wishes, 
>> 
>> Kean 
>> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
>> 
>>> Hi Kean,
>>> 
>>>  Write manager like this ,I give you reference
>>> 
>>> from django.db import models
>>>  # First, define the Manager subclass. 
>>> class BhoopeshBookManager(models.Manager):
>>>def get_queryset(self): 
>>> return super(BhoopeshBookManager, 
>>> self).get_queryset().filter(author='Bhoopesh') 
>>> 
>>> # Then hook it into the Book model explicitly. class Book(models.Model): 
>>> title = models.CharField(max_length=100) 
>>> author = models.CharField(max_length=50)
>>>  # ... 
>>> objects = models.Manager()
>>>  # The default manager. 
>>> 
>>> bhoopesh_objects = BhoopeshBookManager()
>>>  # The Bhoopesh-specific manager.
>>> 
>>> 
>>> Book.bhoopesh_objects.all() # use manager
>>> 
>>> 
>>> Thanks 
>>> Bhoopesh Kumar
>>> 
>>> 
>>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya  
>>> wrote:
>>> Hi kean,
>>> Please check Expenses Class is not Manager
>>> Please make Manager Class.
>>> 
>>> 
>>> Thanks
>>> Bhoopesh sisoudiya
>>> 
>>> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
>>> Hi, 
>>> 
>>> New to Django. when navigating to the reqired view, I get the error above.
>>> 
>>> urls.py
>>> 
>>> path('businesslogin/businessadmin/busproject', views.projectdetail, 
>>> name='projectdetail'),
>>> 
>>> views.py
>>> 
>>> def projectdetail(request):
>>> project = Project.objects.all()
>>> return render(request, 'busprojectdetail.html', {'project': project, 
>>> 'expense_list': project.expenses.all()})
>>> 
>>> models.py
>>> 
>>> # Project model
>>> 
>>> class Project(models.Model):
>>> name = models.CharField(max_length=100)
>>> 

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
def projectdetail(request):
project = Project.objects.all()
return render(request, 'busprojectdetail.html', {'project': project,
'expense_list': project.expenses.all()})

According to me by this archive you want expense details of each project

Then you write

projectDetails = Project.objects.select_related(your foreign key).values
(select column).all()

Thanks
Bhoopesh sisoudiya


On Sat, Sep 7, 2019, 1:22 AM Kean  wrote:

> Hi,
>
> please ignore the manager it is just a naming convention ignore, it if for
> me to identify tables, if i have 50 table, I want to be able to know which
> model is holding which object information and for what I need it.
>
> Please use below, I have removed the # information to reduce confusion.
>
> models.py
>
> class Project(models.Model):
> name = models.CharField(max_length=100)
> budget = IntegerField()
>
> def save(self, *args, **kwargs):
> self.name
> super(Project, self).save(*args, **kwargs)
>
> class Category(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
>
> class Expense(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE, related_name='expenses')
> title = models.CharField(max_length=100)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
> On 6 Sep 2019, at 20:45, Bhoopesh sisoudiya  wrote:
>
> Best wishes,
> Kean
>
> Ok No problem but
> why you want Manager?
>
> Please send me answer
>
> Thanks
> Bhoopesh sisoudiya
>
> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
>
>> Hi Bhoopesh
>> Thanks for this, please can you put it into the context of my specific
>> model setup, so I get it right and understand.
>> This will be easier for me as this approach is causing me some other
>> errors, when i try to apply it.
>>
>> Best wishes,
>>
>> Kean
>> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
>>
>> Hi Kean,
>>
>>  Write manager like this ,I give you reference
>>
>> from django.db import models
>>  # First, define the Manager subclass.
>> class BhoopeshBookManager(models.Manager):
>>def get_queryset(self):
>> return super(BhoopeshBookManager,
>> self).get_queryset().filter(author='Bhoopesh')
>>
>> # Then hook it into the Book model explicitly. class Book(models.Model):
>> title = models.CharField(max_length=100)
>> author = models.CharField(max_length=50)
>>  # ...
>> objects = models.Manager()
>>  # The default manager.
>>
>> bhoopesh_objects = BhoopeshBookManager()
>>  # The Bhoopesh-specific manager.
>>
>>
>> Book.bhoopesh_objects.all() # use manager
>>
>>
>> Thanks
>> Bhoopesh Kumar
>>
>>
>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
>> wrote:
>>
>>> Hi kean,
>>> Please check Expenses Class is not Manager
>>> Please make Manager Class.
>>>
>>>
>>> Thanks
>>> Bhoopesh sisoudiya
>>>
>>> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
>>>
>>>> Hi,
>>>>
>>>> New to Django. when navigating to the reqired view, I get the error
>>>> above.
>>>>
>>>> urls.py
>>>>
>>>> path('businesslogin/businessadmin/busproject', views.projectdetail,
>>>> name='projectdetail'),
>>>>
>>>> views.py
>>>>
>>>> def projectdetail(request):
>>>> project = Project.objects.all()
>>>> return render(request, 'busprojectdetail.html', {'project':
>>>> project, 'expense_list': project.expenses.all()})
>>>>
>>>> models.py
>>>>
>>>> # Project model
>>>>
>>>> class Project(models.Model):
>>>> name = models.CharField(max_length=100)
>>>> budget = IntegerField()
>>>>
>>>> def save(self, *args, **kwargs):
>>>> self.name
>>>> super(Project, self).save(*args, **kwargs)
>>>>
>>>> # Category manager model
>>>>
>>>>
>>>> class Category(models.Model):
>>>> project = models.ForeignKey(
>>>> Project, on_delete=models.CASCADE)
>>>> name = models.CharField(max_length=150)
>>>>
>>>>
>>>> # Expenses manager model
>>>>
>>>> class Expense

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Hi,

please ignore the manager it is just a naming convention ignore, it if for me 
to identify tables, if i have 50 table, I want to be able to know which model 
is holding which object information and for what I need it.

Please use below, I have removed the # information to reduce confusion.

models.py

class Project(models.Model):
name = models.CharField(max_length=100)
budget = IntegerField()

def save(self, *args, **kwargs):
self.name
super(Project, self).save(*args, **kwargs)

class Category(models.Model):
project = models.ForeignKey(
Project, on_delete=models.CASCADE)
name = models.CharField(max_length=150)

class Expense(models.Model):
project = models.ForeignKey(
Project, on_delete=models.CASCADE, related_name='expenses')
title = models.CharField(max_length=100)
amount = models.DecimalField(max_digits=8, decimal_places=2)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
On 6 Sep 2019, at 20:45, Bhoopesh sisoudiya  wrote:

Best wishes,
Kean

> Ok No problem but 
> why you want Manager?
> 
> Please send me answer
> 
> Thanks
> Bhoopesh sisoudiya
> 
> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
> Hi Bhoopesh
> Thanks for this, please can you put it into the context of my specific model 
> setup, so I get it right and understand.
> This will be easier for me as this approach is causing me some other errors, 
> when i try to apply it.
> 
> Best wishes, 
> 
> Kean 
> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
> 
>> Hi Kean,
>> 
>>  Write manager like this ,I give you reference
>> 
>> from django.db import models
>>  # First, define the Manager subclass. 
>> class BhoopeshBookManager(models.Manager):
>>def get_queryset(self): 
>> return super(BhoopeshBookManager, 
>> self).get_queryset().filter(author='Bhoopesh') 
>> 
>> # Then hook it into the Book model explicitly. class Book(models.Model): 
>> title = models.CharField(max_length=100) 
>> author = models.CharField(max_length=50)
>>  # ... 
>> objects = models.Manager()
>>  # The default manager. 
>> 
>> bhoopesh_objects = BhoopeshBookManager()
>>  # The Bhoopesh-specific manager.
>> 
>> 
>> Book.bhoopesh_objects.all() # use manager
>> 
>> 
>> Thanks 
>> Bhoopesh Kumar
>> 
>> 
>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya  
>> wrote:
>> Hi kean,
>> Please check Expenses Class is not Manager
>> Please make Manager Class.
>> 
>> 
>> Thanks
>> Bhoopesh sisoudiya
>> 
>> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
>> Hi, 
>> 
>> New to Django. when navigating to the reqired view, I get the error above.
>> 
>> urls.py
>> 
>> path('businesslogin/businessadmin/busproject', views.projectdetail, 
>> name='projectdetail'),
>> 
>> views.py
>> 
>> def projectdetail(request):
>> project = Project.objects.all()
>> return render(request, 'busprojectdetail.html', {'project': project, 
>> 'expense_list': project.expenses.all()})
>> 
>> models.py
>> 
>> # Project model
>> 
>> class Project(models.Model):
>> name = models.CharField(max_length=100)
>> budget = IntegerField()
>> 
>> def save(self, *args, **kwargs):
>> self.name
>> super(Project, self).save(*args, **kwargs)
>> 
>> # Category manager model
>> 
>> 
>> class Category(models.Model):
>> project = models.ForeignKey(
>> Project, on_delete=models.CASCADE)
>> name = models.CharField(max_length=150)
>> 
>> 
>> # Expenses manager model
>> 
>> class Expense(models.Model):
>> project = models.ForeignKey(
>> Project, on_delete=models.CASCADE, related_name='expenses')
>> title = models.CharField(max_length=100)
>> amount = models.DecimalField(max_digits=8, decimal_places=2)
>> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>> 
>> the error is as follows:
>> 
>> 
>> Exception Type:  AttributeError
>> Exception Value: 
>> 'QuerySet' object has no attribute 'expenses'
>> Exception Location:  
>> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
>> line 238
>> 
>> Please can anyone help?
>> 
>> Best 
>> 
>> K
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving 

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
Hi kean,

Category and Expense is not Manager model this is only model class.

Thanks
Bhoopesh Kumar



On Sat, Sep 7, 2019, 1:15 AM Bhoopesh sisoudiya 
wrote:

> Ok No problem but
> why you want Manager?
>
> Please send me answer
>
> Thanks
> Bhoopesh sisoudiya
>
> On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:
>
>> Hi Bhoopesh
>> Thanks for this, please can you put it into the context of my specific
>> model setup, so I get it right and understand.
>> This will be easier for me as this approach is causing me some other
>> errors, when i try to apply it.
>>
>> Best wishes,
>>
>> Kean
>> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
>>
>> Hi Kean,
>>
>>  Write manager like this ,I give you reference
>>
>> from django.db import models
>>  # First, define the Manager subclass.
>> class BhoopeshBookManager(models.Manager):
>>def get_queryset(self):
>> return super(BhoopeshBookManager,
>> self).get_queryset().filter(author='Bhoopesh')
>>
>> # Then hook it into the Book model explicitly. class Book(models.Model):
>> title = models.CharField(max_length=100)
>> author = models.CharField(max_length=50)
>>  # ...
>> objects = models.Manager()
>>  # The default manager.
>>
>> bhoopesh_objects = BhoopeshBookManager()
>>  # The Bhoopesh-specific manager.
>>
>>
>> Book.bhoopesh_objects.all() # use manager
>>
>>
>> Thanks
>> Bhoopesh Kumar
>>
>>
>> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
>> wrote:
>>
>>> Hi kean,
>>> Please check Expenses Class is not Manager
>>> Please make Manager Class.
>>>
>>>
>>> Thanks
>>> Bhoopesh sisoudiya
>>>
>>> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
>>>
>>>> Hi,
>>>>
>>>> New to Django. when navigating to the reqired view, I get the error
>>>> above.
>>>>
>>>> urls.py
>>>>
>>>> path('businesslogin/businessadmin/busproject', views.projectdetail,
>>>> name='projectdetail'),
>>>>
>>>> views.py
>>>>
>>>> def projectdetail(request):
>>>> project = Project.objects.all()
>>>> return render(request, 'busprojectdetail.html', {'project':
>>>> project, 'expense_list': project.expenses.all()})
>>>>
>>>> models.py
>>>>
>>>> # Project model
>>>>
>>>> class Project(models.Model):
>>>> name = models.CharField(max_length=100)
>>>> budget = IntegerField()
>>>>
>>>> def save(self, *args, **kwargs):
>>>> self.name
>>>>     super(Project, self).save(*args, **kwargs)
>>>>
>>>> # Category manager model
>>>>
>>>>
>>>> class Category(models.Model):
>>>> project = models.ForeignKey(
>>>> Project, on_delete=models.CASCADE)
>>>> name = models.CharField(max_length=150)
>>>>
>>>>
>>>> # Expenses manager model
>>>>
>>>> class Expense(models.Model):
>>>> project = models.ForeignKey(
>>>> Project, on_delete=models.CASCADE, related_name='expenses')
>>>> title = models.CharField(max_length=100)
>>>> amount = models.DecimalField(max_digits=8, decimal_places=2)
>>>> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>>>>
>>>> the error is as follows:
>>>>
>>>>
>>>> Exception Type: AttributeError
>>>> Exception Value:
>>>>
>>>> 'QuerySet' object has no attribute 'expenses'
>>>>
>>>> Exception Location: 
>>>> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py
>>>> in projectdetail, line 238
>>>>
>>>> Please can anyone help?
>>>>
>>>> Best
>>>>
>>>> K
>>>>
>>>>
>>>> --
>>>> 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/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com
>&

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
Ok No problem but
why you want Manager?

Please send me answer

Thanks
Bhoopesh sisoudiya

On Sat, Sep 7, 2019, 1:06 AM Kean  wrote:

> Hi Bhoopesh
> Thanks for this, please can you put it into the context of my specific
> model setup, so I get it right and understand.
> This will be easier for me as this approach is causing me some other
> errors, when i try to apply it.
>
> Best wishes,
>
> Kean
> On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:
>
> Hi Kean,
>
>  Write manager like this ,I give you reference
>
> from django.db import models
>  # First, define the Manager subclass.
> class BhoopeshBookManager(models.Manager):
>def get_queryset(self):
> return super(BhoopeshBookManager,
> self).get_queryset().filter(author='Bhoopesh')
>
> # Then hook it into the Book model explicitly. class Book(models.Model):
> title = models.CharField(max_length=100)
> author = models.CharField(max_length=50)
>  # ...
> objects = models.Manager()
>  # The default manager.
>
> bhoopesh_objects = BhoopeshBookManager()
>  # The Bhoopesh-specific manager.
>
>
> Book.bhoopesh_objects.all() # use manager
>
>
> Thanks
> Bhoopesh Kumar
>
>
> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
> wrote:
>
>> Hi kean,
>> Please check Expenses Class is not Manager
>> Please make Manager Class.
>>
>>
>> Thanks
>> Bhoopesh sisoudiya
>>
>> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
>>
>>> Hi,
>>>
>>> New to Django. when navigating to the reqired view, I get the error
>>> above.
>>>
>>> urls.py
>>>
>>> path('businesslogin/businessadmin/busproject', views.projectdetail,
>>> name='projectdetail'),
>>>
>>> views.py
>>>
>>> def projectdetail(request):
>>> project = Project.objects.all()
>>> return render(request, 'busprojectdetail.html', {'project':
>>> project, 'expense_list': project.expenses.all()})
>>>
>>> models.py
>>>
>>> # Project model
>>>
>>> class Project(models.Model):
>>> name = models.CharField(max_length=100)
>>> budget = IntegerField()
>>>
>>> def save(self, *args, **kwargs):
>>> self.name
>>> super(Project, self).save(*args, **kwargs)
>>>
>>> # Category manager model
>>>
>>>
>>> class Category(models.Model):
>>> project = models.ForeignKey(
>>> Project, on_delete=models.CASCADE)
>>> name = models.CharField(max_length=150)
>>>
>>>
>>> # Expenses manager model
>>>
>>> class Expense(models.Model):
>>> project = models.ForeignKey(
>>> Project, on_delete=models.CASCADE, related_name='expenses')
>>> title = models.CharField(max_length=100)
>>> amount = models.DecimalField(max_digits=8, decimal_places=2)
>>> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>>>
>>> the error is as follows:
>>>
>>>
>>> Exception Type: AttributeError
>>> Exception Value:
>>>
>>> 'QuerySet' object has no attribute 'expenses'
>>>
>>> Exception Location: 
>>> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py
>>> in projectdetail, line 238
>>>
>>> Please can anyone help?
>>>
>>> Best
>>>
>>> K
>>>
>>>
>>> --
>>> 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/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> --
> 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/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC

Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Hi Bhoopesh
Thanks for this, please can you put it into the context of my specific model 
setup, so I get it right and understand.
This will be easier for me as this approach is causing me some other errors, 
when i try to apply it.

Best wishes, 

Kean 
On 6 Sep 2019, at 20:19, Bhoopesh sisoudiya  wrote:

> Hi Kean,
> 
>  Write manager like this ,I give you reference
> 
> from django.db import models
>  # First, define the Manager subclass. 
> class BhoopeshBookManager(models.Manager):
>def get_queryset(self): 
> return super(BhoopeshBookManager, 
> self).get_queryset().filter(author='Bhoopesh') 
> 
> # Then hook it into the Book model explicitly. class Book(models.Model): 
> title = models.CharField(max_length=100) 
> author = models.CharField(max_length=50)
>  # ... 
> objects = models.Manager()
>  # The default manager. 
> 
> bhoopesh_objects = BhoopeshBookManager()
>  # The Bhoopesh-specific manager.
> 
> 
> Book.bhoopesh_objects.all() # use manager
> 
> 
> Thanks 
> Bhoopesh Kumar
> 
> 
> On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya  wrote:
> Hi kean,
> Please check Expenses Class is not Manager
> Please make Manager Class.
> 
> 
> Thanks
> Bhoopesh sisoudiya
> 
> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
> Hi, 
> 
> New to Django. when navigating to the reqired view, I get the error above.
> 
> urls.py
> 
> path('businesslogin/businessadmin/busproject', views.projectdetail, 
> name='projectdetail'),
> 
> views.py
> 
> def projectdetail(request):
> project = Project.objects.all()
> return render(request, 'busprojectdetail.html', {'project': project, 
> 'expense_list': project.expenses.all()})
> 
> models.py
> 
> # Project model
> 
> class Project(models.Model):
> name = models.CharField(max_length=100)
> budget = IntegerField()
> 
> def save(self, *args, **kwargs):
> self.name
> super(Project, self).save(*args, **kwargs)
> 
> # Category manager model
> 
> 
> class Category(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
> 
> 
> # Expenses manager model
> 
> class Expense(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE, related_name='expenses')
> title = models.CharField(max_length=100)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
> 
> the error is as follows:
> 
> 
> Exception Type:   AttributeError
> Exception Value:  
> 'QuerySet' object has no attribute 'expenses'
> Exception Location:   
> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
> line 238
> 
> Please can anyone help?
> 
> Best 
> 
> K
> 
> 
> -- 
> 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/024bc998-b683-41ae-90e2-d33f4527913a%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/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmail.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/52D49AAA-5E17-4F6C-92DE-E1576F305927%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
Hi Kean,

 Write manager like this ,I give you reference

from django.db import models
 # First, define the Manager subclass.
class BhoopeshBookManager(models.Manager):
   def get_queryset(self):
return super(BhoopeshBookManager,
self).get_queryset().filter(author='Bhoopesh')

# Then hook it into the Book model explicitly. class Book(models.Model):
title = models.CharField(max_length=100)
author = models.CharField(max_length=50)
 # ...
objects = models.Manager()
 # The default manager.

bhoopesh_objects = BhoopeshBookManager()
 # The Bhoopesh-specific manager.


Book.bhoopesh_objects.all() # use manager


Thanks
Bhoopesh Kumar


On Sat, Sep 7, 2019, 12:34 AM Bhoopesh sisoudiya 
wrote:

> Hi kean,
> Please check Expenses Class is not Manager
> Please make Manager Class.
>
>
> Thanks
> Bhoopesh sisoudiya
>
> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
>
>> Hi,
>>
>> New to Django. when navigating to the reqired view, I get the error above.
>>
>> urls.py
>>
>> path('businesslogin/businessadmin/busproject', views.projectdetail,
>> name='projectdetail'),
>>
>> views.py
>>
>> def projectdetail(request):
>> project = Project.objects.all()
>> return render(request, 'busprojectdetail.html', {'project': project,
>> 'expense_list': project.expenses.all()})
>>
>> models.py
>>
>> # Project model
>>
>> class Project(models.Model):
>> name = models.CharField(max_length=100)
>> budget = IntegerField()
>>
>> def save(self, *args, **kwargs):
>> self.name
>> super(Project, self).save(*args, **kwargs)
>>
>> # Category manager model
>>
>>
>> class Category(models.Model):
>> project = models.ForeignKey(
>> Project, on_delete=models.CASCADE)
>> name = models.CharField(max_length=150)
>>
>>
>> # Expenses manager model
>>
>> class Expense(models.Model):
>> project = models.ForeignKey(
>> Project, on_delete=models.CASCADE, related_name='expenses')
>> title = models.CharField(max_length=100)
>> amount = models.DecimalField(max_digits=8, decimal_places=2)
>> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>>
>> the error is as follows:
>>
>>
>> Exception Type: AttributeError
>> Exception Value:
>>
>> 'QuerySet' object has no attribute 'expenses'
>>
>> Exception Location: /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py
>> in projectdetail, line 238
>>
>> Please can anyone help?
>>
>> Best
>>
>> K
>>
>> --
>> 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/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/CAAk3c1NmgbP7cQtyX8uOAFX%3DXbyC6f2ug1FURabwxRgD44Mwpg%40mail.gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Hi, 

Thanks for the help.

The header for each model is # out, so is not read when the code parsed, it is 
just to help me identify the models.
I only have 3 models Project, Category and Expense.

Best wishes,

Kean

On 6 Sep 2019, at 20:04, Bhoopesh sisoudiya  wrote:

> Hi kean,
> Please check Expenses Class is not Manager
> Please make Manager Class.
> 
> 
> Thanks
> Bhoopesh sisoudiya
> 
> On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:
> Hi, 
> 
> New to Django. when navigating to the reqired view, I get the error above.
> 
> urls.py
> 
> path('businesslogin/businessadmin/busproject', views.projectdetail, 
> name='projectdetail'),
> 
> views.py
> 
> def projectdetail(request):
> project = Project.objects.all()
> return render(request, 'busprojectdetail.html', {'project': project, 
> 'expense_list': project.expenses.all()})
> 
> models.py
> 
> # Project model
> 
> class Project(models.Model):
> name = models.CharField(max_length=100)
> budget = IntegerField()
> 
> def save(self, *args, **kwargs):
> self.name
> super(Project, self).save(*args, **kwargs)
> 
> # Category manager model
> 
> 
> class Category(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
> 
> 
> # Expenses manager model
> 
> class Expense(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE, related_name='expenses')
> title = models.CharField(max_length=100)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
> 
> the error is as follows:
> 
> 
> Exception Type:   AttributeError
> Exception Value:  
> 'QuerySet' object has no attribute 'expenses'
> Exception Location:   
> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
> line 238
> 
> Please can anyone help?
> 
> Best 
> 
> K
> 
> 
> -- 
> 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/024bc998-b683-41ae-90e2-d33f4527913a%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/CAAk3c1PoGuLeAsnJoEUuB1LdZw8SwpJDFy51%3Di89%2BAv_Zd1sOA%40mail.gmail.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/72107009-5D9C-4EC6-8D4D-233A244E8563%40gmail.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Bhoopesh sisoudiya
Hi kean,
Please check Expenses Class is not Manager
Please make Manager Class.


Thanks
Bhoopesh sisoudiya

On Sat, Sep 7, 2019, 12:20 AM Kean  wrote:

> Hi,
>
> New to Django. when navigating to the reqired view, I get the error above.
>
> urls.py
>
> path('businesslogin/businessadmin/busproject', views.projectdetail,
> name='projectdetail'),
>
> views.py
>
> def projectdetail(request):
> project = Project.objects.all()
> return render(request, 'busprojectdetail.html', {'project': project,
> 'expense_list': project.expenses.all()})
>
> models.py
>
> # Project model
>
> class Project(models.Model):
> name = models.CharField(max_length=100)
> budget = IntegerField()
>
> def save(self, *args, **kwargs):
> self.name
> super(Project, self).save(*args, **kwargs)
>
> # Category manager model
>
>
> class Category(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
>
>
> # Expenses manager model
>
> class Expense(models.Model):
> project = models.ForeignKey(
> Project, on_delete=models.CASCADE, related_name='expenses')
> title = models.CharField(max_length=100)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>
> the error is as follows:
>
>
> Exception Type: AttributeError
> Exception Value:
>
> 'QuerySet' object has no attribute 'expenses'
>
> Exception Location: /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py
> in projectdetail, line 238
>
> Please can anyone help?
>
> Best
>
> K
>
> --
> 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/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAAk3c1PoGuLeAsnJoEUuB1LdZw8SwpJDFy51%3Di89%2BAv_Zd1sOA%40mail.gmail.com.


AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-06 Thread Kean
Hi, 

New to Django. when navigating to the reqired view, I get the error above.

urls.py

path('businesslogin/businessadmin/busproject', views.projectdetail, 
name='projectdetail'),

views.py

def projectdetail(request):
project = Project.objects.all()
return render(request, 'busprojectdetail.html', {'project': project, 
'expense_list': project.expenses.all()})

models.py

# Project model

class Project(models.Model):
name = models.CharField(max_length=100)
budget = IntegerField()

def save(self, *args, **kwargs):
self.name
super(Project, self).save(*args, **kwargs)

# Category manager model


class Category(models.Model):
project = models.ForeignKey(
Project, on_delete=models.CASCADE)
name = models.CharField(max_length=150)


# Expenses manager model

class Expense(models.Model):
project = models.ForeignKey(
Project, on_delete=models.CASCADE, related_name='expenses')
title = models.CharField(max_length=100)
amount = models.DecimalField(max_digits=8, decimal_places=2)
category = models.ForeignKey(Category, on_delete=models.CASCADE)

the error is as follows:


Exception Type: AttributeError
Exception Value: 

'QuerySet' object has no attribute 'expenses'

Exception Location: /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py 
in projectdetail, line 238

Please can anyone help?

Best 

K

-- 
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/024bc998-b683-41ae-90e2-d33f4527913a%40googlegroups.com.


Re: AttributeError 'QuerySet' object has no attribute '_meta'

2019-08-18 Thread Kean Dumba
Ok thanks is there a way to call all objects, as this is more user friendly
and efficient when potentially editing many object fields?

On Sun, 18 Aug 2019 at 18:05, Daniel Roseman  wrote:

> You can't pass *all* the objects to the form. You have to get the specific
> one you want to edit and pass that as the instance.
>
> --
> 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/e78cfd54-9800-4c17-b8a4-0ffaf5ddcfd4%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/CAKvrVZO_rKiPOm9ZLZ%2BmiUpTgUy-xim%2Br7s8kRWskThHtndjpw%40mail.gmail.com.


AttributeError 'QuerySet' object has no attribute '_meta'

2019-08-18 Thread Daniel Roseman
You can't pass *all* the objects to the form. You have to get the specific one 
you want to edit and pass that as the instance.

-- 
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/e78cfd54-9800-4c17-b8a4-0ffaf5ddcfd4%40googlegroups.com.


AttributeError 'QuerySet' object has no attribute '_meta'

2019-08-18 Thread Kean
Hi,

New to Django but trying to stick with it.

I have created a model form, which creates ok.

I am trying to edit records. I have the following, but keep getting the 
QuerySet object has no attribute '_meta' in the browser.

my views.py

def editbusiness(request):
data = models.Businessownercreate.objects.all() 
if request.method == "POST": 
form = forms.Businessownercreate(request.POST, instance=data)
if form.is_valid():
form.save()
return redirect("accounts:editremovebusiness")
else: 
form = forms.Businessownercreate(instance=data)
return render(request, 'editbusiness.html', context={ 'form':form })

my forms.py 

class Businessownercreate(forms.ModelForm):
class Meta:
model = Businessownercreate
fields = [ "Creator", "Micro_Small_Medium", "Business_Name", 
"Owner_Firstname", 
"Owner_Surname", "Companies_House_Number", "Address_Line_1", 
"Address_Line_2",
"Town", "City", "County", "Postcode", "Email", "Phone", "Mobile" ]

I'm have defined the meta, so i can't see why the query cant return the 
objects from the model to the form in this instance.

Please can anyone advise or help?

Best,

K



-- 
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/5e4d57f1-e41b-4692-8814-1c1888e563dc%40googlegroups.com.


Re: Getting AttributeError: module 'asyncio' has no attribute '_get_running_loop'

2019-07-08 Thread Andrew Godwin
The bug was only on Python 3.5. It's possible the other system was 3.6 or
3.7?

Andrew

On Sun, Jul 7, 2019 at 9:48 AM Rohit Chopra  wrote:

> Hi Andrew,
>
> Just a small doubt, why same code is working on my local system.
> Both local and server have same  version of requirements mentioned in
> requirements.txt
>
> Rohit
>
> On Sun 7 Jul, 2019, 9:36 PM Andrew Godwin,  wrote:
>
>> Hi Rohit,
>>
>> This is my fault - we made a change in the "asgiref" library that
>> inadvertently removed Python 3.5 support. Channels still needs to support
>> it (even though Django doesn't).
>>
>> If you update to asgiref 3.1.4, which I've just released, that should fix
>> the issue.
>>
>> Andrew
>>
>> On Sun, Jul 7, 2019 at 8:52 AM Rohit Chopra 
>> wrote:
>>
>>> Hi All,
>>>
>>> I am using channels to implement WebSockets.
>>> I am trying to send data through WebSockets from *post_save *django
>>> signal.
>>> Below is my code.
>>>
>>> **signals.py**
>>>
>>>
>>> @receiver(post_save, sender=CheckIn)
>>> def send_data_on_save(sender, instance, **kwargs):
>>> channel_layer = get_channel_layer()
>>> stats = get_stats()
>>> async_to_sync(channel_layer.group_send)(
>>> 'dashboard',
>>> {
>>> 'type': 'send_data',
>>> 'message': stats
>>> }
>>> )
>>>
>>>
>>> analytics = get_analytics()
>>> async_to_sync(channel_layer.group_send)(
>>> 'analytic',
>>> {
>>> 'type': 'send_data',
>>> 'message': analytics
>>> }
>>> )
>>>
>>>
>>>
>>> **consumers.py**
>>>
>>>
>>> class DashboardConsumer(WebsocketConsumer):
>>> def connect(self):
>>> self.room_group_name = 'dashboard'
>>>
>>>
>>> # Join room group
>>> async_to_sync(self.channel_layer.group_add)(
>>> self.room_group_name,
>>> self.channel_name
>>> )
>>>
>>>
>>> self.accept()
>>>
>>>
>>> def disconnect(self, close_code):
>>> # Leave room group
>>> async_to_sync(self.channel_layer.group_discard)(
>>> self.room_group_name,
>>> self.channel_name
>>> )
>>>
>>>
>>> # Receive message from WebSocket
>>> def receive(self, text_data):
>>> text_data_json = json.loads(text_data)
>>> message = text_data_json['message']
>>>
>>>
>>> # Send message to room group
>>> async_to_sync(self.channel_layer.group_send)(
>>> self.room_group_name,
>>> {
>>> 'type': 'send_data',
>>> 'message': message
>>> }
>>> )
>>>
>>>
>>> # Receive message from room group
>>> def send_data(self, event):
>>> message = event['message']
>>>
>>>
>>> # Send message to WebSocket
>>> self.send(text_data=json.dumps({
>>> 'message': message
>>> }))
>>>
>>>
>>>
>>> this same piece of code is working on my local machine(windows) but when
>>> i am trying to run this code on server(ubuntu 16.04) i am getting bellow
>>> error:
>>>
>>> **Traceback**
>>>
>>>
>>>
>>> Exception inside application: module 'asyncio' has no attribute
>>> '_get_running_loop'
>>> File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
>>> result = coro.throw(exc)
>>> File
>>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/sessions.py"
>>> , line 183, in __call__
>>> return await self.inner(receive, self.send)
>>> File
>>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/middleware.py"
>>> , line 41, in coroutine_call
>>> await inner_instance(receive, send)
>>> File
>>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/consumer.py"
>>> , line 59, in __call__
>>> [receive, self.channel_receive], self.dispatch
>>> File
>>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/utils.py"
>>> , line 52, in await_many_dispatch
>>> await dispatch(result)
>>> File
>>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/asgiref/sync.py"
>>> , line 145, in __call__
>>> return await asyncio.wait_for(future, timeout=None)
>>> File "/usr/lib/python3.5/asyncio/tasks.py", line 373, in wait_for
>>> return (yield from fut)
>>> File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
>>> yield self  # This tells Task to wait for completion.
>>> File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
>>> future.result()
>>> File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
>>> raise self._exception
>>> File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in
>>> run
>>> result = self.fn(*self.args, **self.kwargs)
>>> File
>>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/db.py"
>>> , line 14, in thread_handler
>>> return super().thread_handler(loop, *args, 

Re: Getting AttributeError: module 'asyncio' has no attribute '_get_running_loop'

2019-07-07 Thread Rohit Chopra
Hi Andrew,

Just a small doubt, why same code is working on my local system.
Both local and server have same  version of requirements mentioned in
requirements.txt

Rohit

On Sun 7 Jul, 2019, 9:36 PM Andrew Godwin,  wrote:

> Hi Rohit,
>
> This is my fault - we made a change in the "asgiref" library that
> inadvertently removed Python 3.5 support. Channels still needs to support
> it (even though Django doesn't).
>
> If you update to asgiref 3.1.4, which I've just released, that should fix
> the issue.
>
> Andrew
>
> On Sun, Jul 7, 2019 at 8:52 AM Rohit Chopra 
> wrote:
>
>> Hi All,
>>
>> I am using channels to implement WebSockets.
>> I am trying to send data through WebSockets from *post_save *django
>> signal.
>> Below is my code.
>>
>> **signals.py**
>>
>>
>> @receiver(post_save, sender=CheckIn)
>> def send_data_on_save(sender, instance, **kwargs):
>> channel_layer = get_channel_layer()
>> stats = get_stats()
>> async_to_sync(channel_layer.group_send)(
>> 'dashboard',
>> {
>> 'type': 'send_data',
>> 'message': stats
>> }
>> )
>>
>>
>> analytics = get_analytics()
>> async_to_sync(channel_layer.group_send)(
>> 'analytic',
>> {
>> 'type': 'send_data',
>> 'message': analytics
>> }
>> )
>>
>>
>>
>> **consumers.py**
>>
>>
>> class DashboardConsumer(WebsocketConsumer):
>> def connect(self):
>> self.room_group_name = 'dashboard'
>>
>>
>> # Join room group
>> async_to_sync(self.channel_layer.group_add)(
>> self.room_group_name,
>> self.channel_name
>> )
>>
>>
>> self.accept()
>>
>>
>> def disconnect(self, close_code):
>> # Leave room group
>> async_to_sync(self.channel_layer.group_discard)(
>> self.room_group_name,
>> self.channel_name
>> )
>>
>>
>> # Receive message from WebSocket
>> def receive(self, text_data):
>> text_data_json = json.loads(text_data)
>> message = text_data_json['message']
>>
>>
>> # Send message to room group
>> async_to_sync(self.channel_layer.group_send)(
>> self.room_group_name,
>> {
>> 'type': 'send_data',
>> 'message': message
>> }
>> )
>>
>>
>> # Receive message from room group
>> def send_data(self, event):
>> message = event['message']
>>
>>
>> # Send message to WebSocket
>> self.send(text_data=json.dumps({
>> 'message': message
>> }))
>>
>>
>>
>> this same piece of code is working on my local machine(windows) but when
>> i am trying to run this code on server(ubuntu 16.04) i am getting bellow
>> error:
>>
>> **Traceback**
>>
>>
>>
>> Exception inside application: module 'asyncio' has no attribute
>> '_get_running_loop'
>> File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
>> result = coro.throw(exc)
>> File
>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/sessions.py"
>> , line 183, in __call__
>> return await self.inner(receive, self.send)
>> File
>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/middleware.py"
>> , line 41, in coroutine_call
>> await inner_instance(receive, send)
>> File
>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/consumer.py"
>> , line 59, in __call__
>> [receive, self.channel_receive], self.dispatch
>> File
>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/utils.py"
>> , line 52, in await_many_dispatch
>> await dispatch(result)
>> File
>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/asgiref/sync.py"
>> , line 145, in __call__
>> return await asyncio.wait_for(future, timeout=None)
>> File "/usr/lib/python3.5/asyncio/tasks.py", line 373, in wait_for
>> return (yield from fut)
>> File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
>> yield self  # This tells Task to wait for completion.
>> File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
>> future.result()
>> File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
>> raise self._exception
>> File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in
>> run
>> result = self.fn(*self.args, **self.kwargs)
>> File
>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/db.py",
>> line 14, in thread_handler
>> return super().thread_handler(loop, *args, **kwargs)
>> File
>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/asgiref/sync.py"
>> , line 164, in thread_handler
>> return func(*args, **kwargs)
>> File
>> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/consumer.py"
>> , line 105, in dispatch
>> 

Re: Getting AttributeError: module 'asyncio' has no attribute '_get_running_loop'

2019-07-07 Thread Andrew Godwin
Hi Rohit,

This is my fault - we made a change in the "asgiref" library that
inadvertently removed Python 3.5 support. Channels still needs to support
it (even though Django doesn't).

If you update to asgiref 3.1.4, which I've just released, that should fix
the issue.

Andrew

On Sun, Jul 7, 2019 at 8:52 AM Rohit Chopra  wrote:

> Hi All,
>
> I am using channels to implement WebSockets.
> I am trying to send data through WebSockets from *post_save *django
> signal.
> Below is my code.
>
> **signals.py**
>
>
> @receiver(post_save, sender=CheckIn)
> def send_data_on_save(sender, instance, **kwargs):
> channel_layer = get_channel_layer()
> stats = get_stats()
> async_to_sync(channel_layer.group_send)(
> 'dashboard',
> {
> 'type': 'send_data',
> 'message': stats
> }
> )
>
>
> analytics = get_analytics()
> async_to_sync(channel_layer.group_send)(
> 'analytic',
> {
> 'type': 'send_data',
> 'message': analytics
> }
> )
>
>
>
> **consumers.py**
>
>
> class DashboardConsumer(WebsocketConsumer):
> def connect(self):
> self.room_group_name = 'dashboard'
>
>
> # Join room group
> async_to_sync(self.channel_layer.group_add)(
> self.room_group_name,
> self.channel_name
> )
>
>
> self.accept()
>
>
> def disconnect(self, close_code):
> # Leave room group
> async_to_sync(self.channel_layer.group_discard)(
> self.room_group_name,
> self.channel_name
> )
>
>
> # Receive message from WebSocket
> def receive(self, text_data):
> text_data_json = json.loads(text_data)
> message = text_data_json['message']
>
>
> # Send message to room group
> async_to_sync(self.channel_layer.group_send)(
> self.room_group_name,
> {
> 'type': 'send_data',
> 'message': message
> }
> )
>
>
> # Receive message from room group
> def send_data(self, event):
> message = event['message']
>
>
> # Send message to WebSocket
> self.send(text_data=json.dumps({
> 'message': message
> }))
>
>
>
> this same piece of code is working on my local machine(windows) but when i
> am trying to run this code on server(ubuntu 16.04) i am getting bellow
> error:
>
> **Traceback**
>
>
>
> Exception inside application: module 'asyncio' has no attribute
> '_get_running_loop'
> File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
> result = coro.throw(exc)
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/sessions.py"
> , line 183, in __call__
> return await self.inner(receive, self.send)
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/middleware.py"
> , line 41, in coroutine_call
> await inner_instance(receive, send)
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/consumer.py"
> , line 59, in __call__
> [receive, self.channel_receive], self.dispatch
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/utils.py"
> , line 52, in await_many_dispatch
> await dispatch(result)
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/asgiref/sync.py",
> line 145, in __call__
> return await asyncio.wait_for(future, timeout=None)
> File "/usr/lib/python3.5/asyncio/tasks.py", line 373, in wait_for
> return (yield from fut)
> File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
> yield self  # This tells Task to wait for completion.
> File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
> future.result()
> File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
> raise self._exception
> File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in
> run
> result = self.fn(*self.args, **self.kwargs)
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/db.py",
> line 14, in thread_handler
> return super().thread_handler(loop, *args, **kwargs)
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/asgiref/sync.py",
> line 164, in thread_handler
> return func(*args, **kwargs)
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/consumer.py"
> , line 105, in dispatch
> handler(message)
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/generic/websocket.py"
> , line 39, in websocket_connect
> self.connect()
> File "/home/user1/demowebapps/vmsbackend/check_in/consumers.py", line
> 57, in connect
> self.channel_name
> File
> "/home/user1/demowebapps/env/lib/python3.5/site-packages/asgiref/sync.py",
> line 41, 

Getting AttributeError: module 'asyncio' has no attribute '_get_running_loop'

2019-07-07 Thread Rohit Chopra
Hi All,

I am using channels to implement WebSockets.
I am trying to send data through WebSockets from *post_save *django signal.
Below is my code.

**signals.py**


@receiver(post_save, sender=CheckIn)
def send_data_on_save(sender, instance, **kwargs):
channel_layer = get_channel_layer()
stats = get_stats()
async_to_sync(channel_layer.group_send)(
'dashboard',
{
'type': 'send_data',
'message': stats
}
)


analytics = get_analytics()
async_to_sync(channel_layer.group_send)(
'analytic',
{
'type': 'send_data',
'message': analytics
}
)



**consumers.py**


class DashboardConsumer(WebsocketConsumer):
def connect(self):
self.room_group_name = 'dashboard'


# Join room group
async_to_sync(self.channel_layer.group_add)(
self.room_group_name,
self.channel_name
)


self.accept()


def disconnect(self, close_code):
# Leave room group
async_to_sync(self.channel_layer.group_discard)(
self.room_group_name,
self.channel_name
)


# Receive message from WebSocket
def receive(self, text_data):
text_data_json = json.loads(text_data)
message = text_data_json['message']


# Send message to room group
async_to_sync(self.channel_layer.group_send)(
self.room_group_name,
{
'type': 'send_data',
'message': message
}
)


# Receive message from room group
def send_data(self, event):
message = event['message']


# Send message to WebSocket
self.send(text_data=json.dumps({
'message': message
}))



this same piece of code is working on my local machine(windows) but when i 
am trying to run this code on server(ubuntu 16.04) i am getting bellow 
error:

**Traceback**



Exception inside application: module 'asyncio' has no attribute 
'_get_running_loop'
File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
result = coro.throw(exc)
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/sessions.py"
, line 183, in __call__
return await self.inner(receive, self.send)
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/middleware.py"
, line 41, in coroutine_call
await inner_instance(receive, send)
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/consumer.py"
, line 59, in __call__
[receive, self.channel_receive], self.dispatch
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/utils.py", 
line 52, in await_many_dispatch
await dispatch(result)
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/asgiref/sync.py", 
line 145, in __call__
return await asyncio.wait_for(future, timeout=None)
File "/usr/lib/python3.5/asyncio/tasks.py", line 373, in wait_for
return (yield from fut)
File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
yield self  # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/db.py", 
line 14, in thread_handler
return super().thread_handler(loop, *args, **kwargs)
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/asgiref/sync.py", 
line 164, in thread_handler
return func(*args, **kwargs)
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/consumer.py"
, line 105, in dispatch
handler(message)
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/channels/generic/websocket.py"
, line 39, in websocket_connect
self.connect()
File "/home/user1/demowebapps/vmsbackend/check_in/consumers.py", line 57
, in connect
self.channel_name
File 
"/home/user1/demowebapps/env/lib/python3.5/site-packages/asgiref/sync.py", 
line 41, in __call__
if asyncio._get_running_loop() is not None:
module 'asyncio' has no attribute '_get_running_loop'





also when i am sending data normally from
javascript  .send()


function it is working normally on server but when post_save signal is 
called then only i get this error on server. this is working fine on my 
local system.
I tried removing *async_to_sync *from signals then it is not giving error 
but it is not transmitting data through web socket.
then it is giving:

./check_in/signals.py:47: RuntimeWarning: Coroutine
'RedisChannelLayer.group_send' was never 

AttributeError: type object 'NHTTrainerInline' has no attribute '_meta'

2019-03-11 Thread raghav b
I keep getting this error not sure what i am doing wrong!!

Traceback (most recent call last):
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py",
 
line 225, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py",
 
line 109, in inner_run
autoreload.raise_last_exception()
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py",
 
line 248, in raise_last_exception
raise _exception[1]
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
 
line 337, in execute
autoreload.check_errors(django.setup)()
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py",
 
line 225, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\__init__.py",
 
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\registry.py",
 
line 120, in populate
app_config.ready()
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\admin\apps.py",
 
line 24, in ready
self.module.autodiscover()
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\admin\__init__.py",
 
line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\module_loading.py",
 
line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py",
 
line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 728, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File "C:\Users\IBM_ADMIN\TrainingCentral\NHT\admin.py", line 38, in 

admin.site.register([NHTTrainer, NHTTrainerInline])
  File 
"C:\Users\IBM_ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\admin\sites.py",
 
line 103, in register
if model._meta.abstract:
AttributeError: type object 'NHTTrainerInline' has no attribute '_meta'


Models:

from django.db import models
from TRAC.models import Candidate


# Create your models here.
location = (
('Bangalore-EGL', 'Bangalore-EGL'),
('Bangalore-MTP', 'Bangalore-MTP'),
('Pune', 'Pune'),
('Noida', 'Noida'),
('Gurgaon', 'Gurgaon'),
('Hyderabad', 'Hyderabad'),
)


class NHTTrainer(models.Model):
employee_id = models.CharField(max_length=9, primary_key=True)
first_name = models.CharField(max_length=100)
middle_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=200)
created = models.DateField(auto_now_add=True)
updated = models.DateField(auto_now_add=True)

def __str__(self):
return self.first_name + " " + self.middle_name + " " + self.last_name

class Meta:
verbose_name_plural = "NHT Trainers"
verbose_name = "NHT Trainer"


class NHTBatch(models.Model):
BatchID = models.CharField(max_length=100, primary_key=True)
start_date = models.DateField()
end_date = models.DateField()
location = models.CharField(max_length=200, choices=location)
total_days_in_training = models.IntegerField(default=5)
total_number_of_agents = models.IntegerField()
trainer = models.ForeignKey(NHTTrainer, on_delete=models.DO_NOTHING)

def __str__(self):
return self.BatchID

class Meta:
verbose_name_plural = "Batches"


class NHTraineeDetails(Candidate):
employeeID = models.CharField(max_length=9)
NHTBatch = models.ForeignKey(NHTBatch, on_delete=models.DO_NOTHING)

class Meta:
verbose_name_plural = "NHT Trainee Details"



Admin:

from django.contrib import admin
from .models import *
# Register your models here.


class NHTTrainerInline(admin.TabularInline):
model = NHTTrainer
fk_name = "NHTTrainer"


class NHTraineeDetailsInline(admin.TabularInline):
model = NHTraineeDetails
fk_name = "NHTraineeDetails"


class NHTBatchInline(admin.TabularInline):
model = NHTBatch
fk_name = 

Re: Django 1.11: AttributeError: 'module' object has no attribute 'setup_environ'

2019-03-05 Thread Chi Shiek
Also failing in local dev_appserver. It seemed to work for a very short 
time (couple of queries) and then it stopped with the same error. 
Gave up and reverting back to 1.4 (which is what app engine seems to 
recommend - 1.4 or 1.11).

On Friday, 1 March 2019 08:29:42 UTC+11, Chi Shiek wrote:
>
> Didn't work in production...same error...suggestions welcome
>
> On Friday, 1 March 2019 06:41:55 UTC+11, Chi Shiek wrote:
>>
>> This is related to a bug I raised against app engine while tying to 
>> migrate from django 1.5 to 1.11.
>>
>> The issue is I have an app running on app engine using django 1.5.
>> Recently I was making a number of major updates to the app and decided to 
>> convert to django 1.11 as part of that update.
>>
>> Everything seemed to work fine on my local dev_appserver, but when I 
>> deployed it to app engine, it threw an error similar to this...
>>
>> ERROR2019-02-28 19:01:49,710 wsgi.py:263]
>> Traceback (most recent call last):
>>   File 
>> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
>>  
>> line 240, in Handle
>> handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
>>   File 
>> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
>>  
>> line 299, in _LoadHandler
>> handler, path, err = LoadObject(self._handler)
>>   File 
>> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
>>  
>> line 96, in LoadObject
>> __import__(cumulative_path)
>> INFO 2019-02-28 19:01:49,720 module.py:861] default: "GET 
>> /Common?action=%5B%22logout%22%5D HTTP/1.1" 500 -
>>   File 
>> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/ext/django/main.py",
>>  
>> line 82, in 
>> management.setup_environ(settings, 
>> original_settings_path=settings_path)
>> AttributeError: 'module' object has no attribute 'setup_environ'
>>
>>
>> I downloaded the app back to my local development server and built a 
>> clean python environment using only the exact modules I needed - and then I 
>> saw the same setup_environ error.
>> The module indicated has the following code which is throwing the error.
>>
>> try:
>>   settings = __import__(settings_path)
>>   management.setup_environ(settings, original_settings_path=settings_path)
>> except ImportError:
>> pass
>>
>> I changed the code to 
>> try:
>>   settings = __import__(settings_path)
>>   management.setup_environ(settings, original_settings_path=settings_path)
>> except AttributeError:
>>   django.setup()
>> except ImportError:
>> pass
>>
>> And everything works fine.
>> My problem is that the changed module appears to be inside the 
>> google-cloud-sdk and therefore I cannot change it in production.
>>
>> My app.yaml point to django 1.11
>>
>> I've searched the net and no one seems to have encountered this problem 
>> before...there is a lot about setup_environ, but nothing that addresses 
>> this particular issue.
>>
>> I even raised a ticket against app engine (
>> https://issuetracker.google.com/issues/124539522) but received a reply 
>> that it was a django problem.
>>
>> Question is - has anyone else come across this problem in the app engine 
>> environment - and how did you resolve it?
>>
>> Thanks!
>> /Chi
>>
>>
>>
>>
>>
>>
>>
>>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/80cd55a9-4b28-4600-9671-af909a339df8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.11: AttributeError: 'module' object has no attribute 'setup_environ'

2019-02-28 Thread Chi Shiek
Didn't work in production...same error...suggestions welcome

On Friday, 1 March 2019 06:41:55 UTC+11, Chi Shiek wrote:
>
> This is related to a bug I raised against app engine while tying to 
> migrate from django 1.5 to 1.11.
>
> The issue is I have an app running on app engine using django 1.5.
> Recently I was making a number of major updates to the app and decided to 
> convert to django 1.11 as part of that update.
>
> Everything seemed to work fine on my local dev_appserver, but when I 
> deployed it to app engine, it threw an error similar to this...
>
> ERROR2019-02-28 19:01:49,710 wsgi.py:263]
> Traceback (most recent call last):
>   File 
> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
>  
> line 240, in Handle
> handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
>   File 
> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
>  
> line 299, in _LoadHandler
> handler, path, err = LoadObject(self._handler)
>   File 
> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
>  
> line 96, in LoadObject
> __import__(cumulative_path)
> INFO 2019-02-28 19:01:49,720 module.py:861] default: "GET 
> /Common?action=%5B%22logout%22%5D HTTP/1.1" 500 -
>   File 
> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/ext/django/main.py",
>  
> line 82, in 
> management.setup_environ(settings, 
> original_settings_path=settings_path)
> AttributeError: 'module' object has no attribute 'setup_environ'
>
>
> I downloaded the app back to my local development server and built a clean 
> python environment using only the exact modules I needed - and then I saw 
> the same setup_environ error.
> The module indicated has the following code which is throwing the error.
>
> try:
>   settings = __import__(settings_path)
>   management.setup_environ(settings, original_settings_path=settings_path)
> except ImportError:
> pass
>
> I changed the code to 
> try:
>   settings = __import__(settings_path)
>   management.setup_environ(settings, original_settings_path=settings_path)
> except AttributeError:
>   django.setup()
> except ImportError:
> pass
>
> And everything works fine.
> My problem is that the changed module appears to be inside the 
> google-cloud-sdk and therefore I cannot change it in production.
>
> My app.yaml point to django 1.11
>
> I've searched the net and no one seems to have encountered this problem 
> before...there is a lot about setup_environ, but nothing that addresses 
> this particular issue.
>
> I even raised a ticket against app engine (
> https://issuetracker.google.com/issues/124539522) but received a reply 
> that it was a django problem.
>
> Question is - has anyone else come across this problem in the app engine 
> environment - and how did you resolve it?
>
> Thanks!
> /Chi
>
>
>
>
>
>
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8adf927f-30b7-4d91-8b20-33db30142bdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.11: AttributeError: 'module' object has no attribute 'setup_environ'

2019-02-28 Thread Chi Shiek
Managed to fix it by loading Django as a separate library...
These are the things I had to do...
Used following link to create a libs directory and install django in it 
(via pip - instructions on the page) - also followed the instructions on 
this page for creating a appengine_config.py 

https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27

Removed django from my app.yaml
libraries:
- name: django
  version: "1.11"

commented out these lines from my main.py
#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
#from django.conf import settings

seems I had this in my app.yaml already
env_variables:
  DJANGO_SETTINGS_MODULE: 'core.settings'

That's about it...oh - also removed the changes I made to...

/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/
google_appengine/google/appengine/ext/django/main.py

Haven't deployed it yet - but at least the dev_appserver is now running 
properly.


On Friday, 1 March 2019 06:41:55 UTC+11, Chi Shiek wrote:
>
> This is related to a bug I raised against app engine while tying to 
> migrate from django 1.5 to 1.11.
>
> The issue is I have an app running on app engine using django 1.5.
> Recently I was making a number of major updates to the app and decided to 
> convert to django 1.11 as part of that update.
>
> Everything seemed to work fine on my local dev_appserver, but when I 
> deployed it to app engine, it threw an error similar to this...
>
> ERROR2019-02-28 19:01:49,710 wsgi.py:263]
> Traceback (most recent call last):
>   File 
> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
>  
> line 240, in Handle
> handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
>   File 
> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
>  
> line 299, in _LoadHandler
> handler, path, err = LoadObject(self._handler)
>   File 
> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
>  
> line 96, in LoadObject
> __import__(cumulative_path)
> INFO 2019-02-28 19:01:49,720 module.py:861] default: "GET 
> /Common?action=%5B%22logout%22%5D HTTP/1.1" 500 -
>   File 
> "/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/ext/django/main.py",
>  
> line 82, in 
> management.setup_environ(settings, 
> original_settings_path=settings_path)
> AttributeError: 'module' object has no attribute 'setup_environ'
>
>
> I downloaded the app back to my local development server and built a clean 
> python environment using only the exact modules I needed - and then I saw 
> the same setup_environ error.
> The module indicated has the following code which is throwing the error.
>
> try:
>   settings = __import__(settings_path)
>   management.setup_environ(settings, original_settings_path=settings_path)
> except ImportError:
> pass
>
> I changed the code to 
> try:
>   settings = __import__(settings_path)
>   management.setup_environ(settings, original_settings_path=settings_path)
> except AttributeError:
>   django.setup()
> except ImportError:
> pass
>
> And everything works fine.
> My problem is that the changed module appears to be inside the 
> google-cloud-sdk and therefore I cannot change it in production.
>
> My app.yaml point to django 1.11
>
> I've searched the net and no one seems to have encountered this problem 
> before...there is a lot about setup_environ, but nothing that addresses 
> this particular issue.
>
> I even raised a ticket against app engine (
> https://issuetracker.google.com/issues/124539522) but received a reply 
> that it was a django problem.
>
> Question is - has anyone else come across this problem in the app engine 
> environment - and how did you resolve it?
>
> Thanks!
> /Chi
>
>
>
>
>
>
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a51c874b-1119-4e7e-930a-55228462a613%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.11: AttributeError: 'module' object has no attribute 'setup_environ'

2019-02-28 Thread Chi Shiek
This is related to a bug I raised against app engine while tying to migrate 
from django 1.5 to 1.11.

The issue is I have an app running on app engine using django 1.5.
Recently I was making a number of major updates to the app and decided to 
convert to django 1.11 as part of that update.

Everything seemed to work fine on my local dev_appserver, but when I 
deployed it to app engine, it threw an error similar to this...

ERROR2019-02-28 19:01:49,710 wsgi.py:263]
Traceback (most recent call last):
  File 
"/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
 
line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File 
"/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
 
line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
  File 
"/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/runtime/wsgi.py",
 
line 96, in LoadObject
__import__(cumulative_path)
INFO 2019-02-28 19:01:49,720 module.py:861] default: "GET 
/Common?action=%5B%22logout%22%5D HTTP/1.1" 500 -
  File 
"/home/cshiek/Programs/google-cloud-sdk-1.9.83/platform/google_appengine/google/appengine/ext/django/main.py",
 
line 82, in 
management.setup_environ(settings, original_settings_path=settings_path)
AttributeError: 'module' object has no attribute 'setup_environ'


I downloaded the app back to my local development server and built a clean 
python environment using only the exact modules I needed - and then I saw 
the same setup_environ error.
The module indicated has the following code which is throwing the error.

try:
  settings = __import__(settings_path)
  management.setup_environ(settings, original_settings_path=settings_path)
except ImportError:
pass

I changed the code to 
try:
  settings = __import__(settings_path)
  management.setup_environ(settings, original_settings_path=settings_path)
except AttributeError:
  django.setup()
except ImportError:
pass

And everything works fine.
My problem is that the changed module appears to be inside the 
google-cloud-sdk and therefore I cannot change it in production.

My app.yaml point to django 1.11

I've searched the net and no one seems to have encountered this problem 
before...there is a lot about setup_environ, but nothing that addresses 
this particular issue.

I even raised a ticket against app engine 
(https://issuetracker.google.com/issues/124539522) but received a reply 
that it was a django problem.

Question is - has anyone else come across this problem in the app engine 
environment - and how did you resolve it?

Thanks!
/Chi







-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/853d28f7-9eab-450f-81bf-f05343939da1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


AttributeError:

2018-07-07 Thread Hambali Idrees Ibrahim
 

from django.conf.urls import url
from . import views
from django.contrib.auth import login, logout



urlpatterns = [
url(r'^$', views.home),
url(r'^login/$', login, {'template_name': 'accounts/login.html'}),
url(r'^logout/$', logout, {'template_name': 'accounts/logout.html'}),
url(r'^register/$', views.register, name='register')
]








File "C:\Users\Hambadrees\django\toturial\accounts\urls.py", line 11, in 

url(r'^register/$', views.register, name='register')
AttributeError: module 'accounts.views' has no attribute 'register'

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a89b1e42-4a0f-4bf6-a9c5-34e724efbf8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   >