MySQL caching_sha2_password

2018-05-18 Thread Kadir Guloglu
Hi

I am connect to MySQL database and I am getting this exception

Thanks for help



DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'host': '78.135.79.26',
'database': 'otomabakdb',
'user': 'otomabakus',
'password': 'password1',
'port': 3306,
}
}






Traceback (most recent call last):
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py",
 
line 216, in ensure_connection
self.connect()
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py",
 
line 194, in connect
self.connection = self.get_new_connection(conn_params)
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\mysql\base.py",
 
line 236, in get_new_connection
return Database.connect(**conn_params)
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\MySQLdb\__init__.py",
 
line 86, in Connect
return Connection(*args, **kwargs)
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\MySQLdb\connections.py",
 
line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2059, "Authentication plugin 
'caching_sha2_password' cannot be loaded: The specified module could not be 
found.\r\n")

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

Traceback (most recent call last):
  File "manage.py", line 15, in 
execute_from_command_line(sys.argv)
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py",
 
line 371, in execute_from_command_line
utility.execute()
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py",
 
line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
 
line 288, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
 
line 332, in execute
self.check()
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
 
line 364, in check
include_deployment_checks=include_deployment_checks,
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\migrate.py",
 
line 57, in _run_checks
issues = run_checks(tags=[Tags.database])
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py",
 
line 73, in run_checks
new_errors = check(app_configs=app_configs)
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\database.py",
 
line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\mysql\validation.py",
 
line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\mysql\validation.py",
 
line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py",
 
line 255, in cursor
return self._cursor()
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py",
 
line 232, in _cursor
self.ensure_connection()
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py",
 
line 216, in ensure_connection
self.connect()
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py",
 
line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py",
 
line 216, in ensure_connection
self.connect()
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py",
 
line 194, in connect
self.connection = self.get_new_connection(conn_params)
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\mysql\base.py",
 
line 236, in get_new_connection
return Database.connect(**conn_params)
  File 
"C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\MySQLdb\__init__.py",
 
line 86, in Connect
return Connection(*args, **kwargs)
  File 
"C:\Users\Kadir\AppData

RE: def get_queryset(self): ^ IndentationError: unindent does not match any outer indentation level

2018-05-18 Thread Matthew Pava
Avitab,
Whitespace is very important to Python.
You added an extra tab to your else and else clause of your try expression.
Consider the error message: unindent does not match outer indentation level
The message is mentioning indents, so let’s check our indents for any problems.


try:
selected_choice = 
question.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
#Redisplay the question voting form.
return render(request, 'polls/detail.html', 
{
'question': question,
'error_message': "you didn't 
select a choice.",
})
else:
selected_choice.votes +=1
selected_choice.save()
#...
#...
#...
return 
HttpResponseRedirect(reverse('polls:results', args=(question.id,)))


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Avitab Ayan Sarmah
Sent: Friday, May 18, 2018 11:09 AM
To: Django users
Subject: def get_queryset(self): ^ IndentationError: unindent does not match 
any outer indentation level

While going through the django project i committed an error while executing 
"python manage.py runserver" inside my project directory.It is showing error is 
in line 24 of views.py.Please comment what exact the error is and how do i 
overcome this error.The exceptions and views.py is mentioned below:

Exceptions:

PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
Performing system checks...

Unhandled exception in thread started by .wrapper at 0x017BA5FB29D8>
Traceback (most recent call last):
  File "c:\python36\lib\site-packages\django\utils\autoreload.py", line 225, in 
wrapper
fn(*args, **kwargs)
  File 
"c:\python36\lib\site-packages\django\core\management\commands\runserver.py", 
line 121, in inner_run
self.check(display_num_errors=True)
  File "c:\python36\lib\site-packages\django\core\management\base.py", line 
364, in check
include_deployment_checks=include_deployment_checks,
  File "c:\python36\lib\site-packages\django\core\management\base.py", line 
351, in _run_checks
return checks.run_checks(**kwargs)
  File "c:\python36\lib\site-packages\django\core\checks\registry.py", line 73, 
in run_checks
new_errors = check(app_configs=app_configs)
  File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 40, in 
check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
  File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 57, in 
_load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
  File "c:\python36\lib\site-packages\django\utils\functional.py", line 36, in 
__get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 536, in 
url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "c:\python36\lib\site-packages\django\utils\functional.py", line 36, in 
__get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 529, in 
urlconf_module
return import_module(self.urlconf_name)
  File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\mysite\urls.py", line 5, in 
path('', include('polls.urls')),
  File "c:\python36\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
  File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\polls\urls.py", line 3, in 
from . import views
  File "C:\Users\AVITABAYAN\mysite\polls\views.py", line 24
def get_queryset(self):
  ^
IndentationError: unindent does not match any outer indentation level


views.py:

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRe

Re: New project in virtual env referencing another project's default/redirected path

2018-05-18 Thread Nitin Kumar
There is community version of pycharm.

Please write the logs that will be helpful.

On Fri, May 18, 2018 at 10:48 PM,  wrote:

> Hi James,
>
> Thanks for suggestion. I would buy that.
>
> Meanwhile, is there anyway, i could resolve this.
>
> Regards,
> Ankit
>
> On Friday, May 18, 2018 at 6:41:29 PM UTC+2, James Farris wrote:
>>
>> This is where an IDE like PyCharm comes in handy. It will tell you right
>> away that it doesn’t recognize something and will suggest importing that
>> package. It does a pretty good job with its suggestions.
>>
>> On Fri, May 18, 2018 at 9:35 AM Nitin Kumar  wrote:
>>
>>> you have to import include.
>>>
>>> from django.urls import path, include
>>>
>>> On Fri, May 18, 2018 at 9:45 PM,  wrote:
>>>
 Hi Nitin,

 Thanks for quick response.

 Please find the below code from locallibrary/urls.py

 Could you please let me know, where shall i add the url.


 
 
 
 
 from django.contrib import admin
 from django.urls import path

 urlpatterns = [
 path('admin/', admin.site.urls),
 ]


 from django.urls import path
 from django.contrib import admin

 # Use include() to add URLS from the catalog application and
 authentication system
 from django.urls import include


 urlpatterns = [
 path('admin/', admin.site.urls),
 ]


 urlpatterns += [
 path('catalog/', include('catalog.urls')),
 ]


 # Use static() to add url mapping to serve static files during
 development (only)
 from django.conf import settings
 from django.conf.urls.static import static


 urlpatterns+= static(settings.STATIC_URL, document_root=settings.STATIC_
 ROOT)


 #Add URL maps to redirect the base URL to our application
 from django.views.generic import RedirectView
 urlpatterns += [
 path('', RedirectView.as_view(url='/catalog/', permanent=True)),
 ]

 
 
 
 --

 On Friday, May 18, 2018 at 6:09:33 PM UTC+2, Nitin Kumar wrote:
>
> Hi Ankit,
>
> You must add the urls of catalog to the project urls,
> locallibrary.urls.
>
> On Fri, May 18, 2018 at 8:32 PM,  wrote:
>
>> Hi Doug,
>>
>> I am new to Django and i also started with MDN Locallibrary project.
>> Everything went fine until Django admin site but I stuck at "Creating
>> our home page
>> "
>> I have written the code in the suggested way only but get below error 
>> when
>> try to run the project. I tried taking the urls.py code from github also
>> but it gives same issue.
>>
>> Could you please help me here.
>>
>> Regards,
>> Ankit
>>
>>
>> Page not found (404)
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/catalog/
>>
>> Using the URLconf defined in locallibrary.urls, Django tried these
>> URL patterns, in this order:
>>
>>1. admin/
>>2. ^static\/(?P.*)$
>>3.
>>
>> The current path, catalog/, didn't match any of these.
>>
>> You're seeing this error because you have DEBUG = True in your
>> Django settings file. Change that to False, and Django will display
>> a standard 404 page.
>>
>>
>>
>> On Monday, January 22, 2018 at 5:46:31 AM UTC+2, Doug Nintzel wrote:
>>>
>>> Ok, makes sense. Thank you very much for the details Daniel.
>>> Doug
>>>
>>> On Sunday, January 21, 2018 at 1:02:33 PM UTC-7, Daniel Hepper wrote:

 Yes, kind of. There are two kinds of redirects, temporary and
 permanent redirects. By default Django's redirect() method returns a
 temporary redirect. If you pass permanent=True, it returns a permanent
 redirect.

 So here is what happened in your case:

 1. You run the MDN tutorial project and point your browser to
 http://127.0.0.1:8000/
 2. The browser requests the path / from the server 127.0.0.1:8000
 (the runserver running the MDN tutorial project) and receives a 
 permanent
 redirect to /catalog/
 3. Then you stop the MDN project and run your own project.
 4. You then point your browser to http://127.0.0.1:8000
 5. Your browser thinks "wait a minute, last time I accessed the
 path / on the serv

Re: Django 2.0 MongoDB

2018-05-18 Thread Manuel Pita
I have tried a library called djongo, although I have never used it for a
production environment.

https://nesdis.github.io/djongo/get-started/

Greetings.

2018-05-18 5:59 GMT+02:00 Ryan Nowakowski :

> Django is typically used with a SQL database. There's a fork of Django
> called non-rel that works with mongo but it's not actively developed any
> longer. Instead you can access mongo from a Django view via the standard
> mongo python library but you won't be able to use Django's models or admin.
> Those are pretty dependent on a SQL database.
>
> On May 17, 2018 7:21:10 AM CDT, Kadir Guloglu 
> wrote:
>>
>> Hi
>>
>> how to connection my django 2 project in MongoDB ?
>>
>> 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 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/193821D6-941C-4A67-9478-50427D954F41%40fattuba.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Manuel Pita*

*Ingeniero en Computación*

*e-mail:* mpita1...@gmail.com

*Twitter:* @manuel_pita

*Skype:* mpita1984

*Cel:* +34663491168

*Por favor, Antes de imprimir este e-mail piense bien si es necesario
hacerlo.*

-- 
You received this message because you are subscribed to the Google 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/CAJP2%2B-9L%3DDH-0BssYvwa-BnbnXmyK7oSMNSPUdToPLOqEcRO%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.0 MongoDB

2018-05-18 Thread Manuel Pita
yo he probado una libreria llamada djongo, aunque nunca lo he usado para un
entorno de produccion.

https://nesdis.github.io/djongo/get-started/

Saludos.

2018-05-18 5:59 GMT+02:00 Ryan Nowakowski :

> Django is typically used with a SQL database. There's a fork of Django
> called non-rel that works with mongo but it's not actively developed any
> longer. Instead you can access mongo from a Django view via the standard
> mongo python library but you won't be able to use Django's models or admin.
> Those are pretty dependent on a SQL database.
>
> On May 17, 2018 7:21:10 AM CDT, Kadir Guloglu 
> wrote:
>>
>> Hi
>>
>> how to connection my django 2 project in MongoDB ?
>>
>> 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 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/193821D6-941C-4A67-9478-50427D954F41%40fattuba.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Manuel Pita*

