Access a form method from generic.UpdateView

2019-08-07 Thread אורי
Django users,

I have a view which is a generic.UpdateView, and I need to access a form
method - get_hidden_fields(). How do I access it?

I currently used self.form_class().get_hidden_fields() but I'm not sure if
this is correct. I think it creates a new instance of the form and I want
to use the current instance.

https://github.com/speedy-net/speedy-net/blob/staging/speedy/match/matches/views.py#L54

Thanks,
אורי
u...@speedy.net

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


Re: Enter valid date error

2019-08-07 Thread ANi
Thanks for your help!

Sipum,
I have tried many possibilities and it is some how fixed and I actually 
don't know why, like why it is broken.
but if you look into the class DateInput provided by Django:


class DateInput(DateTimeBaseInput):
format_key = 'DATE_INPUT_FORMATS'
template_name = 'django/forms/widgets/date.html'


it does the same thing, and the template only includes the template same as 
DateTimeBaseInput(which I don't get it)

so I end up inheriting the Django DateInput to create my own DateInput, all 
I need is change the input_type

from django.forms.widgets import DateInput as djangoDateInput


class DateInput(djangoDateInput):
input_type = 'date'

  
or consider what sachin said, simply set format_key = '%Y-%m-%d'





ANi於 2019年8月6日星期二 UTC+8下午2時28分24秒寫道:
>
> I've change the default date field widget slightly,
> but only like this and also define the DATE_INPUT_FORMATS
>
>
>
> class DateInput(DateTimeBaseInput):
> input_type = 'date'
> format_key = 'DATE_INPUT_FORMATS'
>
>
> DATE_INPUT_FORMATS = [
> '%Y-%m-%d',
> ]
>
>
> but still get error on the date field, only success at the first time 
> after I restart the server
>
> any reason could be?
>

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


Re: Tutorial Problems...

2019-08-07 Thread Mike Dewhirst
Two things ...

Look at the error near the bottom of the traceback and notice it says there is 
a syntax faux pas on line 21 of one of your files. If you find and fix that 
python will advance to your next error - if any.

And

runserver is asking you to Ctrl-c and do python manage.py migrate 
--settings=

This will ensure your database matches all the models in your project including 
Django's own models.

Connected by Motorola

Emil Lilja  wrote:

>Hey,
>
>Thanks for your reply!
>
>So yeah i did the tutorial from scratch again and noticed like you were aiming 
>at that the server was actually running. Even though the tutorial clearly 
>states that you should get the following output when running runserver, I only 
>seem to get this after i terminate with Ctrl+C:
>Performing system checks... System check identified no issues (0 silenced). 
>You have unapplied migrations; your app may not work properly until they are 
>applied. Run 'python manage.py migrate' to apply them. August 03, 2019 - 
>15:50:53 Django version 2.2, using settings 'mysite.settings' Starting 
>development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
>
>Anyways i realised why the server probably isn't running, I've created the 
>polls app and followed all the steps (copied code exactly) and i get a 
>SyntaxError?
>What's causing this?
>
>body, pre { margin: 0; padding: 0; } pre { font-family: inherit; } #vt100 { 
>float: left; border: 0px solid; padding: 1px; line-height: 111%; font-size: 
>9pt; font-family: 'Lucida Console', 'Lucida Console ', 'Consolas'; color: 
>#BFBFBF; background-color: #00; } .bd { font-weight: bold } .it { 
>font-style: italic } .ul { text-decoration-line: underline } .st { 
>text-decoration-line: line-through } .lu { text-decoration-line: line-through 
>underline } .fg-color0 { color: #00 } .bg-color0 { background-color: 
>#00 } .fg-color1 { color: #BF } .bg-color1 { background-color: #BF 
>} .fg-color2 { color: #00BF00 } .bg-color2 { background-color: #00BF00 } 
>.fg-color3 { color: #BFBF00 } .bg-color3 { background-color: #BFBF00 } 
>.fg-color4 { color: #BF } .bg-color4 { background-color: #BF } 
>.fg-color5 { color: #BF00BF } .bg-color5 { background-color: #BF00BF } 
>.fg-color6 { color: #00BFBF } .bg-color6 { background-color: #00BFBF } 
>.fg-color7 { color: #BFBFBF } .bg-color7 { background-color: #BFBFBF } 
>.fg-color8 { color: #404040 } .bg-color8 { background-color: #404040 } 
>.fg-color9 { color: #FF4040 } .bg-color9 { background-color: #FF4040 } 
>.fg-color10 { color: #40FF40 } .bg-color10 { background-color: #40FF40 } 
>.fg-color11 { color: #40 } .bg-color11 { background-color: #40 } 
>.fg-color12 { color: #6060FF } .bg-color12 { background-color: #6060FF } 
>.fg-color13 { color: #FF40FF } .bg-color13 { background-color: #FF40FF } 
>.fg-color14 { color: #40 } .bg-color14 { background-color: #40 } 
>.fg-color15 { color: #FF } .bg-color15 { background-color: #FF } 
>.cursor { background-color: #BFBFBF } .font10 { font-family: 'F25 Blackletter 
>Typewriter' } 
>
>$ python manage.py runserver Watching for file changes with StatReloader 
>### I Press Ctrl+C and get the following output: 
>Exception in thread django-main-thread: Traceback (most recent call last): 
>File "C:\Anaconda3\lib\threading.py", line 917, in _bootstrap_inner self.run() 
>File "C:\Anaconda3\lib\threading.py", line 865, in run 
>self._target(*self._args, **self._kwargs) File 
>"C:\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 54, in 
>wrapper fn(*args, **kwargs) File 
>"C:\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", 
>line 117, in inner_run self.check(display_num_errors=True) File 
>"C:\Anaconda3\lib\site-packages\django\core\management\base.py", line 390, in 
>check include_deployment_checks=include_deployment_checks, File 
>"C:\Anaconda3\lib\site-packages\django\core\management\base.py", line 377, in 
>_run_check s return checks.run_checks(**kwargs) File 
>"C:\Anaconda3\lib\site-packages\django\core\checks\registry.py", line 72, in 
>run_checks new_errors = check(app_configs=app_configs) File 
>"C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 13, in 
>check_url_confi g return check_resolver(resolver) File 
>"C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 23, in 
>check_resolver return check_method() File 
>"C:\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 398, in check 
>for pattern in self.url_patterns: File 
>"C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 80, in 
>__get__ res = instance.__dict__[self.name] = self.func(instance) File 
>"C:\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 579, in 
>url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", 
>self.urlconf_module) File 
>"C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 80, in 
>__get__ res = instance.__dict__[self.name] = self.func(instance) File 

Re: Tutorial Problems...

2019-08-07 Thread Emil Lilja
Hey,

Thanks for your reply!

So yeah i did the tutorial from scratch again and noticed like you were 
aiming at that the server was actually running. Even though the tutorial 
clearly states that you should get the following output when running 
*runserver, 
*I only seem to get this after i terminate with Ctrl+C*:*

Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are 
applied.
Run 'python manage.py migrate' to apply them.

August 03, 2019 - 15:50:53
Django version 2.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Anyways i realised why the server probably isn't running, I've created the 
polls app and followed all the steps (copied code exactly) and i get a 
SyntaxError?
What's causing this?

$ python manage.py runserver
   Watching for file changes with StatReloader  


### I Press Ctrl+C and get the following output:

  
Exception in thread django-main-thread: 
   Traceback (most recent call last):   
File "C:\Anaconda3\lib\threading.py", line 917, 
in _bootstrap_inner  self.run() 
  File 
"C:\Anaconda3\lib\threading.py", line 865, in run   
self._target(*self._args, **self._kwargs)   
 File 
"C:\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 54, in 
wrapperfn(*args, **kwargs)  
File 
"C:\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", 
line 117, in inner_run  
self.check(display_num_errors=True) 
 File 
"C:\Anaconda3\lib\site-packages\django\core\management\base.py", line 390, in 
check include_deployment_checks=include_deployment_checks,  
   File 
"C:\Anaconda3\lib\site-packages\django\core\management\base.py", line 377, in 
_run_checks 
 return checks.run_checks(**kwargs) 
  File 
"C:\Anaconda3\lib\site-packages\django\core\checks\registry.py", line 72, in 
run_checks new_errors = check(app_configs=app_configs)  
File 
"C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 13, in 
check_url_config
  return check_resolver(resolver)   
   File 
"C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 23, in 
check_resolver return check_method()
File 
"C:\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 398, in check   
for pattern in self.url_patterns:   
 File 
"C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 80, in 
__get__res = instance.__dict__[self.name] = self.func(instance) 
File 
"C:\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 579, in 
url_patternspatterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)  File 
"C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 80, in 
__get__res = instance.__dict__[self.name] = self.func(instance) 
File 
"C:\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 572, in 
urlconf_module  return import_module(self.urlconf_name) 
 File "C:\Anaconda3\lib\importlib\__init__.py", 
line 127, in import_modulereturn 
_bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_importFile 
"", line 983, in _find_and_load  File "", line 967, 
in _find_and_load_unlocked File "", line 677, in 
_load_unlocked  File "", line 724, in exec_module   
 File "", line 860, in get_code   
File "", line 791, in source_to_code File "", line 219, in 
_call_with_frames_removed 

Django 2.2 mongoengine query pagination performance

2019-08-07 Thread Felix Tillyard
Hi,

We are facing an issue while upgrading from Django 2.1.10 to 2.2.4. We are 
using mongoengine (http://mongoengine.org/) to pull some documents from a 
Mongo database. Following the upgrade performance of this is significantly 
worse.

We ran some profiling using pyspy (https://github.com/benfred/py-spy) which 
produced the attached charts.

Basically it seems like there are many extra function calls, seemingly 
related to pagination, and the control flow here is different following the 
upgrade.

Any ideas / help would be amazing!

Thanks

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


redirects, in django how to set one up correctly

2019-08-07 Thread Kean
Hello, 

Im trying to create a redirect where after the user has created a login, 
and saved they are redirected to a sub.url
i.e. Business registers, at Business register.url and is redirected to 
business register/business admin.url

my views.py

def Business(request):
if request.method == "POST":
form = UserCreationForm(request.POST)
if form.is_valid():
user = form.save()
username = form.cleaned_data.get('username')
messages.success(request, f"New Account Created: {username}")
login(request, user)
message.info(request, f"You are now logged in as: {username}")
return redirect("source:contadmin")
else:
for msg in form.error_messages: 
messages.error(request, f"{msg}: {form.error_messages[msg]}")


form = UserCreationForm(request.POST)
return render(request, "source/Business register.html", 
context={"form":form})

def contadmin(request):
return render(request=request, template_name="source/busadmin.html")

my urls.py

from django.urls import path
from . import views

app_name = "source"

urlpatterns = [
path("", views.homepage, name="homepage"),
path("Business register/", views.Business, name="Business register"),
path("contadmin", views.contadmin, name="busadmin"),
]

my html.template for the sub.url

{% load static %}


https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css;>


https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js";>



Billntrade

Business admin
Business logout
Help


  



I am new to django, and was hoping the community can help with a solution, 

Best wishes,

K

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


Re: tinymce no module exists

2019-08-07 Thread Mike Dewhirst
If you pip install *outside* a virtualenv it gets installed in the system 
python. If yours is purely a development machine you should pip uninstall 
django and anything else you see in the system python's site-packages directory 
to clean things up. Virtualenv theory is to only install stuff in the project 
not the system Python.

Connected by Motorola

Kean  wrote:

>Hi Mike, 
>
>
>thank you for the heip,
>
>
>I tried the relative path  (in main/urls.py) you provided and it threw up 
>errors.
>
>the existing reference I have seems stable, please see below
>
>
>path('tinymce/', include('tinymce.urls')),
>
>
>I have pip3 installed django-tinymce4-lite.
>
>
>What is odd, is if i run the server without a virtualenv, it works fine, 
>
>with a virtualenv, it fails reporting the no module named tinymce error,
>
>
>I’m thinking there is something I am missing 
>
>
>best,
>
>
>K
>
>
>
>On 5 Aug 2019, at 04:54, Mike Dewhirst  wrote:
>
>
> re_path(r'^tinymce/', include(tinymce_urls)),
>
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit 
>https://groups.google.com/d/msgid/django-users/8B44B676-A1F9-40B3-8664-244335DF497D%40gmail.com.

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


Re: can any one help me in solving the following error

2019-08-07 Thread Mike Dewhirst
Provided you are using virtualenv, that sounds right. It us the same for 
everyone starting a new project.

Connected by Motorola

goitom negash  wrote:

>when i want to work on a new django project i have to install it again . if 
>not it gives me an error "no module called django"
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit 
>https://groups.google.com/d/msgid/django-users/f3012896-e11b-4b5b-ab06-8daebfa07cb6%40googlegroups.com.

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


how to store API images in HDFS using Django

2019-08-07 Thread Saurabh Dubey
I created one API for image upload in  Django. I want to stored that image 
into HDFS(hadoop distribution file system) is it posible.
can we connect hadoop with hdfs.

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


Re: I get errors when I try deploying my app on gae

2019-08-07 Thread Solomon Mbak
That was actually it. I got it solved and it's working fine. Thanks a lot.

On Wed, Aug 7, 2019, 8:33 AM Kasper Laudrup  wrote:

> Hi Solomon,
>
> On 06/08/2019 09.27, Solomon Mbak wrote:
> > I have given myself many hours to try and solve this one, all to no
> > avail. I really need some help.
> >
> > My app works perfectly on development environment. When I deploy on
> > Google App Engine, I get series of syntax error.
> >
>
> It would be extremely helpful if you could post the exact syntax error
> you are getting, without that, I can only guess.
>
> >
> > returnHttpResponse(f"{single_slug} doesnt exist at all.")
> > |
> >
> > This error on this piece is on the last line. And the console points to
> > the full-stop on that line.
> >
>
> The "f-string syntax" was introduced in Python 3.6, so I'm guessing
> you're using an older Python version when running in Google App Engine
> which doesn't understand the convenient "f-string syntax".
>
> Hopefully that explains it.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c4c7808a-f3e5-8008-a9e3-8c10847662e7%40stacktrace.dk
> .
>

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


Django GAE deployment DATABASE setting

2019-08-07 Thread Solomon Mbak
Hi guys. 

I've spent a few hours on this one, all to no avail. 

I'm trying to reply my Django App on Google App Engine, but I get errors on 
the database connection. I tried configurations as shown below, but it 
still isn't connecting. I need help please;


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'MySQL_db_Name',
'USER': 'root',
'PASSWORD': '',
'HOST': 'project_Name:us-central1:my_DB_instance_Name',
}
}
I really need help. 
Thanks a lot.  

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


fields.E304 error

2019-08-07 Thread N. Manohar
In one of my system while I'm running 'python manage.py runserver' I'm 
getting fields.E304 error and in another system its working fine. Can 
anyone help me with this.

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


Re: can any one help me in solving the following error

2019-08-07 Thread goitom negash
thanx sir!!


On Tuesday, August 6, 2019 at 7:57:44 PM UTC-7, Mike Dewhirst wrote:
>
> On 6/08/2019 6:19 pm, goitom negash wrote: 
> > when i want to work on a new django project i have to install it again 
> > . if not it gives me an error "no module called django" 
>
> If you are working with virtualenv and creating a new one for each new 
> project - as I do and most Django devs do too - then it is normal to 
> install Django again. 
>
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to django...@googlegroups.com  
> > . 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/f3012896-e11b-4b5b-ab06-8daebfa07cb6%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/f3012896-e11b-4b5b-ab06-8daebfa07cb6%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
>
>

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


Re: I get errors when I try deploying my app on gae

2019-08-07 Thread Kasper Laudrup

Hi Solomon,

On 06/08/2019 09.27, Solomon Mbak wrote:
I have given myself many hours to try and solve this one, all to no 
avail. I really need some help.


My app works perfectly on development environment. When I deploy on 
Google App Engine, I get series of syntax error.




It would be extremely helpful if you could post the exact syntax error 
you are getting, without that, I can only guess.




returnHttpResponse(f"{single_slug} doesnt exist at all.")
|

This error on this piece is on the last line. And the console points to 
the full-stop on that line.




The "f-string syntax" was introduced in Python 3.6, so I'm guessing 
you're using an older Python version when running in Google App Engine 
which doesn't understand the convenient "f-string syntax".


Hopefully that explains it.

Kind regards,

Kasper Laudrup

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


Re: dlango MultiValueDictKeyError

2019-08-07 Thread Ajeet Kumar Gupt
Hi,

Problem was in my code I was using the request.POST['username'] instead of
request.POST.get('username')

You have given the solutions and the same I have implemented.

Once again thanks to you if any issues let you know.

*Actually, I am very new in Django hardly 1 week back started. This is my
first project to start for the learning purpose and I try to implement a
document management system with the workflow approval process.  I need your
support and help while developing the application. Once the design part
completed will share with you.*

def login_view(request):
templates = 'welcome.html'
username = request.POST.get('username')
password = request.POST.get('pass')
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return render(request, templates ,{'user' : user  })
else:
#return redirect('welcome.html')
messages.error(request, 'Login Failed! Invalid username and password.')
return render(request, 'login.html',{'user' : user  })














On Tue, Aug 6, 2019 at 8:55 PM DPM  wrote:

> Hey Ajit,
> Its Great.
> Can you please tell us what was the problem?
>
> On Tue, 6 Aug, 2019, 1:07 PM Ajeet Kumar Gupt, 
> wrote:
>
>> Hi,
>>
>> Thank you very much now issues have been resolved.
>>
>>
>>
>> On Mon, Aug 5, 2019 at 6:14 PM Sipum Mishra  wrote:
>>
>>> Hey Ajit,
>>>
>>> This error comes when You are trying to get username, passwords from the
>>> form.
>>> It is due to the below reason -
>>>
>>> In Login,
>>> You are using -> request.POST['username'] which will raise a KeyError
>>> exception if 'username' is not in request.POST.
>>>
>>> Instead use -> request.POST.get('username') which will return None if '
>>> username' is not in request.POST.
>>>
>>> Additionally, .get allows you to provide an additional parameter of a
>>> default value which is returned if the key is not in the dictionary.
>>>
>>> For example, request.POST.get('username', 'mydefaultvalue')
>>>
>>> Hope this helps. If any concern then let us know.
>>>
>>> On Mon, 5 Aug 2019 at 15:47, Ajeet Kumar Gupt 
>>> wrote:
>>>
 Dear Team,

 I am developing custom registration and login page for end-user but
 getting the below error. Please find the views.py code also in the trail.


 *MultiValueDictKeyError at /login/*

 'username'

 Request Method: GET
 Request URL: http://127.0.0.1:8000/login/
 Django Version: 2.2.3
 Exception Type: MultiValueDictKeyError
 Exception Value:

 'username'

 Exception Location: 
 C:\Python\Python37\lib\site-packages\django\utils\datastructures.py
 in __getitem__, line 80
 Python Executable: C:\Python\Python37\python.exe
 Python Version: 3.7.3

 --
 *Views.py*
 **

 rom django.shortcuts import render
 from django.contrib.auth.models import User
 from django.http import HttpResponseRedirect
 from .forms import RegisterForm
 from django.conf import settings
 from django.shortcuts import redirect
 from django.contrib.auth.decorators import login_required
 from django.contrib import messages
 from django.contrib.auth import authenticate,login
 from django.contrib import auth
 from django.core.exceptions import ObjectDoesNotExist


 def user_register(request):
 # if this is a POST request we need to process the form data
 template = 'mymodule/register.html'
# template = 'index.html'
 if request.method == 'POST':
 # create a form instance and populate it with data from the 
 request:
 form = RegisterForm(request.POST)
 # check whether it's valid:
 if form.is_valid():
 if 
 User.objects.filter(username=form.cleaned_data['username']).exists():
 return render(request, template, {
 'form': form,
 'error_message': 'Username already exists.'
 })
 elif 
 User.objects.filter(email=form.cleaned_data['email']).exists():
 return render(request, template, {
 'form': form,
 'error_message': 'Email already exists.'
 })
 elif form.cleaned_data['password'] != 
 form.cleaned_data['password_repeat']:
 return render(request, template, {
 'form': form,
 'error_message': 'Passwords do not match.'
 })
 else:
 # Create the user:
 user = User.objects.create_user(
 form.cleaned_data['username'],
 form.cleaned_data['email'],
 form.cleaned_data['password']
 )
 

Re: Django Error upon running the system

2019-08-07 Thread Mike Dewhirst

On 7/08/2019 3:34 pm, Davin Pore wrote:

Hi

 How I would define the the environment variable DJANGO_SETTINGS_MODULE


In Windows Explorer, right-click 'This PC' then select 'Properties' and 
finally 'Advanced system settings'. You will see a button labelled 
[Environment variables]


However this can lead to insanity. I speak from personal experience.

Instead, you should specify it at the end of your command line with 
--settings=


for example ...

C:\\python manage.py runserver --settings=projname.settings

https://docs.djangoproject.com/en/2.1/topics/settings/#the-django-admin-utility






On Tuesday, 6 August 2019 09:07:45 UTC+8, DANIEL URBANO DE LA RUA wrote:

not configured. You must either define the environment variable
DJANGO_SETTINGS_MODULE y have the trik in the logs

On Tue, 6 Aug 2019, 02:46 Davin Pore  wrote:

Could you help me to fix this issue. I encountered while
running the system.


C:\Users\davin.l.pore\Documents\JFETM_BMS\jfetmbox\venv\Scripts\python.exe

C:/Users/davin.l.pore/Documents/JFETM_BMS/JFETM/Box_Cronjob/box/cronjob/b0302_get_folder_file.py
Traceback (most recent call last):
  File

"C:/Users/davin.l.pore/Documents/JFETM_BMS/JFETM/Box_Cronjob/box/cronjob/b0302_get_folder_file.py",
line 13, in 
    from box.models import User
  File

"C:\Users\davin.l.pore\Documents\JFETM_BMS\JFETM\Box_Cronjob\box\models.py",
line 17, in 
    class GroupCompany(models.Model):
  File

"C:\Users\davin.l.pore\Documents\JFETM_BMS\jfetmbox\venv\lib\site-packages\django\db\models\base.py",
line 103, in __new__
    app_config = apps.get_containing_app_config(module)
  File

"C:\Users\davin.l.pore\Documents\JFETM_BMS\jfetmbox\venv\lib\site-packages\django\apps\registry.py",
line 252, in get_containing_app_config
    self.check_apps_ready()
  File

"C:\Users\davin.l.pore\Documents\JFETM_BMS\jfetmbox\venv\lib\site-packages\django\apps\registry.py",
line 134, in check_apps_ready
    settings.INSTALLED_APPS
  File

"C:\Users\davin.l.pore\Documents\JFETM_BMS\jfetmbox\venv\lib\site-packages\django\conf\__init__.py",
line 79, in __getattr__
    self._setup(name)
  File

"C:\Users\davin.l.pore\Documents\JFETM_BMS\jfetmbox\venv\lib\site-packages\django\conf\__init__.py",
line 64, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting
INSTALLED_APPS, but settings are not configured. You must
either define the environment variable DJANGO_SETTINGS_MODULE
or call settings.configure() before accessing settings.

Process finished with exit code 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...@googlegroups.com .
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/c7f195d5-7481-43d2-ba87-7a9540286714%40googlegroups.com

.

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


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