Re: if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket): TypeError: expected string or bytes-like object

2024-06-05 Thread Sanjay Sikdar
 django-storages has been updated that's why you are getting this error. 

OLD SYNTAX
from storages.backends.s3boto3 import S3Boto3Storage
import os

class MediaStorage(S3Boto3Storage):
bucket_name = os.environ.get('AWS_STORAGE_BUCKET_NAME')
location = 'media'

class StaticStorage(S3Boto3Storage):
bucket_name = os.environ.get('AWS_STORAGE_BUCKET_NAME')
location = 'static'
UPDATED SYNTAX 

STORAGES = {
"default": {
"BACKEND": "storages.backends.s3.S3Storage",
"OPTIONS": {
"bucket_name": AWS_STORAGE_BUCKET_NAME,
"location": 'media'
},
},
"staticfiles": {
"BACKEND": "storages.backends.s3.S3Storage",
"OPTIONS": {
"bucket_name": AWS_STORAGE_BUCKET_NAME,
"location": 'static'
},
},
}

On Monday, December 14, 2020 at 2:10:32 PM UTC+5:30 KUMBHAGIRI SIVAKRISHNA 
wrote:

> ile 
> "/home/sivakrishna/Downloads/peeljobs-env/lib/python3.8/site-packages/botocore/handlers.py",
>  
> line 200, in validate_bucket_name
> if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket):
> TypeError: expected string or bytes-like object
>
>
> Please help me to solve this problem 
>

-- 
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/561c9981-ae62-4a88-90ac-4704968e1ad2n%40googlegroups.com.


Re: TypeError at /register User() got unexpected keyword arguments: 'name1', 'name2', 'country'

2023-03-30 Thread Fathimanesmi As
django user has the following fields model :

   - username 
   

   - password 
   

   - email 
   

   - first_name 
   

   - last_name 
   

   there is no name1 and name2 attributes.Refer to the django documentation 
   for full details.

user = User.objects.create_user(first_name=name1, last_name= name2)
user.save()

On Thursday, 30 March, 2023 at 5:30:01 am UTC-4 Ebenezer Otchere wrote:

