Re: Django REST Authenticate with Session in external app

2016-12-27 Thread Chris Bartos
Hello there!

Although you COULD use Session Authentication 

 
to authenticate users from external clients. I don't recommend it. It's 
going to be a pain. Instead what I recommend is using either Token 
Authentication 

 
or OAuth2 Authentication. They both allow you to authenticate from any 
client through the API rather than trying to authenticate through the 
Django view.

I'd be interested in hearing how Session Authentication is working for you 
and if you need help don't hesitate to ask questions about Token 
Authentication or OAuth2 Authentication.

Chris

On Sunday, September 11, 2016 at 5:19:15 PM UTC-4, flaudizio wrote:
>
> Hi guys,
>
> I'm a doubt about Django REST auth and an external app's (mobile, desktop).
>
> When we work with django in browser we have a session auth. To use session 
> it's possible using django rest with an external app created in C sharp ? 
> Or need to work with tokens in external app consulting my Django API REST ?
>
> Thank's 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 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/509835c1-40f8-4640-ae90-8799692a2f7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Authentication for mobile devices

2016-12-27 Thread Chris Bartos
Hi Deep,

In order to authenticate on mobile applications, you'll need to create an 
REST API and authenticate using Token Authentication 

 or 
OAuth2 Authentication (Social Media: Google, Facebook, Twitter, etc.). How 
Token Authentication works is you will create an REST API on a Secure HTTP 
site with a route to a built-in view that sends the user's token. You can 
keep the Token saved for the duration of the session within the mobile app 
and it will prevent the user from logging out.

I hope that works!
Chris

On Friday, April 22, 2016 at 9:09:13 AM UTC-4, Deep Shah wrote:
>
> I am new to Django. I want to know how will authentication work on mobile 
> apps. How do I keep the user logged in on my mobile apps and not make them 
> login every time? Is there any in-built method to save a token or something?
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/ab8b5d96-1ea5-48ef-a6ee-13b6b81e3461%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Single Page Application in Django

2017-01-10 Thread Chris Bartos
Hi,

You don't have to use one or the other. You can use both authentication 
mechanisms. You would just list each authentication mechanism backend in 
your settings.py file. So, what would happen is the authentication 
framework will loop through each of the backends and if one backend fails 
than it moves on to the next one. I hope that helps.

Chris

On Tuesday, March 8, 2016 at 5:59:51 AM UTC-5, nikhil...@gmail.com wrote:
>
> I m also working on SPA with angular.js. One problem I have is regarding 
> authentication. 
>
> We have currently mixture of angular.js and html pages served by django 
> but our new version will be SPA.
> Till now our project was using session authentication (web) & token 
> authentication (mobile). 
>
> I was trying to get password related api on REST.While integrating 
> https://github.com/Tivix/django-rest-auth it seems that in SPA we have to 
> use token authentication on web.
>
> If I allow only token authentication on web + mobile then,
> Will token authentication allow us to serve partial templates? Our 
> template are currently served by django.
>
> -Nikhil
>
> On Monday, 7 March 2016 19:57:06 UTC+5:30, tizonzon wrote:
>>
>> Django Rest Framework. A powerful framework to build REST API on top of 
>> Django.
>>
>> Here's the link http://www.django-rest-framework.org/
>>
>> On Mon, Mar 7, 2016 at 9:19 AM, Bob Gailer  wrote:
>>
>>>
>>> On Mar 7, 2016 7:04 AM, "Avraham Serour"  wrote:
>>> >
>>> >  DRF 
>>> I'll bite - what is DRF? Google does not help with that.
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CAP1rxO7AxoUPEpw85at7dRmAuRWL8FTZAok9-dkO24%3Dh2M7KdA%40mail.gmail.com
>>>  
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>>
>>
>> *Adolphe CHER-AIME*
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/f8e5d785-954e-42c2-bf6c-d487992ab1ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: LookupError: No installed app with label 'admin'.

2019-05-21 Thread Chris Bartos
When in your virtual environment, if you run 'pip install django' it should 
install sqlparse automatically. If not, you have to install it manually. 
'pip install sqlparse'

