Re: Admin form in intermediate page

2019-11-20 Thread Derek
This is an old post but one that helped me when I first working on this:
https://www.jpichon.net/blog/2010/08/django-admin-actions-and-intermediate-pages/


On Tuesday, 19 November 2019 16:54:25 UTC+2, Thiago Luiz Parolin wrote:
>
> I have a form in admin that when selecting a particular action, presents an 
> intermediate page with numeric fields to be filled and saved in the selected 
> records.
> How can I save each record of my queryset with its respective field on this 
> intermediate page?
> I have almost everything working, just assigning each field of the 
> intermediate page to its record that I don't know how to do
> Does anyone have any ideas?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/848e068a-654b-4b84-9626-b871a52e971c%40googlegroups.com.


Re: Why I am not able to see the post that I write on this group?

2019-11-20 Thread Derek
I can see it - but I guess that does not help you?

On Wednesday, 20 November 2019 13:50:01 UTC+2, tramites xpress drive wrote:
>
> Why I am not able to see the post that I write on this group?
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/d3ac6c5d-ef69-431a-a5f9-17ec98d245f8%40googlegroups.com.


Re: reg: django Model for MCQs type project

2019-11-20 Thread Yoo
Have a Test model which as a unique identifier (BigAutoField). Get a Questions 
model with a foreign key to a test and a charfield for the question itself (you 
can add BrinIndex for optimization). You can add a booleanfield if the question 
is optional and whatever else you need (like the correct answer letter). Get an 
Answers model with a foreign key to a specific question. This is the most 
efficient.

You say you don’t need authentication, but it looks like students need some 
kind of it... BUT there is an alternative. If the student doesn’t have to fill 
out their name, then, using paths, you can show the student a URL that is 
connected to a record on another model. 

It could look like this: example.com/test/3?completed=846

With the path of completed=846, a view can query this new model, we’ll call 
Completed, that has the following attributes (columns): id (BigAutoField) and 
Your_Answers (ArrayField/JSONField Both PostgreSQL only). The view does a query 
on the test (test 3) to show and now also has data from the Completed table at 
the row with id=846.

Just to open your mind up to another world WHICH IS NOT EFFICIENT AND NOT 
PRETTY TO IMPLEMENT SO PLEASE DO NOT DO IT... You could also try it with 
PostgreSQL’s JSON attribute. Just make a test model which includes a unique 
identifier and a json field. The JSON field would just have keys be the 
question number (1-10) and then a... nvm here’s an example of a piece of json.

{
  1: {“question”: “What is your name?”,
   “answers”: [“blah1”, “blah2”, “blah3”] }
   2: {“question”: “What is your ethnicity?”,
   “answers”: [“blah1”, “blah2”, “blah3”] }
}

You could also try it NoSQL style with MongoDB. Each document is a test with a 
unique identifier
Good luck!
On Wednesday, November 20, 2019 at 12:21:38 AM UTC-5, Amitesh Sahay wrote:
> Hello Members,
> 
> 
> I have below requirements for a project where I need to develop the model 
> based on "multiple Choice Questions". Below are the criteria:-
> 
> 
> 
> Admin can create/edit/delete(soft delete only) a "Test" in the form of 
> MCQs.Admin can then create/edit/delete a "Question"
>  to each test. Each question contains the actual question, the correct 
> answer and 3 incorrect answers. An admin can mark a question as mandatory or 
> optional. An optional question can be skipped by the student.Admin can also 
> set the marks for each questionStudent
>  can view a testStudent can attempt a test. Every test can be attempted 
> multiple times. Each attempt is scored and saved separately. Since the 
> questions are in MCQ format, the students answers are auto-evaluated by the 
> application.
> 
> 
> This is something very new for me. So, I am little reluctant on how to create 
> the model for the above requirement. Here I do not need to develop any 
> authentication environment. 
> 
> 
> 
> Any help would be highly appreciated.
> 
> 
> 
> 
> 
> 
> 
> Regards,
> Amitesh

-- 
You received this message because you are subscribed to the Google Groups 
"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/8c6eb210-dfe4-42e4-8d16-71aa78ebceb5%40googlegroups.com.


Re: Problem trying to use postgresql and psycopg2 in a django project

2019-11-20 Thread Yoo
Hey, I think for OSX (Mac) or anything using the Darwin OS (basically apple) 
has to use psycopg2’s binary. Just install psycopg2-binary and it should work.