> ohk below is the screenshoot of the model.py
> [image: Screenshot (6).png]
>
> On Thursday, March 30, 2023 at 1:58:10 AM UTC-7 Alex Sonar wrote:
>
>> Hi Ebenezer, Could I ask you to show the content of the model file, 
>> please?
>>
>> On Thursday, March 30, 2023 at 5:21:06 AM UTC+3 Ebenezer Otchere wrote:
>>
>>> I am trying to collect user information and save in my database but i 
>>> keep getting this error
>>> and i dont know the way around it so help me the codes and the error 
>>> page are below
>>> [image: Screenshot (3).png][image: Screenshot (4).png][image: 
>>> Screenshot (5).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/725f18b1-0ad2-45ce-a075-f9dcdd316018n%40googlegroups.com.


Re: TypeError at /register User() got unexpected keyword arguments: 'name1', 'name2', 'country'

2023-03-30 Thread Alex Sonar
Hi Ebenezer, Could I ask you to show the content of the model file, please?

On Thursday, March 30, 2023 at 5:21:06 AM UTC+3 Ebenezer Otchere wrote:

> I am trying to collect user information and save in my database but i keep 
> getting this error
> and i dont know the way around it so help me the codes and the error page 
> are below
> [image: Screenshot (3).png][image: Screenshot (4).png][image: Screenshot 
> (5).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/65480c4f-7d81-49ea-a735-4576a8315080n%40googlegroups.com.


Re: Uncaught TypeError: styled_default is not a function

2023-03-15 Thread David Nugent
A Django mailing list is probably not a good place to ask this question 
- this is a JS issue and there are a plethora of more appropriate 
forums.


But - why is Popper.js being loaded? Is it a hangover from using 
bootstrap? Don’t load both bootstrap (and associated scripts) with 
React+mui.



Regards,
Davd

"praveen raj"  writes:

Hi all,
i'm trying to django-react application with postgres db but its giving 
me the following error:

Uncaught TypeError: styled_default is not a function
at Popper.js:11:20
Capture1.PNG


here i'm using mui :
Capture2.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/em1285a485-9cc0-43be-97a6-f5ce2bc846ba%4038724ca3.com.


pgpT4EidOd11s.pgp
Description: PGP signature


Uncaught TypeError: styled_default is not a function

2023-03-15 Thread praveen raj
Hi all,
i'm trying to django-react application with postgres db but its giving me 
the following error:
Uncaught TypeError: styled_default is not a function
at Popper.js:11:20
[image: Capture1.PNG]

here i'm using mui : 
[image: Capture2.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/8e9404ee-e223-43ee-99c9-f73e76a7055bn%40googlegroups.com.


Uncaught TypeError: data.find is not a function

2022-07-10 Thread Kiran Chavan
I am trying to convert the model instances into a JSON object and then 
according to the value selected in the dropdown menu, I want to assign its 
amount to the `line_one_unit_price` text field in the form.

Javascript code:

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

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

document.getElementById('id_line_one').onchange = function(event){
let elementInData = data.find(() => item.pk == event.target.value);
document.getElementById('id_line_one_unit_price').value = 
elementInData && elementInData.amount ? elementInData.amount : 0;
};



I guess, I am getting the error at `data.find` because `.find` is used on 
an array whereas the constant `data` is not an array? How do I convert that 
JSON object into an array? how do I assign the amount of the `title` 
selected in the forms to the `line_one_unit_price`?

[image: Screenshot 2022-07-09 232808.jpg]

When I click some title from the dropdown, I want the amount to be 
displayed in the `Unit Price`.

`views.py`:

def add_invoice(request):
  form = InvoiceForm(request.POST or None)
  data = serializers.serialize("json", Inventory.objects.all())
  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)

`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

Thanks.

-- 
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/5edb2e69-fec9-4140-8658-3f409f795434n%40googlegroups.com.


Re: TypeError: Cannot call delete() after .distinct() in the Admin

2022-04-07 Thread Mike Dewhirst

Sorry - just found it in the docs

M

On 7/04/2022 5:05 pm, Mike Dewhirst wrote:

How can I remove the 'Delete' option from Django Admin actions?

Many thanks

Mike




--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/caa68eb7-f56c-4ca9-36c8-86ccf8c17f91%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


TypeError: Cannot call delete() after .distinct() in the Admin

2022-04-07 Thread Mike Dewhirst

How can I remove the 'Delete' option from Django Admin actions?

Many thanks

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/d51ac9f7-a46b-61ed-1406-184c5e95b108%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: TypeError: fromisoformat: argument must be str

2022-02-12 Thread Sammeeey
 Same solution for me.
If you follow the link to the thread in the Django forum 
<https://forum.djangoproject.com/t/typeerror-fromisoformat-argument-must-be-str/12034>,
 
you'll find a detailed discussion there.✌
gautam...@gmail.com schrieb am Dienstag, 8. Februar 2022 um 11:20:10 UTC+1:

> Same issue in mine project but when database name change and delete all 
> migration file then it is resolve
>
> On Tue, 8 Feb, 2022, 3:45 PM Sammeeey,  wrote:
>
>> I have posted my issue to the Django Forum.
>> Please find it in the respective thread 
>> <https://forum.djangoproject.com/t/typeerror-fromisoformat-argument-must-be-str/12034>
>>
>> -- 
>> 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/e9703ec6-d93e-4ccb-a428-9189dc3bf525n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/e9703ec6-d93e-4ccb-a428-9189dc3bf525n%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/1c607cda-2c50-43b9-bb1e-68625105d7c7n%40googlegroups.com.


Re: TypeError: fromisoformat: argument must be str

2022-02-08 Thread Gautam Ankul
Same issue in mine project but when database name change and delete all
migration file then it is resolve

On Tue, 8 Feb, 2022, 3:45 PM Sammeeey,  wrote:

> I have posted my issue to the Django Forum.
> Please find it in the respective thread
> <https://forum.djangoproject.com/t/typeerror-fromisoformat-argument-must-be-str/12034>
>
> --
> 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/e9703ec6-d93e-4ccb-a428-9189dc3bf525n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e9703ec6-d93e-4ccb-a428-9189dc3bf525n%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/CALKR2n3byUygtxkGAj3bpwPU7YSXYLD6yDnPinE3C_Md3wf8jg%40mail.gmail.com.


TypeError: fromisoformat: argument must be str

2022-02-08 Thread Sammeeey
I have posted my issue to the Django Forum.
Please find it in the respective thread 
<https://forum.djangoproject.com/t/typeerror-fromisoformat-argument-must-be-str/12034>

-- 
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/e9703ec6-d93e-4ccb-a428-9189dc3bf525n%40googlegroups.com.


Re: TypeError: 'module' object is not iterable - django 4

2022-02-01 Thread muwaga micheal
Issue was sorted..
Here is the link.
python 3.x - TypeError: 'module' object is not iterable in django 4 - Stack 
Overflow 
<https://stackoverflow.com/questions/70924854/typeerror-module-object-is-not-iterable-in-django-4>

On Monday, January 31, 2022 at 11:53:03 AM UTC+3 muwaga micheal wrote:

> Hi 
> Team,
>  I am getting the above error, it has persisted long enough than at this 
> point i really need help.
> I am using pickle to load an ML model, POST to get user input. Below is 
> the error, my urls.py file and the views.py file. 
> Any Help will be highly appreciated.
>
> *** Error Message ***
>
> (python10_env) D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\smart_health_consult>python 
> manage.py runserver
> Watching for file changes with StatReloader
> Performing system checks...
>
> Exception in thread django-main-thread:
> Traceback (most recent call last):
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\urls\resolvers.py",
>  
> line 634, in url_patterns
> iter(patterns)
> TypeError: 'module' object is not iterable
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File 
> "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\threading.py", 
> line 1009, in _bootstrap_inner
> self.run()
>   File 
> "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\threading.py", 
> line 946, in run
> self._target(*self._args, **self._kwargs)
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\utils\autoreload.py",
>  
> line 64, in wrapper
> fn(*args, **kwargs)
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\management\commands\runserver.py",
>  
> line 124, in inner_run
> self.check(display_num_errors=True)
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\management\base.py",
>  
> line 438, in check
> all_issues = checks.run_checks(
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\checks\registry.py",
>  
> line 77, in run_checks
> new_errors = check(app_configs=app_configs, databases=databases)
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\checks\urls.py",
>  
> line 40, in check_url_namespaces_unique
> all_namespaces = _load_all_namespaces(resolver)
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\checks\urls.py",
>  
> line 67, in _load_all_namespaces
> namespaces.extend(_load_all_namespaces(pattern, current))
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\checks\urls.py",
>  
> line 57, in _load_all_namespaces
> url_patterns = getattr(resolver, 'url_patterns', [])
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\utils\functional.py",
>  
> line 48, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "D:\Online 
> Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\urls\resolvers.py",
>  
> line 642, in url_patterns
> raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
> django.core.exceptions.ImproperlyConfigured: The included URLconf ' 'ml_dp_model.urls' from 'D:\\Online 
> Drives\\MDigital\\CIT-Letures\\python10_env\\smart_health_consult\\ml_dp_model\\urls.py'>'
>  
> does not appear to have any patterns in it. If you see the 'urlpatterns' 
> variable with valid patterns in the file then the issue is probably caused 
> by a circular import.
>
> **
>
>   urls.py  *
> from django.urls import path
> from . import views
>
> #from .views import index
> #from .views import predict
>
> urlpartterns = [
> path('', views.index, name='index'),
> path('result.html', views.predict, name='predict')
> 
> ]
> **
>
> * views.py *
> from django.shortcuts import render
> # Testing if context can solve circular refference issue.
> from django.template import context
> # Model related imports
> import pandas as pd #install pandas
> import pickle
> import numpy as np #  helps to manipulate the data
>
> # Create your views here.
> def index(request):
> return render(request, 'index.html')
>
> # importing the models using pickle.
> #Loading Naive Bayes P

TypeError: 'module' object is not iterable - django 4

2022-01-31 Thread muwaga micheal
Hi 
Team,
 I am getting the above error, it has persisted long enough than at this 
point i really need help.
I am using pickle to load an ML model, POST to get user input. Below is the 
error, my urls.py file and the views.py file. 
Any Help will be highly appreciated.

*** Error Message ***

(python10_env) D:\Online 
Drives\MDigital\CIT-Letures\python10_env\smart_health_consult>python 
manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\urls\resolvers.py",
 
line 634, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File 
"C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\threading.py", 
line 1009, in _bootstrap_inner
self.run()
  File 
"C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\threading.py", 
line 946, in run
self._target(*self._args, **self._kwargs)
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\utils\autoreload.py",
 
line 64, in wrapper
fn(*args, **kwargs)
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\management\commands\runserver.py",
 
line 124, in inner_run
self.check(display_num_errors=True)
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\management\base.py",
 
line 438, in check
all_issues = checks.run_checks(
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\checks\registry.py",
 
line 77, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\checks\urls.py",
 
line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\checks\urls.py",
 
line 67, in _load_all_namespaces
namespaces.extend(_load_all_namespaces(pattern, current))
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\core\checks\urls.py",
 
line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\utils\functional.py",
 
line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File "D:\Online 
Drives\MDigital\CIT-Letures\python10_env\lib\site-packages\django\urls\resolvers.py",
 
line 642, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf ''
 
does not appear to have any patterns in it. If you see the 'urlpatterns' 
variable with valid patterns in the file then the issue is probably caused 
by a circular import.

**

  urls.py  *
from django.urls import path
from . import views

#from .views import index
#from .views import predict

urlpartterns = [
path('', views.index, name='index'),
path('result.html', views.predict, name='predict')

]
**

* views.py *
from django.shortcuts import render
# Testing if context can solve circular refference issue.
from django.template import context
# Model related imports
import pandas as pd #install pandas
import pickle
import numpy as np #  helps to manipulate the data

# Create your views here.
def index(request):
return render(request, 'index.html')

# importing the models using pickle.
#Loading Naive Bayes Pickle  Model load method 1
nb_pickle = open('./models_store/final_nb_model.pickel','rb+')
nb_model = pickle.load(nb_pickle)
#Loading RandomForest Pickle Modal load method 1
rf_pickle = open('./models_store/final_rf_model.pickel', 'rb+')
rf_model = pickle.load(rf_pickle)
#Loading Scala Vector Machine  Pickle  Model load method 2
svm_model = pickle.load(open('./models_store/final_svm_model.pickel', 
'rb+'))

# Disease prediction Function:
def predict(request):
if request.method=='POST':
symptom_index = {}
symptom_index['symptom1'] =float(request.POST.get('symptom1')) # 
Add data in string format to the dictionary
symptom_index['symptom2'] =float(request.POST.get('symptom2'))
symptom_index['symptom3'] =float(request.POST.get('symptom3'))
user_symptoms = pd.DataFrame({'X':symptom_index}).transpose() 
#think about changing dictionary to list at this line.
# Using pickle model() to predict
nb_prediction = nb_model.predict(user_symptoms

Re: Why does django throw TypeError when sending requests through Apache WSGI?

2021-12-15 Thread Kyle Paterson
Used libapache2-mod-wsgi-py3 instead of python 2 version

On Wednesday, 15 December 2021 at 10:03:27 UTC Kyle Paterson wrote:

> I am not using either of those, I think. The only place I explicitly load 
> settings is in wsgi.py, with the line:
> os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘travel data.settings'
>
> On Thu, 9 Dec 2021 at 12:52, Jason  wrote:
>
>>
>> with your settings usage, are you defining a property in settings and 
>> trying to use it anywhere?
>>
>> furthermore, are you using settings via 
>>
>> from traveldata.traveldata import settings (example)
>>
>> or via
>>
>> from django.conf import settings
>>
>> The latter is the recommended means because settings are lazy loaded.
>> On Wednesday, December 8, 2021 at 10:07:11 AM UTC-5 sencer...@gmail.com 
>> wrote:
>>
>>> Hi,
>>>
>>> I think this is not related with apache
>>>
>>> It seems like class object property is called as a method somehow.
>>> Unfortunately the error does not reveal the property name.
>>>
>>> Regards,
>>> Sencer HAMARAT
>>>
>>>
>>>
>>> On Wed, Dec 8, 2021 at 4:59 PM Kyle Paterson  
>>> wrote:
>>>
>>>> Started a new project after not using Django for roughly two years, 
>>>> works fine when running as a development server but throws TypeError: 
>>>> SimpleLazyObject class: property object not callable.
>>>>
>>>> From apache error log:
>>>> [Wed Dec 08 10:11:53.023239 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946] Traceback (most recent call 
>>>> last):
>>>> [Wed Dec 08 10:11:53.023283 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946]   File 
>>>> "/home/kyle/active-travel/traveldata/traveldata/wsgi.py", line 14, in 
>>>> 
>>>> [Wed Dec 08 10:11:53.023327 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946] from django.core.wsgi 
>>>> import get_wsgi_application
>>>> [Wed Dec 08 10:11:53.023351 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946]   File 
>>>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/__init__.py",
>>>>  
>>>> line 1, in 
>>>> [Wed Dec 08 10:11:53.023371 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946] from 
>>>> django.utils.version import get_version
>>>> [Wed Dec 08 10:11:53.023377 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946]   File 
>>>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/version.py",
>>>>  
>>>> line 7, in 
>>>> [Wed Dec 08 10:11:53.023430 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946] from 
>>>> django.utils.regex_helper import _lazy_re_compile
>>>> [Wed Dec 08 10:11:53.023435 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946]   File 
>>>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/regex_helper.py",
>>>>  
>>>> line 10, in 
>>>> [Wed Dec 08 10:11:53.023524 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946] from 
>>>> django.utils.functional import SimpleLazyObject
>>>> [Wed Dec 08 10:11:53.023529 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946]   File 
>>>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/functional.py",
>>>>  
>>>> line 364, in 
>>>> [Wed Dec 08 10:11:53.023578 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946] class 
>>>> SimpleLazyObject(LazyObject):
>>>> [Wed Dec 08 10:11:53.023611 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946] TypeError: Error when 
>>>> calling the metaclass bases
>>>> [Wed Dec 08 10:11:53.023613 2021] [wsgi:error] [pid 10704:tid 
>>>> 140343150348032] [remote 127.0.0.1:44946] 'property' object is not 
>>>> callable
>>>>
>>>> Apache site config file:
>>>> 
>>>> # The ServerName directive sets the request scheme, hostname 
>>>> and port that
>>>> 

Re: Why does django throw TypeError when sending requests through Apache WSGI?

2021-12-15 Thread Kyle Paterson
I am not using either of those, I think. The only place I explicitly load
settings is in wsgi.py, with the line:
os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘travel data.settings'

On Thu, 9 Dec 2021 at 12:52, Jason  wrote:

>
> with your settings usage, are you defining a property in settings and
> trying to use it anywhere?
>
> furthermore, are you using settings via
>
> from traveldata.traveldata import settings (example)
>
> or via
>
> from django.conf import settings
>
> The latter is the recommended means because settings are lazy loaded.
> On Wednesday, December 8, 2021 at 10:07:11 AM UTC-5 sencer...@gmail.com
> wrote:
>
>> Hi,
>>
>> I think this is not related with apache
>>
>> It seems like class object property is called as a method somehow.
>> Unfortunately the error does not reveal the property name.
>>
>> Regards,
>> Sencer HAMARAT
>>
>>
>>
>> On Wed, Dec 8, 2021 at 4:59 PM Kyle Paterson 
>> wrote:
>>
>>> Started a new project after not using Django for roughly two years,
>>> works fine when running as a development server but throws TypeError:
>>> SimpleLazyObject class: property object not callable.
>>>
>>> From apache error log:
>>> [Wed Dec 08 10:11:53.023239 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946] Traceback (most recent call
>>> last):
>>> [Wed Dec 08 10:11:53.023283 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946]   File
>>> "/home/kyle/active-travel/traveldata/traveldata/wsgi.py", line 14, in
>>> 
>>> [Wed Dec 08 10:11:53.023327 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946] from django.core.wsgi
>>> import get_wsgi_application
>>> [Wed Dec 08 10:11:53.023351 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946]   File
>>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/__init__.py",
>>> line 1, in 
>>> [Wed Dec 08 10:11:53.023371 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946] from django.utils.version
>>> import get_version
>>> [Wed Dec 08 10:11:53.023377 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946]   File
>>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/version.py",
>>> line 7, in 
>>> [Wed Dec 08 10:11:53.023430 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946] from
>>> django.utils.regex_helper import _lazy_re_compile
>>> [Wed Dec 08 10:11:53.023435 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946]   File
>>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/regex_helper.py",
>>> line 10, in 
>>> [Wed Dec 08 10:11:53.023524 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946] from
>>> django.utils.functional import SimpleLazyObject
>>> [Wed Dec 08 10:11:53.023529 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946]   File
>>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/functional.py",
>>> line 364, in 
>>> [Wed Dec 08 10:11:53.023578 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946] class
>>> SimpleLazyObject(LazyObject):
>>> [Wed Dec 08 10:11:53.023611 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946] TypeError: Error when calling
>>> the metaclass bases
>>> [Wed Dec 08 10:11:53.023613 2021] [wsgi:error] [pid 10704:tid
>>> 140343150348032] [remote 127.0.0.1:44946] 'property' object is not
>>> callable
>>>
>>> Apache site config file:
>>> 
>>> # The ServerName directive sets the request scheme, hostname and
>>> port that
>>> # the server uses to identify itself. This is used when creating
>>> # redirection URLs. In the context of virtual hosts, the
>>> ServerName
>>> # specifies what hostname must appear in the request's Host:
>>> header to
>>> # match this virtual host. For the default virtual host (this
>>> file) this
>>> # value is not decisive as it is used as a last resort host
>>> regardless.
>>> # However, you must set it for any further virtual host
>>> explicitly.
>>>

Re: Why does django throw TypeError when sending requests through Apache WSGI?

2021-12-09 Thread Jason

with your settings usage, are you defining a property in settings and 
trying to use it anywhere?

furthermore, are you using settings via 

from traveldata.traveldata import settings (example)

or via

from django.conf import settings

The latter is the recommended means because settings are lazy loaded.
On Wednesday, December 8, 2021 at 10:07:11 AM UTC-5 sencer...@gmail.com 
wrote:

> Hi,
>
> I think this is not related with apache
>
> It seems like class object property is called as a method somehow.
> Unfortunately the error does not reveal the property name.
>
> Regards,
> Sencer HAMARAT
>
>
>
> On Wed, Dec 8, 2021 at 4:59 PM Kyle Paterson  wrote:
>
>> Started a new project after not using Django for roughly two years, works 
>> fine when running as a development server but throws TypeError: 
>> SimpleLazyObject class: property object not callable.
>>
>> From apache error log:
>> [Wed Dec 08 10:11:53.023239 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] Traceback (most recent call 
>> last):
>> [Wed Dec 08 10:11:53.023283 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "/home/kyle/active-travel/traveldata/traveldata/wsgi.py", line 14, in 
>> 
>> [Wed Dec 08 10:11:53.023327 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] from django.core.wsgi 
>> import get_wsgi_application
>> [Wed Dec 08 10:11:53.023351 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/__init__.py",
>>  
>> line 1, in 
>> [Wed Dec 08 10:11:53.023371 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] from django.utils.version 
>> import get_version
>> [Wed Dec 08 10:11:53.023377 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/version.py",
>>  
>> line 7, in 
>> [Wed Dec 08 10:11:53.023430 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] from 
>> django.utils.regex_helper import _lazy_re_compile
>> [Wed Dec 08 10:11:53.023435 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/regex_helper.py",
>>  
>> line 10, in 
>> [Wed Dec 08 10:11:53.023524 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] from 
>> django.utils.functional import SimpleLazyObject
>> [Wed Dec 08 10:11:53.023529 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/functional.py",
>>  
>> line 364, in 
>> [Wed Dec 08 10:11:53.023578 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] class 
>> SimpleLazyObject(LazyObject):
>> [Wed Dec 08 10:11:53.023611 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] TypeError: Error when calling 
>> the metaclass bases
>> [Wed Dec 08 10:11:53.023613 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] 'property' object is not 
>> callable
>>
>> Apache site config file:
>> 
>> # The ServerName directive sets the request scheme, hostname and 
>> port that
>> # the server uses to identify itself. This is used when creating
>> # redirection URLs. In the context of virtual hosts, the 
>> ServerName
>> # specifies what hostname must appear in the request's Host: 
>> header to
>> # match this virtual host. For the default virtual host (this 
>> file) this
>> # value is not decisive as it is used as a last resort host 
>> regardless.
>> # However, you must set it for any further virtual host 
>> explicitly.
>> #ServerName www.example.com
>>
>> ServerAdmin webmaster@localhost
>> 
>> Alias /static /home/kyle/active-travel/traveldata/static
>> 
>> Require all granted
>> 
>>
>> 
>> 
>> Require all granted
>> 
>> 
>>
>> WSGIScriptAlias / 
>> /home/kyle/active-travel/traveldata/traveldata/wsgi.py

Re: Why does django throw TypeError when sending requests through Apache WSGI?

2021-12-08 Thread Sencer Hamarat
Hi,

I think this is not related with apache

It seems like class object property is called as a method somehow.
Unfortunately the error does not reveal the property name.

Regards,
Sencer HAMARAT



On Wed, Dec 8, 2021 at 4:59 PM Kyle Paterson 
wrote:

> Started a new project after not using Django for roughly two years, works
> fine when running as a development server but throws TypeError:
> SimpleLazyObject class: property object not callable.
>
> From apache error log:
> [Wed Dec 08 10:11:53.023239 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946] Traceback (most recent call
> last):
> [Wed Dec 08 10:11:53.023283 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946]   File
> "/home/kyle/active-travel/traveldata/traveldata/wsgi.py", line 14, in
> 
> [Wed Dec 08 10:11:53.023327 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946] from django.core.wsgi
> import get_wsgi_application
> [Wed Dec 08 10:11:53.023351 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946]   File
> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/__init__.py",
> line 1, in 
> [Wed Dec 08 10:11:53.023371 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946] from django.utils.version
> import get_version
> [Wed Dec 08 10:11:53.023377 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946]   File
> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/version.py",
> line 7, in 
> [Wed Dec 08 10:11:53.023430 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946] from
> django.utils.regex_helper import _lazy_re_compile
> [Wed Dec 08 10:11:53.023435 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946]   File
> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/regex_helper.py",
> line 10, in 
> [Wed Dec 08 10:11:53.023524 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946] from
> django.utils.functional import SimpleLazyObject
> [Wed Dec 08 10:11:53.023529 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946]   File
> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/functional.py",
> line 364, in 
> [Wed Dec 08 10:11:53.023578 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946] class
> SimpleLazyObject(LazyObject):
> [Wed Dec 08 10:11:53.023611 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946] TypeError: Error when calling
> the metaclass bases
> [Wed Dec 08 10:11:53.023613 2021] [wsgi:error] [pid 10704:tid
> 140343150348032] [remote 127.0.0.1:44946] 'property' object is not
> callable
>
> Apache site config file:
> 
> # The ServerName directive sets the request scheme, hostname and
> port that
> # the server uses to identify itself. This is used when creating
> # redirection URLs. In the context of virtual hosts, the ServerName
> # specifies what hostname must appear in the request's Host:
> header to
> # match this virtual host. For the default virtual host (this
> file) this
> # value is not decisive as it is used as a last resort host
> regardless.
> # However, you must set it for any further virtual host explicitly.
> #ServerName www.example.com
>
> ServerAdmin webmaster@localhost
>
> Alias /static /home/kyle/active-travel/traveldata/static
> 
> Require all granted
> 
>
> 
> 
> Require all granted
> 
> 
>
> WSGIScriptAlias /
> /home/kyle/active-travel/traveldata/traveldata/wsgi.py
> process-group=traveldata
> WSGIDaemonProcess traveldata
> python-home=/home/kyle/active-travel/venv
> python-path=/home/kyle/active-travel/traveldata/traveldata
> WSGIProcessGroup traveldata
>
> # Available loglevels: trace8, ..., trace1, debug, info, notice,
> warn,
> # error, crit, alert, emerg.
> # It is also possible to configure the loglevel for particular
> # modules, e.g.
> #LogLevel info ssl:warn
> LogLevel info
>
> ErrorLog ${APACHE_LOG_DIR}/error.log
> CustomLog ${APACHE_LOG_DIR}/access.log combined
>
> # For most configuration files from conf-available/, which are
> # enabled or disabled at a global level, it is possible to
> # include a line for only one particular virtual host

Why does django throw TypeError when sending requests through Apache WSGI?

2021-12-08 Thread Kyle Paterson
Started a new project after not using Django for roughly two years, works 
fine when running as a development server but throws TypeError: 
SimpleLazyObject class: property object not callable.

>From apache error log:
[Wed Dec 08 10:11:53.023239 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946] Traceback (most recent call last):
[Wed Dec 08 10:11:53.023283 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946]   File 
"/home/kyle/active-travel/traveldata/traveldata/wsgi.py", line 14, in 

[Wed Dec 08 10:11:53.023327 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946] from django.core.wsgi import 
get_wsgi_application
[Wed Dec 08 10:11:53.023351 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946]   File 
"home/kyle/active-travel/venv/lib/python3.8/site-packages/django/__init__.py", 
line 1, in 
[Wed Dec 08 10:11:53.023371 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946] from django.utils.version 
import get_version
[Wed Dec 08 10:11:53.023377 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946]   File 
"home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/version.py",
 
line 7, in 
[Wed Dec 08 10:11:53.023430 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946] from 
django.utils.regex_helper import _lazy_re_compile
[Wed Dec 08 10:11:53.023435 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946]   File 
"home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/regex_helper.py",
 
line 10, in 
[Wed Dec 08 10:11:53.023524 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946] from django.utils.functional 
import SimpleLazyObject
[Wed Dec 08 10:11:53.023529 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946]   File 
"home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/functional.py",
 
line 364, in 
[Wed Dec 08 10:11:53.023578 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946] class 
SimpleLazyObject(LazyObject):
[Wed Dec 08 10:11:53.023611 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946] TypeError: Error when calling the 
metaclass bases
[Wed Dec 08 10:11:53.023613 2021] [wsgi:error] [pid 10704:tid 
140343150348032] [remote 127.0.0.1:44946] 'property' object is not 
callable

Apache site config file:

# The ServerName directive sets the request scheme, hostname and 
port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header 
to
# match this virtual host. For the default virtual host (this file) 
this
# value is not decisive as it is used as a last resort host 
regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost

Alias /static /home/kyle/active-travel/traveldata/static

Require all granted




Require all granted



WSGIScriptAlias / 
/home/kyle/active-travel/traveldata/traveldata/wsgi.py 
process-group=traveldata
WSGIDaemonProcess traveldata 
python-home=/home/kyle/active-travel/venv 
python-path=/home/kyle/active-travel/traveldata/traveldata
WSGIProcessGroup traveldata

# Available loglevels: trace8, ..., trace1, debug, info, notice, 
warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
LogLevel info

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example 
the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf


Django project wsgi.py:
import os, sys
sys.path.append('home/kyle/active-travel/venv/lib/python3.8/site-packages')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'traveldata.settings')
application = get_wsgi_application()

As you can see, all fairly standard, Debug set to true, no changes to 
standard content of site, followed the documentation instructions to run 
requests through apache and mod_wsgi. Suspect the issue is w

Re: TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

2021-11-20 Thread Peter of the Norse
CommentForm inherits from both ModelForm and “forms”.  I don’t know what 
“forms” is, but PEP-8 says all classes should be capitalized.  If forms is a 
base class that has already defined Meta, then you need to have CommentForm’s 
extend it.  So change the line to class Meta(forms.Meta):

> On Oct 28, 2021, at 8:18 PM, Sabbir Hasan Munna  
> wrote:
> 
> 
> 
> 
> -- 
> 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/f7d8a010-0f68-437c-b3df-ec99a4460aafn%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/E4AE72BA-48B0-4AD8-9D63-4AE9663F7C10%40gmail.com.


Re: TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

2021-11-02 Thread patel dhruvish
Close with Square bracket [ ' ' , ' ']

On Fri, Oct 29, 2021, 19:36 Sabbir Hasan Munna 
wrote:

>
> [image: Annotation 2021-10-29 081743.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/f7d8a010-0f68-437c-b3df-ec99a4460aafn%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/CANMvxF0GRQ2kf9fjHC3LJU2-DSpOzV8y5qP%2BmEYLmaMn0dc2gA%40mail.gmail.com.


Re: TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

2021-10-30 Thread waqar khan
close round bracket

*class Meta:*


On Fri, Oct 29, 2021 at 7:36 PM Sabbir Hasan Munna <
sabbirhasan2...@gmail.com> wrote:

>
> [image: Annotation 2021-10-29 081743.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/f7d8a010-0f68-437c-b3df-ec99a4460aafn%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/CA%2B08CAOqLzjbRa9b_knzsZGqV9h88_G6B5cZjytRCvXDH7SDxA%40mail.gmail.com.


TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

2021-10-29 Thread Sabbir Hasan Munna

[image: Annotation 2021-10-29 081743.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/f7d8a010-0f68-437c-b3df-ec99a4460aafn%40googlegroups.com.


Re: TypeError __init__() takes 1 positional argument but 2 were given

2021-10-19 Thread Lalit Suthar
try changing this

def get_context_data(self, *args, **kwargs):
context = super(registro, self).get_context_data(*args, **kwargs)

to this

def get_context_data(self, **kwargs):
context = super(registro, self).get_context_data(**kwargs)

refer:
https://ccbv.co.uk/projects/Django/3.2/django.views.generic.edit/CreateView/

On Tue, 19 Oct 2021 at 02:27, Jose Cabrera  wrote:

> hello everyone, please help me with this error that is generated in the
> views.py, in class registro(CreateView):
> Thank you
> form.py
> class RegistrationForm(forms.ModelForm):
> password = forms.CharField(label='Password',
> widget=forms.PasswordInput)
> class Meta:
> model = UserProfile
> fields = ('email','password')
>
> def save(self, commit=True):
> # Save the provided password in hashed format
> user = super().save(commit=False)
> user.set_password(self.cleaned_data["password"])
> if commit:
> user.save()
> return user
>
> views.py
> from .models import UserProfile
> from .forms import RegistrationForm
> from django.views.generic.edit import CreateView, UpdateView
> from django.urls import reverse
>
> class registro(CreateView):
> template_name = 'registration/registro.html'
> form_class = RegistrationForm
>
> def get_context_data(self, *args, **kwargs):
> context = super(registro, self).get_context_data(*args, **kwargs)
> context['next'] = self.request.GET.get('next')
> return context
>
> def get_success_url(self):
> next_url = self.request.POST.get('next')
> success_url = reverse('home')
> if next_url:
> success_url += '?next={}'.format(next_url)
>
> return success_url
>
> --
> 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/070868ce-cd4a-4231-9685-38144e2cd417n%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/CAGp2JVFpOiQ04VLBwtFOhXh6SM4h4J6jL03EnikwowBmGux4Xw%40mail.gmail.com.


TypeError __init__() takes 1 positional argument but 2 were given

2021-10-18 Thread Jose Cabrera
hello everyone, please help me with this error that is generated in the 
views.py, in class registro(CreateView):
Thank you
form.py
class RegistrationForm(forms.ModelForm):
password = forms.CharField(label='Password', widget=forms.PasswordInput)
class Meta:
model = UserProfile
fields = ('email','password')

def save(self, commit=True):
# Save the provided password in hashed format
user = super().save(commit=False)
user.set_password(self.cleaned_data["password"])
if commit:
user.save()
return user

views.py
from .models import UserProfile
from .forms import RegistrationForm
from django.views.generic.edit import CreateView, UpdateView
from django.urls import reverse

class registro(CreateView):
template_name = 'registration/registro.html'
form_class = RegistrationForm

def get_context_data(self, *args, **kwargs):
context = super(registro, self).get_context_data(*args, **kwargs)
context['next'] = self.request.GET.get('next')
return context

def get_success_url(self):
next_url = self.request.POST.get('next')
success_url = reverse('home')
if next_url:
success_url += '?next={}'.format(next_url)

return success_url

-- 
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/070868ce-cd4a-4231-9685-38144e2cd417n%40googlegroups.com.


TypeError: dict object is not callable (inside Thread function)

2021-10-17 Thread Hima Bindu chowdary
Hi guys, 


I am getting an error in a program which is using threading to perform 
functions simultaneously, this process is a  job which is run once per 
hour, The data that comes in is from a view in sql.

The function that we call in target arg returns a dictionary and says 
"dict object is not callable".
Inside the function , we return a dictionary in the end.
My doubt is what should we return in this function ..if I dont return 
anything will it affect any other thread??

what my code looks like :
inside the jobs in django I call this function


def ticket_booking():  
  
query = " SELECT * FROM vw_ticket_list;"  

ttd = []
try:
result = query_to_dicts(query)
tickets = json.loads(to_json(result))
if tickets:
# Calling the vaccination push message (php).
for ticket in tickets:

# Getting Generic details used by all categories
full_name = tickets['full_name'] 
gender = tickets['gender']  
email =tickets[email]

if tickets['language_id'] == 1:  #book english movie 
tickets 
   
# Calling the function inside the Thread for a 
Syncronuz Call (Wait and Watch)
myThread = threading.Thread(target=book_english(email, 
full_name))
myThread.start()  
myThread.join()  

if tickets['language_id']  == 2:  # book italian movie 
tickets 
myThread = threading.Thread(target=book_italian( email, 
full_name, gender))
myThread.start()  # Starting the Thread
myThread.join() #Will return here if sth is returned

as you can see in code comments ..if book italian function returns sth , 
only then it can return here and I have 5 threads in total to excute 
simultaneously...book italian function is like :

def book_italian(email,fullname,gender):
try
###posts data to another server #
b=requests.post(some postdata)

 a =log.objects.create(log data from b in crct format)
 return a--->{"Message":"Log created successfully"}

a is type class dict and I tried to change it to many types still gives me 
same error
any suggestions or alternatives,workarounds are welcome, this job is not 
running when run in crontab.

Thanks in advance.




-- 
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/f854bcd9-4ba7-4e4f-b415-8967f253c19cn%40googlegroups.com.


Re: TypeError: 'str' object is not callable

2021-09-13 Thread Salima Begum
Hi,
 In my project for success confirmation messages I am using the Messages
framework from Django. Here I am always getting errors in deployment server.

https://docs.djangoproject.com/en/3.2/ref/contrib/messages/

After deploying site.when i am continuously testing site. After some time I
am getting the 'str' object is not callable error is raised. for success
confirmation messages.
In views.py we are defining confirmation messages.
```

 messages.success(request, "Item is successfully removed.")


```

In settings.py
```
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
MESSAGE_LEVEL = message_constants.DEBUG
```

Django version 3.2.7

Can anyone please help me. how to fix this error I am facing this issue
from long time back again and again same issue is raising. where I am going
wrong i am not understanding could you please help me to fix this issue.

Thanks
~Salima

On Thu, Sep 2, 2021 at 10:27 AM Lalit Suthar 
wrote:

> cool :)
>
>
> On Tue, 31 Aug 2021 at 11:27, Salima Begum 
> wrote:
>
>> Hi all,
>> Actually this error is prompting because in my deployment site I am using
>> django version 3.2. In this version they have some issue with messages so,
>> I referred to this document and I fixed it by adding one line in the
>> settings.py file.
>> https://docs.djangoproject.com/en/3.2/ref/contrib/messages/
>>
>> On Tue, Aug 31, 2021 at 11:22 AM Lalit Suthar 
>> wrote:
>>
>>> go like this
>>>
>>> messages.add_message(request, messages.WARNING, "failure message")
>>> return HttpResponse / render
>>>
>>> On Tue, 31 Aug 2021 at 10:32, Salima Begum 
>>> wrote:
>>>
 Hi, Thank you for your response.
  I have defined as below  I have mentioned snippet in all
 functionalities i am getting error in every functionality  " 'str' object
 is not callable ".Please help me to fix this issue.

 ```
 messages.success(request, """Your Ad is successfully posted.""")
 ```
 Thank you
 ~Salima

 On Tue, Aug 31, 2021 at 10:19 AM Salima Begum <
 salim...@rohteksolutions.com> wrote:

> Hi Thomas,
>
> The way I defined how i have written code for confirmation message
> ```
> messages.success(request, """Your Ad is successfully
> posted.""")
> ```
> Thank you
> ~Salima
>
> On Tue, Aug 31, 2021 at 9:31 AM Thomas Lockhart <
> tlockhart1...@gmail.com> wrote:
>
>> Just guessing that you need to write
>>
>> messages.success = “Your ad is successfully posted”
>>
>> But without more information from you that is only a guess.
>>
>> How is messages.success defined?
>>
>> - Tom
>>
>> On Aug 30, 2021, at 8:57 PM, Salima Begum <
>> salim...@rohteksolutions.com> wrote:
>>
>> Hi all,
>> In my project for each functionality I have written code for
>> confirmation messages. For example
>> ```
>> messages.success("Your ad is successfully posted")
>> ```
>> Every functionality is breaking because of confirmation messages
>> after deployment. How to fix it? Can anyone help me?
>>
>> Thank you
>> ~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/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%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/3831F4E1-0003-4F5A-922D-F6E1534E1B87%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/CAMSz6b%3Dgrd5PeypVZJQ9L9uA90_xxijiq6eQSaqH6bdqhgNukg%40mail.gmail.com
 
 .

>>> --
>>> You received this message because you are 

Re: TypeError: 'str' object is not callable

2021-09-01 Thread Lalit Suthar
cool :)


On Tue, 31 Aug 2021 at 11:27, Salima Begum 
wrote:

> Hi all,
> Actually this error is prompting because in my deployment site I am using
> django version 3.2. In this version they have some issue with messages so,
> I referred to this document and I fixed it by adding one line in the
> settings.py file.
> https://docs.djangoproject.com/en/3.2/ref/contrib/messages/
>
> On Tue, Aug 31, 2021 at 11:22 AM Lalit Suthar 
> wrote:
>
>> go like this
>>
>> messages.add_message(request, messages.WARNING, "failure message")
>> return HttpResponse / render
>>
>> On Tue, 31 Aug 2021 at 10:32, Salima Begum 
>> wrote:
>>
>>> Hi, Thank you for your response.
>>>  I have defined as below  I have mentioned snippet in all
>>> functionalities i am getting error in every functionality  " 'str' object
>>> is not callable ".Please help me to fix this issue.
>>>
>>> ```
>>> messages.success(request, """Your Ad is successfully posted.""")
>>> ```
>>> Thank you
>>> ~Salima
>>>
>>> On Tue, Aug 31, 2021 at 10:19 AM Salima Begum <
>>> salim...@rohteksolutions.com> wrote:
>>>
 Hi Thomas,

 The way I defined how i have written code for confirmation message
 ```
 messages.success(request, """Your Ad is successfully posted.""")
 ```
 Thank you
 ~Salima

 On Tue, Aug 31, 2021 at 9:31 AM Thomas Lockhart <
 tlockhart1...@gmail.com> wrote:

> Just guessing that you need to write
>
> messages.success = “Your ad is successfully posted”
>
> But without more information from you that is only a guess.
>
> How is messages.success defined?
>
> - Tom
>
> On Aug 30, 2021, at 8:57 PM, Salima Begum <
> salim...@rohteksolutions.com> wrote:
>
> Hi all,
> In my project for each functionality I have written code for
> confirmation messages. For example
> ```
> messages.success("Your ad is successfully posted")
> ```
> Every functionality is breaking because of confirmation messages after
> deployment. How to fix it? Can anyone help me?
>
> Thank you
> ~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/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%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/3831F4E1-0003-4F5A-922D-F6E1534E1B87%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/CAMSz6b%3Dgrd5PeypVZJQ9L9uA90_xxijiq6eQSaqH6bdqhgNukg%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/CAGp2JVE6P_5qUAC2Ec%3D8Tzn6mUPTdvXhWJ4dO5XUUC2D-7vYVQ%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/CAMSz6bmDkQio%3DYD9jxHxthnuupwkR80sjWgLEY4E6-SPZ5ofxQ%40mail.gmail.com
> 
> .
>

-- 
You 

Re: TypeError: 'str' object is not callable

2021-08-30 Thread Salima Begum
Hi all,
Actually this error is prompting because in my deployment site I am using
django version 3.2. In this version they have some issue with messages so,
I referred to this document and I fixed it by adding one line in the
settings.py file.
https://docs.djangoproject.com/en/3.2/ref/contrib/messages/

On Tue, Aug 31, 2021 at 11:22 AM Lalit Suthar 
wrote:

> go like this
>
> messages.add_message(request, messages.WARNING, "failure message")
> return HttpResponse / render
>
> On Tue, 31 Aug 2021 at 10:32, Salima Begum 
> wrote:
>
>> Hi, Thank you for your response.
>>  I have defined as below  I have mentioned snippet in all functionalities
>> i am getting error in every functionality  " 'str' object is not callable
>> ".Please help me to fix this issue.
>>
>> ```
>> messages.success(request, """Your Ad is successfully posted.""")
>> ```
>> Thank you
>> ~Salima
>>
>> On Tue, Aug 31, 2021 at 10:19 AM Salima Begum <
>> salim...@rohteksolutions.com> wrote:
>>
>>> Hi Thomas,
>>>
>>> The way I defined how i have written code for confirmation message
>>> ```
>>> messages.success(request, """Your Ad is successfully posted.""")
>>> ```
>>> Thank you
>>> ~Salima
>>>
>>> On Tue, Aug 31, 2021 at 9:31 AM Thomas Lockhart 
>>> wrote:
>>>
 Just guessing that you need to write

 messages.success = “Your ad is successfully posted”

 But without more information from you that is only a guess.

 How is messages.success defined?

 - Tom

 On Aug 30, 2021, at 8:57 PM, Salima Begum 
 wrote:

 Hi all,
 In my project for each functionality I have written code for
 confirmation messages. For example
 ```
 messages.success("Your ad is successfully posted")
 ```
 Every functionality is breaking because of confirmation messages after
 deployment. How to fix it? Can anyone help me?

 Thank you
 ~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/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%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/3831F4E1-0003-4F5A-922D-F6E1534E1B87%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/CAMSz6b%3Dgrd5PeypVZJQ9L9uA90_xxijiq6eQSaqH6bdqhgNukg%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/CAGp2JVE6P_5qUAC2Ec%3D8Tzn6mUPTdvXhWJ4dO5XUUC2D-7vYVQ%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/CAMSz6bmDkQio%3DYD9jxHxthnuupwkR80sjWgLEY4E6-SPZ5ofxQ%40mail.gmail.com.


Re: TypeError: 'str' object is not callable

2021-08-30 Thread Lalit Suthar
go like this

messages.add_message(request, messages.WARNING, "failure message")
return HttpResponse / render

On Tue, 31 Aug 2021 at 10:32, Salima Begum 
wrote:

> Hi, Thank you for your response.
>  I have defined as below  I have mentioned snippet in all functionalities
> i am getting error in every functionality  " 'str' object is not callable
> ".Please help me to fix this issue.
>
> ```
> messages.success(request, """Your Ad is successfully posted.""")
> ```
> Thank you
> ~Salima
>
> On Tue, Aug 31, 2021 at 10:19 AM Salima Begum <
> salim...@rohteksolutions.com> wrote:
>
>> Hi Thomas,
>>
>> The way I defined how i have written code for confirmation message
>> ```
>> messages.success(request, """Your Ad is successfully posted.""")
>> ```
>> Thank you
>> ~Salima
>>
>> On Tue, Aug 31, 2021 at 9:31 AM Thomas Lockhart 
>> wrote:
>>
>>> Just guessing that you need to write
>>>
>>> messages.success = “Your ad is successfully posted”
>>>
>>> But without more information from you that is only a guess.
>>>
>>> How is messages.success defined?
>>>
>>> - Tom
>>>
>>> On Aug 30, 2021, at 8:57 PM, Salima Begum 
>>> wrote:
>>>
>>> Hi all,
>>> In my project for each functionality I have written code for
>>> confirmation messages. For example
>>> ```
>>> messages.success("Your ad is successfully posted")
>>> ```
>>> Every functionality is breaking because of confirmation messages after
>>> deployment. How to fix it? Can anyone help me?
>>>
>>> Thank you
>>> ~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/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%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/3831F4E1-0003-4F5A-922D-F6E1534E1B87%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/CAMSz6b%3Dgrd5PeypVZJQ9L9uA90_xxijiq6eQSaqH6bdqhgNukg%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/CAGp2JVE6P_5qUAC2Ec%3D8Tzn6mUPTdvXhWJ4dO5XUUC2D-7vYVQ%40mail.gmail.com.


Re: TypeError: 'str' object is not callable

2021-08-30 Thread Salima Begum
Hi, Thank you for your response.
 I have defined as below  I have mentioned snippet in all functionalities i
am getting error in every functionality  " 'str' object is not callable
".Please help me to fix this issue.

```
messages.success(request, """Your Ad is successfully posted.""")
```
Thank you
~Salima

On Tue, Aug 31, 2021 at 10:19 AM Salima Begum 
wrote:

> Hi Thomas,
>
> The way I defined how i have written code for confirmation message
> ```
> messages.success(request, """Your Ad is successfully posted.""")
> ```
> Thank you
> ~Salima
>
> On Tue, Aug 31, 2021 at 9:31 AM Thomas Lockhart 
> wrote:
>
>> Just guessing that you need to write
>>
>> messages.success = “Your ad is successfully posted”
>>
>> But without more information from you that is only a guess.
>>
>> How is messages.success defined?
>>
>> - Tom
>>
>> On Aug 30, 2021, at 8:57 PM, Salima Begum 
>> wrote:
>>
>> Hi all,
>> In my project for each functionality I have written code for confirmation
>> messages. For example
>> ```
>> messages.success("Your ad is successfully posted")
>> ```
>> Every functionality is breaking because of confirmation messages after
>> deployment. How to fix it? Can anyone help me?
>>
>> Thank you
>> ~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/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%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/3831F4E1-0003-4F5A-922D-F6E1534E1B87%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/CAMSz6b%3Dgrd5PeypVZJQ9L9uA90_xxijiq6eQSaqH6bdqhgNukg%40mail.gmail.com.


Re: TypeError: 'str' object is not callable

2021-08-30 Thread Salima Begum
Hi Thomas,

The way I defined how i have written code for confirmation message
```
messages.success(request, """Your Ad is successfully posted.""")
```
Thank you
~Salima

On Tue, Aug 31, 2021 at 9:31 AM Thomas Lockhart 
wrote:

> Just guessing that you need to write
>
> messages.success = “Your ad is successfully posted”
>
> But without more information from you that is only a guess.
>
> How is messages.success defined?
>
> - Tom
>
> On Aug 30, 2021, at 8:57 PM, Salima Begum 
> wrote:
>
> Hi all,
> In my project for each functionality I have written code for confirmation
> messages. For example
> ```
> messages.success("Your ad is successfully posted")
> ```
> Every functionality is breaking because of confirmation messages after
> deployment. How to fix it? Can anyone help me?
>
> Thank you
> ~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/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%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/3831F4E1-0003-4F5A-922D-F6E1534E1B87%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/CAMSz6bnyEHFg6oV2M%2Be1pMvktqaKc8WqRRZwek7-WscekmrbOQ%40mail.gmail.com.


Re: TypeError: 'str' object is not callable

2021-08-30 Thread Jacob Greene
You need to pass the request object as the first argument.

https://docs.djangoproject.com/en/3.2/ref/contrib/messages/

On Mon, Aug 30, 2021, 11:01 PM Thomas Lockhart 
wrote:

> Just guessing that you need to write
>
> messages.success = “Your ad is successfully posted”
>
> But without more information from you that is only a guess.
>
> How is messages.success defined?
>
> - Tom
>
> On Aug 30, 2021, at 8:57 PM, Salima Begum 
> wrote:
>
> Hi all,
> In my project for each functionality I have written code for confirmation
> messages. For example
> ```
> messages.success("Your ad is successfully posted")
> ```
> Every functionality is breaking because of confirmation messages after
> deployment. How to fix it? Can anyone help me?
>
> Thank you
> ~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/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%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/3831F4E1-0003-4F5A-922D-F6E1534E1B87%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/CAF-Y%3De6zk%2BS4V0bCSgyN678hby%2BXAkTT66h5rH80_LKj1e0WXw%40mail.gmail.com.


Re: TypeError: 'str' object is not callable

2021-08-30 Thread Thomas Lockhart
Just guessing that you need to write

messages.success = “Your ad is successfully posted”

But without more information from you that is only a guess.

How is messages.success defined?

- Tom

> On Aug 30, 2021, at 8:57 PM, Salima Begum  
> wrote:
> 
> Hi all,
> In my project for each functionality I have written code for confirmation 
> messages. For example
> ```
> messages.success("Your ad is successfully posted")
> ```
> Every functionality is breaking because of confirmation messages after 
> deployment. How to fix it? Can anyone help me? 
> 
> Thank you
> ~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/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%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/3831F4E1-0003-4F5A-922D-F6E1534E1B87%40gmail.com.


TypeError: 'str' object is not callable

2021-08-30 Thread Salima Begum
Hi all,
In my project for each functionality I have written code for confirmation
messages. For example
```
messages.success("Your ad is successfully posted")
```
Every functionality is breaking because of confirmation messages after
deployment. How to fix it? Can anyone help me?

Thank you
~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/CAMSz6bkOz8AXa7d%2BRFFjm0m8xmCLYOyLQNx6syy7tf-NsPTRhA%40mail.gmail.com.


Re: Admin TypeError - Cannot call delete() after .distinct()

2021-07-02 Thread Mike Dewhirst
Just looked at that ticket and it seems probable that is what is happening.I'll 
be patient. Thanks for thatM--(Unsigned mail from my phone)
 Original message From: Jason  Date: 
2/7/21  22:30  (GMT+10:00) To: Django users  
Subject: Re: Admin TypeError - Cannot call delete() after .distinct() 
https://code.djangoproject.com/ticket/32682 might be the root cause, which was 
fixed end of April and part of the 3.2.1 release, doesn't seem like its been 
backported to 3.1On Friday, July 2, 2021 at 2:03:28 AM UTC-4 Mike Dewhirst 
wrote:Trying to delete a record in the Admin list view by checking the 
checkbox and selecting the delete action and clicking [Go] the following 
500 error happened.

It seems to be all within the Admin so I'm not sure how to proceed from 
here.

Thanks for any hints

Mike

Traceback (most recent call last):
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\exception.py", 
line 47, in inner
     response = get_response(request)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\base.py", 
line 181, in _get_response
     response = wrapped_callback(request, *callback_args, **callback_kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 616, in wrapper
     return self.admin_site.admin_view(view)(*args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
line 130, in _wrapped_view
     response = view_func(request, *args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\views\decorators\cache.py", 
line 44, in _wrapped_view_func
     response = view_func(request, *args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\sites.py", 
line 232, in inner
     return view(request, *args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
line 43, in _wrapper
     return bound_method(*args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
line 130, in _wrapped_view
     response = view_func(request, *args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 1739, in changelist_view
     response = self.response_action(request, 
queryset=cl.get_queryset(request))
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 1408, in response_action
     response = func(self, request, queryset)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\actions.py", 
line 45, in delete_selected
     modeladmin.delete_queryset(request, queryset)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 1109, in delete_queryset
     queryset.delete()
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py", 
line 728, in delete
     raise TypeError('Cannot call delete() after .distinct().')

Exception Type: TypeError at /admin/chemical/chemical/
Exception Value: Cannot call delete() after .distinct().

-- 
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.






-- 
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/086bef60-4422-4021-949b-84e19e9768b2n%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/60df20c4.1c69fb81.ed7bc.5675SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Admin TypeError - Cannot call delete() after .distinct()

2021-07-02 Thread Mike Dewhirst
Should have mentioned - I'm running 3.2.4M--(Unsigned mail from my phone)
 Original message From: Jason  Date: 
2/7/21  22:30  (GMT+10:00) To: Django users  
Subject: Re: Admin TypeError - Cannot call delete() after .distinct() 
https://code.djangoproject.com/ticket/32682 might be the root cause, which was 
fixed end of April and part of the 3.2.1 release, doesn't seem like its been 
backported to 3.1On Friday, July 2, 2021 at 2:03:28 AM UTC-4 Mike Dewhirst 
wrote:Trying to delete a record in the Admin list view by checking the 
checkbox and selecting the delete action and clicking [Go] the following 
500 error happened.

It seems to be all within the Admin so I'm not sure how to proceed from 
here.

Thanks for any hints

Mike

Traceback (most recent call last):
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\exception.py", 
line 47, in inner
     response = get_response(request)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\base.py", 
line 181, in _get_response
     response = wrapped_callback(request, *callback_args, **callback_kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 616, in wrapper
     return self.admin_site.admin_view(view)(*args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
line 130, in _wrapped_view
     response = view_func(request, *args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\views\decorators\cache.py", 
line 44, in _wrapped_view_func
     response = view_func(request, *args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\sites.py", 
line 232, in inner
     return view(request, *args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
line 43, in _wrapper
     return bound_method(*args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
line 130, in _wrapped_view
     response = view_func(request, *args, **kwargs)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 1739, in changelist_view
     response = self.response_action(request, 
queryset=cl.get_queryset(request))
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 1408, in response_action
     response = func(self, request, queryset)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\actions.py", 
line 45, in delete_selected
     modeladmin.delete_queryset(request, queryset)
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 1109, in delete_queryset
     queryset.delete()
   File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py", 
line 728, in delete
     raise TypeError('Cannot call delete() after .distinct().')

Exception Type: TypeError at /admin/chemical/chemical/
Exception Value: Cannot call delete() after .distinct().

-- 
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.






-- 
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/086bef60-4422-4021-949b-84e19e9768b2n%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/60df1f7f.1c69fb81.1daca.33a9SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Admin TypeError - Cannot call delete() after .distinct()

2021-07-02 Thread Sebastian Jung
Hello Mike,

i don't understand why you want make a delete from a distict... Then you
delete random entrys. When you want do delete dupletes then this is a wrong
method to delete dupletes...

Regards

Am Fr., 2. Juli 2021 um 08:03 Uhr schrieb Mike Dewhirst <
mi...@dewhirst.com.au>:

> Trying to delete a record in the Admin list view by checking the
> checkbox and selecting the delete action and clicking [Go] the following
> 500 error happened.
>
> It seems to be all within the Admin so I'm not sure how to proceed from
> here.
>
> Thanks for any hints
>
> Mike
>
> Traceback (most recent call last):
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\exception.py",
>
> line 47, in inner
>  response = get_response(request)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\base.py",
> line 181, in _get_response
>  response = wrapped_callback(request, *callback_args,
> **callback_kwargs)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py",
>
> line 616, in wrapper
>  return self.admin_site.admin_view(view)(*args, **kwargs)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py",
> line 130, in _wrapped_view
>  response = view_func(request, *args, **kwargs)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\views\decorators\cache.py",
>
> line 44, in _wrapped_view_func
>  response = view_func(request, *args, **kwargs)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\sites.py",
> line 232, in inner
>  return view(request, *args, **kwargs)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py",
> line 43, in _wrapper
>  return bound_method(*args, **kwargs)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py",
> line 130, in _wrapped_view
>  response = view_func(request, *args, **kwargs)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py",
>
> line 1739, in changelist_view
>  response = self.response_action(request,
> queryset=cl.get_queryset(request))
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py",
>
> line 1408, in response_action
>  response = func(self, request, queryset)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\actions.py",
>
> line 45, in delete_selected
>  modeladmin.delete_queryset(request, queryset)
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py",
>
> line 1109, in delete_queryset
>  queryset.delete()
>File
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py",
> line 728, in delete
>  raise TypeError('Cannot call delete() after .distinct().')
>
> Exception Type: TypeError at /admin/chemical/chemical/
> Exception Value: Cannot call delete() after .distinct().
>
> --
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Just
> ask and I'll send it to you. Your email software can handle signing.
>
>
> --
> 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/4ceeffab-480a-aecd-a12d-01f183598d57%40dewhirst.com.au
> .
>

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


Re: Admin TypeError - Cannot call delete() after .distinct()

2021-07-02 Thread Jason

https://code.djangoproject.com/ticket/32682 might be the root cause, which 
was fixed end of April and part of the 3.2.1 release, doesn't seem like its 
been backported to 3.1
On Friday, July 2, 2021 at 2:03:28 AM UTC-4 Mike Dewhirst wrote:

> Trying to delete a record in the Admin list view by checking the 
> checkbox and selecting the delete action and clicking [Go] the following 
> 500 error happened.
>
> It seems to be all within the Admin so I'm not sure how to proceed from 
> here.
>
> Thanks for any hints
>
> Mike
>
> Traceback (most recent call last):
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\exception.py",
>  
>
> line 47, in inner
> response = get_response(request)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\base.py", 
> line 181, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
>
> line 616, in wrapper
> return self.admin_site.admin_view(view)(*args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
> line 130, in _wrapped_view
> response = view_func(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\views\decorators\cache.py", 
>
> line 44, in _wrapped_view_func
> response = view_func(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\sites.py", 
> line 232, in inner
> return view(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
> line 43, in _wrapper
> return bound_method(*args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
> line 130, in _wrapped_view
> response = view_func(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
>
> line 1739, in changelist_view
> response = self.response_action(request, 
> queryset=cl.get_queryset(request))
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
>
> line 1408, in response_action
> response = func(self, request, queryset)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\actions.py", 
>
> line 45, in delete_selected
> modeladmin.delete_queryset(request, queryset)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
>
> line 1109, in delete_queryset
> queryset.delete()
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py", 
> line 728, in delete
> raise TypeError('Cannot call delete() after .distinct().')
>
> Exception Type: TypeError at /admin/chemical/chemical/
> Exception Value: Cannot call delete() after .distinct().
>
> -- 
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Just
> ask and I'll send it to you. Your email software can handle signing.
>
>
>

-- 
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/086bef60-4422-4021-949b-84e19e9768b2n%40googlegroups.com.


Admin TypeError - Cannot call delete() after .distinct()

2021-07-02 Thread Mike Dewhirst
Trying to delete a record in the Admin list view by checking the 
checkbox and selecting the delete action and clicking [Go] the following 
500 error happened.


It seems to be all within the Admin so I'm not sure how to proceed from 
here.


Thanks for any hints

Mike

Traceback (most recent call last):
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\exception.py", 
line 47, in inner

    response = get_response(request)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\base.py", 
line 181, in _get_response

    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 616, in wrapper

    return self.admin_site.admin_view(view)(*args, **kwargs)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
line 130, in _wrapped_view

    response = view_func(request, *args, **kwargs)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\views\decorators\cache.py", 
line 44, in _wrapped_view_func

    response = view_func(request, *args, **kwargs)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\sites.py", 
line 232, in inner

    return view(request, *args, **kwargs)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
line 43, in _wrapper

    return bound_method(*args, **kwargs)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
line 130, in _wrapped_view

    response = view_func(request, *args, **kwargs)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 1739, in changelist_view
    response = self.response_action(request, 
queryset=cl.get_queryset(request))
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 1408, in response_action

    response = func(self, request, queryset)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\actions.py", 
line 45, in delete_selected

    modeladmin.delete_queryset(request, queryset)
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
line 1109, in delete_queryset

    queryset.delete()
  File 
"D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py", 
line 728, in delete

    raise TypeError('Cannot call delete() after .distinct().')

Exception Type: TypeError at /admin/chemical/chemical/
Exception Value: Cannot call delete() after .distinct().

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.


--
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/4ceeffab-480a-aecd-a12d-01f183598d57%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: TypeError: Password must be a string or bytes, got BoundField

2021-06-04 Thread DJANGO DEVELOPER
have you converted your password into hashed? if not then do it by using
set_password.

On Fri, Jun 4, 2021 at 10:29 PM Kasper Laudrup 
wrote:

>
> https://betterprogramming.pub/how-to-ask-questions-about-programming-dcd948fcd2bd
>
> --
> 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/cf6e4a2a-62a3-18b2-d9f4-1c9228a59259%40stacktrace.dk
> .
>

-- 
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/CAKPY9pne3j9CC3cjouZbjemfXOHJhmrVsYxSVd9EH%3DaemNV%3DcQ%40mail.gmail.com.


Re: TypeError: Password must be a string or bytes, got BoundField

2021-06-04 Thread Kasper Laudrup
https://betterprogramming.pub/how-to-ask-questions-about-programming-dcd948fcd2bd

-- 
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/cf6e4a2a-62a3-18b2-d9f4-1c9228a59259%40stacktrace.dk.


OpenPGP_signature
Description: OpenPGP digital signature


TypeError: Password must be a string or bytes, got BoundField

2021-06-04 Thread pikasu pikasu
*models.py*
class recruiterLogin(models.Model):

user = models.ForeignKey(User, on_delete=models.CASCADE)
mobile = models.CharField(max_length=15,null=True)
image = models.FileField(null=True)
gender = models.CharField(max_length=10)
type = models.CharField(max_length=15)
def __str__(self):
return self.user.username
-
*Views.py*
def recruiteRegister(request):
error = ""
if request.method == 'POST':
fname = request.POST['firstname'],
lname = request.POST['lastname'],
email = request.POST['email'],
phone = request.POST['phone'],
Pwd = request.POST['password1'],
gender = request.POST['gender'],
img = request.FILES['images'],
userss = User.objects.create_user(first_name=fname,last_name=lname,username=
email,password=Pwd)
recruiterLogin.objects.create(user=userss,mobile=phone,gender=gender,image=
img,type="Recruiter")
userss.save()
return redirect("/")
print("success")
else: 
return render(request, 'recruiteRegister.html')

-
*userform*

{% csrf_token %}
































Gender: 



Male



Female















-- 
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/4a5d00c8-9213-4e87-a3a6-d57dc3034e46n%40googlegroups.com.


TypeError at /

2021-04-08 Thread Izzuan Ariffin
Background: I'm trying to test a localhost login of django-microsoft-auth 
2.4.0. 

I've read and followed the documentation: *Usage 
<https://django-microsoft-auth.readthedocs.io/en/latest/usage.html#quickstart>*

I've configured it step by step and it returns an error. TypeError: 
'NoneType' Object is not subscriptable. 

Here is the dpaste:

Environment: Request Method: GET Request URL: http://127.0.0.1:8000/ Django 
Version: 3.2 Python Version: 3.9.2 Installed Applications: 
['django.contrib.admin', 
'django.contrib.auth', 'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.messages', 'django.contrib.staticfiles', 
'STMain.apps.StmainConfig', 
'django.contrib.sites', 'microsoft_auth'] Installed Middleware: 
['django.middleware.security.SecurityMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.common.CommonMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware', 
'django.middleware.clickjacking.XFrameOptionsMiddleware'] 
Traceback (most recent call last): File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\exception.py",
 
line 47, in inner response = get_response(request) File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\base.py",
 
line 181, in _get_response response = wrapped_callback(request, 
*callback_args, **callback_kwargs) File 
"C:\Users\Muhammad.ariffin\PycharmProjects\Django_Website\STWebsite\STMain\views.py",
 
line 11, in home return render(response, "STMain/home.html", {}) File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\shortcuts.py",
 
line 19, in render content = loader.render_to_string(template_name, 
context, request, using=using) File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\loader.py",
 
line 62, in render_to_string return template.render(context, request) File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\backends\django.py",
 
line 61, in render return self.template.render(context) File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py",
 
line 168, in render with context.bind_template(self): File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\contextlib.py",
 
line 117, in __enter__ return next(self.gen) File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\context.py",
 
line 244, in bind_template updates.update(processor(self.request)) File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\site-packages\microsoft_auth\context_processors.py",
 
line 48, in microsoft auth_url = microsoft.authorization_url()[0] File 
"C:\Users\Muhammad.ariffin\AppData\Local\Programs\Python\Python39\lib\site-packages\microsoft_auth\client.py",
 
line 161, in authorization_url auth_url = 
self.openid_config["authorization_endpoint"] Exception Type: TypeError at / 
Exception 
Value: 'NoneType' object is not subscriptable

-- 
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/5d0c60e6-260b-4f64-8983-11a7e44067e3n%40googlegroups.com.


TypeError: filename must be a str or bytes object, or a file

2021-03-16 Thread Mira
Hi All,
I need some help. My Django 3.1.4 on debian Linux with Python 3.6 is not
behaving properly. Seems there is some issue with few of the packages.

Issue is same, trying to replicate from all three way to show so that I
could get some help.

Here are some of the observations, need your help
1. Super User creation through command line throwing exception
  as

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
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
line 401, in execute_from_command_line

utility.execute()

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
line 395, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py",
line 330, in run_from_argv

self.execute(*args, **cmd_options)

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
line 79, in execute

return super().execute(*args, **options)

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py",
line 371, in execute

output = self.handle(*args, **options)

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
line 157, in handle

validate_password(password2, self.UserModel(**fake_user_data))

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/password_validation.py",
line 44, in validate_password

password_validators = get_default_password_validators()

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/password_validation.py",
line 19, in get_default_password_validators

return get_password_validators(settings.AUTH_PASSWORD_VALIDATORS)

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/password_validation.py",
line 30, in get_password_validators

validators.append(klass(**validator.get('OPTIONS', {})))

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/password_validation.py",
line 174, in __init__

with gzip.open(password_list_path, 'rt', encoding='utf-8') as f:

  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/gzip.py",
line 57, in open

raise TypeError("filename must be a str or bytes object, or a file")

TypeError: filename must be a str or bytes object, or a file
2. Admin page on the local host is throwing an exception
TypeError at /admin/login/

expected str, bytes or os.PathLike object, not PosixPath

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/
Django Version: 3.1.4
Exception Type: TypeError
Exception Value:

expected str, bytes or os.PathLike object, not PosixPath

Exception Location:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/posixpath.py,
line 78, in join
Python Executable: /usr/local/bin/python3
3. command shell for creating user is throwing exception during save() call

 /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/gzip.py in
open(filename, mode, compresslevel, encoding, errors, newline)

* 55* binary_file = GzipFile(None, gz_mode, compresslevel,
filename)

* 56* else:

---> 57 raise TypeError("filename must be a str or bytes object, or
a file")

* 58*

* 59* if "t" in mode:


TypeError: filename must be a str or bytes object, or a 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/CAANDXNt40ssFQqCaO2DHWwvVcrS-dG4FdaYR9L0NJ_wCrU--WQ%40mail.gmail.com.


Re: if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket): TypeError: expected string or bytes-like object

2020-12-14 Thread Kasper Laudrup

On 14/12/2020 09.38, KUMBHAGIRI SIVAKRISHNA wrote:
ile 
"/home/sivakrishna/Downloads/peeljobs-env/lib/python3.8/site-packages/botocore/handlers.py", 
line 200, in validate_bucket_name

     if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket):
TypeError: expected string or bytes-like object


Please help me to solve this problem



https://stackoverflow.com/help/how-to-ask

--
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/886570b2-6eee-45ef-83a3-16a8cc939e12%40stacktrace.dk.


if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket): TypeError: expected string or bytes-like object

2020-12-14 Thread KUMBHAGIRI SIVAKRISHNA
ile
"/home/sivakrishna/Downloads/peeljobs-env/lib/python3.8/site-packages/botocore/handlers.py",
line 200, in validate_bucket_name
if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket):
TypeError: expected string or bytes-like object


Please help me to solve this problem

-- 
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/CAMM5N90eXxofy6AOG54bC%2B_qN1-UcECOR6tKZYdzhhPrgmSecg%40mail.gmail.com.


Re: TypeError: object() takes No Parameters

2020-09-17 Thread coolguy
The error lies in the following line

>>>  queryset = monthlyCostTable(getMonthlyCostQuery(2020, 'region')) 

Your class monthlyCostTable does not take any parameter while you are 
passing getMonthlyCost... you know better what your doing but this line is 
the root cause...
 

On Thursday, September 17, 2020 at 4:00:08 PM UTC-4 pcar...@gmail.com wrote:

> The actual trace coolguy is 
>
> TypeError at /functions/ClassMonthlyCost/object() takes no 
> parametersRequest 
> Method: GETRequest 
> URL: http://98.8.61.133:8080/functions/ClassMonthlyCost/Django 
> Version: 2.2.4Exception 
> Type: TypeErrorException 
> Value: object() takes no parametersException 
> Location: 
> /home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py
>  
> in _get_response, line 113Python 
> Executable: /home/db_user/ciopsdb/venv/bin/pythonPython 
> Version:3.6.8
> Python Path:
> ['/home/db_user/ciopsdb', '/usr/lib64/python36.zip', 
> '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf']
> Server time: Thu, 17 Sep 2020 18:29:52 +  
>
> On Thursday, September 17, 2020 at 2:26:32 PM UTC-5 coolguy wrote:
>
>> is there any specific line number that message is pointing too. Can you 
>> share the actual error message and its trace...
>>
>> On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com 
>> wrote:
>>
>>> Hello everyone, I am trying to utilize the SIngleTableMixin of 
>>> django_tables2 using a custom function that queries my database and 
>>> aggregates the data into a list of dictionaries.  I read to use the 
>>> SingleTableMixin that all I needed was an iterable containing a data 
>>> structure that has a key(a list of dicts) and then to instantiate a table 
>>> in tables.py and pass to a my views Class.  I am getting an error when I do 
>>> this TypeError: Object() takes no parameters.  I have included a link to 
>>> the django tables 2 doc and my code below:
>>>
>>> #views.py
>>> from django_tables2.views import SingleTableMixin
>>> from django_tables2.export.views import ExportMixin
>>> from django_filters.views import FilterView
>>> from django.views.generic.list import ListView
>>> from django.shortcuts import render
>>>
>>> from finance.models import Circuitinfotable, Budget
>>> from .forms import monthlyCostForm
>>> from .tables import CircuitTable, monthlyCostTable
>>> from .filters import CircuitinfotableFilter
>>>
>>> from datetime import datetime
>>> from decimal import Decimal
>>> from re import sub
>>> import calendar
>>>
>>> #convert a distinct queryset into a singular list of values
>>> def getList(qs, key):
>>> resultsList = []
>>> for each in qs:
>>> resultsList.append(each[key])
>>> return resultsList
>>>
>>>
>>> def getDistinct(key):
>>> return Circuitinfotable.objects.all().values(key).distinct()
>>>
>>>
>>> def convertCurrency(val):
>>> return Decimal(sub(r'[^\d.]', '', val))
>>>
>>>
>>> def getMonthlyCostQuery(year, field):
>>> circuits = Circuitinfotable.objects.all()
>>> field_list = getList(getDistinct(field), field)
>>>
>>> results_list = []
>>> resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 
>>> 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
>>> 'Dec': 0,
>>>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
>>> 'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
>>> 'Novbw': 0, 'Decbw': 0}
>>> results_list.append(resultsDict)
>>> for each in field_list:
>>> if each!=None and each!='None':
>>> resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 
>>> 'Apr': 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 
>>> 'Nov': 0,

Re: TypeError: object() takes No Parameters

2020-09-17 Thread Patrick Carra
[Thu Sep 17 23:07:26.870983 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] Internal Server Error: /functions/ClassMonthlyCost/
[Thu Sep 17 23:07:26.871052 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] Traceback (most recent call last):
[Thu Sep 17 23:07:26.871057 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py",
 
line 34, in inner
[Thu Sep 17 23:07:26.871060 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] response = get_response(request)
[Thu Sep 17 23:07:26.871064 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
 
line 115, in _get_response
[Thu Sep 17 23:07:26.871067 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] response = self.process_exception_by_middleware(e, 
request)
[Thu Sep 17 23:07:26.871070 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
 
line 113, in _get_response
[Thu Sep 17 23:07:26.871073 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] response = wrapped_callback(request, 
*callback_args, **callback_kwargs)
[Thu Sep 17 23:07:26.871079 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] TypeError: object() takes no parameters


On Thursday, September 17, 2020 at 3:00:08 PM UTC-5 Patrick Carra wrote:

> The actual trace coolguy is 
>
> TypeError at /functions/ClassMonthlyCost/object() takes no 
> parametersRequest 
> Method: GETRequest 
> URL: http://98.8.61.133:8080/functions/ClassMonthlyCost/Django 
> Version: 2.2.4Exception 
> Type: TypeErrorException 
> Value: object() takes no parametersException 
> Location: 
> /home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py
>  
> in _get_response, line 113Python 
> Executable: /home/db_user/ciopsdb/venv/bin/pythonPython 
> Version:3.6.8
> Python Path:
> ['/home/db_user/ciopsdb', '/usr/lib64/python36.zip', 
> '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf']
> Server time: Thu, 17 Sep 2020 18:29:52 +  
>
> On Thursday, September 17, 2020 at 2:26:32 PM UTC-5 coolguy wrote:
>
>> is there any specific line number that message is pointing too. Can you 
>> share the actual error message and its trace...
>>
>> On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com 
>> wrote:
>>
>>> Hello everyone, I am trying to utilize the SIngleTableMixin of 
>>> django_tables2 using a custom function that queries my database and 
>>> aggregates the data into a list of dictionaries.  I read to use the 
>>> SingleTableMixin that all I needed was an iterable containing a data 
>>> structure that has a key(a list of dicts) and then to instantiate a table 
>>> in tables.py and pass to a my views Class.  I am getting an error when I do 
>>> this TypeError: Object() takes no parameters.  I have included a link to 
>>> the django tables 2 doc and my code below:
>>>
>>> #views.py
>>> from django_tables2.views import SingleTableMixin
>>> from django_tables2.export.views import ExportMixin
>>> from django_filters.views import FilterView
>>> from django.views.generic.list import ListView
>>> from django.shortcuts import render
>>>
>>> from finance.models import Circuitinfotable, Budget
>>> from .forms import monthlyCostForm
>>> from .tables import CircuitTable, monthlyCostTable
>>> from .filters import CircuitinfotableFilter
>>>
>>> from datetime import datetime
>>> from decimal import Decimal
>>> from re import sub
>>> import calendar
>>>
>>> #convert a distinct queryset into a singular list of values
>>> def getList(qs, key):
>>> resultsList = []
>>> for each in qs:
>>> resultsList.append(each[key])
>>> return resultsList
>>>
>>>
>>> def ge

Re: TypeError: object() takes No Parameters

2020-09-17 Thread Patrick Carra
The actual trace coolguy is 

TypeError at /functions/ClassMonthlyCost/object() takes no 
parametersRequest 
Method: GETRequest 
URL: http://98.8.61.133:8080/functions/ClassMonthlyCost/Django 
Version: 2.2.4Exception 
Type: TypeErrorException 
Value: object() takes no parametersException 
Location: 
/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py
 
in _get_response, line 113Python 
Executable: /home/db_user/ciopsdb/venv/bin/pythonPython 
Version:3.6.8
Python Path:
['/home/db_user/ciopsdb', '/usr/lib64/python36.zip', 
'/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages', 
'/home/db_user/ciopsdb/venv/lib/python3.6/site-packages', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf']
Server time: Thu, 17 Sep 2020 18:29:52 +  

On Thursday, September 17, 2020 at 2:26:32 PM UTC-5 coolguy wrote:

> is there any specific line number that message is pointing too. Can you 
> share the actual error message and its trace...
>
> On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com 
> wrote:
>
>> Hello everyone, I am trying to utilize the SIngleTableMixin of 
>> django_tables2 using a custom function that queries my database and 
>> aggregates the data into a list of dictionaries.  I read to use the 
>> SingleTableMixin that all I needed was an iterable containing a data 
>> structure that has a key(a list of dicts) and then to instantiate a table 
>> in tables.py and pass to a my views Class.  I am getting an error when I do 
>> this TypeError: Object() takes no parameters.  I have included a link to 
>> the django tables 2 doc and my code below:
>>
>> #views.py
>> from django_tables2.views import SingleTableMixin
>> from django_tables2.export.views import ExportMixin
>> from django_filters.views import FilterView
>> from django.views.generic.list import ListView
>> from django.shortcuts import render
>>
>> from finance.models import Circuitinfotable, Budget
>> from .forms import monthlyCostForm
>> from .tables import CircuitTable, monthlyCostTable
>> from .filters import CircuitinfotableFilter
>>
>> from datetime import datetime
>> from decimal import Decimal
>> from re import sub
>> import calendar
>>
>> #convert a distinct queryset into a singular list of values
>> def getList(qs, key):
>> resultsList = []
>> for each in qs:
>> resultsList.append(each[key])
>> return resultsList
>>
>>
>> def getDistinct(key):
>> return Circuitinfotable.objects.all().values(key).distinct()
>>
>>
>> def convertCurrency(val):
>> return Decimal(sub(r'[^\d.]', '', val))
>>
>>
>> def getMonthlyCostQuery(year, field):
>> circuits = Circuitinfotable.objects.all()
>> field_list = getList(getDistinct(field), field)
>>
>> results_list = []
>> resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 0, 
>> 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
>> 'Dec': 0,
>>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 'Maybw': 
>> 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 'Novbw': 0, 
>> 'Decbw': 0}
>> results_list.append(resultsDict)
>> for each in field_list:
>> if each!=None and each!='None':
>> resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 
>> 'Apr': 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 
>> 'Nov': 0, 'Dec': 0,
>>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
>> 'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
>> 'Novbw': 0, 'Decbw': 0}
>> resultsDict['field'] = each
>> results_list.append(resultsDict)
>>
>> for circuit in circuits:
>> #If you add a field to forms.py to aggregate by then add here
>> if field=='region':
>> matchField = circuit.region
>> elif field=='carrier':
>> matchField = circuit.carrier
>> elif field=='bandwidth':
>> matchField = circuit.bandwidth
>> elif field=='status':
>> m

Re: TypeError: object() takes No Parameters

2020-09-17 Thread coolguy
is there any specific line number that message is pointing too. Can you 
share the actual error message and its trace...

On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com wrote:

> Hello everyone, I am trying to utilize the SIngleTableMixin of 
> django_tables2 using a custom function that queries my database and 
> aggregates the data into a list of dictionaries.  I read to use the 
> SingleTableMixin that all I needed was an iterable containing a data 
> structure that has a key(a list of dicts) and then to instantiate a table 
> in tables.py and pass to a my views Class.  I am getting an error when I do 
> this TypeError: Object() takes no parameters.  I have included a link to 
> the django tables 2 doc and my code below:
>
> #views.py
> from django_tables2.views import SingleTableMixin
> from django_tables2.export.views import ExportMixin
> from django_filters.views import FilterView
> from django.views.generic.list import ListView
> from django.shortcuts import render
>
> from finance.models import Circuitinfotable, Budget
> from .forms import monthlyCostForm
> from .tables import CircuitTable, monthlyCostTable
> from .filters import CircuitinfotableFilter
>
> from datetime import datetime
> from decimal import Decimal
> from re import sub
> import calendar
>
> #convert a distinct queryset into a singular list of values
> def getList(qs, key):
> resultsList = []
> for each in qs:
> resultsList.append(each[key])
> return resultsList
>
>
> def getDistinct(key):
> return Circuitinfotable.objects.all().values(key).distinct()
>
>
> def convertCurrency(val):
> return Decimal(sub(r'[^\d.]', '', val))
>
>
> def getMonthlyCostQuery(year, field):
> circuits = Circuitinfotable.objects.all()
> field_list = getList(getDistinct(field), field)
>
> results_list = []
> resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 0, 
> 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
> 'Dec': 0,
>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 'Maybw': 
> 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 'Novbw': 0, 
> 'Decbw': 0}
> results_list.append(resultsDict)
> for each in field_list:
> if each!=None and each!='None':
> resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 
> 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
> 'Dec': 0,
>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
> 'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
> 'Novbw': 0, 'Decbw': 0}
> resultsDict['field'] = each
> results_list.append(resultsDict)
>
> for circuit in circuits:
> #If you add a field to forms.py to aggregate by then add here
> if field=='region':
> matchField = circuit.region
> elif field=='carrier':
> matchField = circuit.carrier
> elif field=='bandwidth':
> matchField = circuit.bandwidth
> elif field=='status':
> matchField = circuit.status
> #get the budget for each circuit
> for budgetItem in circuit.budget_set.filter(yearnum=year):
> #if an item is budgeted for given month
> if(budgetItem.actualmrc!=0):
> #Cycle through results_list to find the correct dictionary
> for each in results_list:
> if each['field']==matchField:
> #update budgetItem and bw
> if budgetItem != None:
> 
> each[calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
> if circuit.bw!= None:
> each[calendar.month_abbr[budgetItem.monthnum] 
> + 'bw']+=int(circuit.bw)
> elif matchField==None:
> if budgetItem != None:
> 
> results_list[0][calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
> if circuit.bw!= None:
> 
> results_list[0][calendar.month_abbr[budgetItem.monthnum]+'bw']+=int(
> circuit.bw)
>
> results_list = sorted(results_list, key=lambda i:i['field'])
> return results_list
>
>
> class MonthlyCost(SingleTableMixin):
> template_name = 'functions/ClassMonthlyCost.html'
> context_object_name = 'qs'
> queryset = monthlyCostTable(getMonthlyCostQuery(2020, 'region'))
>
>
> #tables.py
> import django_tables2 as tables
> from django_tables2.util

TypeError: object() takes No Parameters

2020-09-17 Thread Patrick Carra
Hello everyone, I am trying to utilize the SIngleTableMixin of 
django_tables2 using a custom function that queries my database and 
aggregates the data into a list of dictionaries.  I read to use the 
SingleTableMixin that all I needed was an iterable containing a data 
structure that has a key(a list of dicts) and then to instantiate a table 
in tables.py and pass to a my views Class.  I am getting an error when I do 
this TypeError: Object() takes no parameters.  I have included a link to 
the django tables 2 doc and my code below:

#views.py
from django_tables2.views import SingleTableMixin
from django_tables2.export.views import ExportMixin
from django_filters.views import FilterView
from django.views.generic.list import ListView
from django.shortcuts import render

from finance.models import Circuitinfotable, Budget
from .forms import monthlyCostForm
from .tables import CircuitTable, monthlyCostTable
from .filters import CircuitinfotableFilter

from datetime import datetime
from decimal import Decimal
from re import sub
import calendar

#convert a distinct queryset into a singular list of values
def getList(qs, key):
resultsList = []
for each in qs:
resultsList.append(each[key])
return resultsList


def getDistinct(key):
return Circuitinfotable.objects.all().values(key).distinct()


def convertCurrency(val):
return Decimal(sub(r'[^\d.]', '', val))


def getMonthlyCostQuery(year, field):
circuits = Circuitinfotable.objects.all()
field_list = getList(getDistinct(field), field)

results_list = []
resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 0, 
'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
'Dec': 0,
 'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 'Maybw': 
0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 'Novbw': 0, 
'Decbw': 0}
results_list.append(resultsDict)
for each in field_list:
if each!=None and each!='None':
resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 
0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
'Dec': 0,
 'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
'Novbw': 0, 'Decbw': 0}
resultsDict['field'] = each
results_list.append(resultsDict)

for circuit in circuits:
#If you add a field to forms.py to aggregate by then add here
if field=='region':
matchField = circuit.region
elif field=='carrier':
matchField = circuit.carrier
elif field=='bandwidth':
matchField = circuit.bandwidth
elif field=='status':
matchField = circuit.status
#get the budget for each circuit
for budgetItem in circuit.budget_set.filter(yearnum=year):
#if an item is budgeted for given month
if(budgetItem.actualmrc!=0):
#Cycle through results_list to find the correct dictionary
for each in results_list:
if each['field']==matchField:
#update budgetItem and bw
if budgetItem != None:

each[calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
if circuit.bw!= None:
each[calendar.month_abbr[budgetItem.monthnum] + 
'bw']+=int(circuit.bw)
elif matchField==None:
if budgetItem != None:

results_list[0][calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
if circuit.bw!= None:

results_list[0][calendar.month_abbr[budgetItem.monthnum]+'bw']+=int(circuit.bw)

results_list = sorted(results_list, key=lambda i:i['field'])
return results_list


class MonthlyCost(SingleTableMixin):
template_name = 'functions/ClassMonthlyCost.html'
context_object_name = 'qs'
queryset = monthlyCostTable(getMonthlyCostQuery(2020, 'region'))


#tables.py
import django_tables2 as tables
from django_tables2.utils import A
from .models import Circuitinfotable

class CircuitTable(tables.Table):
class Meta:
model = Circuitinfotable
export_formats = ['csv', 'xlsx']
template_name = "django_tables2/bootstrap.html"
Id1 = tables.Column(linkify={"viewname": "viewLit", "args": 
[tables.A('id1__pk')]})
fields = ("id1", "circuitid", "bandwidth", "region", "carrier", 
"segmentname", "status", "mrcnew", "diversity", )

class monthlyCostTable(tables.Table):
field = tables.Column()
Jan = tables.Column()
Janbw = tables.Column()
Feb = tables.Column()
Febbw = tables.Column()
 

Re: Proxy User and AUTH_USER_MODEL: TypeError: MyUser cannot proxy the swapped model 'myapp.MyUser'.

2020-06-22 Thread Eugene Kulak
It is not clear why it is not possible and what is the rationale behind 
this limitation? I see a lot of questions about this error. Perhaps a nice 
receipt what to do instead could help. For my understanding using the Proxy 
model as Custom User Model is most natural way to override some User's 
methods (like set password, etc)... Importing my custom model instead is 
not an option, as the User model used in Admin and standard views.

Thanks,

On Sunday, April 15, 2018 at 10:10:58 PM UTC-3, Tim Graham wrote:
>
> The behavior seems expected. 
> https://docs.djangoproject.com/en/dev/topics/auth/customizing/#custom-users-and-proxy-models
>
> It looks like if you use a proxy model, then you should import it where 
> needed rather than use AUTH_USER_MODEL.
>
> On Saturday, April 14, 2018 at 6:34:59 PM UTC-4, Nicolas Pantel wrote:
>>
>> Hi,
>>
>> I need help on the topic: Proxy for User model referenced as 
>> AUTH_USER_MODEL.
>>
>> As stated in the doc, needing to add some methods to User model, I tried 
>> to make a 'proxy' model.
>>
>> I made a 'from scratch app', with only a MyUser(User) model, and 
>> AUTH_USER_MODEL = 'myapp.MyUser' in settings.py
>> MyUser has only 'class Meta: proxy = True'
>>
>> On a ./manage.py shell (for example), I have the following traceback:
>>
>> Traceback (most recent call last):
>>>   File "./manage.py", line 22, in 
>>> execute_from_command_line(sys.argv)
>>>   File 
>>> "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py",
>>>  line 363, in execute_from_command_line
>>> utility.execute()
>>>   File 
>>> "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py",
>>>  line 337, in execute
>>> django.setup()
>>>   File "/usr/local/lib/python3.6/dist-packages/django/__init__.py", line 
>>> 27, in setup
>>> apps.populate(settings.INSTALLED_APPS)
>>>   File "/usr/local/lib/python3.6/dist-packages/django/apps/registry.py", 
>>> line 108, in populate
>>> app_config.import_models()
>>>   File "/usr/local/lib/python3.6/dist-packages/django/apps/config.py", line 
>>> 202, in import_models
>>> self.models_module = import_module(models_module_name)
>>>   File "/usr/lib/python3.6/importlib/__init__.py", line 126, in 
>>> import_module
>>> return _bootstrap._gcd_import(name[level:], package, level)
>>>   File "", line 978, in _gcd_import
>>>   File "", line 961, in _find_and_load
>>>   File "", line 950, in _find_and_load_unlocked
>>>   File "", line 655, in _load_unlocked
>>>   File "", line 678, in exec_module
>>>   File "", line 205, in 
>>> _call_with_frames_removed
>>>   File "/home/npantel/proxy_user/proxy_user/models.py", line 4, in 
>>> class MyUser(User):
>>>   File "/usr/local/lib/python3.6/dist-packages/django/db/models/base.py", 
>>> line 158, in __new__
>>> raise TypeError("%s cannot proxy the swapped model '%s'." % (name, 
>>> base_meta.swapped))
>>> TypeError: MyUser cannot proxy the swapped model 'proxy_user.MyUser'.
>>>
>>>
>> Anybody already tried to use proxy on User model?
>>
>> Thanks,
>> Nicolas Pantel
>>
>

-- 
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/9c22f6fd-8dfe-4798-929f-d28e17ed8589o%40googlegroups.com.


Re: TypeError: __init__() got an unexpected keyword argument 'Null'

2020-05-21 Thread Samsul Islam
null=True

On Thursday, May 21, 2020 at 6:27:10 AM UTC+6, jlgimeno71 wrote:
>
> Similar to keys in a dictionary, keyword argument names are case 
> sensitive.  Try to pass in the lowercase version 'null':
>
> Raison_Non_Delivery_cd = models.ForeignKey(Raison, 
> on_delete=models.CASCADE, related_name='raisonNonDelivery', null=True)
>
> -Jorge
>
> On Wed, May 20, 2020 at 5:05 PM hajar > 
> wrote:
>
>> hello django users , I hope u r doing well ! 
>>
>>
>> why can't I use Null in this case of foreign key , I hope you can see the 
>> picture below that's my class and the error 
>>
>>
>>
>> [image: err.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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/ce736614-3ff9-47fa-885d-3f5b87160291%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/9040381d-458f-409d-acf5-208f5a78939e%40googlegroups.com.


Re: TypeError: __init__() got an unexpected keyword argument 'Null'

2020-05-20 Thread Jorge Gimeno
Similar to keys in a dictionary, keyword argument names are case
sensitive.  Try to pass in the lowercase version 'null':

Raison_Non_Delivery_cd = models.ForeignKey(Raison,
on_delete=models.CASCADE, related_name='raisonNonDelivery', null=True)

-Jorge

On Wed, May 20, 2020 at 5:05 PM hajar  wrote:

> hello django users , I hope u r doing well !
>
>
> why can't I use Null in this case of foreign key , I hope you can see the
> picture below that's my class and the error
>
>
>
> [image: err.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/ce736614-3ff9-47fa-885d-3f5b87160291%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/CANfN%3DK8aTYjLmtyTsPCSrViFFAd9ZTiF5S4W%3DwHr0EEFxNzNmQ%40mail.gmail.com.


TypeError: __init__() got an unexpected keyword argument 'Null'

2020-05-20 Thread hajar


hello django users , I hope u r doing well ! 


why can't I use Null in this case of foreign key , I hope you can see the 
picture below that's my class and the error 



[image: err.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/ce736614-3ff9-47fa-885d-3f5b87160291%40googlegroups.com.


Re: TypeError: resolve() got an unexpected keyword argument 'strict' in Django

2020-05-14 Thread uday
Abhi,
Did you got any resolution for this issue. I did recent upgrade to Django 
3.0.6 and started getting the same issue.
My pathlib library is also upto date.

On Monday, April 13, 2020 at 4:28:57 AM UTC+5:30, Abhishek Pandey wrote:
>
> Hello Everyone!
>
> I am a new Django learner. I followed some tutorials to install django but 
> when i try to runserver an error message comes up. Whenever I hit this 
> command: python manage.py runserver
> the following error comes up.
>
> Watching for file changes with StatReloader
> Performing system checks...
>
> 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 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
>  
> line 401, in execute_from_command_line
> utility.execute()
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
>  
> line 395, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/base.py",
>  
> line 328, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 60, in execute
> super().execute(*args, **options)
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/base.py",
>  
> line 369, in execute
> output = self.handle(*args, **options)
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 95, in handle
> self.run(**options)
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 102, in run
> autoreload.run_with_reloader(self.inner_run, **options)
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 599, in run_with_reloader
> start_django(reloader, main_func, *args, **kwargs)
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 584, in start_django
> reloader.run(django_main_thread)
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 299, in run
> self.run_loop()
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 305, in run_loop
> next(ticker)
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 345, in tick
> for filepath, mtime in self.snapshot_files():
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 361, in snapshot_files
> for file in self.watched_files():
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 260, in watched_files
> yield from iter_all_python_module_files()
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 105, in iter_all_python_module_files
> return iter_modules_and_files(modules, frozenset(_error_files))
>   File 
> "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 141, in iter_modules_and_files
> resolved_path = path.resolve(strict=True).absolute()
> TypeError: resolve() got an unexpected keyword argument 'strict'
>
>
>
> Can anyone help me out with this, please?
>
>

-- 
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/8f9d6e92-d645-4e49-9ea3-0ffce3f56ae3%40googlegroups.com.


Re: TypeError: resolve() got an unexpected keyword argument 'strict' in Django

2020-04-12 Thread Ernest Thuku
Can you please provide more details...your views.. models etc
On Apr 13, 2020 01:58, "Abhishek Pandey"  wrote:

> Hello Everyone!
>
> I am a new Django learner. I followed some tutorials to install django but
> when i try to runserver an error message comes up. Whenever I hit this
> command: python manage.py runserver
> the following error comes up.
>
> Watching for file changes with StatReloader
> Performing system checks...
>
> 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 "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/__init__.py", line 401, in
> execute_from_command_line
> utility.execute()
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/__init__.py", line 395, in
> execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/base.py", line 328, in
> run_from_argv
> self.execute(*args, **cmd_options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/commands/runserver.py",
> line 60, in execute
> super().execute(*args, **options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/base.py", line 369, in
> execute
> output = self.handle(*args, **options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/commands/runserver.py",
> line 95, in handle
> self.run(**options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/commands/runserver.py",
> line 102, in run
> autoreload.run_with_reloader(self.inner_run, **options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 599, in
> run_with_reloader
> start_django(reloader, main_func, *args, **kwargs)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 584, in
> start_django
> reloader.run(django_main_thread)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 299, in run
> self.run_loop()
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 305, in run_loop
> next(ticker)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 345, in tick
> for filepath, mtime in self.snapshot_files():
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 361, in
> snapshot_files
> for file in self.watched_files():
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 260, in
> watched_files
> yield from iter_all_python_module_files()
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 105, in
> iter_all_python_module_files
> return iter_modules_and_files(modules, frozenset(_error_files))
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 141, in
> iter_modules_and_files
> resolved_path = path.resolve(strict=True).absolute()
> TypeError: resolve() got an unexpected keyword argument 'strict'
>
>
>
> Can anyone help me out with this, please?
>
> --
> 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/df96311a-d9ef-4dec-aca3-1b003f279c76%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/df96311a-d9ef-4dec-aca3-1b003f279c76%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/CAPsfuofTQ2F8C%2BhymMZfXdhqiAx%2BrbBYP4rch-qHm-DKhNKV_A%40mail.gmail.com.


TypeError: resolve() got an unexpected keyword argument 'strict' in Django

2020-04-12 Thread Abhishek Pandey
Hello Everyone!

I am a new Django learner. I followed some tutorials to install django but 
when i try to runserver an error message comes up. Whenever I hit this 
command: python manage.py runserver
the following error comes up.

Watching for file changes with StatReloader
Performing system checks...

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 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 401, in execute_from_command_line
utility.execute()
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 328, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 
line 60, in execute
super().execute(*args, **options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 369, in execute
output = self.handle(*args, **options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 
line 95, in handle
self.run(**options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 
line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 599, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 584, in start_django
reloader.run(django_main_thread)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 299, in run
self.run_loop()
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 305, in run_loop
next(ticker)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 345, in tick
for filepath, mtime in self.snapshot_files():
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 361, in snapshot_files
for file in self.watched_files():
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 260, in watched_files
yield from iter_all_python_module_files()
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 105, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
TypeError: resolve() got an unexpected keyword argument 'strict'



Can anyone help me out with this, please?

-- 
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/df96311a-d9ef-4dec-aca3-1b003f279c76%40googlegroups.com.


Re: JSONField filter fails with TypeError: can only concatenate tuple (not "list") to tuple

2019-11-12 Thread John-Paul Navarro
Django 2.2.7 fixed the problem.

Thanks!

On Friday, November 1, 2019 at 4:59:11 PM UTC-5, Raffaele Salmaso wrote:
>
> On Fri, Nov 1, 2019 at 10:38 PM John-Paul Navarro  > wrote:
>
>> The following fails with Django 2.2.6 but works with Django 1.11.x.
>>
> https://code.djangoproject.com/ticket/30826
>
> -- 
> | Raffaele Salmaso
> | https://salmaso.org
> | https://bitbucket.org/rsalmaso
> | https://github.com/rsalmaso
>

-- 
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/2a8c9b12-bfbc-46e0-b197-3fa28145a5f9%40googlegroups.com.


Re: JSONField filter fails with TypeError: can only concatenate tuple (not "list") to tuple

2019-11-01 Thread Raffaele Salmaso
On Fri, Nov 1, 2019 at 10:38 PM John-Paul Navarro 
wrote:

> The following fails with Django 2.2.6 but works with Django 1.11.x.
>
https://code.djangoproject.com/ticket/30826

-- 
| Raffaele Salmaso
| https://salmaso.org
| https://bitbucket.org/rsalmaso
| https://github.com/rsalmaso

-- 
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/CABgH4JuOC3D0iKdye9y_Orpw4kKFu-xZZWo7Y%2B%2BATtWSQbF1Bg%40mail.gmail.com.


JSONField filter fails with TypeError: can only concatenate tuple (not "list") to tuple

2019-11-01 Thread John-Paul Navarro
The following fails with Django 2.2.6 but works with Django 1.11.x.

Did filter() of JSONfield change in 2.2.6 and the query needs to change, or 
could this be a bug?

Goal:
   Select model rows where the related AbstractService.EntityJSON contents 
“Capability" list includes the value 'data.transfer.nonstriped'
Given: EntityJSON field contains "Capability": ["data.transfer.striped", 
"data.transfer.nonstriped"],

Executing:
  objects = 
Endpoint.objects.filter(AbstractService__EntityJSON__Capability__contains=['data.transfer.nonstriped’])
  serializernonstriped = xdinfo_gridftpn_Serializer(objects, many=True)
  len(serializernonstriped.data)

Failes like this:
(Pdb) n
> 
/soft/python-pipenv/python-201910-zz_fwp56/lib/python3.7/site-packages/django/contrib/postgres/lookups.py(11)as_sql()
-> params = lhs_params + rhs_params
(Pdb) n
TypeError: can only concatenate tuple (not "list") to tuple
> 
/soft/python-pipenv/python-201910-zz_fwp56/lib/python3.7/site-packages/django/contrib/postgres/lookups.py(11)as_sql()
-> params = lhs_params + rhs_params
(Pdb) l
  6   
  7   class PostgresSimpleLookup(Lookup):
  8  def as_sql(self, qn, connection):
  9  lhs, lhs_params = self.process_lhs(qn, connection)
 10  rhs, rhs_params = self.process_rhs(qn, connection)
 11  ->params = lhs_params + rhs_params
 12  return '%s %s %s' % (lhs, self.operator, rhs), params
 13   
 14   
 15   class DataContains(PostgresSimpleLookup):
 16  lookup_name = 'contains'
(Pdb) lhs, lhs_params
('("glue2_db_abstractservice"."EntityJSON" -> %s)', ('Capability',))
(Pdb) rhs, rhs_params
('%s', [])


Models:
class AbstractGlue2EntityModel(models.Model):
ID = models.CharField(primary_key=True, max_length=200)
Name = models.CharField(max_length=128, null=True)
CreationTime = models.DateTimeField()
Validity = models.DurationField(null=True)
EntityJSON = JSONField()
class Meta:
abstract = True
db_name = 'glue2'
def __str__(self):
return str(self.ID)
class AbstractService(AbstractGlue2EntityModel):
ResourceID = models.CharField(db_index=True, max_length=40)
ServiceType = models.CharField(max_length=32)
Type = models.CharField(max_length=32)
QualityLevel = models.CharField(max_length=16, null=True)

class Endpoint(AbstractGlue2EntityModel):
ResourceID = models.CharField(db_index=True, max_length=40)
AbstractService = models.ForeignKey(AbstractService,
related_name='endpoints',
on_delete=models.CASCADE,
null=True)
HealthState = models.CharField(max_length=16)
ServingState = models.CharField(max_length=16)
URL = models.CharField(max_length=320)
QualityLevel = models.CharField(max_length=16, null=True)
InterfaceVersion = models.CharField(max_length=16)
InterfaceName = models.CharField(max_length=32)



-- 
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/2ded869b-4706-47f7-aba3-f6c290ccb719%40googlegroups.com.


Re: TypeError: api_view() takes from 0 to 1 positional arguments but 2 were given

2019-10-24 Thread chiyabgs
Thanks Jorge , 
this is working fine on my local (mac) but failing on the linux m/c 
hence getting confused
but fixing it seems to have done the trick -Thanks again for the response. 
my first attempt posting on a group :-)

BGS
On Friday, October 25, 2019 at 5:58:13 AM UTC+5:30, jlgimeno71 wrote:
>
> It looks like the call to @api_view should be like this:
>
> @api_view(['GET', 'POST'])
>
> In other words, pass in a single list of the permitted HTTP methods. Docs 
> here: https://www.django-rest-framework.org/api-guide/views/#api_view
>
> -Jorge
>
> On Thu, Oct 24, 2019 at 5:01 PM chiyabgs > 
> wrote:
>
>> Project was working fine on macos. Now trying to host on linux.
>> Getting this error on makemigrations / createsuperuser / runserver .
>>
>>  @api_view(['GET'], ['POST'])
>> TypeError: api_view() takes from 0 to 1 positional arguments but 2 were 
>> given ( full trace below):
>>
>> Other projects with similar function based views was working fine on 
>> linux.
>>
>> Have no clue - no google / django community mentions.
>>
>>
>> Any help appreciated
>> Thanks
>>
>>
>> Exception in thread django-main-thread:
>> Traceback (most recent call last):
>>   File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line 
>> 916, in _bootstrap_inner
>> self.run()
>>   File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line 
>> 864, in run
>> self._target(*self._args, **self._kwargs)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/autoreload.py",
>>  
>> line 54, in wrapper
>> fn(*args, **kwargs)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>>  
>> line 117, in inner_run
>> self.check(display_num_errors=True)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py",
>>  
>> line 390, in check
>> include_deployment_checks=include_deployment_checks,
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py",
>>  
>> line 377, in _run_checks
>> return checks.run_checks(**kwargs)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/registry.py",
>>  
>> line 72, in run_checks
>> new_errors = check(app_configs=app_configs)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/urls.py",
>>  
>> line 40, in check_url_namespaces_unique
>> all_namespaces = _load_all_namespaces(resolver)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/urls.py",
>>  
>> line 57, in _load_all_namespaces
>> url_patterns = getattr(resolver, 'url_patterns', [])
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/functional.py",
>>  
>> line 80, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/resolvers.py",
>>  
>> line 584, in url_patterns
>> patterns = getattr(self.urlconf_module, "urlpatterns", 
>> self.urlconf_module)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/functional.py",
>>  
>> line 80, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/resolvers.py",
>>  
>> line 577, in urlconf_module
>> return import_module(self.urlconf_name)
>>   File 
>> "/root/anaconda3/envs/py36latest/lib/python3.6/importlib/__init__.py", line 
>> 126, in import_module
>> return _bootstrap._gcd_import(name[level:], package, level)
>>   File "", line 994, in _gcd_import
>>   File "", line 971, in _find_and_load
>>   File "", line 955, in 
>> _find_and_load_unlocked
>>   File "", line 665, in _load_unlocked
>>   File "", line 678, in exec_module
>>   File "", line 219, in 
>> _call_with_frames_removed
>>   File "/usr//drf_api/drf_api/urls.py", line 23, in 
>> re_path(r'^api/', include(XYZApp.urls')),
>>   File 
>> &qu

Re: TypeError: api_view() takes from 0 to 1 positional arguments but 2 were given

2019-10-24 Thread Jorge Gimeno
It looks like the call to @api_view should be like this:

@api_view(['GET', 'POST'])

In other words, pass in a single list of the permitted HTTP methods. Docs
here: https://www.django-rest-framework.org/api-guide/views/#api_view

-Jorge

On Thu, Oct 24, 2019 at 5:01 PM chiyabgs  wrote:

> Project was working fine on macos. Now trying to host on linux.
> Getting this error on makemigrations / createsuperuser / runserver .
>
>  @api_view(['GET'], ['POST'])
> TypeError: api_view() takes from 0 to 1 positional arguments but 2 were
> given ( full trace below):
>
> Other projects with similar function based views was working fine on linux.
>
> Have no clue - no google / django community mentions.
>
>
> Any help appreciated
> Thanks
>
>
> Exception in thread django-main-thread:
> Traceback (most recent call last):
>   File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line
> 916, in _bootstrap_inner
> self.run()
>   File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line
> 864, in run
> self._target(*self._args, **self._kwargs)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/autoreload.py",
> line 54, in wrapper
> fn(*args, **kwargs)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
> line 117, in inner_run
> self.check(display_num_errors=True)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py",
> line 390, in check
> include_deployment_checks=include_deployment_checks,
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py",
> line 377, in _run_checks
> return checks.run_checks(**kwargs)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/registry.py",
> line 72, in run_checks
> new_errors = check(app_configs=app_configs)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/urls.py",
> line 40, in check_url_namespaces_unique
> all_namespaces = _load_all_namespaces(resolver)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/urls.py",
> line 57, in _load_all_namespaces
> url_patterns = getattr(resolver, 'url_patterns', [])
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/functional.py",
> line 80, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/resolvers.py",
> line 584, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/functional.py",
> line 80, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/resolvers.py",
> line 577, in urlconf_module
> return import_module(self.urlconf_name)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/importlib/__init__.py", line
> 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 994, in _gcd_import
>   File "", line 971, in _find_and_load
>   File "", line 955, in
> _find_and_load_unlocked
>   File "", line 665, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File "/usr//drf_api/drf_api/urls.py", line 23, in 
> re_path(r'^api/', include(XYZApp.urls')),
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/conf.py",
> line 34, in include
> urlconf_module = import_module(urlconf_module)
>   File
> "/root/anaconda3/envs/py36latest/lib/python3.6/importlib/__init__.py", line
> 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 994, in _gcd_import
>   File "", line 971, in _find_and_load
>   File "", line 955, in
> _find_and_load_unlocked
>   File "", line 665, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File "/usr/.drf_api/XYZApp/urls.py", line 4, in 
> from .import views
>   File ""/us

TypeError: api_view() takes from 0 to 1 positional arguments but 2 were given

2019-10-24 Thread chiyabgs
Project was working fine on macos. Now trying to host on linux.
Getting this error on makemigrations / createsuperuser / runserver .

 @api_view(['GET'], ['POST'])
TypeError: api_view() takes from 0 to 1 positional arguments but 2 were 
given ( full trace below):

Other projects with similar function based views was working fine on linux.

Have no clue - no google / django community mentions.


Any help appreciated
Thanks


Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line 
916, in _bootstrap_inner
self.run()
  File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line 
864, in run
self._target(*self._args, **self._kwargs)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 54, in wrapper
fn(*args, **kwargs)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 
line 117, in inner_run
self.check(display_num_errors=True)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py",
 
line 390, in check
include_deployment_checks=include_deployment_checks,
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py",
 
line 377, in _run_checks
return checks.run_checks(**kwargs)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/registry.py",
 
line 72, in run_checks
new_errors = check(app_configs=app_configs)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/urls.py",
 
line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/urls.py",
 
line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/functional.py",
 
line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/resolvers.py",
 
line 584, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/functional.py",
 
line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/resolvers.py",
 
line 577, in urlconf_module
return import_module(self.urlconf_name)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/importlib/__init__.py", line 
126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File "/usr//drf_api/drf_api/urls.py", line 23, in 
re_path(r'^api/', include(XYZApp.urls')),
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/conf.py",
 
line 34, in include
urlconf_module = import_module(urlconf_module)
  File 
"/root/anaconda3/envs/py36latest/lib/python3.6/importlib/__init__.py", line 
126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File "/usr/.drf_api/XYZApp/urls.py", line 4, in 
from .import views
  File ""/usr/.drf_api/XYZApp/views.py", line 161, in 
@api_view(['GET'], ['POST'])
TypeError: api_view() takes from 0 to 1 positional arguments but 2 were 
given

-- 
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/0577b8aa-4903-4b5b-b3ed-3c0935bf1530%40googlegroups.com.


[Django][ Pandas] TypeError: crosstab() missing 1 required positional argument: 'columns'

2019-09-22 Thread Dilipkumar Noone
Hi,

I am new to django.

MyTask:
==
while handling asynchronous task in Django using celery i need to export 
some data to excel and need to create a pivotal table from it,
I am using "crosstab" in pandas.[ 
https://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.crosstab.html
 ]

*I have a data frame[df] like below:*
*df :*

# read the specific columns from an excel file.
require_cols = ['ID', 'Category', 'PatchLeve1', 'HQ Domain Owners', 
'LGSIDomainOwners', 'Ownershipstatus']

# only read the specific columns from an excel file.
df = pd.read_excel(excel_name, use_cols=require_cols)


SerialNo RecordId Category SecurityPatchLevel Applicability Description 
GSP_ID HQDomainOwners LGSIDomainOwners OwnerShipStatus 
1 16 Google Security Patch 2019-02-01 O https://www.collab.com/en/20 
CVE_2019_201920 IT1 IT1   
2 17 Google Security Patch 2019-02-01 O https://www.collab.com/en/21 
CVE_2019_201921 Connectivity-GPS Connectivity-GPS   
3 18 Google Security Patch 2019-02-01 O https://www.collab.com/en/22 
CVE_2019_201922 Media-Framework MM   


===
while executing below statement, cross tab i am getting *TypeError: 
crosstab() missing 1 required positional argument: 'columns'*
===

*gsp_pivoted_table= pd.crosstab([df.Category,df.LGSIDomainOwners],margins=True)*

---

print("crosstab for LGSIDomainOwner and ownership status Count")
gsp_pending_notification = 
pd.crosstab([df.LGSIDomainOwners,df.OwnerShipStatus], margins=True)

return gsp_pivoted_table, gsp_pending_notification;


==



Please let us know how to proceed further.


Regards,
N.Dilip Kumar.

-- 
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/df08beb7-379f-4a7e-89ca-d5255da18872%40googlegroups.com.


Re: TypeError: expected string or bytes-like object

2019-08-30 Thread Suraj Thapa FC
Code pls

On Fri, 30 Aug, 2019, 6:06 PM Soumen Khatua, 
wrote:

> Hi Folks,
>
> After do some modification in models.py like I remove some column and add
> some column in my models,now I'm getting this error:
>
> *TypeError: expected string or bytes-like object*
>
>
> Please tell me how can i solve this problem?
>
>
> Thank You
>
> Regards,
> Soumen
>
> --
> 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/CAPUw6WaHcREmx0Nw8NTXoxdC-fKrQKQuVMfdk5DmGz6%3DTd4yFw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPUw6WaHcREmx0Nw8NTXoxdC-fKrQKQuVMfdk5DmGz6%3DTd4yFw%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/CAPjsHcHtxZa8wTY%2Bb0EpAOXgu4PfrSM232OXS9V6pmt-Lve%3DdQ%40mail.gmail.com.


TypeError: expected string or bytes-like object

2019-08-30 Thread Soumen Khatua
Hi Folks,

After do some modification in models.py like I remove some column and add
some column in my models,now I'm getting this error:

*TypeError: expected string or bytes-like object*


Please tell me how can i solve this problem?


Thank You

Regards,
Soumen

-- 
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/CAPUw6WaHcREmx0Nw8NTXoxdC-fKrQKQuVMfdk5DmGz6%3DTd4yFw%40mail.gmail.com.


Re: TypeError: missing 1 required positional argument (word counter app)

2019-07-10 Thread drone4four


For what it is worth, here is some of the documentation I’ve been working 
with.

I’ve referred to official Django docs for:

   - 
   
   File uploads: 
   https://docs.djangoproject.com/en/2.2/topics/http/file-uploads/
   - 
   
   Form handling with class-based views: 
   
https://docs.djangoproject.com/en/2.1/topics/class-based-views/generic-editing/
   - 
   
   HttpRequest.FILES: 
   
https://docs.djangoproject.com/en/2.2/ref/request-response/#django.http.HttpRequest.FILES
   

Stack Overflow questions I’ve used:

   - 
   
   What does the if __name__ == "__main__": do? 
   https://stackoverflow.com/questions/419163/what-does-if-name-main-do
   - 
   
   reverse for success_url on Django Class Based View complain about 
   circular import 
   
https://stackoverflow.com/questions/31275574/reverse-for-success-url-on-django-class-based-view-complain-about-circular-impor
   - 
   
   How can I get uploaded text file in view through Django? 
   
https://stackoverflow.com/questions/39436612/how-can-i-get-uploaded-text-file-in-view-through-django

   - 
   
   How can i get the file name from request.FILES? 
   
https://stackoverflow.com/questions/3111779/how-can-i-get-the-file-name-from-request-files
   - 
   
   How to reverse_lazy to a view/url with variable? 
   
https://stackoverflow.com/questions/46184193/how-to-reverse-lazy-to-a-view-url-with-variable
   


On Wednesday, July 10, 2019 at 1:13:16 PM UTC-4, drone4four wrote:
>
> I’ve got a Python script which counts and prints the number of words in a 
> text file. The script runs beautifully. It takes a public domain book (a 
> text file such as Alice and Wonderland) which then counts the top 10 most 
> used words (but which also filters out stopwords).  See here for some of my 
> previous work: 
> https://stackoverflow.com/questions/56436291/filtering-stop-words-out-of-a-large-text-file-using-package-nltk-corpus
>
>
> Now I am trying to ‘port’ this Python shell script to Django. My intention 
> for this project is to have the Django app count the number of words in a 
> blog post. But for now I’m still using Alice and Wonderland in .txt format.
>
>
> I’ve encountered some issues with my local dev server running but serving 
> me a series of name errors involving my views module when I navigate to the 
> url. I was hoping some of you could provide some insight.
>
>
> When I run the server and navigate to http://127.0.0.1:8000/seth/, this 
> is the error showing in my web browser pointing to the issue at hand: 
> https://pastebin.com/52x2c4iN
>
>
> Here is the traceback from my local Django dev server in my shell: 
> https://pastebin.com/a8PTcRki
>
>
> The file with the most problems is my counters/views.py (current app 
> only): 
> https://github.com/Angeles4four/CC_Redact_Iter2/blob/v1.2/counters/views.py
>
>
> I realize that the problem is with the way the text variable is tossed 
> around. I probably should not be invoking global variables as I do at lines 
> 24, 38, 39 in my views model (above). Furthermore, out of the Udemy course 
> material I’ve watched and in the official Django docs I’ve read, I’ve never 
> seen a views.py which uses main() for calling functions. I realize I am 
> sort of departing from Django norms here. What might you people recommend I 
> try instead?
>
>
> Here is counters/models.py:
>
>
> https://github.com/Angeles4four/CC_Redact_Iter2/blob/v1.2/counters/models.py
>
>
> counters/forms.py: 
> https://github.com/Angeles4four/CC_Redact_Iter2/blob/v1.2/counters/forms.py
>  
>
>
> urls.py in parent project directory: 
> https://github.com/Angeles4four/CC_Redact_Iter2/blob/master/CC_Redact_Iter2/urls.py
>
>
> Here is Alice and Wonderland in .txt format: 
> https://github.com/Angeles4four/CC_Redact_Iter2/blob/v1.2/counters/Alice.txt
>
>
> What other comments might you have about my code, in particular the 
> views.py linked to above?
>
>
> I’m running Django 2.2 and Python 3.7 on Manjaro.
>
>
> Pull requests on GitHub are welcome although I realize if asking for pull 
> requests like this might not be reasonable for most of you but I thought 
> I’d say as always, just in case a kind and generous forum contributor has 
> time on their hands. Requirements.txt is included on the master branch.
>
>
>

-- 
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/8d7c1b44-b262-46ee-b83b-0b43ba011847%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


TypeError: missing 1 required positional argument (word counter app)

2019-07-10 Thread drone4four


I’ve got a Python script which counts and prints the number of words in a 
text file. The script runs beautifully. It takes a public domain book (a 
text file such as Alice and Wonderland) which then counts the top 10 most 
used words (but which also filters out stopwords).  See here for some of my 
previous work: 
https://stackoverflow.com/questions/56436291/filtering-stop-words-out-of-a-large-text-file-using-package-nltk-corpus


Now I am trying to ‘port’ this Python shell script to Django. My intention 
for this project is to have the Django app count the number of words in a 
blog post. But for now I’m still using Alice and Wonderland in .txt format.


I’ve encountered some issues with my local dev server running but serving 
me a series of name errors involving my views module when I navigate to the 
url. I was hoping some of you could provide some insight.


When I run the server and navigate to http://127.0.0.1:8000/seth/, this is 
the error showing in my web browser pointing to the issue at hand: 
https://pastebin.com/52x2c4iN


Here is the traceback from my local Django dev server in my shell: 
https://pastebin.com/a8PTcRki


The file with the most problems is my counters/views.py (current app only): 
https://github.com/Angeles4four/CC_Redact_Iter2/blob/v1.2/counters/views.py


I realize that the problem is with the way the text variable is tossed 
around. I probably should not be invoking global variables as I do at lines 
24, 38, 39 in my views model (above). Furthermore, out of the Udemy course 
material I’ve watched and in the official Django docs I’ve read, I’ve never 
seen a views.py which uses main() for calling functions. I realize I am 
sort of departing from Django norms here. What might you people recommend I 
try instead?


Here is counters/models.py:

https://github.com/Angeles4four/CC_Redact_Iter2/blob/v1.2/counters/models.py


counters/forms.py: 
https://github.com/Angeles4four/CC_Redact_Iter2/blob/v1.2/counters/forms.py 


urls.py in parent project directory: 
https://github.com/Angeles4four/CC_Redact_Iter2/blob/master/CC_Redact_Iter2/urls.py


Here is Alice and Wonderland in .txt format: 
https://github.com/Angeles4four/CC_Redact_Iter2/blob/v1.2/counters/Alice.txt


What other comments might you have about my code, in particular the 
views.py linked to above?


I’m running Django 2.2 and Python 3.7 on Manjaro.


Pull requests on GitHub are welcome although I realize if asking for pull 
requests like this might not be reasonable for most of you but I thought 
I’d say as always, just in case a kind and generous forum contributor has 
time on their hands. Requirements.txt is included on the master branch.


-- 
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/d9665256-b0e7-46fc-8b32-0cca19265acc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError

2019-05-22 Thread Bob Gailer
On May 22, 2019 6:09 AM, "Soumen Khatua"  wrote:
>
> Hi Folks,
>
> I'm getting this error "TypeError:" everytime, Can You guys tell me where
is the problem in this code.

it would help us a lot if you would copy the entire traceback and paste it
into an email reply.

> Cart
>
> views.py
> @require_POST
> def cart_add(request,product_id):
> cart = Cart(request)
> product = get_object_or_404(Product,id  = product_id)
> form = forms.CartAddProductForm(request.POST)
> if form.is_valid():
> cd  = form.cleaned_data
> cart.add(
>product = product,
>quantity = cd['quantity'],
>update_quantity = cd['update'])
> return redirect('cart:cart_detail')
>
>
> def cart_detail(request):
> cart = Cart(request)
> return render (request,'cart/cartdetail.html',{'cart':cart})
>
>
>
> cartdetail.html:
> {% for item in cart %}
> {{ item.quantity }}
> {% endfor %}
>
> --
> 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/CAPUw6WYVTQWq-5WtiMo6HekSmaw6%2BRCxfRu4wbFF9BgYaDsPqg%40mail.gmail.com
.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/CAP1rxO6ck3Mg1w6Rz_TjZq51G06brVK08zHa4_XtehA%2BKn78Kg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


TypeError

2019-05-22 Thread Soumen Khatua
Hi Folks,

I'm getting this error "TypeError:" everytime, Can You guys tell me where
is the problem in this code.

*Cart*

views.py
@require_POST
def cart_add(request,product_id):
cart = Cart(request)
product = get_object_or_404(Product,id  = product_id)
form = forms.CartAddProductForm(request.POST)
if form.is_valid():
cd  = form.cleaned_data
cart.add(
   product = product,
   quantity = cd['quantity'],
   update_quantity = cd['update'])
return redirect('cart:cart_detail')


def cart_detail(request):
cart = Cart(request)
return render (request,'cart/cartdetail.html',{'cart':cart})



cartdetail.html:
{% for item in cart %}
{{ item.quantity }}
{% endfor %}

-- 
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/CAPUw6WYVTQWq-5WtiMo6HekSmaw6%2BRCxfRu4wbFF9BgYaDsPqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to make the mock object iterable ['TypeError: 'Mock' object is not iterable'] Need to Mock the django query that is iterating through for loop

2019-05-08 Thread Shashank Gupta
I am trying to mock the below django query object : 
   
1.) if MyModel.objects.filter(data='some_data').exists():
then 2.) for row in MyModel.objects.filter(ListId=id):

I am trying to test below django query inside my method.

def my_method(some_parameter):
 if formsList.objects.filter(data=some_data).exists():
for item in formsList.objects.filter(data1='data1',data2='data2'):
formNameInDb = (item.fileId).formName
if formNameInDb == formName:
return True

Below is my approach:

@mock.patch('MyModel.objects')  
def test_checkCombinationOfStateAndProduct(self, formsList_mock):

formsList_mock_data = mock.MagicMock(spec=MyModel)
formsList_mock_data.fileId.formName ='test data'

formsList_queryset = Mock()
formsList_mock.filter.return_value = formsList_queryset

# formsList_mock.filter.return_value = [formsList_queryset] 

formsList_queryset.exists.return_value = True


For the query 1). 
It is working like I am able to mockupto  **if 
formsList.objects.filter(data=some_data).exists()**

but again for the query 
2) for item in formsList.objects.filter(data1='data1',data2='data2'):
I am getting **mock object(formsList_queryset) should be iterable**
so if I make it iterable like this **[formsList_queryset]**.

Then i am getting error **" AttributeError: 'list' object has no attribute 
'exists'**.

I guess it is because after making the mock object iterable it is behaving 
like list so it does not has the exists attribute.

My problem is I am not able to make the mock object(formsList_queryset) 
iterable so that it will work in the both above mentioned query.

Is there other way mock both query to handle this issue.

Can anyone help to solve the chain queries. Any help or lead, I will really 
appreciate.
Please let me know if any information required.

-- 
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/f5558d18-6872-4715-b5e2-8f2baa627478%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unhashable TypeError when deleted from model, Django 2.2

2019-04-17 Thread Sithembewena L. Dube
Interesting. Good catch.

Kind regards,
Sithu


*Sent with Shift
<https://tryshift.com/?utm_source=SentWithShift_campaign=Sent%20with%20Shift%20Signature_medium=Email%20Signature_content=General%20Email%20Group>*

On Wed, Apr 17, 2019 at 9:48 PM Matthew Pava  wrote:

> Okay, the model I’m using specifies an __eq__ function without a
> corresponding __hash__ function. I’ve opened a pull request with the owner
> of that project.
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Matthew Pava
> *Sent:* Wednesday, April 17, 2019 11:18 AM
> *To:* django-users@googlegroups.com
> *Subject:* RE: Unhashable TypeError when deleted from model, Django 2.2
>
>
>
> Hi Sithu,
>
> I would still need to a way determine when a record expires. A Boolean
> wouldn’t help in that regard.
>
> But I think this error has something to do with Django’s delete method.
> The filtering aspect works just fine.
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Sithembewena L. Dube
> *Sent:* Tuesday, April 16, 2019 2:49 PM
> *To:* django-users@googlegroups.com
> *Subject:* Re: Unhashable TypeError when deleted from model, Django 2.2
>
>
>
> Why not use a boolean field on the model to denote expires? Then if that
> field is True, delete the object? I think that would be cheaper and
> cleaner, especially with lookups.
>
>
>
> Kind regards,
> Sithu
>
>
>
> *Sent with Shift
> <https://tryshift.com/?utm_source=SentWithShift_campaign=Sent%20with%20Shift%20Signature_medium=Email%20Signature_content=General%20Email%20Group>*
>
>
>
> On Tue, Apr 16, 2019 at 9:29 PM Matthew Pava  wrote:
>
> I have a model that has a nullable field called expires. If expires is
> null, then the record never expires.
>
> I’m performing a delete on the model for any record that has an expires
> date that has passed, and I keep getting a TypeError that Model is
> unhashable. Am I doing something wrong?
>
>
>
> Model.objects.filter(expires__lt=timezone.now()).delete()
>
>
>
> Here’s the traceback:
>
>
>
> Traceback (most recent call last):
>
>   File "\django\core\handlers\exception.py", line 34, in inner
>
> response = get_response(request)
>
>   File "\django\core\handlers\base.py", line 115, in _get_response
>
> response = self.process_exception_by_middleware(e, request)
>
>   File "\django\core\handlers\base.py", line 113, in _get_response
>
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>
>   File "\django\views\decorators\csrf.py", line 54, in wrapped_view
>
> return view_func(*args, **kwargs)
>
>   File "\django\views\generic\base.py", line 71, in view
>
> return self.dispatch(request, *args, **kwargs)
>
>   File "\rest_framework\views.py", line 495, in dispatch
>
> response = self.handle_exception(exc)
>
>   File "\rest_framework\views.py", line 455, in handle_exception
>
> self.raise_uncaught_exception(exc)
>
>   File "\rest_framework\views.py", line 492, in dispatch
>
> response = handler(request, *args, **kwargs)
>
>   File "\rest_framework\decorators.py", line 55, in handler
>
> return func(*args, **kwargs)
>
>   File "C:\project\general\views.py", line 88, in all_messages_for_user
>
> Model.objects.filter(expires__lt=timezone.now()).delete()
>
>   File "\django\db\models\query.py", line 710, in delete
>
> collector.collect(del_query)
>
>   File "\django\db\models\deletion.py", line 192, in collect
>
> reverse_dependency=reverse_dependency)
>
>   File "\django\db\models\deletion.py", line 94, in add
>
> if obj not in instances:
>
> TypeError: unhashable type: 'Model'
>
> --
> 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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL
> <https://groups.google.com/d/msgid/django-users/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message becau

RE: Unhashable TypeError when deleted from model, Django 2.2

2019-04-17 Thread Matthew Pava
Okay, the model I’m using specifies an __eq__ function without a corresponding 
__hash__ function. I’ve opened a pull request with the owner of that project.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Matthew Pava
Sent: Wednesday, April 17, 2019 11:18 AM
To: django-users@googlegroups.com
Subject: RE: Unhashable TypeError when deleted from model, Django 2.2

Hi Sithu,
I would still need to a way determine when a record expires. A Boolean wouldn’t 
help in that regard.
But I think this error has something to do with Django’s delete method. The 
filtering aspect works just fine.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Sithembewena L. Dube
Sent: Tuesday, April 16, 2019 2:49 PM
To: django-users@googlegroups.com
Subject: Re: Unhashable TypeError when deleted from model, Django 2.2

Why not use a boolean field on the model to denote expires? Then if that field 
is True, delete the object? I think that would be cheaper and cleaner, 
especially with lookups.

Kind regards,
Sithu


Sent with 
Shift<https://tryshift.com/?utm_source=SentWithShift_campaign=Sent%20with%20Shift%20Signature_medium=Email%20Signature_content=General%20Email%20Group>

On Tue, Apr 16, 2019 at 9:29 PM Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:
I have a model that has a nullable field called expires. If expires is null, 
then the record never expires.
I’m performing a delete on the model for any record that has an expires date 
that has passed, and I keep getting a TypeError that Model is unhashable. Am I 
doing something wrong?

Model.objects.filter(expires__lt=timezone.now()).delete()

Here’s the traceback:

Traceback (most recent call last):
  File "\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
  File "\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
  File "\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
  File "\rest_framework\views.py", line 495, in dispatch
response = self.handle_exception(exc)
  File "\rest_framework\views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
  File "\rest_framework\views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
  File "\rest_framework\decorators.py", line 55, in handler
return func(*args, **kwargs)
  File "C:\project\general\views.py", line 88, in all_messages_for_user
Model.objects.filter(expires__lt=timezone.now()).delete()
  File "\django\db\models\query.py", line 710, in delete
collector.collect(del_query)
  File "\django\db\models\deletion.py", line 192, in collect
reverse_dependency=reverse_dependency)
  File "\django\db\models\deletion.py", line 94, in add
if obj not in instances:
TypeError: unhashable type: 'Model'
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL<https://groups.google.com/d/msgid/django-users/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%40mail.gmail.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You r

RE: Unhashable TypeError when deleted from model, Django 2.2

2019-04-17 Thread Matthew Pava
Hi Sithu,
I would still need to a way determine when a record expires. A Boolean wouldn’t 
help in that regard.
But I think this error has something to do with Django’s delete method. The 
filtering aspect works just fine.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Sithembewena L. Dube
Sent: Tuesday, April 16, 2019 2:49 PM
To: django-users@googlegroups.com
Subject: Re: Unhashable TypeError when deleted from model, Django 2.2

Why not use a boolean field on the model to denote expires? Then if that field 
is True, delete the object? I think that would be cheaper and cleaner, 
especially with lookups.

Kind regards,
Sithu


Sent with 
Shift<https://tryshift.com/?utm_source=SentWithShift_campaign=Sent%20with%20Shift%20Signature_medium=Email%20Signature_content=General%20Email%20Group>

On Tue, Apr 16, 2019 at 9:29 PM Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:
I have a model that has a nullable field called expires. If expires is null, 
then the record never expires.
I’m performing a delete on the model for any record that has an expires date 
that has passed, and I keep getting a TypeError that Model is unhashable. Am I 
doing something wrong?

Model.objects.filter(expires__lt=timezone.now()).delete()

Here’s the traceback:

Traceback (most recent call last):
  File "\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
  File "\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
  File "\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
  File "\rest_framework\views.py", line 495, in dispatch
response = self.handle_exception(exc)
  File "\rest_framework\views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
  File "\rest_framework\views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
  File "\rest_framework\decorators.py", line 55, in handler
return func(*args, **kwargs)
  File "C:\project\general\views.py", line 88, in all_messages_for_user
Model.objects.filter(expires__lt=timezone.now()).delete()
  File "\django\db\models\query.py", line 710, in delete
collector.collect(del_query)
  File "\django\db\models\deletion.py", line 192, in collect
reverse_dependency=reverse_dependency)
  File "\django\db\models\deletion.py", line 94, in add
if obj not in instances:
TypeError: unhashable type: 'Model'
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL<https://groups.google.com/d/msgid/django-users/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%40mail.gmail.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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/cbdab94a9c2b481bbddb1b242009de80%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Unhashable TypeError when deleted from model, Django 2.2

2019-04-16 Thread Sithembewena L. Dube
Why not use a boolean field on the model to denote expires? Then if that
field is True, delete the object? I think that would be cheaper and
cleaner, especially with lookups.

Kind regards,
Sithu


*Sent with Shift
<https://tryshift.com/?utm_source=SentWithShift_campaign=Sent%20with%20Shift%20Signature_medium=Email%20Signature_content=General%20Email%20Group>*

On Tue, Apr 16, 2019 at 9:29 PM Matthew Pava  wrote:

> I have a model that has a nullable field called expires. If expires is
> null, then the record never expires.
>
> I’m performing a delete on the model for any record that has an expires
> date that has passed, and I keep getting a TypeError that Model is
> unhashable. Am I doing something wrong?
>
>
>
> Model.objects.filter(expires__lt=timezone.now()).delete()
>
>
>
> Here’s the traceback:
>
>
>
> Traceback (most recent call last):
>
>   File "\django\core\handlers\exception.py", line 34, in inner
>
> response = get_response(request)
>
>   File "\django\core\handlers\base.py", line 115, in _get_response
>
> response = self.process_exception_by_middleware(e, request)
>
>   File "\django\core\handlers\base.py", line 113, in _get_response
>
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>
>   File "\django\views\decorators\csrf.py", line 54, in wrapped_view
>
> return view_func(*args, **kwargs)
>
>   File "\django\views\generic\base.py", line 71, in view
>
> return self.dispatch(request, *args, **kwargs)
>
>   File "\rest_framework\views.py", line 495, in dispatch
>
> response = self.handle_exception(exc)
>
>   File "\rest_framework\views.py", line 455, in handle_exception
>
> self.raise_uncaught_exception(exc)
>
>   File "\rest_framework\views.py", line 492, in dispatch
>
> response = handler(request, *args, **kwargs)
>
>   File "\rest_framework\decorators.py", line 55, in handler
>
> return func(*args, **kwargs)
>
>   File "C:\project\general\views.py", line 88, in all_messages_for_user
>
> Model.objects.filter(expires__lt=timezone.now()).delete()
>
>   File "\django\db\models\query.py", line 710, in delete
>
> collector.collect(del_query)
>
>   File "\django\db\models\deletion.py", line 192, in collect
>
> reverse_dependency=reverse_dependency)
>
>   File "\django\db\models\deletion.py", line 94, in add
>
> if obj not in instances:
>
> TypeError: unhashable type: 'Model'
>
> --
> 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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL
> <https://groups.google.com/d/msgid/django-users/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Unhashable TypeError when deleted from model, Django 2.2

2019-04-16 Thread Matthew Pava
I have a model that has a nullable field called expires. If expires is null, 
then the record never expires.
I'm performing a delete on the model for any record that has an expires date 
that has passed, and I keep getting a TypeError that Model is unhashable. Am I 
doing something wrong?

Model.objects.filter(expires__lt=timezone.now()).delete()

Here's the traceback:

Traceback (most recent call last):
  File "\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
  File "\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
  File "\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
  File "\rest_framework\views.py", line 495, in dispatch
response = self.handle_exception(exc)
  File "\rest_framework\views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
  File "\rest_framework\views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
  File "\rest_framework\decorators.py", line 55, in handler
return func(*args, **kwargs)
  File "C:\project\general\views.py", line 88, in all_messages_for_user
Model.objects.filter(expires__lt=timezone.now()).delete()
  File "\django\db\models\query.py", line 710, in delete
collector.collect(del_query)
  File "\django\db\models\deletion.py", line 192, in collect
reverse_dependency=reverse_dependency)
  File "\django\db\models\deletion.py", line 94, in add
if obj not in instances:
TypeError: unhashable type: 'Model'

-- 
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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Getting a TypeError

2019-04-16 Thread laudrup


Hi Aakash,

Aakash Baranwal – Tue, 16. April 2019 13:12
> Hi Kasper,
> Thanks a lot for your help. I did as you suggested.
> This is the code now:
> def video_detail_view(request, pk=None): # pk == idobj =
> get_object_or_404(Video, pk=pk)print(obj)context = {"object": obj}return
> render(request, "deploy/detail_view.html", context)
> But still it is showing the error. Now the error is: Page Not Found
> Now what should I do?

First of all, please keep this thread on the mailing list instead of writing 
just to me.

The reason you're getting a "Page not found" error should be pretty obvious. 
It's because you don't have an object with that primary key (pk, probably 
"None"?) in your Video model.

This is all pretty basic django stuff, so I suggest you revisit the excellent 
Django documentation and read up on how the Django model/view stuff works.

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 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/20190416111910.Horde.TEd9eA83AgCxC1KME4bktdt%40cloud.stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Getting a TypeError

2019-04-16 Thread laudrup


Hi Aakash,

Aakash Baranwal – Tue, 16. April 2019 11:12

> The error I am getting is:int() argument must be a string, a bytes-like object
> or a number not 'builtin_function_or_method'.
>
> The error is in views.py file in obj = str(Video.objects.get(id=id)).

You need to pass an id argument to your video_detail_view() function.

The reason for the rather obscure error message you are getting is, that "id" 
is a builtin function in python. Try this in a python shell:

>>> type(id)


If you had named the argument something else, you'd get a less confusing error 
message.

Hope this helps.

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 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/20190416093628.Horde.HfLj1UxMG_IDKVfpOv1As-a%40cloud.stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Getting a TypeError

2019-04-16 Thread Aakash Baranwal
Hi Everybody,

Kindly help me out.

My views.py file is:

def video_detail_view(request):
obj = str(Video.objects.get(id=id))
print(obj)
context = {
"object": obj
}
return render(request, "deploy/list_view.html", context)


def video_list_view(request):
queryset = Video.objects.all()
print(queryset)
for obj in queryset:
print(obj.Video_Description, obj.videofile)
context = {
"object_list": queryset
}
return render(request, "deploy/detail_view.html", context)


The models.py file is:

class Video(models.Model):
Video_Description= models.CharField(max_length=500)
videofile= models.FileField(upload_to='videos/', null=True,
verbose_name="")

def __str__(self):
return self.Video_Description + ": " + str(self.videofile)

The error I am getting is:
int() argument must be a string, a bytes-like object or a number not
'builtin_function_or_method'.

The error is in views.py file in obj = str(Video.objects.get(id=id)).

Kindly help me out.

Thank you

Best
Aakash

-- 
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/CALr9hQ0c%2Bn5VYCzP24XSekY8R%3DSZ2bORWWRjH31o2hsWM_s%3DWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError unsupported operand type(s) for *: 'NoneType' and 'int'

2019-04-07 Thread omar ahmed
ok i understood 
thanks for help

On Sunday, April 7, 2019 at 11:58:50 AM UTC+2, Roger Gammans wrote:
>
> Omar,
>
> When posting question to the list it's good practice to practice tell us a 
> little bit about what your trying to do, and how what
> actions cause the error to occur.
>
> In this case though you only have a (single line in CalcPoints) which uses 
> the '*' operator.
>
> On Sat, 2019-04-06 at 10:35 -0700, omar ahmed wrote:
>
> models.py
> def CalcPoints(self):
> return self.won*3 + self.draw
>
>
>
> The python documentation has this to say about the '*' operator
> *(from: *
> https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
> )
>
> *The * (multiplication) operator yields the product of its arguments. The 
> arguments must either both be numbers, or one argument must be an integer 
> and the other must be a sequence. In the former case, the numbers are 
> converted to a common type and then multiplied together. In the latter 
> case, sequence repetition is performed; a negative repetition factor yields 
> an empty sequence.*
>
> Since you've provided a literal integer ( the '3') as one of your 
> arguments, we can deduce the None value
> is in self.won. Since you have 'declared' self.won as an IntegerField; we 
> can see that as in the
> normal case we should satisfy the first clause of the reference, "*arguments 
> must either both be numbers"*
> however so some reason self.won is None in your case.
>
> Without seeing the rest of your code it's impossible to guess accurately 
> but my instinct is your haven't
> initialised your instance from the database (or set a won value when 
> creating the object).
>
> If you expected to have a default value you need to set one where you set 
> up self.won see 
> : https://docs.djangoproject.com/en/2.2/ref/models/fields/#default
>
> HTH,
>
> -- 
>
> Roger Gammans >
>
>

-- 
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/d152c3b3-591d-4012-b18a-d4014156c8a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError unsupported operand type(s) for *: 'NoneType' and 'int'

2019-04-07 Thread Roger Gammans
Omar,

When posting question to the list  it's good practice to  practice tell
us a little bit about what your trying to do, and how what
actions cause the error to occur.

In this case though you only have a (single line in CalcPoints) which
uses the '*' operator.

On Sat, 2019-04-06 at 10:35 -0700, omar ahmed wrote:
> models.py
> def CalcPoints(self):
> return self.won*3 + self.draw


The python documentation has this to say about the '*' operator
(from: 
https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
)

The * (multiplication) operator yields the product of its
arguments.  The
arguments must either both be numbers, or one argument must be an
integer and
the other must be a sequence. In the former case, the numbers are
converted to a
common type and then multiplied together.  In the latter case, sequence
repetition is performed; a negative repetition factor yields an empty
sequence.

Since you've provided a literal integer ( the '3') as one of your
arguments, we can deduce the None value
is in self.won. Since you have 'declared' self.won as an
IntegerField;  we can see that as in the
normal case we should satisfy the first clause of the reference,
"arguments must either both be numbers"
however so some reason self.won is None in your case.

Without seeing the rest of your code it's impossible to guess
accurately but my instinct is your haven't
initialised your instance from the database (or set a won value when
creating the object).

If you expected to have a default value you need to set one where you
set up self.won see 
:  https://docs.djangoproject.com/en/2.2/ref/models/fields/#default

HTH,


-- 
Roger Gammans 

-- 
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/ea23ce16123320b41ad5f468ebb742f1bcb25b37.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


TypeError unsupported operand type(s) for *: 'NoneType' and 'int'

2019-04-06 Thread omar ahmed
models.py
class Club(models.Model):
league_names = models.ForeignKey(League, on_delete= models.CASCADE, 
related_name='club')
name = models.CharField(max_length=100)
logo = models.ImageField(upload_to='media/core', max_length=255, null=True, 
blank=True)
won = models.IntegerField()
draw = models.IntegerField()
lost = models.IntegerField()
goal_for = models.IntegerField()
goal_against = models.IntegerField()
club_position = models.IntegerField()

def CalcPoints(self):
return self.won*3 + self.draw


admin.py

class ClubAdmin(admin.ModelAdmin):
list_display = ['league_names', 'name', 'logo', 'won', 'draw', 'lost', 
'total_points', 'goal_for', 'goal_against', 'goal_diff']
readonly_fields = ('total_points', 'goal_diff',)

admin.site.register(Club, ClubAdmin)

total_points = property(CalcPoints)

def GoalDiff(self):
return self.goal_for - self.goal_against

goal_diff = property(GoalDiff)


def __str__(self):
return self.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 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/8ccf9b0f-da36-470e-9489-a4edd264943a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django channels raises TypeError on close: An asyncio.Future, a coroutine or an awaitable is required

2019-03-23 Thread Rodrigo Bistolfi
Hi there,

I am using Channels 2.1.7 with Python 3.7.2.
My consumer does this on connect:

async def connect(self): 
"""Accept connect if user has been provided by middleware"""  
self.user = self.scope.get('user') 
if self.user: 
await self.accept() 
else: 
await self.close() 

When `self.close()` is called, an exception is raised:

Traceback (most recent call last): 
  File 
"/opt/sps/.venv/lib/python3.7/site-packages/uvicorn/protocols/websockets/websockets_impl.py"
, line 147, in run_asgi 
result = await asgi(self.asgi_receive, self.asgi_send) 
  File "/opt/sps/.venv/lib/python3.7/site-packages/channels/consumer.py", 
line 59, in __call__ 
[receive, self.channel_receive], self.dispatch 
  File "/opt/sps/.venv/lib/python3.7/site-packages/channels/utils.py", line 
59, in await_many_dispatch 
await task 
  File "/opt/sps/.venv/lib/python3.7/site-packages/channels/utils.py", line 
51, in await_many_dispatch 
result = task.result() 
  File 
"/opt/sps/.venv/lib/python3.7/site-packages/uvicorn/protocols/websockets/websockets_impl.py"
, line 227, in asgi_receive 
data = await self.recv() 
  File "/opt/sps/.venv/lib/python3.7/site-packages/websockets/protocol.py", 
line 420, in recv 
return_when=asyncio.FIRST_COMPLETED, 
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 361, in wait 
fs = {ensure_future(f, loop=loop) for f in set(fs)} 
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 361, in 
fs = {ensure_future(f, loop=loop) for f in set(fs)} 
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 592, in 
ensure_future 
raise TypeError('An asyncio.Future, a coroutine or an awaitable is ' 
TypeError: An asyncio.Future, a coroutine or an awaitable is required 

The relevant code seems to be this:

while len(self.messages) <= 0: 
pop_message_waiter = asyncio.Future(loop=self.loop) 
self._pop_message_waiter = pop_message_waiter 
try: 
# If asyncio.wait() is canceled, it doesn't cancel 
# pop_message_waiter and self.transfer_data_task. 
tasks = [pop_message_waiter, self.transfer_data_task] 
yield from asyncio.wait( 
tasks, 
loop=self.loop,
return_when=asyncio.FIRST_COMPLETED,
)
finally:
self._pop_message_waiter = None 

In websockets/protocol.py line 410 and ss, `self.trasfer_data_task` is 
`None`. If I remove it from the wait list it seems to work.
Any ideas?

Thanks in advance, Rodrigo

-- 
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/d92a08a5-1080-4212-9cea-e46c53c4f3ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-26 Thread Abba Haruna
thank you

-- 
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/23a22766-8296-416c-8734-a3771eb6beb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-22 Thread Jason
on_delete is a required parameter now in django 2.0

https://docs.djangoproject.com/en/2.0/releases/2.0/#features-removed-in-2-0


   - The on_delete argument for ForeignKey and OneToOneField is now 
   required in models and migrations. Consider squashing migrations so that 
   you have fewer of them to update.

-- 
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/c3ea951d-4426-4973-b1bf-1d645402d1bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-22 Thread vineeth sagar
For a foreign keys you have to specify an on_delete attribute,

food=models.ForiegnKey(Food,on_delete=models.CASCADE)

If a row in the parent table(food for example) is deleted this will cause
the row/s that refers to that particular food item in your Restraunt model
be deleted.

on_delete can be given other options as SET_NULL,DO_NOTHING. Refer the docs
they are extensive on this topic.

On Nov 23, 2018 1:20 AM, "Abba Haruna"  wrote:

> from django.db import models
>
> class Food(models.Model):
> name = models.CharField(max_length=30)
> picture = models.ImageField(upload_to='images/', null=True)
> def __unicode__(self):
> return self.name
> class Town(models.Model):
> name = models.CharField(max_length=30)
>
> def __unicode__(self):
> return self.name
> class Restaurant(models.Model):
> name = models.CharField(max_length=100)
> desc = models.CharField(max_length=100)
> menu = models.CharField(max_length=100)
> web = models.CharField(max_length=100)
> phone = models.CharField(max_length=40)
> address = models.CharField(max_length=100)
> post_code = models.CharField(max_length=20)
> picture = models.ImageField(upload_to='images/', null=True)
> map = models.ImageField(upload_to='images/', null=True)
> gmap_url = models.CharField(max_length=200, null=True)
> food = models.ForeignKey(Food)
> town = models.ForeignKey(Town)
> STARS = ((1,'one'),
> (2,'two'),
> (3,'three'),
> (4,'four'),)
> votes = models.IntegerField(choices=STARS, default=4)
> def __unicode__(self):
> return self.name
> def __str__(self):
>
> --
> 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/de6ad3df-e330-43e1-875a-58895e245851%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMMZq8OuObyCbPXrwb47uSozX3sk7RXPiHaJnZxV%3Dk6SPjYpuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-22 Thread Abba Haruna
from django.db import models

class Food(models.Model):
name = models.CharField(max_length=30)
picture = models.ImageField(upload_to='images/', null=True)
def __unicode__(self):
return self.name
class Town(models.Model):
name = models.CharField(max_length=30)

def __unicode__(self):
return self.name
class Restaurant(models.Model):
name = models.CharField(max_length=100)
desc = models.CharField(max_length=100)
menu = models.CharField(max_length=100)
web = models.CharField(max_length=100)
phone = models.CharField(max_length=40)
address = models.CharField(max_length=100)
post_code = models.CharField(max_length=20)
picture = models.ImageField(upload_to='images/', null=True)
map = models.ImageField(upload_to='images/', null=True)
gmap_url = models.CharField(max_length=200, null=True)
food = models.ForeignKey(Food)
town = models.ForeignKey(Town)
STARS = ((1,'one'),
(2,'two'),
(3,'three'),
(4,'four'),)
votes = models.IntegerField(choices=STARS, default=4)
def __unicode__(self):
return self.name
def __str__(self):

-- 
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/de6ad3df-e330-43e1-875a-58895e245851%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError at /users/login/ login() got an unexpected keyword argument 'template_name'

2018-11-12 Thread Jason
 path('login/', auth_views.LoginView, {'template_name':'accounts/login.html'} 
name='login'),


There's no comma to separate the kwarg dict from the `name` positional 
argument.  As you can see in the docs 
https://docs.djangoproject.com/en/2.1/ref/urls/#path, the path function 
takes four params:

path(route, view, kwargs=None, name=None)

you're providing route and view, but the dict and name are looking like two 
positional args instead of one.

-- 
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/1c82620a-cd22-46c7-87ee-035a8901984b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError at /users/login/ login() got an unexpected keyword argument 'template_name'

2018-11-12 Thread Alex Callaway

>
> path('login/', auth_views.LoginView.as_view(), name='login'),


How does it re-direct to which page to open in above method? How does it 
open the template the user wanted here? He is trying to open the page 
'users/login.html'  when users type: http://127.0.0.1/login/ on the browser.

I have the same issue as OP. I am never directed to open the page 
*login.html*. I am using Django version 2.1.2.

My* `urls.py` (in the app) *is like this :

from django.urls import path, re_path
from django.conf.urls import url
from . import views
from django.contrib.auth import views as auth_views
#from django.contrib.auth import login
from django.contrib.auth.views import LoginView

urlpatterns=[
re_path(r'^$',views.home, name='home'),
path('login/', auth_views.LoginView, {'template_name':'accounts/login.html'} 
name='login'),
]
And I get this error :


*TypeError at /accounts/login/login/__init__() takes 1 positional argument 
but 2 were given*

Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/login/login/
Django Version: 2.1.2
Exception Type: TypeError
Exception Value: __init__() takes 1 positional argument but 2 were given

Exception Location: 
C:\Python3\lib\site-packages\django\core\handlers\base.py in _get_response, 
line 124
Python Executable: C:\Python3\python.exe
Python Version: 3.6.4
Python Path: ['C:\\Git\\projects\\projectname', 
'C:\\Python3\\python36.zip', 'C:\\Python3\\DLLs', 'C:\\Python3\\lib', 
'C:\\Python3', 'C:\\Python3\\lib\\site-packages', 
'/projectname/projectname']

Server time: Tue, 13 Nov 2018 00:11:05 +
Traceback said :

File "C:\Python3\lib\site-packages\django\core\handlers\exception.py" in 
inner
  34. response = get_response(request)

File "C:\Python3\lib\site-packages\django\core\handlers\base.py" in 
_get_response
  126. response = self.process_exception_by_middleware(e, 
request)

File "C:\Python3\lib\site-packages\django\core\handlers\base.py" in 
_get_response
  124. response = wrapped_callback(request, *callback_args, 
**callback_kwargs)

*Exception Type: TypeError at /accounts/login/login/*
*Exception Value: __init__() takes 1 positional argument but 2 were given*

My *url.py *in my project *(not in the app)* is like this :

urlpatterns = [
path('admin/', admin.site.urls),
path('home/', include('clientview.urls')),
path('accounts/login/', include('clientview.urls')),
]

On Monday, August 27, 2018 at 8:47:05 AM UTC-7, kimeualexis wrote:
>
> *#Import auth views*
>
> from django.contrib.auth import views as auth_views
>
> *#Use the views in the url*
>
> path('login/', auth_views.LoginView.as_view(), name='login'),
>
> Happy coding!
>
>
> On Mon, Aug 27, 2018 at 6:29 PM Tim Vogt (Tim Vogt)  > wrote:
>
>> Hi Jason, 
>> Thank !
>>
>> my urls.py in /users looks like this
>>
>> This is the error I get with amusement.
>>
>> How to change the old import? I suppose this is the way. Because the 
>> admin is imported from django. 
>>
>>
>>
>>
>>
>>
>> """Defines URL patterns for users"""
>>
>> from django.conf.urls import url
>> from . import views
>> # from django.contrib.auth import login
>> from django.contrib.auth.views import LoginView
>>
>> app_name='users'
>>
>>
>> urlpatterns = [
>>   # Login page
>> url('login/', LoginView, {'template_name': 'users/login.html'}, 
>> name='login'),
>> # Logout page
>> url('logout/', views.logout_view, name='logout'),
>> ]
>>
>>
>>
>>
>> TypeError at /users/login/
>>
>> __init__() takes 1 positional argument but 2 were given
>>
>> Request Method: GET
>> Request URL: http://localhost:8000/users/login/
>> Django Version: 2.0.7
>> Exception Type: TypeError
>> Exception Value: 
>>
>> __init__() takes 1 positional argument but 2 were given
>>
>> Exception Location: 
>> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py
>>  
>> in _get_response, line 126
>> Python Executable: 
>> /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
>> Python Version: 3.6.5
>> Python Path: 
>>
>> ['/Users/timvogt/Software_projects/learning_log',
>>  '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
>>  '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
>>  
>> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
>>  '/Users/timvogt/Library/Python/3.6/lib/python/site-packages',
>>  
>> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']
>>
&g

Re: path('/',views.polls_details,name="polls_details") TypeError: list indices must be integers or slices, not tuple

2018-10-11 Thread Daniel Hepper
Happens to the best of us :)

Glad I could help!

- Daniel

On Thu, Oct 11, 2018 at 11:54 AM tribhuvan kishor <
tribhuvankishor...@gmail.com> wrote:

> thanks man ... i was doing school boy error . thanks for shaving my day :)
>
> On Thu, Oct 11, 2018 at 3:20 PM Daniel Hepper 
> wrote:
>
>> You are missing a =. It should be:
>>
>> urlpatterns = [
>> ...
>> ]
>>
>> instead of:
>>
>> urlpatterns[
>> ...
>> ]
>>
>> On Thu, Oct 11, 2018 at 11:42 AM tribhuvan kishor <
>> tribhuvankishor...@gmail.com> wrote:
>>
>>> please help me I am searching about this error throw out  DAY .
>>>
>>> --
>>> regards
>>> Tribhuvan Kishor Bhaskar
>>>
>>> --
>>> 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/CACiphSUFoTdUn923%2ByVse5GFt0yrrXJ%3Dim_S1FxNPEi9ksu4EQ%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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/CAHEnUVXoLoM%2BCHPZ%3DLQSx62LXpFkUQkC2djeUwV4V0NYuq4SAw%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> regards
> Tribhuvan Kishor Bhaskar
>
> --
> 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/CACiphSWewMr_1LmMrxMdxijNCy15TMrGjjYw9x_-RHO4sk9XcQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAHEnUVWF38Ftz2jPX03_aXLHv7KD000EAsYDwDUByLwFkAPMwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: path('/',views.polls_details,name="polls_details") TypeError: list indices must be integers or slices, not tuple

2018-10-11 Thread tribhuvan kishor
thanks man ... i was doing school boy error . thanks for shaving my day :)

On Thu, Oct 11, 2018 at 3:20 PM Daniel Hepper 
wrote:

> You are missing a =. It should be:
>
> urlpatterns = [
> ...
> ]
>
> instead of:
>
> urlpatterns[
> ...
> ]
>
> On Thu, Oct 11, 2018 at 11:42 AM tribhuvan kishor <
> tribhuvankishor...@gmail.com> wrote:
>
>> please help me I am searching about this error throw out  DAY .
>>
>> --
>> regards
>> Tribhuvan Kishor Bhaskar
>>
>> --
>> 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/CACiphSUFoTdUn923%2ByVse5GFt0yrrXJ%3Dim_S1FxNPEi9ksu4EQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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/CAHEnUVXoLoM%2BCHPZ%3DLQSx62LXpFkUQkC2djeUwV4V0NYuq4SAw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
regards
Tribhuvan Kishor Bhaskar

-- 
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/CACiphSWewMr_1LmMrxMdxijNCy15TMrGjjYw9x_-RHO4sk9XcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: path('/',views.polls_details,name="polls_details") TypeError: list indices must be integers or slices, not tuple

2018-10-11 Thread Daniel Hepper
You are missing a =. It should be:

urlpatterns = [
...
]

instead of:

urlpatterns[
...
]

On Thu, Oct 11, 2018 at 11:42 AM tribhuvan kishor <
tribhuvankishor...@gmail.com> wrote:

> please help me I am searching about this error throw out  DAY .
>
> --
> regards
> Tribhuvan Kishor Bhaskar
>
> --
> 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/CACiphSUFoTdUn923%2ByVse5GFt0yrrXJ%3Dim_S1FxNPEi9ksu4EQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAHEnUVXoLoM%2BCHPZ%3DLQSx62LXpFkUQkC2djeUwV4V0NYuq4SAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError at /users/login/ login() got an unexpected keyword argument 'template_name'

2018-08-27 Thread Alex Kimeu
*#Import auth views*

from django.contrib.auth import views as auth_views

*#Use the views in the url*

path('login/', auth_views.LoginView.as_view(), name='login'),

Happy coding!


On Mon, Aug 27, 2018 at 6:29 PM Tim Vogt (Tim Vogt) 
wrote:

> Hi Jason,
> Thank !
>
> my urls.py in /users looks like this
>
> This is the error I get with amusement.
>
> How to change the old import? I suppose this is the way. Because the admin
> is imported from django.
>
>
>
>
>
>
> """Defines URL patterns for users"""
>
> from django.conf.urls import url
> from . import views
> # from django.contrib.auth import login
> from django.contrib.auth.views import LoginView
>
> app_name='users'
>
>
> urlpatterns = [
>   # Login page
> url('login/', LoginView, {'template_name': 'users/login.html'}, name='login'),
> # Logout page
> url('logout/', views.logout_view, name='logout'),
> ]
>
>
>
>
> TypeError at /users/login/
>
> __init__() takes 1 positional argument but 2 were given
>
> Request Method: GET
> Request URL: http://localhost:8000/users/login/
> Django Version: 2.0.7
> Exception Type: TypeError
> Exception Value:
>
> __init__() takes 1 positional argument but 2 were given
>
> Exception Location: 
> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py
> in _get_response, line 126
> Python Executable:
> /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
> Python Version: 3.6.5
> Python Path:
>
> ['/Users/timvogt/Software_projects/learning_log',
>  '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
>  '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
>  
> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
>  '/Users/timvogt/Library/Python/3.6/lib/python/site-packages',
>  
> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']
>
> Server time: Mon, 27 Aug 2018 15:26:32 +
> Traceback Switch to copy-and-paste view
> <http://localhost:8000/users/login/#>
>
>-
>
> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/exception.py
> in inner
>1.
>
>   response = get_response(request)
>
>   ...
>▶ Local vars <http://localhost:8000/users/login/#>
>-
>
> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py
> in _get_response
>1.
>
>   response = self.process_exception_by_middleware(e, 
> request)
>
>   ...
>▶ Local vars <http://localhost:8000/users/login/#>
>-
>
> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py
> in _get_response
>1.
>
>   response = wrapped_callback(request, *callback_args, 
> **callback_kwargs)
>
>   ...
>▶ Local vars <http://localhost:8000/users/login/#>
>
> Request informationUSER
> AnonymousUser
> GET
> No GET data
> POST
> No POST data
> FILES
> No FILES data
> COOKIES
> VariableValue
> csrftoken
>
> 'zKJ7uZOTcHNiYr4arCV6YjzR36mq7Ie2HpK607EMlKDhQcxObqHBTFSRrtkyaNZa'
>
> snipcart_order_token
>
> '142952d7-baae-4ab2-b2b0-ac5462367122'
>
> _xsrf
>
> '2|878cf834|c449d16f85d12cdef7046b0ac6567a54|1534532218'
>
> username-localhost-
>
> '2|1:0|10:1534532218|23:username-localhost-|44:YWY3N2MyNDAxYzQ0NDI3NmIxNWY4ZjUyNTI5Y2Y4YTY=|060151f0b69a6428ef01d3516fe0550735f7c8e205b9f59bf602134027e9'
>
> _ga
>
> 'GA1.1.581090691.1515705617'
>
> pretix_csrftoken
>
> '4D01Mhbc4oN2AvqmkxKaDPdzh040pxwHykOr0hc5afYoMMWtYpFcukamsEO2j3lg'
>
> __stripe_mid
>
> 'c72941fc-ac1e-4460-b838-5c87b673'
>
> Pycharm-77c83f85
>
> '1f4c7cc4-a97c-4bdc-b2cc-4c190f485abd'
>
> META
> VariableValue
> Apple_PubSub_Socket_Render
>
> '/private/tmp/com.apple.launchd.v0QRbL5XFB/Render'
>
> CONTENT_LENGTH
>
> ''
>
> CONTENT_TYPE
>
> 'text/plain'
>
> CSRF_COOKIE
>
> 'zKJ7uZOTcHNiYr4arCV6YjzR36mq7Ie2HpK607EMlKDhQcxObqHBTFSRrtkyaNZa'
>
> DISPLAY
>
> '/private/tmp/com.apple.launchd.n1qjsNP13q/org.macosforge.xquartz:0'
>
> DJANGO_SETTINGS_MODULE
>
> 'learning_log.settings'
>
> GATEWAY_INTERFACE
>
> 'CGI/1.1'
>
> HOME
>
> '/Users/timvogt'
>
> HTTP_ACCEPT
>
> 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
>
> HTTP_ACCEPT_ENCODING
>
> 'gzip, deflate'
>
> HTTP_ACCEPT_LANGUAG

Re: TypeError at /users/login/ login() got an unexpected keyword argument 'template_name'

2018-08-27 Thread Jason
you changed the import to something else, right?  but you didn't change the 
actual use of the old import to the new.

On Monday, August 27, 2018 at 8:05:03 AM UTC-4, Tim Vogt wrote:
>
> Thanks I tired bout get another error
>
> File "/Users/timvogt/Software_projects/learning_log/users/urls.py", line 
> 15, in 
> url('login/', login, {'template_name': 'users/login.html'}, 
> name='login'),
> NameError: name 'login' is not defined
>
>
>
> """Defines URL patterns for users"""
>
> from django.conf.urls import url
> from . import views
> # from django.contrib.auth import login
> from django.contrib.auth.views import LoginView
> app_name='users'
>
>
> urlpatterns = [
>   # Login page
> url('login/', login, {'template_name': 'users/login.html'}, name='login'),
> # Logout page
> url('logout/', views.logout_view, name='logout'),
> ]
>
>
> tim
>
> Op 27 aug. 2018, om 13:29 heeft Jason > 
> het volgende geschreven:
>
> you're importing the wrong login.  you need to import the login view.  
> almost there, just
>
> from django.contrib.auth.views import LoginView
>
>
>
> -- 
> 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 post to this group, send email to django...@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/5b12c855-6fb8-4887-b0ba-0dde7d29fea2%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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/b8793c00-d957-4794-91be-ff1083961376%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError at /users/login/ login() got an unexpected keyword argument 'template_name'

2018-08-27 Thread Tim Vogt (Tim Vogt)
Thanks I tired bout get another error

File "/Users/timvogt/Software_projects/learning_log/users/urls.py", line 15, in 

url('login/', login, {'template_name': 'users/login.html'}, name='login'),
NameError: name 'login' is not defined



"""Defines URL patterns for users"""

from django.conf.urls import url
from . import views
# from django.contrib.auth import login
from django.contrib.auth.views import LoginView
app_name='users'


urlpatterns = [
  # Login page
url('login/', login, {'template_name': 'users/login.html'}, name='login'),
# Logout page
url('logout/', views.logout_view, name='logout'),
]

tim

> Op 27 aug. 2018, om 13:29 heeft Jason  het volgende 
> geschreven:
> 
> you're importing the wrong login.  you need to import the login view.  almost 
> there, just
> 
> from django.contrib.auth.views import LoginView
> 
> 
> 
> -- 
> 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/5b12c855-6fb8-4887-b0ba-0dde7d29fea2%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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/0B170A66-C6B7-46D5-BAE8-1724486CF8A5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError at /users/login/ login() got an unexpected keyword argument 'template_name'

2018-08-27 Thread Jason
you're importing the wrong login.  you need to import the login view.  
almost there, just

from django.contrib.auth.views import LoginView


-- 
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/5b12c855-6fb8-4887-b0ba-0dde7d29fea2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError: view must be a callable or a list/tuple in the case of include().

2018-08-25 Thread ansh srivastav
Use the following in urls.py:



  from django.conf.urls import include,url

On Sat, Aug 25, 2018 at 12:54 PM Aware Fun 
wrote:

>
>
> rahul
>
> On Fri, Aug 24, 2018, 3:17 AM herve kabore  wrote:
>
>> this is the urls.py
>>
>>
>> from django.conf.urls import include,url
>> from django.contrib import admin
>>
>> urlpatterns = [
>> url(r'^admin/', include(admin.site.urls)),
>>
>>  url(r'^$', 'blog.views.home', name='home'),
>> ]
>>
>>
>> this is the views
>>
>>
>> from django.shortcuts import render
>>
>> from django.http import HttpResponse
>>
>> # Create your views here.
>>
>> def home(request):
>> return HttpResponse("Bonjour monde!")
>>
>>
>>
>> Unhandled exception in thread started by > check_errors..wrapper at 0x7f8f4a8afe18>
>> Traceback (most recent call last):
>>   File "/usr/lib/python3/dist-packages/django/utils/autoreload.py", line
>> 228, in wrapper
>> fn(*args, **kwargs)
>>   File
>> "/usr/lib/python3/dist-packages/django/core/management/commands/runserver.py",
>> line 124, in inner_run
>> self.check(display_num_errors=True)
>>   File "/usr/lib/python3/dist-packages/django/core/management/base.py",
>> line 359, in check
>> include_deployment_checks=include_deployment_checks,
>>   File "/usr/lib/python3/dist-packages/django/core/management/base.py",
>> line 346, in _run_checks
>> return checks.run_checks(**kwargs)
>>   File "/usr/lib/python3/dist-packages/django/core/checks/registry.py",
>> line 81, in run_checks
>> new_errors = check(app_configs=app_configs)
>>   File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line
>> 16, in check_url_config
>> return check_resolver(resolver)
>>   File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line
>> 26, in check_resolver
>> return check_method()
>>   File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line
>> 256, in check
>> for pattern in self.url_patterns:
>>   File "/usr/lib/python3/dist-packages/django/utils/functional.py", line
>> 35, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line
>> 407, in url_patterns
>> patterns = getattr(self.urlconf_module, "urlpatterns",
>> self.urlconf_module)
>>   File "/usr/lib/python3/dist-packages/django/utils/functional.py", line
>> 35, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line
>> 400, in urlconf_module
>> return import_module(self.urlconf_name)
>>   File "/usr/lib/python3.6/importlib/__init__.py", line 126, in
>> import_module
>>     return _bootstrap._gcd_import(name[level:], package, level)
>>   File "", line 994, in _gcd_import
>>   File "", line 971, in _find_and_load
>>   File "", line 955, in
>> _find_and_load_unlocked
>>   File "", line 665, in _load_unlocked
>>   File "", line 678, in exec_module
>>   File "", line 219, in
>> _call_with_frames_removed
>>   File "/home/herve/Bureau/mes_projets/eboutique/eboutique/urls.py", line
>> 20, in 
>> url(r'^$', 'backoffice.views.home', name='home'),
>>   File "/usr/lib/python3/dist-packages/django/conf/urls/__init__.py",
>> line 85, in url
>> raise TypeError('view must be a callable or a list/tuple in the case
>> of include().')
>> TypeError: view must be a callable or a list/tuple in the case of
>> include().
>>
>> --
>> 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/c20e08d2-2578-4430-963e-bb14df3a0ece%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/c20e08d2-2578-4430-963e-bb14df3a0ece%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https

Re: TypeError: view must be a callable or a list/tuple in the case of include().

2018-08-25 Thread Aware Fun
rahul

On Fri, Aug 24, 2018, 3:17 AM herve kabore  wrote:

> this is the urls.py
>
>
> from django.conf.urls import include,url
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^admin/', include(admin.site.urls)),
>
>  url(r'^$', 'blog.views.home', name='home'),
> ]
>
>
> this is the views
>
>
> from django.shortcuts import render
>
> from django.http import HttpResponse
>
> # Create your views here.
>
> def home(request):
> return HttpResponse("Bonjour monde!")
>
>
>
> Unhandled exception in thread started by  check_errors..wrapper at 0x7f8f4a8afe18>
> Traceback (most recent call last):
>   File "/usr/lib/python3/dist-packages/django/utils/autoreload.py", line
> 228, in wrapper
> fn(*args, **kwargs)
>   File
> "/usr/lib/python3/dist-packages/django/core/management/commands/runserver.py",
> line 124, in inner_run
> self.check(display_num_errors=True)
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py",
> line 359, in check
> include_deployment_checks=include_deployment_checks,
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py",
> line 346, in _run_checks
> return checks.run_checks(**kwargs)
>   File "/usr/lib/python3/dist-packages/django/core/checks/registry.py",
> line 81, in run_checks
> new_errors = check(app_configs=app_configs)
>   File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line
> 16, in check_url_config
> return check_resolver(resolver)
>   File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line
> 26, in check_resolver
> return check_method()
>   File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line
> 256, in check
> for pattern in self.url_patterns:
>   File "/usr/lib/python3/dist-packages/django/utils/functional.py", line
> 35, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line
> 407, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
>   File "/usr/lib/python3/dist-packages/django/utils/functional.py", line
> 35, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line
> 400, in urlconf_module
> return import_module(self.urlconf_name)
>   File "/usr/lib/python3.6/importlib/__init__.py", line 126, in
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 994, in _gcd_import
>   File "", line 971, in _find_and_load
>   File "", line 955, in
> _find_and_load_unlocked
>   File "", line 665, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File "/home/herve/Bureau/mes_projets/eboutique/eboutique/urls.py", line
> 20, in 
> url(r'^$', 'backoffice.views.home', name='home'),
>   File "/usr/lib/python3/dist-packages/django/conf/urls/__init__.py", line
> 85, in url
> raise TypeError('view must be a callable or a list/tuple in the case
> of include().')
> TypeError: view must be a callable or a list/tuple in the case of
> include().
>
> --
> 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/c20e08d2-2578-4430-963e-bb14df3a0ece%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c20e08d2-2578-4430-963e-bb14df3a0ece%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B8bEuQ%2BuF7YM7S9q-DSPD9QCOgeXrLKp_5M_XNEEJp_JKQG%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError: view must be a callable or a list/tuple in the case of include().

2018-08-25 Thread Glen D souza
  url(r'^$', 'blog.views.home', name='home')

You are passing a string as view by quoting blog.views.home

remove the quotes and try, i.e  url(r'^$', blog.views.home, name='home')

On Fri, 24 Aug 2018 at 03:17, herve kabore  wrote:

> this is the urls.py
>
>
> from django.conf.urls import url
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^admin/', include(admin.site.urls)),
>
>  url(r'^$', 'blog.views.home', name='home'),
> ]
>
>
> this is the views
>
>
> from django.shortcuts import render
>
> from django.http import HttpResponse
>
> # Create your views here.
>
> def home(request):
> return HttpResponse("Bonjour monde!")
>
>
>
> Unhandled exception in thread started by  check_errors..wrapper at 0x7f8f4a8afe18>
> Traceback (most recent call last):
>   File "/usr/lib/python3/dist-packages/django/utils/autoreload.py", line
> 228, in wrapper
> fn(*args, **kwargs)
>   File
> "/usr/lib/python3/dist-packages/django/core/management/commands/runserver.py",
> line 124, in inner_run
> self.check(display_num_errors=True)
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py",
> line 359, in check
> include_deployment_checks=include_deployment_checks,
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py",
> line 346, in _run_checks
> return checks.run_checks(**kwargs)
>   File "/usr/lib/python3/dist-packages/django/core/checks/registry.py",
> line 81, in run_checks
> new_errors = check(app_configs=app_configs)
>   File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line
> 16, in check_url_config
> return check_resolver(resolver)
>   File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line
> 26, in check_resolver
> return check_method()
>   File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line
> 256, in check
> for pattern in self.url_patterns:
>   File "/usr/lib/python3/dist-packages/django/utils/functional.py", line
> 35, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line
> 407, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
>   File "/usr/lib/python3/dist-packages/django/utils/functional.py", line
> 35, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line
> 400, in urlconf_module
> return import_module(self.urlconf_name)
>   File "/usr/lib/python3.6/importlib/__init__.py", line 126, in
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 994, in _gcd_import
>   File "", line 971, in _find_and_load
>   File "", line 955, in
> _find_and_load_unlocked
>   File "", line 665, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File "/home/herve/Bureau/mes_projets/eboutique/eboutique/urls.py", line
> 20, in 
> url(r'^$', 'backoffice.views.home', name='home'),
>   File "/usr/lib/python3/dist-packages/django/conf/urls/__init__.py", line
> 85, in url
> raise TypeError('view must be a callable or a list/tuple in the case
> of include().')
> TypeError: view must be a callable or a list/tuple in the case of
> include().
>
> --
> 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/c20e08d2-2578-4430-963e-bb14df3a0ece%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c20e08d2-2578-4430-963e-bb14df3a0ece%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAHfehoXwqTdBb4e43Z4uXtgHLkrAvv4F-%3D5_scCvACCq7EaPgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   5   >