*Ingeniero en Computación*

*e-mail:* mpita1...@gmail.com

*Twitter:* @manuel_pita

*Skype:* mpita1984

*Cel:* +34663491168

*Por favor, Antes de imprimir este e-mail piense bien si es necesario
hacerlo.*

-- 
You received this message because you are subscribed to the Google 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/CAJP2%2B-8aG3b50q4%2BtqvgqVrdNJsyZpcxc5kM%2BNPgMWPfDV-J7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: New project in virtual env referencing another project's default/redirected path

2018-05-18 Thread ankitklinkedin
Hi James,

Thanks for suggestion. I would buy that.

Meanwhile, is there anyway, i could resolve this.

Regards,
Ankit

On Friday, May 18, 2018 at 6:41:29 PM UTC+2, James Farris wrote:
>
> This is where an IDE like PyCharm comes in handy. It will tell you right 
> away that it doesn’t recognize something and will suggest importing that 
> package. It does a pretty good job with its suggestions. 
>
> On Fri, May 18, 2018 at 9:35 AM Nitin Kumar  > wrote:
>
>> you have to import include.
>>
>> from django.urls import path, include
>>
>> On Fri, May 18, 2018 at 9:45 PM, > 
>> wrote:
>>
>>> Hi Nitin,
>>>
>>> Thanks for quick response.
>>>
>>> Please find the below code from locallibrary/urls.py
>>>
>>> Could you please let me know, where shall i add the url.
>>>
>>>
>>>
>>> 
>>> from django.contrib import admin
>>> from django.urls import path
>>>
>>> urlpatterns = [
>>> path('admin/', admin.site.urls),
>>> ]
>>>
>>>
>>> from django.urls import path
>>> from django.contrib import admin
>>>
>>> # Use include() to add URLS from the catalog application and 
>>> authentication system
>>> from django.urls import include
>>>
>>>
>>> urlpatterns = [
>>> path('admin/', admin.site.urls),
>>> ]
>>>
>>>
>>> urlpatterns += [
>>> path('catalog/', include('catalog.urls')),
>>> ]
>>>
>>>
>>> # Use static() to add url mapping to serve static files during 
>>> development (only)
>>> from django.conf import settings
>>> from django.conf.urls.static import static
>>>
>>>
>>> urlpatterns+= static(settings.STATIC_URL, 
>>> document_root=settings.STATIC_ROOT)
>>>
>>>
>>> #Add URL maps to redirect the base URL to our application
>>> from django.views.generic import RedirectView
>>> urlpatterns += [
>>> path('', RedirectView.as_view(url='/catalog/', permanent=True)),
>>> ]
>>>
>>>
>>> --
>>>
>>> On Friday, May 18, 2018 at 6:09:33 PM UTC+2, Nitin Kumar wrote:

 Hi Ankit, 

 You must add the urls of catalog to the project urls, 
 locallibrary.urls.

 On Fri, May 18, 2018 at 8:32 PM,  wrote:

> Hi Doug,
>
> I am new to Django and i also started with MDN Locallibrary project. 
> Everything went fine until Django admin site but I stuck at "Creating 
> our home page 
> "
>  
> I have written the code in the suggested way only but get below error 
> when 
> try to run the project. I tried taking the urls.py code from github also 
> but it gives same issue. 
>
> Could you please help me here.
>
> Regards,
> Ankit 
>
>
> Page not found (404)
> Request Method: GET
> Request URL: http://127.0.0.1:8000/catalog/
>
> Using the URLconf defined in locallibrary.urls, Django tried these 
> URL patterns, in this order:
>
>1. admin/
>2. ^static\/(?P.*)$
>3. 
>
> The current path, catalog/, didn't match any of these.
>
> You're seeing this error because you have DEBUG = True in your Django 
> settings file. Change that to False, and Django will display a 
> standard 404 page.
>
>
>
> On Monday, January 22, 2018 at 5:46:31 AM UTC+2, Doug Nintzel wrote:
>>
>> Ok, makes sense. Thank you very much for the details Daniel.
>> Doug
>>
>> On Sunday, January 21, 2018 at 1:02:33 PM UTC-7, Daniel Hepper wrote:
>>>
>>> Yes, kind of. There are two kinds of redirects, temporary and 
>>> permanent redirects. By default Django's redirect() method returns a 
>>> temporary redirect. If you pass permanent=True, it returns a permanent 
>>> redirect.
>>>
>>> So here is what happened in your case:
>>>
>>> 1. You run the MDN tutorial project and point your browser to 
>>> http://127.0.0.1:8000/
>>> 2. The browser requests the path / from the server 127.0.0.1:8000 
>>> (the runserver running the MDN tutorial project) and receives a 
>>> permanent 
>>> redirect to /catalog/
>>> 3. Then you stop the MDN project and run your own project.
>>> 4. You then point your browser to http://127.0.0.1:8000
>>> 5. Your browser thinks "wait a minute, last time I accessed the path 
>>> / on the server 127.0.0.1:8000, it returned a permanent redirect to 
>>> /catalog/. I'll save my user some time and just go directly to 
>>> /catalog/".
>>>
>>> Now, if a URL returns a temporary redirect, the browser knows that 
>>> this redirect is, well, temp

Re: getting error while reloading the url"http://localhost:8000/polls/".The error is given below.Please tell my why i am seeing this error?

2018-05-18 Thread James Farris
What does your urls.py look like?

According to the error it doesn’t appear that polls/ is defined in your
urls.py file

On Fri, May 18, 2018 at 10:05 AM Avitab Ayan Sarmah 
wrote:

> Page not found (404)
> Request Method: GET
> Request URL: http://localhost:8000/polls/
>
> Using the URLconf defined in mysite.urls, Django tried these URL
> patterns, in this order:
>
>1. [name='index']
>2. / [name='detail']
>3. /results/ [name='results']
>4. /vote/ [name='vote']
>5. admin/
>
> The current path, polls/, didn't match any of these.
>
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a standard
> 404 page.
>
> --
> You received this message because you are subscribed to the Google 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/54b07f4e-663c-4ed0-a419-541d735148a1%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/CAE-E-_2Gms%3DtqeXpJ_FFJ1p6_i1ECAf15yGmw1PCJz%3DN4yZQYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: def get_queryset(self): ^ IndentationError: unindent does not match any outer indentation level

2018-05-18 Thread Avitab Ayan Sarmah
Thank you james i found the error and now another error i found please help 
me on this.You will see this as  another topic

On Friday, May 18, 2018 at 10:22:13 PM UTC+5:30, Avitab Ayan Sarmah wrote:
>
> Hi james,Please check my code clearly because i didn;t found any 
> indentation error and everything is same
>
> On Friday, May 18, 2018 at 10:09:35 PM UTC+5:30, James Farris wrote:
>>
>> The Indentation error is related to the spaces you have when you write 
>> your code. 
>>
>> Based on looking at what you copy/pasted
>> The indentation of your def get_queryset is different from your other 
>> def’s. 
>>
>> Python is very picky of how much or how little you indent your code for 
>> good reason. 
>>
>> Everything that is nested inside something else should be 4 spaces or a 
>> tab in. For example a def should be 4 spaces in from its class, a variable 
>> should be 4 spaces in from its def. 
>>
>> IndentationError: unindent does not match any outer indentation level
>>
>> On Fri, May 18, 2018 at 9:08 AM Avitab Ayan Sarmah  
>> wrote:
>>
>>> While going through the django project i committed an error while 
>>> executing "python manage.py runserver" inside my project directory.It is 
>>> showing error is in line 24 of views.py.Please comment what exact the error 
>>> is and how do i overcome this error.The exceptions and views.py is 
>>> mentioned below:
>>>
>>> Exceptions:
>>>
>>> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
>>> Performing system checks...
>>>
>>> Unhandled exception in thread started by >> check_errors..wrapper at 0x017BA5FB29D8>
>>> Traceback (most recent call last):
>>>   File "c:\python36\lib\site-packages\django\utils\autoreload.py", line 
>>> 225, in wrapper
>>> fn(*args, **kwargs)
>>>   File 
>>> "c:\python36\lib\site-packages\django\core\management\commands\runserver.py",
>>>  
>>> line 121, in inner_run
>>> self.check(display_num_errors=True)
>>>   File "c:\python36\lib\site-packages\django\core\management\base.py", 
>>> line 364, in check
>>> include_deployment_checks=include_deployment_checks,
>>>   File "c:\python36\lib\site-packages\django\core\management\base.py", 
>>> line 351, in _run_checks
>>> return checks.run_checks(**kwargs)
>>>   File "c:\python36\lib\site-packages\django\core\checks\registry.py", 
>>> line 73, in run_checks
>>> new_errors = check(app_configs=app_configs)
>>>   File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 
>>> 40, in check_url_namespaces_unique
>>> all_namespaces = _load_all_namespaces(resolver)
>>>   File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 
>>> 57, in _load_all_namespaces
>>> url_patterns = getattr(resolver, 'url_patterns', [])
>>>   File "c:\python36\lib\site-packages\django\utils\functional.py", line 
>>> 36, in __get__
>>> res = instance.__dict__[self.name] = self.func(instance)
>>>   File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 
>>> 536, in url_patterns
>>> patterns = getattr(self.urlconf_module, "urlpatterns", 
>>> self.urlconf_module)
>>>   File "c:\python36\lib\site-packages\django\utils\functional.py", line 
>>> 36, in __get__
>>> res = instance.__dict__[self.name] = self.func(instance)
>>>   File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 
>>> 529, in urlconf_module
>>> return import_module(self.urlconf_name)
>>>   File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\mysite\urls.py", line 5, in 
>>> path('', include('polls.urls')),
>>>   File "c:\python36\lib\site-packages\django\urls\conf.py", line 34, in 
>>> include
>>> urlconf_module = import_module(urlconf_module)
>>>   File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\polls\urls.py", line 3, in 
>>> from . import views
>>>   File "C:\Users\AVITABAYAN\mysite\polls\views.py", line 24
>>> def get_queryset(self):
>>>   ^
>>> IndentationError: unindent does not match any outer indentation level
>>>
>>>
>>> views.py:
>>>
>>> from django.shortcuts import get_object_or_404, render
>>> from django.http import HttpResponseRedirect
>>> from django.urls import reverse
>>> from django.vie

getting error while reloading the url"http://localhost:8000/polls/".The error is given below.Please tell my why i am seeing this error?

2018-05-18 Thread Avitab Ayan Sarmah
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/polls/