On Sunday, May 19, 2019 at 10:11:15 PM UTC-4, This is a test message wrote:
>
> Hi,
>
>  
>
> I am new to django and am trying out the tutorial. Get the following error:
>
>1. Create a virtual environment using anaconda
>2. Activate the virtual environment
>3. Create the project
>4. Get the following error when trying to start the server:
>
>  
>
> Directory of C:\Users\bradl\Documents\web sites\poll
>
>  
>
> 2019/05/19  02:25 PM  .
>
> 2019/05/19  02:25 PM  ..
>
> 2019/05/19  02:25 PM   645 manage.py
>
> 2019/05/19  02:26 PM  poll
>
>1 File(s)645 bytes
>
>3 Dir(s)  200 980 545 536 bytes free
>
>  
>
> (pollapp) C:\Users\bradl\Documents\web sites\poll>python manage.py 
> runserver
>
> Watching for file changes with StatReloader
>
> Exception in thread Thread-1:
>
> Traceback (most recent call last):
>
>   File "C:\Users\bradl\Anaconda3\envs\pollapp\lib\threading.py", line 917, 
> in _bootstrap_inner
>
> self.run()
>
>   File "C:\Users\bradl\Anaconda3\envs\pollapp\lib\threading.py", line 865, 
> in run
>
> self._target(*self._args, **self._kwargs)
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\utils\autoreload.py",
>  
> line 54, in wrapper
>
> fn(*args, **kwargs)
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\core\management\commands\runserver.py",
>  
> line 109, in inner_run
>
> autoreload.raise_last_exception()
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\utils\autoreload.py",
>  
> line 77, in raise_last_exception
>
> raise _exception[0](_exception[1]).with_traceback(_exception[2])
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\utils\autoreload.py",
>  
> line 54, in wrapper
>
> fn(*args, **kwargs)
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\__init__.py", 
> line 24, in setup
>
> apps.populate(settings.INSTALLED_APPS)
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\apps\registry.py",
>  
> line 114, in populate
>
> app_config.import_models()
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\apps\config.py",
>  
> line 211, in import_models
>
> self.models_module = import_module(models_module_name)
>
>   File "C:\Users\bradl\Anaconda3\envs\pollapp\lib\importlib\__init__.py", 
> line 127, in import_module
>
> return _bootstrap._gcd_import(name[level:], package, level)
>
>   File "", line 1006, in _gcd_import
>
>   File "", line 983, in _find_and_load
>
>   File "", line 967, in 
> _find_and_load_unlocked
>
>   File "", line 677, in _load_unlocked
>
>   File "", line 728, in exec_module
>
>   File "", line 219, in 
> _call_with_frames_removed
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\contrib\auth\models.py",
>  
> line 2, in 
>
> from django.contrib.auth.base_user import AbstractBaseUser, 
> BaseUserManager
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\contrib\auth\base_user.py",
>  
> line 47, in 
>
> class AbstractBaseUser(models.Model):
>
>  File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\models\base.py",
>  
> line 117, in __new__
>
> new_class.add_to_class('_meta', Options(meta, app_label))
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\models\base.py",
>  
> line 321, in add_to_class
>
> value.contribute_to_class(cls, name)
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\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 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\__init__.py",
>  
> line 28, in __getattr__
>
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\utils.py", 
> line 201, in __getitem__
>
> backend = load_backend(db['ENGINE'])
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\utils.py", 
> line 110, in load_backend
>
> return import_module('%s.base' % backend_name)
>
>   File "C:\Users\bradl\Anaconda3\envs\pollapp\lib\importlib\__init__.py", 
> line 127, in import_module
>
> return _bootstrap._gcd_import(name[level:], package, level)
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\backends\sqlite3\base.py",
>  
> line 28, in 
>
> from .introspection import DatabaseIntrospection# 
> isort:skip
>
>   File 
> "C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\b

Re: Django-admin.py Error

2017-04-17 Thread Chris Bartos
This issue is something to do with your Python version. Uninstall Python 
and install Python 2.7.8 instead of 2.7.7 as it seems there are issues with 
it.

Chris