On Wednesday, November 20, 2019 at 6:50:01 AM UTC-5, tramites xpress drive 
wrote:
> Hi, I Have been trying to setup my django 2 developement environment and to 
> connect it to postgresql but whern I change the parameters in settings.py on 
> the sections of DATABASES to use POSTGRES and Psycopg2  I Receive the 
> following error
> 
> 
> 
> 
> 
> 
> 
> eztve) Indiras-MBP-16a3:ezt Sindira$ python manage.py runserver
> 
> 
> 
> 
> 
> Watching for file changes with StatReloader
> 
> Exception in thread django-main-thread:
> 
> Traceback (most recent call last):
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/backends/postgresql/base.py",
>  line 20, in 
> 
>     import psycopg2 as Database
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/psycopg2/__init__.py",
>  line 50, in 
> 
>     from psycopg2._psycopg import (                     # noqa
> 
> ImportError: 
> dlopen(/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so,
>  2): Library not loaded: libssl.1.1.dylib
> 
>   Referenced from: 
> /Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so
> 
>   Reason: image not found
> 
> 
> 
> 
> 
> During handling of the above exception, another exception occurred:
> 
> 
> 
> 
> 
> Traceback (most recent call last):
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py",
>  line 926, in _bootstrap_inner
> 
>     self.run()
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py",
>  line 870, in run
> 
>     self._target(*self._args, **self._kwargs)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/utils/autoreload.py",
>  line 54, in wrapper
> 
>     fn(*args, **kwargs)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/core/management/commands/runserver.py",
>  line 109, in inner_run
> 
>     autoreload.raise_last_exception()
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/utils/autoreload.py",
>  line 77, in raise_last_exception
> 
>     raise _exception[1]
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/core/management/__init__.py",
>  line 337, in execute
> 
>     autoreload.check_errors(django.setup)()
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/utils/autoreload.py",
>  line 54, in wrapper
> 
>     fn(*args, **kwargs)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/__init__.py",
>  line 24, in setup
> 
>     apps.populate(settings.INSTALLED_APPS)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/apps/registry.py",
>  line 114, in populate
> 
>     app_config.import_models()
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/apps/config.py",
>  line 211, in import_models
> 
>     self.models_module = import_module(models_module_name)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/importlib/__init__.py", 
> line 127, in import_module
> 
>     return _bootstrap._gcd_import(name[level:], package, level)
> 
>   File "", line 1006, in _gcd_import
> 
>   File "", line 983, in _find_and_load
> 
>   File "", line 967, in _find_and_load_unlocked
> 
>   File "", line 677, in _load_unlocked
> 
>   File "", line 728, in exec_module
> 
>   File "", line 219, in _call_with_frames_removed
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/contrib/auth/models.py",
>  line 2, in 
> 
>     from django.contrib.auth.base_user import AbstractBaseUser, 
> BaseUserManager
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/contrib/auth/base_user.py",
>  line 47, in 
> 
>     class AbstractBaseUser(models.Model):
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/models/base.py",
>  line 117, in __new__
> 
>     new_class.add_to_class('_meta', Options(meta, app_label))
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/models/base.py",
>  line 321, in add_to_class
> 
>     value.contribute_to_class(cls, name)
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/models/options.py",
>  line 204, in contribute_to_class
> 
>     self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
> 
>   File 
> "/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/__init__.py",
>  line 28, in __getattr__
> 
>     return getattr(connections[DEFAULT_DB_ALIAS], item)
> 
>   File 
> 

Re: Django authentication best practice

2019-11-20 Thread Yoo
Whenever I deploy an app, I always use cookiecutter-django. I’m pretty sure 
there is an option lying somewhere in the settings that let you disable 
username. If not, I believe the BaseUser model has the option of the unique 
identifier or username be set to the email itself.

Otherwise, you can do what you said, which is abstractbaseuser model. Or you 
can setup a manager class. Check the Django source code for a little more 
insight.

On Wednesday, November 20, 2019 at 6:50:01 AM UTC-5, mmk mmk wrote:
> I want to replace django default username and password authentication with 
> email and password authentication,
> i have many solution like extends Abstractbaseuser or using 3rd part like 
> django-allauth .
> My question now which is best practice to using to do 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/e9dbd28e-3fc0-4954-bdd4-12938f80e24d%40googlegroups.com.


Re: Correct Design: one app depending on another app

2019-11-20 Thread Andrew C.
I’m not sure what you mean by content management, so I’m gonna take a
guess: website builder like Weebly or Wix. You need a NoSQL database,
completely unstructured data. Kind of like a crime file drawer with folders
dedicated to each case and all its evidence. Some folders only have one
piece of evidence and others a whole lot, right?

By the looks of it, you’re making some revolutionary Weebly or Wix or
whatever with some custom features. If so, here’s what I’d recommend:

1) Read up on how jinja is developed. Jinja is the templating thing we use
in Django, for example: { if user.is_authenticated}
This will help you layout each individual website.

2) Use an unstructured database, like MongoDB or Cassandra. I almost always
tell people you should never have to use a NoSQL db, but in your case, it
might work. Take MongoDB’s document-based schema: each document belongs to
a single website. Within each document would be the site’s content using
keys as a way to input the key’s values on to the website (hopefully that
makes sense) using a jinja inspired template.

The thing I’m confused about is your media app. So I’m gonna guess again
and hopefully you can clear it up for me if need be. If not, still lemme
know.

Let’s say — I’m imagining a website builder like Wix and Weebly right now
btw — that a user drags some music container onto his/her website. The user
adds music and stuff via a different app? I don’t think that’s necessary
unless you code this part in C (for finding the files. Read on for what I
mean).

If you’re not using AWS with cookiecutter-django for deployment, I’d
recommend you go to The Eye (somewhere on Reddit and Discord or their
website) to figure out how to name these uploaded files or make some sort
of system to find these files quickly while keeping them private from other
users (by replacing uploaded file names with extremely long names. That’s
how Dropbox does it I believe).

The Eye is like an Archive team. They’re lovely and helpful people,
especially regarding data hoarding which you’re project might entail in...

I try my best to help completely new Django members with great ideas start
their journey or make that giant leap. So if this shit made no sense, don’t
feel frustrated when you could simply clarify some stuff for me. Good luck!

On Wed, Nov 20, 2019 at 8:42 AM Random Body Parts 
wrote:

> So I want to realise a small content management system. I want to make an
> app that allows for the creation of site content. A site content element
> can be a headline, an image, a block of text, etc... Individual content
> elements will be associated with a content container, which is essentially
> a list. A simple blog article would for instance contain a headline and a
> text block. The site content app will also provide its services for other
> apps. For instance there will be an archive for media files (images, music
> in the form of mp3, videos, etc...). So another content container would be
> a music album. It would be made up of a headline, an image (the cover
> artwork) and a list of music files. Now here it gets a little bit more
> complex. The media files will be handled by yet another app. So the content
> container for a music album would incorporate the headline from the site
> content app, but it would also incorporate the media files from the media
> files app, yet it would be displayed by the archive app.
> The before mentioned apps don't really have a hierarchical relationship.
> My instinct tells me that all the content container elements (blog article,
> music album, image gallery, etc...) should all be living insidethe site
> content app. However the site content app would then depend on all sorts of
> models from other apps. So is this the correct way to go about it? I want
> the site content app to be pluggable by itself. Now for the more complex
> container elements I need external models. So I'm thinking I would do a
> conditional import, kinda like this:
>
> try:
> import jsonexcept ImportError:
> import simplejson as json
>
> So then the more complex container models would only be available if the
> needed apps and their models are present.
> Any advice on this design approach is very welcome.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/e479e9bf-0bbd-4197-8930-1f2c65d2689f%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 

Re:

2019-11-20 Thread Paras Jain
i need the code i am not able to understand by reading documenetation

On Thu, Nov 21, 2019 at 1:34 AM Kasper Laudrup 
wrote:

> Hi Paras,
>
> I hope I'm mistaken but these lines:
>
> On 20/11/2019 18.52, Paras Jain wrote:
> >  user = User.objects.get(email=email)
> >  if user.password == password:
> >
>
> Makes it look like you are storing users passwords in cleartext.
>
> If that is correct, then please don't do that. Never, ever. This is
> hopefully just a hobby project, but still it's good to do things
> correctly and learn good habits from the beginning.
>
> Considering your question, you generally can't as HTTP is basically
> stateless, so the "details" view doesn't know about the user object you
> created in your "login" view.
>
> A workaround for this is using session cookies which isn't exactly
> trivial to handle, so thankfully Django provides a way to make that very
> transparent with Django authentication:
>
> https://docs.djangoproject.com/en/2.2/topics/auth/
>
> If you read up on that documentation you would find the answer to your
> question.
>
> It seems a bit like your trying to reinvent something Django already
> provides for you, I could be wrong of course.
>
> 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/6529ab99-2733-6511-dc86-2e8f69a7cbc0%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/CAMtmBS_kd9TghqeoU99H2fjWh3ta920yzE%2B3aH7AdmODDFpX5A%40mail.gmail.com.


Re:

2019-11-20 Thread Paras Jain
but i have passed two argument in login function its showing error
  if user.type == 'Normal':
print('hobbies : ', user.hobbies)
return detail(request, user)

def detail(request):
print('hobbies : ', user.hobbies)
return render(request, 'company/detail.html',{'details':request.user})

it wont work tell me what should i do to get at render page

On Thu, Nov 21, 2019 at 1:04 AM Jordan Micle 
wrote:

> def detail(request,user):
>> print('hobbies : ', user.hobbies)
>> return render(request, 'company/detail.html',{'details':user})
>>
>
> change detail function like this
> def detail(request):
> print('hobbies : ', user.hobbies)
> return render(request, 'company/detail.html',{'details':request.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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3f6f3d82-63cf-45ff-99da-e008d2cd3841%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/CAMtmBS8oF0CD%3DAqcmw8KwGPoXr5NoNXVsi%2Bg7pyfC-MUW4Tfbw%40mail.gmail.com.


Re: DRF UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6

2019-11-20 Thread Aldian Fazrihady
I guess texts in your database is encoded using other than UTF-8.

Please change `getline(self.filename, ..)` to
`getline(self.filename.decode('utf-16'), ..`

On Mon, Oct 21, 2019 at 7:48 PM Kerstin Rohm <
kerstin.r...@ibmt.fraunhofer.de> wrote:

> Dear Django Community,
>
>
> we have a curious encoding error and we are running out of ideas to solve
> the problem.
>
> We build a Django REST Service with the following packages:
>
>
>
> dj-database-url 0.5.0
>
> Django 2.2.1
>
> django-filter 2.1.0
>
> django-oauth-toolkit 1.2.0
>
> django-widget-tweaks 1.4.3
>
> djangorestframework 3.9.3
>
> python-decouple 3.1
>
> argon2-cffi 19.1.0
>
> plotly 4.1.1
>
>
> When we call a specific REST function (e.g.
>
> *@api_view*([*'POST'*])
>
> *@permission_classes*([AllowAny])
>
> def *token*(request):
>
> r = requests.post(*'http://127.0.0.1:8000/rest/oauth2/token/
> '*,
>
>   data={*'grant_type'* : *'password'*,
>
> *'username'* : request.data[*'username'*],
>
> *'password'* : request.data[*'password'*],
>
> *'client_id'* : settings.REST_CLIENT_ID,
>
> *'client_secret'* :
> settings.REST_CLIENT_SECRET,},)
>
> return Response(r.json())
>
> )
>
>
> We are getting a UFT8 encoding error (Traceback see below). The content of
> “data” seems to be ok:
>
>
> data= {'grant_type': 'password', 'username': 'x', 'password': 'x',
> 'client_id': 'TQmAHzCM2r9nfkruVQw0eMQ0AziSvLAnf4ufvZ1o', 'client_secret':
> 'GISUGXxa2e4JHejUCImMMUMJMtZ13byvc8fySUvX7shELNLPE5xZBA3p0cvbXvvrPIWgltSkTNZ9a7JHPQswEKHzZEDkl21ekS3T6NefUrzVFsdyRS0A2qOHL1L4Nra5'}
>
>
> We have the same error on our testing LINUX system and our development
> environment on windows. We tried to call the REST function via local
> testing method, Android app and CURL – same behavior.
>
> The settings of UNICODE_JSON = True/False causes no difference.
>
>
> We tried it with a REST function without OAUTH Token creation (username
> and password credentials) – same behavior.
>
>
> But – when we call the function with the arguments REST_CLIENT_ID and
> REST_CLIENT_SECRET the function is working fine:
>
> curl -X POST -d 
> "grant_type=password=emilia.muel...@email.com=qwertzui"
> -u"VAOpqwqOTl99jRVXY63Bv5uNXs2MpJWUlZSwSZBf:cgrDaIjPyAy45Z1yxarT0iP9UOjw7gvbpnMirgwz24A56EeJGONHYSsqs9eVPHAyLrsPZdwfdQxoGPnM4LFtihltxlrX24hCQIIE57JezwSHIJab9VjTwAjS9LxYFVJm"
> "127.0.0.1:8000/rest/oauth2/token/"
>
> response: {"access_token": "Fz7yTNSsdUxRaWuMj4Sf4OnPe0Ujf6", "expires_in":
> 3000, "token_type": "Bearer", "scope": "read write", "refresh_token":
> "r9H5E8MK5AAy57ZdiFUJaWaJT63kJL"}
>
>
> But – when we tried to call the other functions with this token and are 
> getting the same encoding error (traceback below):
>
>
>
> curl -X GET -H "Authorization: Bearer Fz7yTNSsdUxRaWuMj4Sf4OnPe0Ujf6"
> 127.0.0.1:8000/rest/patient/1
>
> Everything worked fine a few weeks ago, but after a database change the
> problem occurs. Setting the DB Model to the previous entries was not
> successful.
>
>
> It would be really great if some of you would have any idea what is
> working wrong here!
>
> Thanks in advance!
>
>
> Kerstin and Romy
>
>
> ---
> Traceback
>
>
> Traceback (most recent call last):
>   File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", 
> line 34, in inner
> response = get_response(request)
>   File "C:\Python37\lib\site-packages\django\core\handlers\base.py", line 
> 115, in _get_response
> response = self.process_exception_by_middleware(e, request)
>   File "C:\Python37\lib\site-packages\django\core\handlers\base.py", line 
> 113, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File "C:\Python37\lib\site-packages\django\views\decorators\csrf.py", line 
> 54, in wrapped_view
> return view_func(*args, **kwargs)
>   File "C:\Python37\lib\site-packages\django\views\generic\base.py", line 71, 
> in view
> return self.dispatch(request, *args, **kwargs)
>   File "C:\Python37\lib\site-packages\rest_framework\views.py", line 495, in 
> dispatch
> response = self.handle_exception(exc)
>   File "C:\Python37\lib\site-packages\rest_framework\views.py", line 455, in 
> handle_exception
> self.raise_uncaught_exception(exc)
>   File "C:\Python37\lib\site-packages\rest_framework\views.py", line 492, in 
> dispatch
> response = handler(request, *args, **kwargs)
>   File "C:\Users\andresr\InsisT\Server\insist_rest\views.py", line 93, in get
> return Response(self.serializer_class(patient[0]).data, 
> status=status.HTTP_200_OK)
>   File "C:\Python37\lib\site-packages\rest_framework\response.py", line 32, 
> in __init__
> super(Response, self).__init__(None, status=status)
>   File "C:\Python37\lib\site-packages\django\template\response.py", line 36, 
> in __init__
> super().__init__('', content_type, status, charset=charset)
>  

Re: DRF UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6

2019-11-20 Thread Sarah Werker
On Monday, October 21, 2019 at 8:49:02 AM UTC-4, Kerstin Rohm wrote:
> Dear Django Community,
> 
> I think you should call me at 574-217-1330 or text and we can discuss it
> 
> 
> we have a curious encoding error and we are running out of ideas to
> solve the problem.
> 
> 
> We build a Django REST Service with the following packages: 
> 
> 
>  
> 
> 
> dj-database-url 0.5.0
> 
> 
> Django 2.2.1
> 
> 
> django-filter 2.1.0
> 
> 
> django-oauth-toolkit 1.2.0
> 
> 
> django-widget-tweaks 1.4.3
> 
> 
> djangorestframework 3.9.3
> 
> 
> python-decouple 3.1
> 
> 
> argon2-cffi 19.1.0
> 
> 
> plotly 4.1.1
> 
> 
> 
> 
> When we call a specific REST function (e.g.
> 
> 
> @api_view(['POST'])
> 
> 
> @permission_classes([AllowAny])
> 
> 
> def token(request):
> 
> 
>    
> r = requests.post('http://127.0.0.1:8000/rest/oauth2/token/',
> 
> 
>   data={'grant_type' : 'password',
> 
> 
>     'username' : request.data['username'],
> 
> 
>     'password' : request.data['password'],
> 
> 
>     'client_id' :
> settings.REST_CLIENT_ID,
> 
> 
>     'client_secret' :
> settings.REST_CLIENT_SECRET,},)
> 
> 
>     return
> Response(r.json())
> 
> 
> )
> 
> 
> 
> 
> We are getting a UFT8 encoding error (Traceback see below).
> The content of “data” seems to be ok:
> 
> 
> 
> 
> data=
> {'grant_type': 'password', 'username': 'x', 'password': 'x', 'client_id':
> 'TQmAHzCM2r9nfkruVQw0eMQ0AziSvLAnf4ufvZ1o', 'client_secret':
> 'GISUGXxa2e4JHejUCImMMUMJMtZ13byvc8fySUvX7shELNLPE5xZBA3p0cvbXvvrPIWgltSkTNZ9a7JHPQswEKHzZEDkl21ekS3T6NefUrzVFsdyRS0A2qOHL1L4Nra5'}
> 
> 
> 
> 
> We have the same
> error on our testing LINUX system and our development environment on windows.
> We tried to call the REST function via local testing method, Android app and
> CURL – same behavior.
> 
> 
> The settings of UNICODE_JSON = True/False causes no difference.
> 
> 
> 
> 
> We tried it with a
> REST function without OAUTH Token creation (username and password 
> credentials) –
> same behavior.
> 
> 
> 
> 
> But – when we call
> the function with the arguments REST_CLIENT_ID and REST_CLIENT_SECRET
> the function is working fine: 
> 
> 
> curl -X POST -d
> "grant_type=password=emilia.muel...@email.com=qwertzui"
> -u"VAOpqwqOTl99jRVXY63Bv5uNXs2MpJWUlZSwSZBf:cgrDaIjPyAy45Z1yxarT0iP9UOjw7gvbpnMirgwz24A56EeJGONHYSsqs9eVPHAyLrsPZdwfdQxoGPnM4LFtihltxlrX24hCQIIE57JezwSHIJab9VjTwAjS9LxYFVJm"
> "127.0.0.1:8000/rest/oauth2/token/"
> 
> 
> response: {"access_token":
> "Fz7yTNSsdUxRaWuMj4Sf4OnPe0Ujf6", "expires_in": 3000,
> "token_type": "Bearer", "scope": "read
> write", "refresh_token": "r9H5E8MK5AAy57ZdiFUJaWaJT63kJL"}
> 
> 
> 
> But – when we tried to call the other functions with this token and are 
> getting the same encoding error (traceback below):  
> 
> 
> curl -X GET -H
> "Authorization: Bearer Fz7yTNSsdUxRaWuMj4Sf4OnPe0Ujf6"
> 127.0.0.1:8000/rest/patient/1
> 
> 
> Everything worked
> fine a few weeks ago, but after a database change the problem occurs. Setting
> the DB Model to the previous entries was not successful.
> 
> 
> 
> 
> It would be really
> great if some of you would have any idea what is working wrong here!
> Thanks in advance!
> 
> 
> Kerstin and Romy
> 
> 
> 
>  
> 
> 
> ---
> 
> Traceback
> 
>   
> Traceback (most recent call last):
>   File "C:\Python37\lib\site-packages\django\core\handlers\exception.py", 
> line 34, in inner
> response = get_response(request)
>   File "C:\Python37\lib\site-packages\django\core\handlers\base.py", line 
> 115, in _get_response
> response = self.process_exception_by_middleware(e, request)
>   File "C:\Python37\lib\site-packages\django\core\handlers\base.py", line 
> 113, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File "C:\Python37\lib\site-packages\django\views\decorators\csrf.py", line 
> 54, in wrapped_view
> return view_func(*args, **kwargs)
>   File "C:\Python37\lib\site-packages\django\views\generic\base.py", line 71, 
> in view
> return self.dispatch(request, *args, **kwargs)
>   File "C:\Python37\lib\site-packages\rest_framework\views.py", line 495, in 
> dispatch
> response = self.handle_exception(exc)
>   File "C:\Python37\lib\site-packages\rest_framework\views.py", line 455, in 
> handle_exception
> self.raise_uncaught_exception(exc)
>   File "C:\Python37\lib\site-packages\rest_framework\views.py", line 492, in 
> dispatch
> response = handler(request, *args, **kwargs)
>   File "C:\Users\andresr\InsisT\Server\insist_rest\views.py", line 93, in get
> return Response(self.serializer_class(patient[0]).data, 
> status=status.HTTP_200_OK)
>   File "C:\Python37\lib\site-packages\rest_framework\response.py", line 32, 
> in __init__
> super(Response, self).__init__(None, status=status)
>   File "C:\Python37\lib\site-packages\django\template\response.py", line 36, 
> in __init__
> 

Re:

2019-11-20 Thread Kasper Laudrup

Hi Paras,

I hope I'm mistaken but these lines:

On 20/11/2019 18.52, Paras Jain wrote:

                 user = User.objects.get(email=email)
                 if user.password == password:



Makes it look like you are storing users passwords in cleartext.

If that is correct, then please don't do that. Never, ever. This is 
hopefully just a hobby project, but still it's good to do things 
correctly and learn good habits from the beginning.


Considering your question, you generally can't as HTTP is basically 
stateless, so the "details" view doesn't know about the user object you 
created in your "login" view.


A workaround for this is using session cookies which isn't exactly 
trivial to handle, so thankfully Django provides a way to make that very 
transparent with Django authentication:


https://docs.djangoproject.com/en/2.2/topics/auth/

If you read up on that documentation you would find the answer to your 
question.


It seems a bit like your trying to reinvent something Django already 
provides for you, I could be wrong of course.


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/6529ab99-2733-6511-dc86-2e8f69a7cbc0%40stacktrace.dk.


Re:

2019-11-20 Thread Jordan Micle

>
> def detail(request,user):
> print('hobbies : ', user.hobbies)
> return render(request, 'company/detail.html',{'details':user})
>

change detail function like this 
def detail(request):
print('hobbies : ', user.hobbies)
return render(request, 'company/detail.html',{'details':request.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3f6f3d82-63cf-45ff-99da-e008d2cd3841%40googlegroups.com.


[no subject]

2019-11-20 Thread Paras Jain
my render function its not working in detail function its not rendering to
detail.html.please help any one

views.py:
def detail(request,user):
print('hobbies : ', user.hobbies)
return render(request, 'company/detail.html',{'details':user})

def login(request):
if request.method == 'POST':
email  = request.POST['email']
password = request.POST['password']

user = User.objects.get(email=email)

if user.password == password:

if user.type == 'Manager':
return redirect('company-add')

if user.type == 'Normal':
print('hobbies : ', user.hobbies)
return detail(request, user) #calling the detail
function
else:
messages.success(request, 'invalids credentials')
return redirect('company-login')

else:
return render(request, 'company/login.html')

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

urlpatterns=[
path('', views.home, name='company-home'),
path('register/', views.register, name='company-register'),
path('detail/', views.detail, name='company-detail'),
path('login/', views.login, name='company-login'),
path('add/', views.add, name='company-add'),

]

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAMtmBS-nQC5D1XGdSJxck2E46ouMdAmNciE58LcbwBCVpVCBjw%40mail.gmail.com.


Re: Directly Accessing Dictionary Values

2019-11-20 Thread Andrew Stringfield
I have not!  I did see something about that on a website.  Would it go 
something like: dictionary_name.fieldname.0 ?  I will try it out later today.

-- 
You received this message because you are subscribed to the Google Groups 
"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/f1615df3-04bc-4a28-9914-535c51f13268%40googlegroups.com.


Re: Directly Accessing Dictionary Values

2019-11-20 Thread Jim Illback
Have you tried  for the first element, and so forth? Of 
course, you have to keep track of the number of entries.


> On Nov 20, 2019, at 5:57 AM, Andrew Stringfield  wrote:
> 
> Okie-dokie.  Thank you.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/83187d02-2f28-4652-8986-83dfcd65108e%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/38AB6CE6-A1D1-4E9F-90F7-0DA1417B76BF%40hotmail.com.


Re:

2019-11-20 Thread Paras Jain
  'user = User.objects.get(email=email) '  i have to pass this 'user'
instance  from login function to detail function  in django

  views.py:

def login(request):
if request.method == 'POST':
email  = request.POST['email']
password = request.POST['password']

user = User.objects.get(email=email)
if user.password == password:

if user.type == 'Manager':
return redirect('company-add')


if user.type == 'Normal':
details = user# i want this instance
user  to be passed onto detail function


#return
redirect('company-detail',{'details':details})


else:
messages.success(request, 'invalids credentials')
return redirect('company-login')

else:
return render(request, 'company/login.html')

def detail(request):

return render(request, 'company/detail.html')



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

urlpatterns=[
path('', views.home, name='company-home'),
path('register/', views.register, name='company-register'),
path('detail/', views.detail, name='company-detail'),
path('login/', views.login, name='company-login'),
path('add/', views.add, name='company-add'),



On Wed, Nov 20, 2019 at 9:07 PM Bob Gailer  wrote:

> On Nov 20, 2019 10:27 AM, "Paras Jain"  wrote:
> >
> > how to take pass one object of one function to other in django
>
> I do not understand your question. Perhaps someone else will understand it
> and give you the answer you're seeking. If you don't get an answer please
> try restating your question or give us an example of what you're trying to
> do.
>
> Bob Gailer
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAP1rxO4fZcKofjNFkF9VNkW%3DMPrRD%3DcBfOz8xKq-z2_HcHqhKA%40mail.gmail.com
> 
> .
>

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


Re:

2019-11-20 Thread Bob Gailer
On Nov 20, 2019 10:27 AM, "Paras Jain"  wrote:
>
> how to take pass one object of one function to other in django

I do not understand your question. Perhaps someone else will understand it
and give you the answer you're seeking. If you don't get an answer please
try restating your question or give us an example of what you're trying to
do.

Bob Gailer

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAP1rxO4fZcKofjNFkF9VNkW%3DMPrRD%3DcBfOz8xKq-z2_HcHqhKA%40mail.gmail.com.


[no subject]

2019-11-20 Thread Paras Jain
how to take pass one object of one function to other in 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/CAMtmBS9f-vgmp80t6zj6txi1BMKM8aSnW0avQkL2khy1Yj_few%40mail.gmail.com.


Re: bootstrap4 panel as card plugin is not working in djangocms

2019-11-20 Thread হজমুলা খান
hi everyone

sorry for the post as i have solved it by myself rght now using text 
plugin. i am sharing the code, if any one needs:


  
Card title
Card subtitle
Some quick example text to build on the card title and 
make up the bulk of the card's content.
  


actually i copied it from bootstrap4 website and it worked. now i need to 
tune it. besides before doing that i have selected the column size 
according to the screen requirement.

thanks :)
On Wednesday, November 20, 2019 at 2:16:04 PM UTC, হজমুলা খান wrote:
>
> hi
>
> i am working on a project of bootstrap4 website where i require to make 
> panels in 3 columns. i am using djangocms (the latest version). but there 
> is no panel under any column. so i tried with card but this plugin has no 
> title and text option. what should i do? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/cc1431c3-357e-4123-9cb8-2aae51f1864f%40googlegroups.com.


bootstrap4 panel as card plugin is not working in djangocms

2019-11-20 Thread হজমুলা খান
hi

i am working on a project of bootstrap4 website where i require to make 
panels in 3 columns. i am using djangocms (the latest version). but there 
is no panel under any column. so i tried with card but this plugin has no 
title and text option. what should i do? 

-- 
You received this message because you are subscribed to the Google Groups 
"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/438df501-816e-4783-aa75-b8ba260935dc%40googlegroups.com.


Re: Directly Accessing Dictionary Values

2019-11-20 Thread Andrew Stringfield
Okie-dokie.  Thank you.

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


Re: Directly Accessing Dictionary Values

2019-11-20 Thread Suraj Thapa FC
You can't

On Wed, 20 Nov 2019, 3:57 pm Andrew Stringfield, 
wrote:

> First, thank you for the reply Suraj!  I think that I misstated what I was
> really trying to do.  I am trying to access the dictionary values directly
> in the Template and not in the View.  I am trying to remove:
>
> {% for question in unique_key_object %}
>{{ question.filename }}
>{% endfor %}
>
> and just have:
> {{ unique_key_object.filename }}
>
>
>
>
> On Tuesday, November 19, 2019 at 10:59:07 PM UTC-5, Suraj Thapa FC wrote:
>>
>> Return the unique key object... Like
>> return render(request, 'abc.html',unique_key)
>>
>> On Wed, 20 Nov 2019, 9:18 am Andrew Stringfield, 
>> wrote:
>>
>>> Hello all,
>>>
>>>  I am trying to access Dictionary values directly.  Here is my view:
>>>
>>> def unique_key_query(request, unique_key):
>>> unique_key_object =
>>> simpleformmodel.objects.all().filter(id=unique_key)
>>> context = {'unique_key_object': unique_key_object}
>>> return render(request, "bash_file_page.html", context)
>>>
>>> Here is my template:
>>> {% if unique_key_object %}
>>> {% for question in unique_key_object %}
>>> {{ question.filename }}
>>> {% endfor %}
>>> {% else %}
>>> No data is available.
>>> {% endif %}
>>>
>>> I can access Dictionary values with a for loop, but I just do not want
>>> to do that.  How can I access the values directly?
>>>
>>> Thank you.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/b8ee9cc4-1d49-4464-b181-583042182576%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/5dc09b06-1daa-432f-b31d-18a698bb0b4b%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/CAPjsHcFwibVAc%2BaiJs76D_Yn%3D1CyO%3DmY%3DvGxoDOn%3DgLTzEYGLw%40mail.gmail.com.


Correct Design: one app depending on another app

2019-11-20 Thread Random Body Parts
So I want to realise a small content management system. I want to make an 
app that allows for the creation of site content. A site content element 
can be a headline, an image, a block of text, etc... Individual content 
elements will be associated with a content container, which is essentially 
a list. A simple blog article would for instance contain a headline and a 
text block. The site content app will also provide its services for other 
apps. For instance there will be an archive for media files (images, music 
in the form of mp3, videos, etc...). So another content container would be 
a music album. It would be made up of a headline, an image (the cover 
artwork) and a list of music files. Now here it gets a little bit more 
complex. The media files will be handled by yet another app. So the content 
container for a music album would incorporate the headline from the site 
content app, but it would also incorporate the media files from the media 
files app, yet it would be displayed by the archive app.
The before mentioned apps don't really have a hierarchical relationship. My 
instinct tells me that all the content container elements (blog article, 
music album, image gallery, etc...) should all be living insidethe site 
content app. However the site content app would then depend on all sorts of 
models from other apps. So is this the correct way to go about it? I want 
the site content app to be pluggable by itself. Now for the more complex 
container elements I need external models. So I'm thinking I would do a 
conditional import, kinda like this:

try:
import jsonexcept ImportError:
import simplejson as json

So then the more complex container models would only be available if the 
needed apps and their models are present.
Any advice on this design approach is very welcome.

-- 
You received this message because you are subscribed to the Google Groups 
"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/e479e9bf-0bbd-4197-8930-1f2c65d2689f%40googlegroups.com.


Problem trying to use postgresql and psycopg2 in a django project

2019-11-20 Thread tramites xpress drive
 

*Hi, I Have been trying to setup my django 2 developement environment and 
to connect it to postgresql but whern I change the parameters in 
settings.py on the sections of DATABASES to use POSTGRES and Psycopg2  I 
Receive the following error*



eztve) Indiras-MBP-16a3:ezt Sindira$ python manage.py runserver


Watching for file changes with StatReloader

Exception in thread django-main-thread:

Traceback (most recent call last):

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/backends/postgresql/base.py",
 
line 20, in 

import psycopg2 as Database

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/psycopg2/__init__.py",
 
line 50, in 

from psycopg2._psycopg import ( # noqa

ImportError: 
dlopen(/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so,
 
2): Library not loaded: libssl.1.1.dylib

  Referenced from: 
/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so

  Reason: image not found


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File 
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", 
line 926, in _bootstrap_inner

self.run()

  File 
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", 
line 870, in run

self._target(*self._args, **self._kwargs)

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/utils/autoreload.py",
 
line 54, in wrapper

fn(*args, **kwargs)

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/core/management/commands/runserver.py",
 
line 109, in inner_run

autoreload.raise_last_exception()

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/utils/autoreload.py",
 
line 77, in raise_last_exception

raise _exception[1]

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/core/management/__init__.py",
 
line 337, in execute

autoreload.check_errors(django.setup)()

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/utils/autoreload.py",
 
line 54, in wrapper

fn(*args, **kwargs)

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/__init__.py",
 
line 24, in setup

apps.populate(settings.INSTALLED_APPS)

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/apps/registry.py",
 
line 114, in populate

app_config.import_models()

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/apps/config.py",
 
line 211, in import_models

self.models_module = import_module(models_module_name)

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/importlib/__init__.py", 
line 127, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

  File "", line 1006, in _gcd_import

  File "", line 983, in _find_and_load

  File "", line 967, in _find_and_load_unlocked

  File "", line 677, in _load_unlocked

  File "", line 728, in exec_module

  File "", line 219, in 
_call_with_frames_removed

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/contrib/auth/models.py",
 
line 2, in 

from django.contrib.auth.base_user import AbstractBaseUser, 
BaseUserManager

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/contrib/auth/base_user.py",
 
line 47, in 

class AbstractBaseUser(models.Model):

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/models/base.py",
 
line 117, in __new__

new_class.add_to_class('_meta', Options(meta, app_label))

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/models/base.py",
 
line 321, in add_to_class

value.contribute_to_class(cls, name)

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/models/options.py",
 
line 204, in contribute_to_class

self.db_table = truncate_name(self.db_table, 
connection.ops.max_name_length())

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/__init__.py",
 
line 28, in __getattr__

return getattr(connections[DEFAULT_DB_ALIAS], item)

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/utils.py",
 
line 201, in __getitem__

backend = load_backend(db['ENGINE'])

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/utils.py",
 
line 110, in load_backend

return import_module('%s.base' % backend_name)

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/importlib/__init__.py", 
line 127, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

  File 
"/Users/Sindira/Documents/ezt/eztve/lib/python3.7/site-packages/django/db/backends/postgresql/base.py",
 

Re: mysql data connectivity problem

2019-11-20 Thread Bill Hughes
no

From: django-users@googlegroups.com  on behalf 
of Franz Ulenaers 
Sent: Tuesday, November 19, 2019 5:15 PM
To: Django users 
Subject: Re: mysql data connectivity problem

Hi,
Do you want to write a python program which read a sqlite3 database and maybe 
do some updates and/or create new records in the database ?




--
You received this message because you are subscribed to the Google Groups 
"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/8bdbafa4-9815-4683-b0f2-d86068614799%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/BN3PR07MB25649593C3933E8C5AD8BAE4C24C0%40BN3PR07MB2564.namprd07.prod.outlook.com.


Why I am not able to see the post that I write on this group?

2019-11-20 Thread tramites xpress drive
Why I am not able to see the post that I write on this group?

-- 
You received this message because you are subscribed to the Google Groups 
"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/70278677-ed15-424e-bac3-7af6070c8ce5%40googlegroups.com.


Django authentication best practice

2019-11-20 Thread mmk mmk
I want to replace django default username and password authentication with 
email and password authentication,
i have many solution like extends Abstractbaseuser or using 3rd part like 
django-allauth .
My question now which is best practice to using to do 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/1a8f7584-a5bb-412f-9490-a9045ccacf3f%40googlegroups.com.


Re: mysql data connectivity problem

2019-11-20 Thread Chaithanya Reddy
Post a pic of what is error
First connect with the internet
Run it on any other any browser
And next post it what is error, so we can check where the error gets

-- 
You received this message because you are subscribed to the Google Groups 
"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/CALx9%3DGbYhoXcCB%3DmTeEVsabZOF8VscPa3%2BMqZLFbYTSw9o5-%2BA%40mail.gmail.com.


Re: mysql data connectivity problem

2019-11-20 Thread Chaithanya Reddy
Check whether any database connection u have given in your pc
ex:- if u have already installed any mysql data base in your pc,  then
uninstall that mysql application, restart the pc
After that u can connect to the database of django

Next time post with a pic(what is the error is..??)
So that i can see where the error is getting


On Tue, Nov 19, 2019, 6:59 PM Prof soul  wrote:

> Hi i'm soul i'm new to django and late, i got an idea to handle the django
> but  there is still lack of database  connectivity with django anybody know
> about it in easy manner
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/9b619168-8796-4d81-a728-ec34cd9eac11%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/CALx9%3DGZjAcYvZ3CVWRjaQymF4je3h2YwqPDe5wheR-rpHGyeEw%40mail.gmail.com.


Re: Directly Accessing Dictionary Values

2019-11-20 Thread Andrew Stringfield
First, thank you for the reply Suraj!  I think that I misstated what I was 
really trying to do.  I am trying to access the dictionary values directly 
in the Template and not in the View.  I am trying to remove:

{% for question in unique_key_object %}
   {{ question.filename }}
   {% endfor %}

and just have:
{{ unique_key_object.filename }}




On Tuesday, November 19, 2019 at 10:59:07 PM UTC-5, Suraj Thapa FC wrote:
>
> Return the unique key object... Like
> return render(request, 'abc.html',unique_key)
>
> On Wed, 20 Nov 2019, 9:18 am Andrew Stringfield,  > wrote:
>
>> Hello all,
>>
>>  I am trying to access Dictionary values directly.  Here is my view:
>>
>> def unique_key_query(request, unique_key):
>> unique_key_object = 
>> simpleformmodel.objects.all().filter(id=unique_key)
>> context = {'unique_key_object': unique_key_object}
>> return render(request, "bash_file_page.html", context)
>>
>> Here is my template:
>> {% if unique_key_object %}
>> {% for question in unique_key_object %}
>> {{ question.filename }}
>> {% endfor %}
>> {% else %}
>> No data is available.
>> {% endif %}
>>
>> I can access Dictionary values with a for loop, but I just do not want to 
>> do that.  How can I access the values directly?
>>
>> Thank you.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/b8ee9cc4-1d49-4464-b181-583042182576%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/5dc09b06-1daa-432f-b31d-18a698bb0b4b%40googlegroups.com.