Using the URLconf defined in mysite.urls, Django tried these URL patterns, 
in this order:

   1. [name='index']
   2. / [name='detail']
   3. /results/ [name='results']
   4. /vote/ [name='vote']
   5. admin/

The current path, polls/, didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page.

-- 
You received this message because you are subscribed to the Google 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/54b07f4e-663c-4ed0-a419-541d735148a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: def get_queryset(self): ^ IndentationError: unindent does not match any outer indentation level

2018-05-18 Thread Avitab Ayan Sarmah
Hi james,Please check my code clearly because i didn;t found any 
indentation error and everything is same

On Friday, May 18, 2018 at 10:09:35 PM UTC+5:30, James Farris wrote:
>
> The Indentation error is related to the spaces you have when you write 
> your code. 
>
> Based on looking at what you copy/pasted
> The indentation of your def get_queryset is different from your other 
> def’s. 
>
> Python is very picky of how much or how little you indent your code for 
> good reason. 
>
> Everything that is nested inside something else should be 4 spaces or a 
> tab in. For example a def should be 4 spaces in from its class, a variable 
> should be 4 spaces in from its def. 
>
> IndentationError: unindent does not match any outer indentation level
>
> On Fri, May 18, 2018 at 9:08 AM Avitab Ayan Sarmah  > wrote:
>
>> While going through the django project i committed an error while 
>> executing "python manage.py runserver" inside my project directory.It is 
>> showing error is in line 24 of views.py.Please comment what exact the error 
>> is and how do i overcome this error.The exceptions and views.py is 
>> mentioned below:
>>
>> Exceptions:
>>
>> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
>> Performing system checks...
>>
>> Unhandled exception in thread started by > check_errors..wrapper at 0x017BA5FB29D8>
>> Traceback (most recent call last):
>>   File "c:\python36\lib\site-packages\django\utils\autoreload.py", line 
>> 225, in wrapper
>> fn(*args, **kwargs)
>>   File 
>> "c:\python36\lib\site-packages\django\core\management\commands\runserver.py",
>>  
>> line 121, in inner_run
>> self.check(display_num_errors=True)
>>   File "c:\python36\lib\site-packages\django\core\management\base.py", 
>> line 364, in check
>> include_deployment_checks=include_deployment_checks,
>>   File "c:\python36\lib\site-packages\django\core\management\base.py", 
>> line 351, in _run_checks
>> return checks.run_checks(**kwargs)
>>   File "c:\python36\lib\site-packages\django\core\checks\registry.py", 
>> line 73, in run_checks
>> new_errors = check(app_configs=app_configs)
>>   File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 
>> 40, in check_url_namespaces_unique
>> all_namespaces = _load_all_namespaces(resolver)
>>   File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 
>> 57, in _load_all_namespaces
>> url_patterns = getattr(resolver, 'url_patterns', [])
>>   File "c:\python36\lib\site-packages\django\utils\functional.py", line 
>> 36, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 
>> 536, in url_patterns
>> patterns = getattr(self.urlconf_module, "urlpatterns", 
>> self.urlconf_module)
>>   File "c:\python36\lib\site-packages\django\utils\functional.py", line 
>> 36, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 
>> 529, in urlconf_module
>> return import_module(self.urlconf_name)
>>   File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\mysite\urls.py", line 5, in 
>> path('', include('polls.urls')),
>>   File "c:\python36\lib\site-packages\django\urls\conf.py", line 34, in 
>> include
>> urlconf_module = import_module(urlconf_module)
>>   File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\polls\urls.py", line 3, in 
>> from . import views
>>   File "C:\Users\AVITABAYAN\mysite\polls\views.py", line 24
>> def get_queryset(self):
>>   ^
>> IndentationError: unindent does not match any outer indentation level
>>
>>
>> views.py:
>>
>> from django.shortcuts import get_object_or_404, render
>> from django.http import HttpResponseRedirect
>> from django.urls import reverse
>> from django.views import generic
>> from django.utils import timezone
>>
>> from . models import Choice, Question
>>
>>
>> class IndexView(generic.ListView):
>> template_name = 'polls/index.html'
>> context_object_name = 'latest_question_list'
>>
>> def get_queryset(self):
>> """Return the last five published questions(not including those set

Re: ImportError : cannot import name include

2018-05-18 Thread James Farris
If you are not using a virtual env, did you install pip3? If so, since you
are using puthon3 -V to get that python version, try running
$ pip3 install django
And see if you get a different result

I think what is happening is when you run pip install it’s referencing
another python version, not python 3.

At least that is what I experienced back before I used virtual envs

On Fri, May 18, 2018 at 9:01 AM Journal-Immo 
wrote:

> Thank you for all your answers
>
> I know my problem with version
>
> So for me it's very strange...
>
> python3 -V
>
> Python 3.5.3
>
> pip install Django==2.0.5
>
> Collecting Django==2.0.5...
>
> Could nt find a version... 1.2.1, 1.2.2 etc and the last one 1.11.13
>
> No matching distribution found fot Django==2.0.5
>
> Do you think Virtual Envirenment will solve my problem ?
>
> Many thank again
>
> Le 18/05/2018 à 16:38, Daniel Hepper a écrit :
>
> Your problem is right here:
>
> > django-admin --version 1.11.13
> You are using Django 1.11. The documentation you are using refers to a
> newer version of Django, version 2.0.
>
> Use the right documentation for your version of Django:
>
> https://docs.djangoproject.com/en/1.11/
>
> You are seeing this specific error because in Django 2.0, you can write
> "from django.urls import include", while in Django 1.11, you have to write
> "from django.conf.urls import include".
>
> Note that using Debian packages, you won't get the latest version of
> Django (or any other Python packages). You might want to consider
> installing the latest version with pip.
>
>
> https://docs.djangoproject.com/en/2.0/topics/install/#installing-official-release
>
> Hope that helps,
> Daniel
>
> On Fri, May 18, 2018 at 4:20 PM, Journal-Immo 
> wrote:
>
>> Thank
>>
>> But (I use debian 9)
>>
>> Apt-get update
>>
>> Apt-get install python python3 python-django
>>
>> django-admin --version 1.11.13
>>
>> Where is the problem ?
>>
>> Le 17/05/2018 à 21:01, Fidel Leon a écrit :
>>
>> You are using the wrong combination of Django and tutorial: “include” is
>> available in Django 2 and up, but you’re using Django 1.11.
>>
>> Fidel Leon
>> fi...@flm.cat
>> Phone: +34 622 26 44 92 
>> GPG: 2585 30C2 E3C7 7151 0864  946B 7423 F94B 5753 5FC7
>>
>> El 17 de mayo de 2018 a las 20:56:56, Tristan Demot (
>> cont...@journal-immo.com) escribió:
>>
>> Hello,
>>
>>  I use docs.djangoproject.co/en/2.0
>>  Python 2 7 13
>> Gjango 1.11.13
>>
>> Creating the Polls app OK
>> Write your first view OK
>> But python manage runserver don't work
>> With : python -Wall manage.py test
>> ImportError : cannot import name include
>> If you want to see something, ask me
>> Many 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 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/1fe7df04-dc85-4a3d-940e-4dde7de31477%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/CAHXg%3DN090U8JCFfdvZJWH1qSoWQgp2mQH6z2RfCzj3384epQKQ%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/7e9e643b-6e7e-681c-eed2-dc9ab9be94e6%40journal-immo.com
>> .
>>
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Grou

Re: New project in virtual env referencing another project's default/redirected path

2018-05-18 Thread James Farris
This is where an IDE like PyCharm comes in handy. It will tell you right
away that it doesn’t recognize something and will suggest importing that
package. It does a pretty good job with its suggestions.

On Fri, May 18, 2018 at 9:35 AM Nitin Kumar  wrote:

> you have to import include.
>
> from django.urls import path, include
>
> On Fri, May 18, 2018 at 9:45 PM,  wrote:
>
>> Hi Nitin,
>>
>> Thanks for quick response.
>>
>> Please find the below code from locallibrary/urls.py
>>
>> Could you please let me know, where shall i add the url.
>>
>>
>>
>> 
>> from django.contrib import admin
>> from django.urls import path
>>
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> ]
>>
>>
>> from django.urls import path
>> from django.contrib import admin
>>
>> # Use include() to add URLS from the catalog application and
>> authentication system
>> from django.urls import include
>>
>>
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> ]
>>
>>
>> urlpatterns += [
>> path('catalog/', include('catalog.urls')),
>> ]
>>
>>
>> # Use static() to add url mapping to serve static files during
>> development (only)
>> from django.conf import settings
>> from django.conf.urls.static import static
>>
>>
>> urlpatterns+= static(settings.STATIC_URL,
>> document_root=settings.STATIC_ROOT)
>>
>>
>> #Add URL maps to redirect the base URL to our application
>> from django.views.generic import RedirectView
>> urlpatterns += [
>> path('', RedirectView.as_view(url='/catalog/', permanent=True)),
>> ]
>>
>>
>> --
>>
>> On Friday, May 18, 2018 at 6:09:33 PM UTC+2, Nitin Kumar wrote:
>>>
>>> Hi Ankit,
>>>
>>> You must add the urls of catalog to the project urls, locallibrary.urls.
>>>
>>> On Fri, May 18, 2018 at 8:32 PM,  wrote:
>>>
 Hi Doug,

 I am new to Django and i also started with MDN Locallibrary project.
 Everything went fine until Django admin site but I stuck at "Creating
 our home page
 "
 I have written the code in the suggested way only but get below error when
 try to run the project. I tried taking the urls.py code from github also
 but it gives same issue.

 Could you please help me here.

 Regards,
 Ankit


 Page not found (404)
 Request Method: GET
 Request URL: http://127.0.0.1:8000/catalog/

 Using the URLconf defined in locallibrary.urls, Django tried these URL
 patterns, in this order:

1. admin/
2. ^static\/(?P.*)$
3.

 The current path, catalog/, didn't match any of these.

 You're seeing this error because you have DEBUG = True in your Django
 settings file. Change that to False, and Django will display a
 standard 404 page.



 On Monday, January 22, 2018 at 5:46:31 AM UTC+2, Doug Nintzel wrote:
>
> Ok, makes sense. Thank you very much for the details Daniel.
> Doug
>
> On Sunday, January 21, 2018 at 1:02:33 PM UTC-7, Daniel Hepper wrote:
>>
>> Yes, kind of. There are two kinds of redirects, temporary and
>> permanent redirects. By default Django's redirect() method returns a
>> temporary redirect. If you pass permanent=True, it returns a permanent
>> redirect.
>>
>> So here is what happened in your case:
>>
>> 1. You run the MDN tutorial project and point your browser to
>> http://127.0.0.1:8000/
>> 2. The browser requests the path / from the server 127.0.0.1:8000
>> (the runserver running the MDN tutorial project) and receives a permanent
>> redirect to /catalog/
>> 3. Then you stop the MDN project and run your own project.
>> 4. You then point your browser to http://127.0.0.1:8000
>> 5. Your browser thinks "wait a minute, last time I accessed the path
>> / on the server 127.0.0.1:8000, it returned a permanent redirect to
>> /catalog/. I'll save my user some time and just go directly to 
>> /catalog/".
>>
>> Now, if a URL returns a temporary redirect, the browser knows that
>> this redirect is, well, temporary, so it might point to a different
>> location the next time or there might be no redirect at all. Therefore, 
>> it
>> must load the original URL.
>>
>> In the example of the tutorial, a permanent redirect should not be
>> used, not only because it can lead to the problem you encountered.
>>
>> Imagine you use this software for your local library at

Re: New project in virtual env referencing another project's default/redirected path

2018-05-18 Thread ankitklinkedin
Hi Nitin,

Thanks for response. 

I think, include has been imported already. Please check below. Kindly see 
if this not correct. (Picking these lines from earlier code). 


# Use include() to add URLS from the catalog application and authentication 
system
from django.urls import include

Regards,
Ankit 

On Friday, May 18, 2018 at 6:35:22 PM UTC+2, Nitin Kumar wrote:
>
> you have to import include.
>
> from django.urls import path, include
>
> On Fri, May 18, 2018 at 9:45 PM, > 
> wrote:
>
>> Hi Nitin,
>>
>> Thanks for quick response.
>>
>> Please find the below code from locallibrary/urls.py
>>
>> Could you please let me know, where shall i add the url.
>>
>>
>>
>> 
>> from django.contrib import admin
>> from django.urls import path
>>
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> ]
>>
>>
>> from django.urls import path
>> from django.contrib import admin
>>
>> # Use include() to add URLS from the catalog application and 
>> authentication system
>> from django.urls import include
>>
>>
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> ]
>>
>>
>> urlpatterns += [
>> path('catalog/', include('catalog.urls')),
>> ]
>>
>>
>> # Use static() to add url mapping to serve static files during 
>> development (only)
>> from django.conf import settings
>> from django.conf.urls.static import static
>>
>>
>> urlpatterns+= static(settings.STATIC_URL, 
>> document_root=settings.STATIC_ROOT)
>>
>>
>> #Add URL maps to redirect the base URL to our application
>> from django.views.generic import RedirectView
>> urlpatterns += [
>> path('', RedirectView.as_view(url='/catalog/', permanent=True)),
>> ]
>>
>>
>> --
>>
>> On Friday, May 18, 2018 at 6:09:33 PM UTC+2, Nitin Kumar wrote:
>>>
>>> Hi Ankit, 
>>>
>>> You must add the urls of catalog to the project urls, locallibrary.urls.
>>>
>>> On Fri, May 18, 2018 at 8:32 PM,  wrote:
>>>
 Hi Doug,

 I am new to Django and i also started with MDN Locallibrary project. 
 Everything went fine until Django admin site but I stuck at "Creating 
 our home page 
 "
  
 I have written the code in the suggested way only but get below error when 
 try to run the project. I tried taking the urls.py code from github also 
 but it gives same issue. 

 Could you please help me here.

 Regards,
 Ankit 


 Page not found (404)
 Request Method: GET
 Request URL: http://127.0.0.1:8000/catalog/

 Using the URLconf defined in locallibrary.urls, Django tried these URL 
 patterns, in this order:

1. admin/
2. ^static\/(?P.*)$
3. 

 The current path, catalog/, didn't match any of these.

 You're seeing this error because you have DEBUG = True in your Django 
 settings file. Change that to False, and Django will display a 
 standard 404 page.



 On Monday, January 22, 2018 at 5:46:31 AM UTC+2, Doug Nintzel wrote:
>
> Ok, makes sense. Thank you very much for the details Daniel.
> Doug
>
> On Sunday, January 21, 2018 at 1:02:33 PM UTC-7, Daniel Hepper wrote:
>>
>> Yes, kind of. There are two kinds of redirects, temporary and 
>> permanent redirects. By default Django's redirect() method returns a 
>> temporary redirect. If you pass permanent=True, it returns a permanent 
>> redirect.
>>
>> So here is what happened in your case:
>>
>> 1. You run the MDN tutorial project and point your browser to 
>> http://127.0.0.1:8000/
>> 2. The browser requests the path / from the server 127.0.0.1:8000 
>> (the runserver running the MDN tutorial project) and receives a 
>> permanent 
>> redirect to /catalog/
>> 3. Then you stop the MDN project and run your own project.
>> 4. You then point your browser to http://127.0.0.1:8000
>> 5. Your browser thinks "wait a minute, last time I accessed the path 
>> / on the server 127.0.0.1:8000, it returned a permanent redirect to 
>> /catalog/. I'll save my user some time and just go directly to 
>> /catalog/".
>>
>> Now, if a URL returns a temporary redirect, the browser knows that 
>> this redirect is, well, temporary, so it might point to a different 
>> location the next time or there might be no redirect at all. Therefore, 
>> it 
>> must load the original URL.
>>
>> In the example of the tutorial, a permanent redirect

Re: def get_queryset(self): ^ IndentationError: unindent does not match any outer indentation level

2018-05-18 Thread James Farris
The Indentation error is related to the spaces you have when you write your
code.

Based on looking at what you copy/pasted
The indentation of your def get_queryset is different from your other
def’s.

Python is very picky of how much or how little you indent your code for
good reason.

Everything that is nested inside something else should be 4 spaces or a tab
in. For example a def should be 4 spaces in from its class, a variable
should be 4 spaces in from its def.

IndentationError: unindent does not match any outer indentation level

On Fri, May 18, 2018 at 9:08 AM Avitab Ayan Sarmah 
wrote:

> While going through the django project i committed an error while
> executing "python manage.py runserver" inside my project directory.It is
> showing error is in line 24 of views.py.Please comment what exact the error
> is and how do i overcome this error.The exceptions and views.py is
> mentioned below:
>
> Exceptions:
>
> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
> Performing system checks...
>
> Unhandled exception in thread started by  check_errors..wrapper at 0x017BA5FB29D8>
> Traceback (most recent call last):
>   File "c:\python36\lib\site-packages\django\utils\autoreload.py", line
> 225, in wrapper
> fn(*args, **kwargs)
>   File
> "c:\python36\lib\site-packages\django\core\management\commands\runserver.py",
> line 121, in inner_run
> self.check(display_num_errors=True)
>   File "c:\python36\lib\site-packages\django\core\management\base.py",
> line 364, in check
> include_deployment_checks=include_deployment_checks,
>   File "c:\python36\lib\site-packages\django\core\management\base.py",
> line 351, in _run_checks
> return checks.run_checks(**kwargs)
>   File "c:\python36\lib\site-packages\django\core\checks\registry.py",
> line 73, in run_checks
> new_errors = check(app_configs=app_configs)
>   File "c:\python36\lib\site-packages\django\core\checks\urls.py", line
> 40, in check_url_namespaces_unique
> all_namespaces = _load_all_namespaces(resolver)
>   File "c:\python36\lib\site-packages\django\core\checks\urls.py", line
> 57, in _load_all_namespaces
> url_patterns = getattr(resolver, 'url_patterns', [])
>   File "c:\python36\lib\site-packages\django\utils\functional.py", line
> 36, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 536,
> in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
>   File "c:\python36\lib\site-packages\django\utils\functional.py", line
> 36, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 529,
> in urlconf_module
> return import_module(self.urlconf_name)
>   File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\mysite\urls.py", line 5, in 
> path('', include('polls.urls')),
>   File "c:\python36\lib\site-packages\django\urls\conf.py", line 34, in
> include
> urlconf_module = import_module(urlconf_module)
>   File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\polls\urls.py", line 3, in 
> from . import views
>   File "C:\Users\AVITABAYAN\mysite\polls\views.py", line 24
> def get_queryset(self):
>   ^
> IndentationError: unindent does not match any outer indentation level
>
>
> views.py:
>
> from django.shortcuts import get_object_or_404, render
> from django.http import HttpResponseRedirect
> from django.urls import reverse
> from django.views import generic
> from django.utils import timezone
>
> from . models import Choice, Question
>
>
> class IndexView(generic.ListView):
> template_name = 'polls/index.html'
> context_object_name = 'latest_question_list'
>
> def get_queryset(self):
> """Return the last five published questions(not including those settings
> to be
> published in the future)."""
> return
> Question.objects.filter(pub_date__lte=timezone.now()).order_by('-pub_date')[:5]
>
> class DetailView(generic.DetailView):
> model = Question
> template_name = 'polls/detail.html'
>
> def get_queryset(self):
> """Excludes any questions that aren't published yet.
> """
>

Re: New project in virtual env referencing another project's default/redirected path

2018-05-18 Thread Nitin Kumar
you have to import include.

from django.urls import path, include

On Fri, May 18, 2018 at 9:45 PM,  wrote:

> Hi Nitin,
>
> Thanks for quick response.
>
> Please find the below code from locallibrary/urls.py
>
> Could you please let me know, where shall i add the url.
>
>
> 
> 
> 
> 
> from django.contrib import admin
> from django.urls import path
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> ]
>
>
> from django.urls import path
> from django.contrib import admin
>
> # Use include() to add URLS from the catalog application and
> authentication system
> from django.urls import include
>
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> ]
>
>
> urlpatterns += [
> path('catalog/', include('catalog.urls')),
> ]
>
>
> # Use static() to add url mapping to serve static files during development
> (only)
> from django.conf import settings
> from django.conf.urls.static import static
>
>
> urlpatterns+= static(settings.STATIC_URL, document_root=settings.STATIC_
> ROOT)
>
>
> #Add URL maps to redirect the base URL to our application
> from django.views.generic import RedirectView
> urlpatterns += [
> path('', RedirectView.as_view(url='/catalog/', permanent=True)),
> ]
>
> 
> 
> 
> --
>
> On Friday, May 18, 2018 at 6:09:33 PM UTC+2, Nitin Kumar wrote:
>>
>> Hi Ankit,
>>
>> You must add the urls of catalog to the project urls, locallibrary.urls.
>>
>> On Fri, May 18, 2018 at 8:32 PM,  wrote:
>>
>>> Hi Doug,
>>>
>>> I am new to Django and i also started with MDN Locallibrary project.
>>> Everything went fine until Django admin site but I stuck at "Creating
>>> our home page
>>> "
>>> I have written the code in the suggested way only but get below error when
>>> try to run the project. I tried taking the urls.py code from github also
>>> but it gives same issue.
>>>
>>> Could you please help me here.
>>>
>>> Regards,
>>> Ankit
>>>
>>>
>>> Page not found (404)
>>> Request Method: GET
>>> Request URL: http://127.0.0.1:8000/catalog/
>>>
>>> Using the URLconf defined in locallibrary.urls, Django tried these URL
>>> patterns, in this order:
>>>
>>>1. admin/
>>>2. ^static\/(?P.*)$
>>>3.
>>>
>>> The current path, catalog/, didn't match any of these.
>>>
>>> You're seeing this error because you have DEBUG = True in your Django
>>> settings file. Change that to False, and Django will display a standard
>>> 404 page.
>>>
>>>
>>>
>>> On Monday, January 22, 2018 at 5:46:31 AM UTC+2, Doug Nintzel wrote:

 Ok, makes sense. Thank you very much for the details Daniel.
 Doug

 On Sunday, January 21, 2018 at 1:02:33 PM UTC-7, Daniel Hepper wrote:
>
> Yes, kind of. There are two kinds of redirects, temporary and
> permanent redirects. By default Django's redirect() method returns a
> temporary redirect. If you pass permanent=True, it returns a permanent
> redirect.
>
> So here is what happened in your case:
>
> 1. You run the MDN tutorial project and point your browser to
> http://127.0.0.1:8000/
> 2. The browser requests the path / from the server 127.0.0.1:8000
> (the runserver running the MDN tutorial project) and receives a permanent
> redirect to /catalog/
> 3. Then you stop the MDN project and run your own project.
> 4. You then point your browser to http://127.0.0.1:8000
> 5. Your browser thinks "wait a minute, last time I accessed the path /
> on the server 127.0.0.1:8000, it returned a permanent redirect to
> /catalog/. I'll save my user some time and just go directly to /catalog/".
>
> Now, if a URL returns a temporary redirect, the browser knows that
> this redirect is, well, temporary, so it might point to a different
> location the next time or there might be no redirect at all. Therefore, it
> must load the original URL.
>
> In the example of the tutorial, a permanent redirect should not be
> used, not only because it can lead to the problem you encountered.
>
> Imagine you use this software for your local library at
> http://smalltownlibrary.com/. After a while, you want to add another
> feature, e.g. a book shop under /shop/ where visitor can buy used books.
> You then want to add a homepage at / where users can select whether they
> want to access catalogue or the shop. It works fine for new users, but
> everyone who accessed the site http://smalltownlibrary.com/ before is
> not able to 

Re: New project in virtual env referencing another project's default/redirected path

2018-05-18 Thread ankitklinkedin
Hi Nitin,

Thanks for quick response.

Please find the below code from locallibrary/urls.py

Could you please let me know, where shall i add the url.



from django.contrib import admin
from django.urls import path

urlpatterns = [
path('admin/', admin.site.urls),
]


from django.urls import path
from django.contrib import admin

# Use include() to add URLS from the catalog application and authentication 
system
from django.urls import include


urlpatterns = [
path('admin/', admin.site.urls),
]


urlpatterns += [
path('catalog/', include('catalog.urls')),
]


# Use static() to add url mapping to serve static files during development 
(only)
from django.conf import settings
from django.conf.urls.static import static


urlpatterns+= static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)


#Add URL maps to redirect the base URL to our application
from django.views.generic import RedirectView
urlpatterns += [
path('', RedirectView.as_view(url='/catalog/', permanent=True)),
]

--

On Friday, May 18, 2018 at 6:09:33 PM UTC+2, Nitin Kumar wrote:
>
> Hi Ankit, 
>
> You must add the urls of catalog to the project urls, locallibrary.urls.
>
> On Fri, May 18, 2018 at 8:32 PM, > 
> wrote:
>
>> Hi Doug,
>>
>> I am new to Django and i also started with MDN Locallibrary project. 
>> Everything went fine until Django admin site but I stuck at "Creating 
>> our home page 
>> "
>>  
>> I have written the code in the suggested way only but get below error when 
>> try to run the project. I tried taking the urls.py code from github also 
>> but it gives same issue. 
>>
>> Could you please help me here.
>>
>> Regards,
>> Ankit 
>>
>>
>> Page not found (404)
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/catalog/
>>
>> Using the URLconf defined in locallibrary.urls, Django tried these URL 
>> patterns, in this order:
>>
>>1. admin/
>>2. ^static\/(?P.*)$
>>3. 
>>
>> The current path, catalog/, didn't match any of these.
>>
>> You're seeing this error because you have DEBUG = True in your Django 
>> settings file. Change that to False, and Django will display a standard 
>> 404 page.
>>
>>
>>
>> On Monday, January 22, 2018 at 5:46:31 AM UTC+2, Doug Nintzel wrote:
>>>
>>> Ok, makes sense. Thank you very much for the details Daniel.
>>> Doug
>>>
>>> On Sunday, January 21, 2018 at 1:02:33 PM UTC-7, Daniel Hepper wrote:

 Yes, kind of. There are two kinds of redirects, temporary and permanent 
 redirects. By default Django's redirect() method returns a temporary 
 redirect. If you pass permanent=True, it returns a permanent redirect.

 So here is what happened in your case:

 1. You run the MDN tutorial project and point your browser to 
 http://127.0.0.1:8000/
 2. The browser requests the path / from the server 127.0.0.1:8000 (the 
 runserver running the MDN tutorial project) and receives a permanent 
 redirect to /catalog/
 3. Then you stop the MDN project and run your own project.
 4. You then point your browser to http://127.0.0.1:8000
 5. Your browser thinks "wait a minute, last time I accessed the path / 
 on the server 127.0.0.1:8000, it returned a permanent redirect to 
 /catalog/. I'll save my user some time and just go directly to /catalog/".

 Now, if a URL returns a temporary redirect, the browser knows that this 
 redirect is, well, temporary, so it might point to a different location 
 the 
 next time or there might be no redirect at all. Therefore, it must load 
 the 
 original URL.

 In the example of the tutorial, a permanent redirect should not be 
 used, not only because it can lead to the problem you encountered.

 Imagine you use this software for your local library at 
 http://smalltownlibrary.com/. After a while, you want to add another 
 feature, e.g. a book shop under /shop/ where visitor can buy used books. 
 You then want to add a homepage at / where users can select whether they 
 want to access catalogue or the shop. It works fine for new users, but 
 everyone who accessed the site http://smalltownlibrary.com/ before is 
 not able to access the new homepage because their browser has cached the 
 permanent redirect to the catalog.

 Permanent redirects definitely have their place, e.g. if you moved your 
 website to a new URL and want to tell the search engines that 

Re: New project in virtual env referencing another project's default/redirected path

2018-05-18 Thread Nitin Kumar
Hi Ankit,

You must add the urls of catalog to the project urls, locallibrary.urls.

On Fri, May 18, 2018 at 8:32 PM,  wrote:

> Hi Doug,
>
> I am new to Django and i also started with MDN Locallibrary project.
> Everything went fine until Django admin site but I stuck at "Creating our
> home page
> "
> I have written the code in the suggested way only but get below error when
> try to run the project. I tried taking the urls.py code from github also
> but it gives same issue.
>
> Could you please help me here.
>
> Regards,
> Ankit
>
>
> Page not found (404)
> Request Method: GET
> Request URL: http://127.0.0.1:8000/catalog/
>
> Using the URLconf defined in locallibrary.urls, Django tried these URL
> patterns, in this order:
>
>1. admin/
>2. ^static\/(?P.*)$
>3.
>
> The current path, catalog/, didn't match any of these.
>
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a standard
> 404 page.
>
>
>
> On Monday, January 22, 2018 at 5:46:31 AM UTC+2, Doug Nintzel wrote:
>>
>> Ok, makes sense. Thank you very much for the details Daniel.
>> Doug
>>
>> On Sunday, January 21, 2018 at 1:02:33 PM UTC-7, Daniel Hepper wrote:
>>>
>>> Yes, kind of. There are two kinds of redirects, temporary and permanent
>>> redirects. By default Django's redirect() method returns a temporary
>>> redirect. If you pass permanent=True, it returns a permanent redirect.
>>>
>>> So here is what happened in your case:
>>>
>>> 1. You run the MDN tutorial project and point your browser to
>>> http://127.0.0.1:8000/
>>> 2. The browser requests the path / from the server 127.0.0.1:8000 (the
>>> runserver running the MDN tutorial project) and receives a permanent
>>> redirect to /catalog/
>>> 3. Then you stop the MDN project and run your own project.
>>> 4. You then point your browser to http://127.0.0.1:8000
>>> 5. Your browser thinks "wait a minute, last time I accessed the path /
>>> on the server 127.0.0.1:8000, it returned a permanent redirect to
>>> /catalog/. I'll save my user some time and just go directly to /catalog/".
>>>
>>> Now, if a URL returns a temporary redirect, the browser knows that this
>>> redirect is, well, temporary, so it might point to a different location the
>>> next time or there might be no redirect at all. Therefore, it must load the
>>> original URL.
>>>
>>> In the example of the tutorial, a permanent redirect should not be used,
>>> not only because it can lead to the problem you encountered.
>>>
>>> Imagine you use this software for your local library at
>>> http://smalltownlibrary.com/. After a while, you want to add another
>>> feature, e.g. a book shop under /shop/ where visitor can buy used books.
>>> You then want to add a homepage at / where users can select whether they
>>> want to access catalogue or the shop. It works fine for new users, but
>>> everyone who accessed the site http://smalltownlibrary.com/ before is
>>> not able to access the new homepage because their browser has cached the
>>> permanent redirect to the catalog.
>>>
>>> Permanent redirects definitely have their place, e.g. if you moved your
>>> website to a new URL and want to tell the search engines that they should
>>> only look at the new URL. But you have to be aware that they are indeed
>>> permanent.
>>>
>>> Hope that clarifies it a bit.
>>>
>>> Daniel
>>>
>>> On Sunday, January 21, 2018 at 7:26:39 PM UTC+1, Doug Nintzel wrote:

 That got it Daniel...thanks for the quick help. Was it
 " permanent=True" in particular that was the problem?
 Thanks again,
 Doug

 On Sunday, January 21, 2018 at 10:29:33 AM UTC-7, Daniel Hepper wrote:
>
> I realized that the Mozilla tutorial is a wiki, so I took the liberty
> to remove the "permant=True" from the redirect.
>
> On Sun, Jan 21, 2018 at 6:23 PM, Daniel Hepper 
> wrote:
>
>> It's not the new project referencing the old project, it is actually
>> your browser caching the redirect from http://127.0.0.1:8000/ to
>> http://127.0.0.1:8000/catalog/.
>> Because it is a permanent redirect, your browser won't access
>> http://127.0.0.1:8000/, it will go http://127.0.0.1:8000/catalog/.
>>
>> You can usually get rid of this redirect by clearing your browser
>> cache. How exactly that is done depends on the browser you are using.
>>
>> This also teaches an important lesson about permanent redirects. Only
>> use them when you are absolutely sure that you (and more importantly your
>> users) will never again want to access the old URL.
>>
>> Hope that helps,
>> Daniel
>>
>>
>>
>> On Sun, Jan 21, 2018 at 6:06 PM, Doug Nintzel 
>> wrote:
>>
>>> Hello,
>>>
>>> I am new to Django and followed this Mozilla Django Tutorial
>>> 

def get_queryset(self): ^ IndentationError: unindent does not match any outer indentation level

2018-05-18 Thread Avitab Ayan Sarmah
While going through the django project i committed an error while executing 
"python manage.py runserver" inside my project directory.It is showing 
error is in line 24 of views.py.Please comment what exact the error is and 
how do i overcome this error.The exceptions and views.py is mentioned below:

Exceptions:

PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
Performing system checks...

Unhandled exception in thread started by .wrapper at 0x017BA5FB29D8>
Traceback (most recent call last):
  File "c:\python36\lib\site-packages\django\utils\autoreload.py", line 
225, in wrapper
fn(*args, **kwargs)
  File 
"c:\python36\lib\site-packages\django\core\management\commands\runserver.py", 
line 121, in inner_run
self.check(display_num_errors=True)
  File "c:\python36\lib\site-packages\django\core\management\base.py", line 
364, in check
include_deployment_checks=include_deployment_checks,
  File "c:\python36\lib\site-packages\django\core\management\base.py", line 
351, in _run_checks
return checks.run_checks(**kwargs)
  File "c:\python36\lib\site-packages\django\core\checks\registry.py", line 
73, in run_checks
new_errors = check(app_configs=app_configs)
  File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 40, 
in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
  File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 57, 
in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
  File "c:\python36\lib\site-packages\django\utils\functional.py", line 36, 
in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 536, 
in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
  File "c:\python36\lib\site-packages\django\utils\functional.py", line 36, 
in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 529, 
in urlconf_module
return import_module(self.urlconf_name)
  File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\mysite\urls.py", line 5, in 
path('', include('polls.urls')),
  File "c:\python36\lib\site-packages\django\urls\conf.py", line 34, in 
include
urlconf_module = import_module(urlconf_module)
  File "c:\python36\lib\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 "C:\Users\AVITABAYAN\mysite\polls\urls.py", line 3, in 
from . import views
  File "C:\Users\AVITABAYAN\mysite\polls\views.py", line 24
def get_queryset(self):
  ^
IndentationError: unindent does not match any outer indentation level


views.py:

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.views import generic
from django.utils import timezone

from . models import Choice, Question


class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_question_list'

def get_queryset(self):
"""Return the last five published questions(not including those settings
to be
published in the future)."""
return 
Question.objects.filter(pub_date__lte=timezone.now()).order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
model = Question
template_name = 'polls/detail.html'

def get_queryset(self):
"""Excludes any questions that aren't published yet.
"""
return Question.objects.filter(pub_date__lte=timezone.now())


class ResultsView(generic.DetailView):
model = Question
template_name = 'polls/results.html'


def vote(request, question_id):
question = get_object_or_404(Question, pk=question_id)
try:
selected_choice = question.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
#Redisplay the question voting form.
return render(request, 'polls/detail.html', {
'question': question,
'error_message': "you didn't select a choice.",
})
else:
selected_choice.votes +=1
selected_choice.save()
#...
#...
#...
return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and s

Re: ImportError : cannot import name include

2018-05-18 Thread Journal-Immo

Thank you for all your answers

I know my problem with version

So for me it's very strange...

python3 -V

Python 3.5.3

pip install Django==2.0.5

Collecting Django==2.0.5...

Could nt find a version... 1.2.1, 1.2.2 etc and the last one 1.11.13

No matching distribution found fot Django==2.0.5

Do you think Virtual Envirenment will solve my problem ?

Many thank again


Le 18/05/2018 à 16:38, Daniel Hepper a écrit :


Your problem is right here:

> django-admin --version 1.11.13

You are using Django 1.11. The documentation you are using refers to a 
newer version of Django, version 2.0.


Use the right documentation for your version of Django:

https://docs.djangoproject.com/en/1.11/

You are seeing this specific error because in Django 2.0, you can 
write "from django.urls import include", while in Django 1.11, you 
have to write "from django.conf.urls import include".


Note that using Debian packages, you won't get the latest version of 
Django (or any other Python packages). You might want to consider 
installing the latest version with pip.


https://docs.djangoproject.com/en/2.0/topics/install/#installing-official-release

Hope that helps,
Daniel

On Fri, May 18, 2018 at 4:20 PM, Journal-Immo 
mailto:cont...@journal-immo.com>> wrote:


Thank

But (I use debian 9)

Apt-get update

Apt-get install python python3 python-django

django-admin --version 1.11.13

Where is the problem ?


Le 17/05/2018 à 21:01, Fidel Leon a écrit :

You are using the wrong combination of Django and tutorial:
“include” is available in Django 2 and up, but you’re using
Django 1.11.

Fidel Leon
fi...@flm.cat 
Phone: +34 622 26 44 92 
GPG: 2585 30C2 E3C7 7151 0864  946B 7423 F94B 5753 5FC7

El 17 de mayo de 2018 a las 20:56:56, Tristan Demot
(cont...@journal-immo.com )
escribió:


Hello,

 I use docs.djangoproject.co/en/2.0

 Python 2 7 13
Gjango 1.11.13


Creating the Polls app OK


Write your first view OK

But python manage runserver don't work
With : python -Wall manage.py test
ImportError : cannot import name include
If you want to see something, ask me
Many 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 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/1fe7df04-dc85-4a3d-940e-4dde7de31477%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/CAHXg%3DN090U8JCFfdvZJWH1qSoWQgp2mQH6z2RfCzj3384epQKQ%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/7e9e643b-6e7e-681c-eed2-dc9ab9be94e6%40journal-immo.com



Re: New project in virtual env referencing another project's default/redirected path

2018-05-18 Thread ankitklinkedin
Hi Doug,

I am new to Django and i also started with MDN Locallibrary project. 
Everything went fine until Django admin site but I stuck at "Creating our 
home page 
" 
I have written the code in the suggested way only but get below error when 
try to run the project. I tried taking the urls.py code from github also 
but it gives same issue. 

Could you please help me here.

Regards,
Ankit 


Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/catalog/

Using the URLconf defined in locallibrary.urls, Django tried these URL 
patterns, in this order:

   1. admin/
   2. ^static\/(?P.*)$
   3. 

The current path, catalog/, didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page.



On Monday, January 22, 2018 at 5:46:31 AM UTC+2, Doug Nintzel wrote:
>
> Ok, makes sense. Thank you very much for the details Daniel.
> Doug
>
> On Sunday, January 21, 2018 at 1:02:33 PM UTC-7, Daniel Hepper wrote:
>>
>> Yes, kind of. There are two kinds of redirects, temporary and permanent 
>> redirects. By default Django's redirect() method returns a temporary 
>> redirect. If you pass permanent=True, it returns a permanent redirect.
>>
>> So here is what happened in your case:
>>
>> 1. You run the MDN tutorial project and point your browser to 
>> http://127.0.0.1:8000/
>> 2. The browser requests the path / from the server 127.0.0.1:8000 (the 
>> runserver running the MDN tutorial project) and receives a permanent 
>> redirect to /catalog/
>> 3. Then you stop the MDN project and run your own project.
>> 4. You then point your browser to http://127.0.0.1:8000
>> 5. Your browser thinks "wait a minute, last time I accessed the path / on 
>> the server 127.0.0.1:8000, it returned a permanent redirect to 
>> /catalog/. I'll save my user some time and just go directly to /catalog/".
>>
>> Now, if a URL returns a temporary redirect, the browser knows that this 
>> redirect is, well, temporary, so it might point to a different location the 
>> next time or there might be no redirect at all. Therefore, it must load the 
>> original URL.
>>
>> In the example of the tutorial, a permanent redirect should not be used, 
>> not only because it can lead to the problem you encountered.
>>
>> Imagine you use this software for your local library at 
>> http://smalltownlibrary.com/. After a while, you want to add another 
>> feature, e.g. a book shop under /shop/ where visitor can buy used books. 
>> You then want to add a homepage at / where users can select whether they 
>> want to access catalogue or the shop. It works fine for new users, but 
>> everyone who accessed the site http://smalltownlibrary.com/ before is 
>> not able to access the new homepage because their browser has cached the 
>> permanent redirect to the catalog.
>>
>> Permanent redirects definitely have their place, e.g. if you moved your 
>> website to a new URL and want to tell the search engines that they should 
>> only look at the new URL. But you have to be aware that they are indeed 
>> permanent.
>>
>> Hope that clarifies it a bit.
>>
>> Daniel
>>
>> On Sunday, January 21, 2018 at 7:26:39 PM UTC+1, Doug Nintzel wrote:
>>>
>>> That got it Daniel...thanks for the quick help. Was it " permanent=True" 
>>> in particular that was the problem?
>>> Thanks again,
>>> Doug
>>>
>>> On Sunday, January 21, 2018 at 10:29:33 AM UTC-7, Daniel Hepper wrote:

 I realized that the Mozilla tutorial is a wiki, so I took the liberty 
 to remove the "permant=True" from the redirect.

 On Sun, Jan 21, 2018 at 6:23 PM, Daniel Hepper  
 wrote:

> It's not the new project referencing the old project, it is actually 
> your browser caching the redirect from http://127.0.0.1:8000/ to 
> http://127.0.0.1:8000/catalog/.
> Because it is a permanent redirect, your browser won't access 
> http://127.0.0.1:8000/, it will go http://127.0.0.1:8000/catalog/.
>
> You can usually get rid of this redirect by clearing your browser 
> cache. How exactly that is done depends on the browser you are using.
>
> This also teaches an important lesson about permanent redirects. Only 
> use them when you are absolutely sure that you (and more importantly your 
> users) will never again want to access the old URL.
>
> Hope that helps,
> Daniel
>
>
>
> On Sun, Jan 21, 2018 at 6:06 PM, Doug Nintzel  
> wrote:
>
>> Hello,
>>
>> I am new to Django and followed this Mozilla Django Tutorial 
>> 
>>  which 
>> was very helpful, and created the 'locallibrary' project.
>> As part of the exercise, it has you create a 'catalog' app and has 
>> you set up a redirect to the defaul

Re: ImportError : cannot import name include

2018-05-18 Thread Gerald Brown
Another option to get the current version of Django is to create a file 
called requirements.txt.  In this file enter django on a line, and other 
requirements on other lines.  You can also specify a specific version 
with django==1.11 or any other version by changing the number after the 
==. If this is left off then the latest version will be installed.  Then 
in your virtual environment enter the command 'pip install -r 
requirements.txt'. This will download and install everything that is in 
the requirements.txt.  This file will grow as you enter more requirements.



On 05/18/2018 10:38 PM, Daniel Hepper wrote:


Your problem is right here:

> django-admin --version 1.11.13

You are using Django 1.11. The documentation you are using refers to a 
newer version of Django, version 2.0.


Use the right documentation for your version of Django:

https://docs.djangoproject.com/en/1.11/

You are seeing this specific error because in Django 2.0, you can 
write "from django.urls import include", while in Django 1.11, you 
have to write "from django.conf.urls import include".


Note that using Debian packages, you won't get the latest version of 
Django (or any other Python packages). You might want to consider 
installing the latest version with pip.


https://docs.djangoproject.com/en/2.0/topics/install/#installing-official-release

Hope that helps,
Daniel

On Fri, May 18, 2018 at 4:20 PM, Journal-Immo 
mailto:cont...@journal-immo.com>> wrote:


Thank

But (I use debian 9)

Apt-get update

Apt-get install python python3 python-django

django-admin --version 1.11.13

Where is the problem ?


Le 17/05/2018 à 21:01, Fidel Leon a écrit :

You are using the wrong combination of Django and tutorial:
“include” is available in Django 2 and up, but you’re using
Django 1.11.

Fidel Leon
fi...@flm.cat 
Phone: +34 622 26 44 92 
GPG: 2585 30C2 E3C7 7151 0864  946B 7423 F94B 5753 5FC7

El 17 de mayo de 2018 a las 20:56:56, Tristan Demot
(cont...@journal-immo.com )
escribió:


Hello,

 I use docs.djangoproject.co/en/2.0

 Python 2 7 13
Gjango 1.11.13


Creating the Polls app OK


Write your first view OK

But python manage runserver don't work
With : python -Wall manage.py test
ImportError : cannot import name include
If you want to see something, ask me
Many 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 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/1fe7df04-dc85-4a3d-940e-4dde7de31477%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/CAHXg%3DN090U8JCFfdvZJWH1qSoWQgp2mQH6z2RfCzj3384epQKQ%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

Re: ImportError : cannot import name include

2018-05-18 Thread Fidel Leon
You need to follow the CORRECT tutorial:

https://docs.djangoproject.com/en/1.11/

In the urls.py file, instead of:

from django.contrib import adminfrom django.urls import include, path
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),]

you need this:

from django.conf.urls import include, urlfrom django.contrib import admin
urlpatterns = [
url(r'^polls/', include('polls.urls')),
url(r'^admin/', admin.site.urls),]

Please note the django.conf.urls INSTEAD of django.contrib


El vie., 18 may. 2018 a las 16:20, Journal-Immo ()
escribió:

> Thank
>
> But (I use debian 9)
>
> Apt-get update
>
> Apt-get install python python3 python-django
>
> django-admin --version 1.11.13
>
> Where is the problem ?
>
> Le 17/05/2018 à 21:01, Fidel Leon a écrit :
>
> You are using the wrong combination of Django and tutorial: “include” is
> available in Django 2 and up, but you’re using Django 1.11.
>
> Fidel Leon
> fi...@flm.cat
> Phone: +34 622 26 44 92 
> GPG: 2585 30C2 E3C7 7151 0864  946B 7423 F94B 5753 5FC7
>
> El 17 de mayo de 2018 a las 20:56:56, Tristan Demot (
> cont...@journal-immo.com) escribió:
>
> Hello,
>
>  I use docs.djangoproject.co/en/2.0
>  Python 2 7 13
> Gjango 1.11.13
>
> Creating the Polls app OK
> Write your first view OK
> But python manage runserver don't work
> With : python -Wall manage.py test
> ImportError : cannot import name include
> If you want to see something, ask me
> Many 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 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/1fe7df04-dc85-4a3d-940e-4dde7de31477%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/CAHXg%3DN090U8JCFfdvZJWH1qSoWQgp2mQH6z2RfCzj3384epQKQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
>


-- 
Fidel Leon
fi...@flm.cat
Phone: +34 622 26 44 92

-- 
You received this message because you are subscribed to the Google 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/CAHXg%3DN3nMbGtHLjQO2WoJgr8rjFwO7L5Sm-MRduf4yEPpfH7EA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ImportError : cannot import name include

2018-05-18 Thread Daniel Hepper
Your problem is right here:

> django-admin --version 1.11.13
You are using Django 1.11. The documentation you are using refers to a
newer version of Django, version 2.0.

Use the right documentation for your version of Django:

https://docs.djangoproject.com/en/1.11/

You are seeing this specific error because in Django 2.0, you can write
"from django.urls import include", while in Django 1.11, you have to write
"from django.conf.urls import include".

Note that using Debian packages, you won't get the latest version of Django
(or any other Python packages). You might want to consider installing the
latest version with pip.

https://docs.djangoproject.com/en/2.0/topics/install/#installing-official-release

Hope that helps,
Daniel

On Fri, May 18, 2018 at 4:20 PM, Journal-Immo 
wrote:

> Thank
>
> But (I use debian 9)
>
> Apt-get update
>
> Apt-get install python python3 python-django
>
> django-admin --version 1.11.13
>
> Where is the problem ?
>
> Le 17/05/2018 à 21:01, Fidel Leon a écrit :
>
> You are using the wrong combination of Django and tutorial: “include” is
> available in Django 2 and up, but you’re using Django 1.11.
>
> Fidel Leon
> fi...@flm.cat
> Phone: +34 622 26 44 92 
> GPG: 2585 30C2 E3C7 7151 0864  946B 7423 F94B 5753 5FC7
>
> El 17 de mayo de 2018 a las 20:56:56, Tristan Demot (
> cont...@journal-immo.com) escribió:
>
> Hello,
>
>  I use docs.djangoproject.co/en/2.0
>  Python 2 7 13
> Gjango 1.11.13
>
> Creating the Polls app OK
> Write your first view OK
> But python manage runserver don't work
> With : python -Wall manage.py test
> ImportError : cannot import name include
> If you want to see something, ask me
> Many 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 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/1fe7df04-dc85-4a3d-940e-4dde7de31477%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/CAHXg%3DN090U8JCFfdvZJWH1qSoWQgp2mQH
> 6z2RfCzj3384epQKQ%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/7e9e643b-6e7e-681c-eed2-dc9ab9be94e6%40journal-immo.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/CAHEnUVWWkRsOVD6AfvDoGS05z33R7qu9SuA2Q1o2se%2BPf0M-xg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ImportError : cannot import name include

2018-05-18 Thread Journal-Immo

Thank

But (I use debian 9)

Apt-get update

Apt-get install python python3 python-django

django-admin --version 1.11.13

Where is the problem ?


Le 17/05/2018 à 21:01, Fidel Leon a écrit :
You are using the wrong combination of Django and tutorial: “include” 
is available in Django 2 and up, but you’re using Django 1.11.


Fidel Leon
fi...@flm.cat 
Phone: +34 622 26 44 92 
GPG: 2585 30C2 E3C7 7151 0864  946B 7423 F94B 5753 5FC7

El 17 de mayo de 2018 a las 20:56:56, Tristan Demot 
(cont...@journal-immo.com ) escribió:



Hello,

 I use docs.djangoproject.co/en/2.0 
 Python 2 7 13
Gjango 1.11.13


Creating the Polls app OK


Write your first view OK

But python manage runserver don't work
With : python -Wall manage.py test
ImportError : cannot import name include
If you want to see something, ask me
Many 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 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/1fe7df04-dc85-4a3d-940e-4dde7de31477%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/CAHXg%3DN090U8JCFfdvZJWH1qSoWQgp2mQH6z2RfCzj3384epQKQ%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/7e9e643b-6e7e-681c-eed2-dc9ab9be94e6%40journal-immo.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with debug = True/False

2018-05-18 Thread Gerald Brown
My site now looks the same in Development and Production.  I think why this 
is happening is that I ran ./manage.py collectstatic awhile ago,  So if you 
are getting weird formatting when DEBUG = False try running ./manage.py 
collectstatic and see if that solves your problem!!!

On Friday, May 11, 2018 at 9:09:03 AM UTC+8, Gerald Brown wrote:
>
> On my admin site if I have Debug set to true (I have read that for 
> production this is a no-no) everything looks fine.  When I change it to 
> FALSE all of the styling goes away as if it is being run using gunicorn.
>
> Has anyone observed this?  If so have you found a correction?
>
> 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 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/4546359f-2828-4833-b55b-9a48437a65d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error Djongo MongoDB

2018-05-18 Thread 180328818
test

在 2018年5月18日星期五 UTC+10上午7:09:18,Kadir Guloglu写道:
>
> Hi
>
> I am try to connect MongoDB and I am getting an exception
>
> *Thanks for help*
>
> *CMD*
>
> *c:\Proje\otomabakv2\otomabak\otomabak>python manage.py makemigrations*
> *Traceback (most recent call last):*
> *  File "manage.py", line 15, in *
> *execute_from_command_line(sys.argv)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py",
>  
> line 371, in execute_from_command_line*
> *utility.execute()*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py",
>  
> line 365, in execute*
> *self.fetch_command(subcommand).run_from_argv(self.argv)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>  
> line 288, in run_from_argv*
> *self.execute(*args, **cmd_options)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>  
> line 335, in execute*
> *output = self.handle(*args, **options)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\makemigrations.py",
>  
> line 92, in handle*
> *loader.check_consistent_history(connection)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py",
>  
> line 275, in check_consistent_history*
> *applied = recorder.applied_migrations()*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py",
>  
> line 61, in applied_migrations*
> *if self.has_table():*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py",
>  
> line 44, in has_table*
> *return self.Migration._meta.db_table in 
> self.connection.introspection.table_names(self.connection.cursor())*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\introspection.py",
>  
> line 56, in table_names*
> *return get_names(cursor)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\introspection.py",
>  
> line 51, in get_names*
> *return sorted(ti.name  for ti in 
> self.get_table_list(cursor)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\djongo\introspection.py",
>  
> line 34, in get_table_list*
> *for c in cursor.db_conn.collection_names(False)]*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymongo\database.py",
>  
> line 617, in collection_names*
> *for result in self.list_collections(session=session, **kws)]*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymongo\database.py",
>  
> line 586, in list_collections*
> *ReadPreference.PRIMARY) as (sock_info, slave_okay):*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\contextlib.py", 
> line 81, in __enter__*
> *return next(self.gen)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymongo\mongo_client.py",
>  
> line 982, in _socket_for_reads*
> *server = topology.select_server(read_preference)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymongo\topology.py",
>  
> line 224, in select_server*
> *address))*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymongo\topology.py",
>  
> line 183, in select_servers*
> *selector, server_timeout, address)*
> *  File 
> "C:\Users\Kadir\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymongo\topology.py",
>  
> line 199, in _select_servers_loop*
> *self._error_message(selector))*
> *pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 
> 10061] No connection could be made because the target machine actively 
> refused it*
>
>
>
> DATABASES = {
> "default": {
> 'ENGINE': 'djongo',
> "NAME": "admin",
> "host": "MONGO DB SERVER IP",
> "PASSWORD": "PASSWORD",
> "USER": "kadirguloglu1",
> "PORT": 27017,
> },
> }
>
>

-- 
You received this message because you are subscribed to the Google 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/69c5887b-8c4c-4643-b700-f0beb2d17a33%40googlegroups.com.
For more options, visit https://groups.go

Re: Django 2.1 alpha 1 released

2018-05-18 Thread Cigi Sebastine
Fantastic framework in web technology.

Thanks & Regards
Cigi Sebastine

On Fri, May 18, 2018 at 7:18 AM, Aditya Singh 
wrote:

> Wow wow wow! My best and nost powerful framework in the world. Super
> excited for the new release!
> Kind Regards,
> Aditya
>
> On Fri, May 18, 2018, 6:45 AM Tim Graham  wrote:
>
>> We've made the first release on the way to Django's next major
>> release, Django 2.1! With about two and a half months until the
>> final release (scheduled for August 1), we'll need timely testing
>> from the community to ensure an on time, stable release. Check out the
>> blog post:
>> https://www.djangoproject.com/weblog/2018/may/17/django-21-alpha-1/
>>
>> --
>> You received this message because you are subscribed to the Google 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/CAD-rxRCubeJJQ36%3DV4kaaaYUr82fWq-
>> hsnrNy7e-4YqGT-sQQA%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/CAEPfumg%2BF2MQa8p33sooFV61Z37V06Ujw9RA
> fYJsmrvqwf7kKA%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/CAAaRqFP45Q1RbRC9CXF6_%3DTe-p9VrB2z1ST_RQ%2BRwJaF9Sr9Gg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Public Django administrative database

2018-05-18 Thread Christian Ledermann
https://github.com/mysociety/mapit
http://djjr-courses.wikidot.com/soc128:qgis-voronoi-polygons

On 18 May 2018 at 11:27, Christian Ledermann 
wrote:

> and to get areas from the Postcode points:
> https://github.com/roblascelles/uk-postcode-map/wiki/Cobbling-together-UK-
> postcode-area-data
>
> On 18 May 2018 at 11:24, Christian Ledermann <
> christian.lederm...@gmail.com> wrote:
>
>> https://github.com/cleder/os-opendata-edubase
>>
>> TL;DR:  use OS-Open
>>
>> On 18 May 2018 at 09:18, Daniel Chimeno  wrote:
>>
>>> Hi community!
>>>
>>> I'm involved in a project heavily related to administrative geographic
>>> entities in UK.
>>> (postal_sectors, postal areas, etc..)
>>> Although at the moment is only for UK, could be expanded to other
>>> countries.
>>> At first, I look into https://github.com/django
>>> /django-localflavor/tree/master/localflavor/gb
>>> but there aren't so many entities there.
>>>
>>> Then, searched in Google for some hours and couldn't find any reliable
>>> database or csv.
>>>
>>> How you folks get this kind of information? Any resource?
>>> If it's Django related would be awesome, if not, I could process it.
>>>
>>> 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 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/ms
>>> gid/django-users/4bbc9772-01e2-43f1-bb5a-4a8dafa30f2a%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Best Regards,
>>
>> Christian Ledermann
>>
>> Newark-on-Trent - UK
>> Mobile : +44 7474997517
>>
>> https://uk.linkedin.com/in/christianledermann
>> https://github.com/cleder/
>>
>>
>> <*)))>{
>>
>> If you save the living environment, the biodiversity that we have left,
>> you will also automatically save the physical environment, too. But If
>> you only save the physical environment, you will ultimately lose both.
>>
>> 1) Don’t drive species to extinction
>>
>> 2) Don’t destroy a habitat that species rely on.
>>
>> 3) Don’t change the climate in ways that will result in the above.
>>
>> }<(((*>
>>
>
>
>
> --
> Best Regards,
>
> Christian Ledermann
>
> Newark-on-Trent - UK
> Mobile : +44 7474997517
>
> https://uk.linkedin.com/in/christianledermann
> https://github.com/cleder/
>
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>



-- 
Best Regards,

Christian Ledermann

Newark-on-Trent - UK
Mobile : +44 7474997517

https://uk.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>

-- 
You received this message because you are subscribed to the Google 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/CABCjzWpfhdaHBH4rp9cZ5zNKUkXi%2BxQn2H%3DeqvoYfSkXKWGBUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Public Django administrative database

2018-05-18 Thread Christian Ledermann
and to get areas from the Postcode points:
https://github.com/roblascelles/uk-postcode-map/wiki/Cobbling-together-UK-postcode-area-data

On 18 May 2018 at 11:24, Christian Ledermann 
wrote:

> https://github.com/cleder/os-opendata-edubase
>
> TL;DR:  use OS-Open
>
> On 18 May 2018 at 09:18, Daniel Chimeno  wrote:
>
>> Hi community!
>>
>> I'm involved in a project heavily related to administrative geographic
>> entities in UK.
>> (postal_sectors, postal areas, etc..)
>> Although at the moment is only for UK, could be expanded to other
>> countries.
>> At first, I look into https://github.com/django/django-localflavor/tree/
>> master/localflavor/gb
>> but there aren't so many entities there.
>>
>> Then, searched in Google for some hours and couldn't find any reliable
>> database or csv.
>>
>> How you folks get this kind of information? Any resource?
>> If it's Django related would be awesome, if not, I could process it.
>>
>> 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 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/ms
>> gid/django-users/4bbc9772-01e2-43f1-bb5a-4a8dafa30f2a%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Best Regards,
>
> Christian Ledermann
>
> Newark-on-Trent - UK
> Mobile : +44 7474997517
>
> https://uk.linkedin.com/in/christianledermann
> https://github.com/cleder/
>
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>



-- 
Best Regards,

Christian Ledermann

Newark-on-Trent - UK
Mobile : +44 7474997517

https://uk.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>

-- 
You received this message because you are subscribed to the Google 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/CABCjzWqALhQaSvdRDF%3D-fW%3DEVxMwdMZKX_nF9KiOQfdNNYJMdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Public Django administrative database

2018-05-18 Thread Christian Ledermann
https://github.com/cleder/os-opendata-edubase

TL;DR:  use OS-Open

On 18 May 2018 at 09:18, Daniel Chimeno  wrote:

> Hi community!
>
> I'm involved in a project heavily related to administrative geographic
> entities in UK.
> (postal_sectors, postal areas, etc..)
> Although at the moment is only for UK, could be expanded to other
> countries.
> At first, I look into https://github.com/django/django-localflavor/
> tree/master/localflavor/gb
> but there aren't so many entities there.
>
> Then, searched in Google for some hours and couldn't find any reliable
> database or csv.
>
> How you folks get this kind of information? Any resource?
> If it's Django related would be awesome, if not, I could process it.
>
> 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 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/4bbc9772-01e2-43f1-bb5a-4a8dafa30f2a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Best Regards,

Christian Ledermann

Newark-on-Trent - UK
Mobile : +44 7474997517

https://uk.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>

-- 
You received this message because you are subscribed to the Google 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/CABCjzWpDpzV1P%3DZNcZ5J_et3RKyi3eT7%2B2Uym5r5hvZ%3DnF61HA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Public Django administrative database

2018-05-18 Thread Daniel Chimeno
Hi community!

I'm involved in a project heavily related to administrative geographic 
entities in UK.
(postal_sectors, postal areas, etc..)
Although at the moment is only for UK, could be expanded to other countries.
At first, I look 
into https://github.com/django/django-localflavor/tree/master/localflavor/gb
but there aren't so many entities there.

Then, searched in Google for some hours and couldn't find any reliable 
database or csv.

How you folks get this kind of information? Any resource?
If it's Django related would be awesome, if not, I could process it.

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 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/4bbc9772-01e2-43f1-bb5a-4a8dafa30f2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django ModelAdmin ignores has_delete_permission

2018-05-18 Thread Vitaly Trifanov


I have simple project on Django 1.11.13, that uses ordinary Django's admin 
module. Staff user can not delete object while is permitted 
(has_delete_permission returns always true).

models.py:


class MyModel(models.Model):
name = models.IntegerField("Value", blank=True, null=True)

admin.py:


@admin.register(MyModel)class MyModelAdmin(admin.ModelAdmin):
def has_add_permission(self, request):
return True

def has_change_permission(self, request, obj=None):
return True

def has_delete_permission(self, request, obj=None):
return True


I created user and logged in. He can create MyModel object (as expected), 
can edit (as expected), but can not delete!!

That's what I see if I try to delete it:

Deleting the selected my model would result in deleting related objects, 
but your account doesn't have permission to delete the following types of 
objects:

my model

What am I doing wrong? How should I give permissions to delete MyModels to 
ordinary staff user?

-- 
You received this message because you are subscribed to the Google 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/f2a89d70-b488-4584-8fad-0d5b7a5d20e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Field.choices get all items as json

2018-05-18 Thread Majid Hojati
In fact I want to convert all of these choises into json format and then 
send them to user 
thanks

On Thursday, May 17, 2018 at 8:46:42 PM UTC+4:30, C. Kirby wrote:
>
> if you just want to put that into json do:
> import json
>
> YEAR_IN_SCHOOL_CHOICES = (
> ('FR', 'Freshman'),
> ('SO', 'Sophomore'),
> ('JR', 'Junior'),
> ('SR', 'Senior'),
> )
>
> serialized_year_choices = json.dumps(Model.YEAR_IN_SCHOOL_CHOICES) 
>
>
>
>
>
> On Thursday, May 17, 2018 at 10:52:15 AM UTC-4, Majid Hojati wrote:
>>
>> Hi,
>> I have a Field.choices in my model. lets say it is:
>>
>> YEAR_IN_SCHOOL_CHOICES = (
>>> ('FR', 'Freshman'),
>>> ('SO', 'Sophomore'),
>>> ('JR', 'Junior'),
>>> ('SR', 'Senior'),
>>> )
>>
>>
>> I can access them using this method Model. YEAR_IN_SCHOOL_CHOICES  but 
>> how can I convert it to a json then I can send them using a webservice ? is 
>> there any good method?
>>
>

-- 
You received this message because you are subscribed to the Google 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/be3eabf9-939a-429f-a7c8-62ba30b98981%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.