On Tuesday, May 26, 2015 at 1:06:07 AM UTC-5, Shashwat singh wrote:
>
> Django is properly installed but when i run, django-admin.py it returns 
> the following error.
>
> Traceback (most recent call last):
>   File "/usr/local/bin/django-admin.py", line 5, in 
> management.execute_from_command_line()
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
> line 338, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
> line 312, in execute
> django.setup()
>   File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 
> 15, in setup
> from django.utils.log import configure_logging
>   File "/usr/local/lib/python2.7/site-packages/django/utils/log.py", line 
> 16, in 
> from django.views.debug import ExceptionReporter, 
> get_exception_reporter_filter
>   File "/usr/local/lib/python2.7/site-packages/django/views/debug.py", 
> line 9, in 
> from django.core.urlresolvers import Resolver404, resolve
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 
> 18, in 
> from django.http import Http404
>   File "/usr/local/lib/python2.7/site-packages/django/http/__init__.py", 
> line 2, in 
> from django.http.request import (HttpRequest, QueryDict,
>   File "/usr/local/lib/python2.7/site-packages/django/http/request.py", 
> line 12, in 
> from django.core import signing
>   File "/usr/local/lib/python2.7/site-packages/django/core/signing.py", 
> line 46, in 
> from django.utils.crypto import constant_time_compare, salted_hmac
>   File "/usr/local/lib/python2.7/site-packages/django/utils/crypto.py", 
> line 8, in 
> import hmac
>   File 
> "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py",
>  
> line 8, in 
> from operator import _compare_digest as compare_digest
> ImportError: cannot import name _compare_digest
>
> And here is my python path - when i ran echo $PATH:
>
>
> /Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin
>
>
>
> Please help. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/ce6e2d8d-3fb1-4937-912d-53bce11864a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Data base connection problem

2017-04-17 Thread Chris Bartos
Few things you can do:


   1. Check to make sure your app is in INSTALLED_APPS
   2. Delete the migrations folder and run 'manage.py makemigrations' & 
   'manage.py migrate' again
   3. depending on the name of the app (let's say student) you can try 
   running 'manage.py makemigrations student' & 'manage.py migrate'

Chris

On Saturday, February 13, 2016 at 11:42:23 PM UTC-6, News Latest wrote:
>
> i have made a model  names STUDENT and when i run migrataion no migration 
> applied but when from admin i tried to browse student i got following error
>
> OperationalError at /admin/app/student/
>
> no such table: app_student
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/admin/app/student/
> Django Version: 1.9.2
> Exception Type: OperationalError
> Exception Value: 
>
> no such table: app_student
>
> Exception Location: C:\Users\nauman malik\Google 
> Drive\feedbacknew\feedbacknew\env\lib\site-packages\django\db\backends\sqlite3\base.py
>  
> in execute, line 323
> Python Executable: C:\Users\nauman malik\Google 
> Drive\feedbacknew\feedbacknew\env\Scripts\python.exe
> Python Version: 2.7.10
> Python Path: 
>
> ['C:\\Users\\nauman malik\\Google Drive\\feedbacknew\\feedbacknew',
>  'C:\\Windows\\SYSTEM32\\python27.zip',
>  'C:\\Users\\nauman malik\\Google Drive\\feedbacknew\\feedbacknew\\env\\DLLs',
>  'C:\\Users\\nauman malik\\Google Drive\\feedbacknew\\feedbacknew\\env\\lib',
>  'C:\\Users\\nauman malik\\Google 
> Drive\\feedbacknew\\feedbacknew\\env\\lib\\plat-win',
>  'C:\\Users\\nauman malik\\Google 
> Drive\\feedbacknew\\feedbacknew\\env\\lib\\lib-tk',
>  'C:\\Users\\nauman malik\\Google 
> Drive\\feedbacknew\\feedbacknew\\env\\Scripts',
>  'C:\\Python27\\Lib',
>  'C:\\Python27\\DLLs',
>  'C:\\Python27\\Lib\\lib-tk',
>  'C:\\Users\\nauman malik\\Google Drive\\feedbacknew\\feedbacknew\\env',
>  'C:\\Users\\nauman malik\\Google 
> Drive\\feedbacknew\\feedbacknew\\env\\lib\\site-packages']
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/a344e7e4-8ca4-4211-90ae-7b7a04922d41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New to Django

2016-03-01 Thread Chris Bartos
The best way to use Python especially Django is by creating what is called 
a "Virtual Environment". This is a separate instance of Python that you can 
install all the tools that you need to run your Django app without having 
to messing up your current Python instance.

It will also help to freeze the packages you install which is great for 
deploying to different environments and such. But, the steps are pretty 
much the same everything you create a new Virtual Environment. These steps 
are assuming you use a Unix based operating system. If you are using 
Windows, these steps will be a little different.

Step 1: Install 'virtualenv'

First things first. You need to install virtualenv. You can do this with 
the 'pip' command.

$ pip install virtualenv

Step 2: Create your virtual environment

The next step to creating a virtual environment is to actually create it. 
This step will install an instance of Python and also install Pip for you 
so you can install the packages that you want.

$ virtualenv venv

You can call the virtual environment anything you like. I like to call it 
'venv'

Step 3: Activate the virtual environment

This step will change your Python path so that you will use the virtual 
environment version of Python and Pip. You'll notice that when you enter 
this command, you might see '(venv)' next to your commandline. That's how 
you know that you're running the virtual environment

$ source venv/bin/activate

Step 4: Install your packages

You can then install your packages at this point. You'll be happy to know 
that you're packages will be installed inside of your virtual environment. 
So, when you try to 'import django', the Python interpreter will be able to 
find it.

Step 5: Deactivate your virtual environment

When you are done working on your Django app, and you want to exit from 
your virtual environment, simply call:

$ deactivate

You'll be back to your default Python path.

I hope this helps some. If you have any other questions, please let me know!

On Monday, February 29, 2016 at 8:05:12 PM UTC-5, Gary Dhillon wrote:
>
> I've installed Django and I keep getting no module named django when 
> importing. I have python 3.5.1 and used pip to install django 1.9.2. Its 
> showing up on my python 2.7 though. Any help would be appreciated.
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/7caa0d87-b87e-4928-b3c0-e4ebffec62b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: variable to a template

2016-04-09 Thread Chris Bartos
There are probably 3 ways you can do this:

1) Use a Filter 

 
You should be able to use the "add" filter to concatenate two strings. 

2) Map the elements of your array in your view with the contents of 
settings.STATIC_URL. 

3) You can't nest a context variable inside another tag like you're trying 
to do but you can concatenate two variables together:

{% static 'my_app' %}/{{filename}}

I hope that helps.

On Wednesday, March 2, 2016 at 5:41:37 AM UTC-5, luca72 wrote:
>
> Hello i have write this in a template:
> {% for a in lista %}
>  height="100"  
>  {% endfor %}
> But i get no image
>
> if i add just a  {{a}}  i see that the file name is righ, 
> also if i direct write the file i get it
>  {% for a in lista %}
>  height="100"  
>  {% endfor %}
>
> can you tell me what is wrong
>
> 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/ecc28ce3-bc33-4beb-9063-53335dee7102%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.