Re: Error when I use python manage.py makemigrations polls

2018-11-01 Thread M Hashmi
Share Installed App snapshot again. Its not showing "polls" in installed
apps.

On Thu, Nov 1, 2018 at 6:27 PM ALLAN NJOROGE 
wrote:

> Hey, I am a newbie in Django and am trying to learn by following the
> official documentation, I am stuck on writing your first code part 2, I
> have followed every step but keeps getting this error when I use python
> manage.py makemigrations polls, below is my code attached, 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/438e8bb9-f71f-4df2-936e-2444cf4b8e4f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Server Error on deployment to Digitalocean server

2018-08-02 Thread M Hashmi
You need to do little extra. Login to your DigitalOcean account and follow
instructions in the link to add MX records for sendgrid.


https://www.digitalocean.com/community/questions/how-to-make-sendgrid-work-on-digitalocean

On Thu, Aug 2, 2018 at 7:03 AM, Azeez Akinsola 
wrote:

> Thank you Hashmi for your help. I am using sendgrid for sending emails
>
> Please check my .env and settings.py files I deployed to the server, I am
> not sure if need to add or remove any variables
>
> SEND_GRID_API_KEY = ''
> EMAIL_HOST_USER = 'xx...@gmail.com'
> EMAIL_HOST_PASSWORD = 'xxx'
> EMAIL_PORT = 587
> EMAIL_USE_TLS = True
> DEFAULT_FROM_EMAIL = '...@gmail.com'
> ACCOUNT_EMAIL_SUBJECT_PREFIX = 'Registration Confirmation'
> EMAIL_BACKEND = 'sgbackend.SendGridBackend'
>
>
> settings.py
>
> EMAIL_BACKEND = os.getenv("EMAIL_BACKEND")
> SENDGRID_API_KEY = os.getenv("SEND_GRID_API_KEY")
> DEFAULT_EMAIL_BCC=""
> DEFAULT_EMAIL_FROM = os.getenv("DEFAULT_FROM_EMAIL")
>
>
> On Thursday, August 2, 2018 at 2:32:51 PM UTC+1, M Hashmi wrote:
>>
>> Set your SMTP configurations in settings.py. Make sure to follow wsgi
>> handler properly by adding IP in ALLOWED_HOSTS = ['yourIP']. Make sure
>> you've setup MX records for your domain configuration with DIgitalocean.
>>
>> On Thu, Aug 2, 2018 at 4:42 AM, Azeez Akinsola 
>> wrote:
>>
>>> Hello everyone,
>>>
>>>   I need help to fix this problem. My application works perfectly on my
>>> localhost, but after deployment to a digital ocean server, I encounter
>>> server error 500 and 400.
>>> I attached the log error. Please, I need someone to help to fix 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...@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/ms
>>> gid/django-users/21a8d436-43db-4d6f-8579-a906f5fe61ea%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/21a8d436-43db-4d6f-8579-a906f5fe61ea%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/af49aac4-5779-4252-a64f-e3546b791018%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/af49aac4-5779-4252-a64f-e3546b791018%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts6maFWQ3fgo6j%3DAEXt1UwsvEAeCcO0%3Ds-6%3Dktocv%2BaVFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Server Error on deployment to Digitalocean server

2018-08-02 Thread M Hashmi
Set your SMTP configurations in settings.py. Make sure to follow wsgi
handler properly by adding IP in ALLOWED_HOSTS = ['yourIP']. Make sure
you've setup MX records for your domain configuration with DIgitalocean.

On Thu, Aug 2, 2018 at 4:42 AM, Azeez Akinsola 
wrote:

> Hello everyone,
>
>   I need help to fix this problem. My application works perfectly on my
> localhost, but after deployment to a digital ocean server, I encounter
> server error 500 and 400.
> I attached the log error. Please, I need someone to help to fix 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 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/21a8d436-43db-4d6f-8579-a906f5fe61ea%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts6HE%3D9bS-BBr0GmLD6n-rAmruHwyEYn7ngwL5WPd4Q16w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sample of GeoDjanco websites

2018-03-19 Thread M Hashmi
I've been searching for one from last couple of weeks and after using
Djnago-map-widgets, django-google-maps, django-forms I came to conclusion
that no much work done in GeoDjango. All these apps do not work very well
with everything GeoDjango has to offer.

Only way out for me is that using GoogleAPI Javascript code in templates
and then create a GET/POST requests to manage user interaction with api.
Saving that to database based on JS triggers. If you happen to find
something please let me know as well.

Making a tutorial will help community to great deal coz location aware
applications are in demand.

Regards,
Mudassar

On Mon, Mar 19, 2018 at 12:37 PM, Zachary Nickens  wrote:

> I’m really interested in this too. Please share if you find anything.
>
> On Mon, Mar 19, 2018 at 2:28 PM Ezequias Rocha 
> wrote:
>
>> Hi
>>
>> I would like to know if there is any list of websites that are using
>> GeoDjango on the web.
>>
>> Could anyone tell me if you have experiences putting Leaflet in the
>> frontend and GeoDjango in the backend (geoprocessing).
>>
>> Sincerely
>> Ezequias
>>
>> --
>> 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/09ae2680-65d0-4c6e-bb32-9f776a76f138%
>> 40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout
>> 
>> .
>>
> --
> Fight On!
>
> Zachary Nickens
> znick...@usc.edu
>
> 
>
> 
>
>
> 
> Become a Member of the Wild Sheep Foundation to Put and Keep Wild Sheep on
> the Mountain 
>
> --
> 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/CAEapDEBqPaC_8bYq8b%2BSgtv6Utv_BHc%
> 3Dhgc38jSZ58hMtQpUiw%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts50JfjeaanLmJXBBiZ%2B_Oc1m-6O3q7ZZkM7pANi8fL-KA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where use JSON in Django?

2018-02-13 Thread M Hashmi
JSON is parsing in and out information from JS to Python or Django in your
case directly. For instance let's suppose you have a JS script in your
template and you need to pass your context variables into JS code as
variables. You can jsonify your request/response to get or post data.

A good example would be charts, lets suppose you need to show the number of
student per class in any project and you want to visually project the
quantity. In that case you need to parse your Student model to JS charting
scripts. That is where you create JSON request/response objects to supply
or capture the events.

Please check this out an try the following link for practice:

https://www.youtube.com/watch?v=B4Vmm3yZPgc

Regards,

Mudassar



On Tue, Feb 13, 2018 at 7:08 AM, Hayk Manukyan  wrote:

> Maybe my question is stupid but I want understand where and why developer
> need use json.
> project  on github
> 
> this is my project. In templates used
> django tags.
> Have to need project changes for example from ({% for product in products
> %}{{ product }}{% endfor %}) to json?
> Thank you for your time
>
> --
> 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/5402f8e4-0d15-4fe8-a1d6-6f54a0bab451%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts46R7aS_5e1-un%3DyuLUj4O%3DEmT6KVQShG3oT3oqfuvNDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Gunicorn Import Error: no module name wsgi

2017-09-03 Thread M Hashmi
Try:

gunicorn --bind ip:port wsgi:application

Make sure you run it from the directory where manage.py is located.
Regards,
M

On Sun, Sep 3, 2017 at 9:04 AM, Jonathan Cheng 
wrote:

> I use Python3.5.2 Django1.9
>
> I use `python -m venv venv/weather_station` to create virtual evnironment
> (/home/user/venv)
>
> This is my project tree in Ubuntu /home/user/myproject:
> (`export project=/home/user/myproject`)
>
> myproject
>|
>├── gunicorn.conf.py
>├── static
>│   ├── admin
>└── weather_station
>├── base
>│   ├── migrations
>│   ├── static
>│   └── templates
>└── weather_station
>├── __init__.py
>├── wsgi.py
>├── urls.py
>├── settings
>├── base.py
>├── production.py
> 在此輸入代碼...
>
> __init__.py:
> import pymysql
> pymysql.install_as_MySQLdb()
> wsgi.py
> import os
>
> from django.core.wsgi import get_wsgi_application
>
> os.environ.setdefault("DJANGO_SETTINGS_MODULE",
> "weather_station.settings.production")
>
> application = get_wsgi_application()
> The partial in the settings.base.py:
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.
> path.abspath(__file__
>
> ROOT_URLCONF = 'weather_station.urls'
>
> WSGI_APPLICATION = 'weather_station.wsgi.application'
>
> STATIC_URL = '/static/'
> In the partial of settings.production.py:
> from .base import *
>
> DEBUG = False
>
> STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static')
>
> MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media')
> gunicorn.conf.py:
> import os
>
> bind = '127.0.0.1:8080'
> worders = (os.sysconf('SC_NPROCESSORS_ONLN') * 2) + 1
> loglevel = 'error'
> command = '/home/user/venv/weather_station/bin/gunicorn'
> pythonpath = '/home/user/myproject/weather_station'
>
> And in the /etc/nginx/sites-available/weather.conf:
>
> upstream weather_station {
> server 127.0.0.1:8080;
> }
>
> server {
> listen 80 default_server;
> listen 443 default ssl;
> server_name http://my_ip;
> client_max_body_size 10M;
> keepalive_timeout15;
>
> location /static/ {
> alias   /$project/static/;
> }
> location /media/ {
> alias   /$project/media/;
> }
>
> location / {
> proxy_redirect  off;
> proxy_set_headerHost$host;
> proxy_set_headerX-Real-IP   $remote_addr;
> proxy_set_headerX-Forwarded-For
> $proxy_add_x_forwarded_for;
> proxy_set_headerX-Forwarded-Protocol$scheme;
> proxy_pass  http://myproject;
>
> When I the follwoing command under myproject
> gunicorn -c gunicorn.conf.py weather_station.weather_station.wsgi
>
>
>
> It showed `ImportError: No module named 'weather_station.settings'`
>
> Does any know the reason ?
>
>
> it successfully weather_station.wsgi.
>
> But the new error is  `ImportError: No module named
> 'weather_station.settings'`
>
> detailed log
>
>
>  File "/home/user/myproject/weather_station/weather_station/wsgi.py",
> line 17, in 
> application = get_wsgi_application()
>   File "/home/user/.local/lib/python3.5/site-packages/
> django/core/wsgi.py", line 13, in get_wsgi_application
> django.setup()
>   File "/home/user/.local/lib/python3.5/site-packages/
> django/__init__.py", line 17, in setup
> configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
>   File "/home/user/.local/lib/python3.5/site-packages/
> django/conf/__init__.py", line 55, in __getattr__
> self._setup(name)
>   File "/home/user/.local/lib/python3.5/site-packages/
> django/conf/__init__.py", line 43, in _setup
> self._wrapped = Settings(settings_module)
>   File "/home/user/.local/lib/python3.5/site-packages/
> django/conf/__init__.py", line 99, in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
>   File "/usr/lib/python3.5/importlib/__init__.py", line 126, in
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
> ImportError: No module named 'weather_station.settings'
>
>
>
>
>
>
>
> --
> 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/87a81098-2124-4702-a429-4f161cd055d8%40googlegroups.com
> 
> .
> For more

Re: Dynamic Model ID cannot be called

2017-07-26 Thread M Hashmi
Nothing wrong with your function based view. Just try to fill data in DB
field. It will work. Because you don't have any record in DB. Try to use
'get_or_create' function.


M

On Wed, Jul 26, 2017 at 4:50 AM, Shazia Nusrat 
wrote:

> Hi,
>
> I have a simple model like below:
>
> class Artists(models.Model):
>name = models.CharField(max_length=200)
>description = models.TextField()
>
>def __unicode__(self):
>  return self.name
>
> I am trying to call it in my view like below:
>
> def artistdetail(request, id):
>artista = Artist.objects.get(id=id # this line is giving me
> error.
>
>
> Can someone explain me how to get the id in operational mode. I can call
> IDs with filtering by name in shell. But how to set it up for the user who
> uses it.
>
>
> Regards,
> Shazia
>
> --
> 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/CAD83tOyL_Sdi3eeuManMXnsNBXHhvpwzGA0Tt2q
> XX_MgAbOUaQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts5nmSEeqNVa-%2B-vZ%3DPtmndnkDG%2B5gehMjA1r208u6ggxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: JS static file is not accessible in Django

2017-01-10 Thread M Hashmi
RIght click on the page when local server is running and click inspect
elements. Check if there is any error in console section.
If JS is showing file then it means the issue is with the function not with
loading file. Send snapshot for further help.

On Tue, Jan 10, 2017 at 10:19 PM,  wrote:

> Ihave an application for that I am trying to use multifilter js script. I
> am able to load the file through my application.
> Ex: /static/js/multifilter.js
>  if i open this link it will print my js file on html without any issues,
> But in the application js functionality is not working.
>
> Can anyone suggest me on this.
>
>
> Thanks in advance,
> Anjali
>
> --
> 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/0991e99b-3002-441b-b1f1-0d8051010215%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts6T%2BibHKtD80O%3D8g63jjV99w2-SpPuGBNMJUXbqDoL_gw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question Is Django Rest Framework only for APIs or can i Use it to create Users for a website?

2017-01-06 Thread M Hashmi
Django RestAPI is a layer that exposes part of your application or your
whole website to other platforms for connectivity. Once it is integrated
then whatever tasks you've specified for DjangoRestFramwork to carry to
another platform will act for everything what that application tend to
present. So if your app is for creating users or authentication and you
exposed that part to receive signals from cross platform then yes you will
be able to create users or authenticate them.

Hope you got the essence.
Regards,
Mudassar

On Fri, Jan 6, 2017 at 8:54 PM, djangorobert 
wrote:

> Ya the question is what it means Ive gone through it and looks like you
> could but not sure I know its good for apis but wanted to see if it could
> be used for Authenticating User for a website that im building
>
> any responses would be appreciated thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/577d45ba-6286-4b44-8508-0c100b3638f1%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts5qhqHU2%3DRQ6LJJy2RqBT%3Dfof-MKjNCJBEe_KF3gq5-hQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: finding get_user_model

2017-01-06 Thread M Hashmi
from django.apps.config import get_model

On Fri, Jan 6, 2017 at 2:03 AM, roboslone  wrote:

> Hi! Did you run migrations after adding 'django.contrib.auth' to your
> INSTALLED_APPS?
>
> On 6 Jan 2017, at 07:30, Rasika  wrote:
>
> from django.contrib.auth import get_user_model
> why I am not able to find the code forget_user_model in auth app.
>
> While when I searched https://docs.djangoproject.
> com/en/dev/_modules/django/contrib/auth/#get_user_model I find this
> definition
>
> def get_user_model(): """ Returns the User model that is active in this
> project. """ try: return django_apps.get_model(settings.AUTH_USER_MODEL,
> require_ready=False) except ValueError: raise 
> ImproperlyConfigured("AUTH_USER_MODEL
> must be of the form 'app_label.model_name'") except LookupError: raise
> ImproperlyConfigured( "AUTH_USER_MODEL refers to model '%s' that has not
> been installed" % settings.AUTH_USER_MODEL )
> Please help me.
>
> Thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/25d99dff-e122-460e-9102-1e2a3331f737%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/752EA800-E630-4692-A55E-04E91F3A4DB1%40gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts40F3%3DMBesXKoi2DLAEWqHb-Qcs1nNyzbzgO6T8-apraw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Subclassing Models in non model class

2016-12-28 Thread M Hashmi
Thanks for the reply. I was trying to understand sql level inheritance
difference between Proxy based models and abstract models.

I got it figured out.
Thanks

Regards,
Mudassar

On Wed, Dec 28, 2016 at 4:09 AM, Melvyn Sopacua 
wrote:

> On Tuesday 27 December 2016 05:51:55 M Hashmi wrote:
>
>
>
> > I created a model Address like a normal practice below. Now I need to
>
> > create a subclass without using models.Model. But its not letting me
>
> > do because obviously it won't create tables unless I call
>
> > models.Model in class parameters.
>
> >
>
> > Idea is to create a model and use that model with non db reference in
>
> > admin.py. Following is the code:
>
>
>
> It's quite unclear what you want and why you want it especially. What does
> this other Address model represent?
>
> --
>
> Melvyn Sopacua
>
> --
> 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/5208735.ZJ1U0fmsWf%40devstation
> <https://groups.google.com/d/msgid/django-users/5208735.ZJ1U0fmsWf%40devstation?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts4rinzvF%2BdHfuN8WKof6CjsXWE4O5w-J-MZoB%3DuGS3N6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Experiences/tips for deploying and supporting on-premise in enterprises?

2016-12-27 Thread M Hashmi
Todd,

This is django presenting complete Cloud architecture to end user connected
to the core hardware structure at backend. You get registered for example
and spin up a VM, so the signals will get your site session connected to
the core datacenter implementations to complete the task. I remember for
the first three year it was not even million dollar investment on
development side and still the team was able to get it in to the market.
Even though cloud structure built on KVM with mix of VMware had few
challenges on industry level but it was easy to come around things with
very little R&D.

Still the information you provided is pretty generic as for now to explain
how would it work for you. But as we call Django battery loaded framework,
so yes it is pretty helpful to work with such framework by keeping your
focus on main logic. But no platform is perfect and there are always
challenges to go around things to satisfy your goal.

If I were you I would build it on paper for at least MVP and would double
check with docs if Django satisfies the core requirements. For instance if
you like to go with Saas model then there are a lot considerations to work
on.

If you like we can have discussion about it with as much knowledge I would
be able to present. I am currently building industry scale django based
application as side project for apparel manufacturers, designers, suppliers
and few other variants and I was surprised to see things going that smooth
comparatively while I was working with PHP.

All your requirements above pretty much satisfied by default but I am not
sure what challenges you may have on implementation level for Saas model.

Regards,

Mudassar

On Tue, Dec 27, 2016 at 11:00 AM, Todd Schiller 
wrote:

> Thanks - I intentionally left it vague, as I'd like to better understand
> the space of options when working with Python + Django and where headaches
> might arise. I suspect there are aspects that seem straightforward, but end
> up being a headache for certain environments.
>
> The main application is CRUD with analytics and visualization over
> relatively small data. It will have a small number of geographically
> diverse users. No scalability issues, though the application may benefit
> from splitting across geographies. Therefore, we'd be primarily looking to
> optimize for ease of deployment, integration, licensing, updating, and
> support. For example, we'd ideally have to make minimal changes to
> accommodate each new enterprise client and environment.
>
> "Hook into existing services" means whether you ended up deploying
> associated infrastructure (caching, logging, task queue) in the deployment,
> or whether you integrated into the enterprises services. For example, if
> you're deploying via VM, would you just go ahead and package Memcached in
> that VM, or take a different route? Similarly, have you run into problems
> using the migration framework for some enterprise clients?
>
> Mudassar, what in particular should I look at on that site? It looks like
> it's a service for migrate on-premise infrastructure to the cloud?
>
> On Monday, December 26, 2016 at 12:34:47 PM UTC-6, Todd Schiller wrote:
>>
>> My team is considering using Django for a SaaS/on-premise enterprise web
>> application. We've been happy with building with Django for SaaS, but don't
>> have experience deploying and supporting it on-premise in enterprise Linux
>> and Windows environments. Therefore, we'd like to get the community's
>> perspective before going down this path.
>>
>> While we appreciate all feedback, the areas we most need clarity are the
>> following. For each, we'd like to hear: How did you address the area? What
>> went well? What didn't go well? What do you wish you had known before
>> starting?
>>
>>- Deployment: e.g., direct, container, VM, or a packaging solution
>>such as Replicated
>>- Integration: did you hook into existing services (caching, logging,
>>etc.) or did you deploy these services alongside the application?
>>- Licensing: e.g., based on # of seats
>>- Authentication/Authorization: e.g., LDAP, AD, etc.
>>- Updates: bug fixes, and changes requiring migrations
>>
>> Also, if you're a development shop that has experience building
>> enterprise Django applications, we'd love to chat with you because we're
>> looking for some extra resources on our projects.
>>
>> Thanks,
>> Todd
>>
>> --
> 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/a142e6e8-9781-450a-9c54-3c6469e92e7c%40googlegroups.com
> 

Subclassing Models in non model class

2016-12-27 Thread M Hashmi
Hi All,

I created a model Address like a normal practice below. Now I need to
create a subclass without using models.Model. But its not letting me do
because obviously it won't create tables unless I call models.Model in
class parameters.

Idea is to create a model and use that model with non db reference in
admin.py. Following is the code:

"class Address(models.Model):
 ...
class ShippingAddress(Address):
phone_number = PhoneNumberField(
_("Phone number"), blank=True,
help_text=_("In case we need to call you about your order"))
notes = models.TextField(
blank=True, verbose_name=_('Instructions'),
help_text=_("Tell us anything we should know when delivering "
"your order."))

class Meta:
app_label = 'order'
verbose_name = _("Shipping address")
verbose_name_plural = _("Shipping addresses")

@property
def order(self):
try:
return self.order_set.all()[0]
except IndexError:
return None


class UserAddress(ShippingAddress):
user = models.ForeignKey(
AUTH_USER_MODEL, related_name='addresses', verbose_name=_("User"))
is_default_for_shipping = models.BooleanField(
_("Default shipping address?"), default=False)
is_default_for_billing = models.BooleanField(
_("Default billing address?"), default=False)
num_orders = models.PositiveIntegerField(_("Number of Orders"),
default=0)
hash = models.CharField(_("Address Hash"), max_length=255,
db_index=True,
editable=False)
date_created = models.DateTimeField(_("Date Created"),
auto_now_add=True)

def save(self, *args, **kwargs):
self.hash = self.generate_hash()
self._ensure_defaults_integrity()
super(UserAddress, self).save(*args, **kwargs)

def _ensure_defaults_integrity(self):
if self.is_default_for_shipping:
self.__class__._default_manager\
.filter(user=self.user, is_default_for_shipping=True)\
.update(is_default_for_shipping=False)
if self.is_default_for_billing:
self.__class__._default_manager\
.filter(user=self.user, is_default_for_billing=True)\
.update(is_default_for_billing=False)

class Meta:
app_label = 'address'
verbose_name = _("User address")
verbose_name_plural = _("User addresses")
ordering = ['-num_orders']
unique_together = ('user', 'hash')

def validate_unique(self, exclude=None):
super(Address, self).validate_unique(exclude)
qs = self.__class__.objects.filter(
user=self.user,
hash=self.generate_hash())
if self.id:
qs = qs.exclude(id=self.id)
if qs.exists():
raise exceptions.ValidationError({
'__all__': [_("This address is already in your address"
  " book")]})

.."

I know that I needed to create a parent class without calling models and
then I can inherit that class in models.Model.

But is there a way around it or do I need to create abstract models?

Regards,
Mudassar

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


Re: installed apps

2016-12-27 Thread M Hashmi
All your files at your system are located in site-packages folder. Whatever
you installed even Django itself is located there. In case you need to
override any method you need to subclass the original model to alter its
behavior. www.djangoproject.com provides to detail documentation about how
to work with the source.

This is good approach to understand any framework by looking at its default
code.

Good luck.
Mudassar

On Tue, Dec 27, 2016 at 3:25 AM, Rasika 
wrote:

> hello all
> my question is,on my system where all installed apps are located by django.
> If i want to modify those where I can find those like admin app,auth app
> etc.
> and how the auth_user table saves the superuser and the user created by
> admin for this i have to understand the admin app first.
> thank you.
> 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/971280f9-3572-4513-837c-55840a99e111%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Experiences/tips for deploying and supporting on-premise in enterprises?

2016-12-27 Thread M Hashmi
I was part of dinCloud hosting provider and they have complete solution
built in Python/Django. You can see the website where all the VM's
architecture is built using django framework. Its a cloud hosting provider
with few enterprise applications provided as Saas and hardware monitoring
with NOC PaaS etc.

dincloud.com

Regards,
Mudassar

On Tue, Dec 27, 2016 at 3:17 AM, Antonis Christofides <
anto...@djangodeployment.com> wrote:

> Hi,
>
> The solutions depend on what you need and what knowledge and resources you
> already have. As you describe it I think it's a bit vague. For example,
> whether you will deploy on metal or on VM depends on what load you expect,
> who administers the VM, who administers the metal, and so on and so on.
> What do you mean by "hook into existing services"? Authentication using
> LDAP shouldn't be a problem (I've done it for years using a custom backend,
> but now I think there are ready-made modules).
>
> Better explain in more detail which area gives you a headache and why.
>
> Regards,
>
> Antonis
>
> Antonis Christofideshttp://djangodeployment.com
>
> On 12/26/2016 06:25 PM, Todd Schiller wrote:
>
> My team is considering using Django for a SaaS/on-premise enterprise web
> application. We've been happy with building with Django for SaaS, but don't
> have experience deploying and supporting it on-premise in enterprise Linux
> and Windows environments. Therefore, we'd like to get the community's
> perspective before going down this path.
>
> While we appreciate all feedback, the areas we most need clarity are the
> following. For each, we'd like to hear: How did you address the area? What
> went well? What didn't go well? What do you wish you had known before
> starting?
>
>- Deployment: e.g., direct, container, VM, or a packaging solution
>such as Replicated
>- Integration: did you hook into existing services (caching, logging,
>etc.) or did you deploy these services alongside the application?
>- Licensing: e.g., based on # of seats
>- Authentication/Authorization: e.g., LDAP, AD, etc.
>- Updates: bug fixes, and changes requiring migrations
>
> Also, if you're a development shop that has experience building enterprise
> Django applications, we'd love to chat with you because we're looking for
> some extra resources on our projects.
>
> Thanks,
> Todd
>
> --
> 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/230c508a-94ed-494a-8d99-88c89aeb9e78%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/ffe0df62-97f7-fdc1-8c10-05b51792ef73%
> 40djangodeployment.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django Browser issue

2016-12-12 Thread M Hashmi
Browser's has nothing to with DB connection. Can you clear cache on your
machine to see if it works?
Still if there is issue than send your Apache settings for detailed look on
how you have configured it on hosting server.


On Mon, Dec 12, 2016 at 1:53 AM,  wrote:

> Hi,
>
> I am facing a peculiar issue. My application is working fine in all
> browsers if it ran through local host. But when the application is hosted
> an apache server, everything works fine in firefox browser but in other
> browsers application is not connecting to oracle db and the page is shwing
> empty content.
> Please provide me some suggestions to solve this issue.
>
> Thanks in advance,
> Anjali
>
> --
> 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/323689f9-62da-4840-8cef-3af945a8eb6f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts4Dt%3Dhb2eNOvJa_nQvbTFBBrk%2BZG07A7W-qp0PuTdwgpw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DateTimeField Outside Admin

2016-11-27 Thread M Hashmi
Its simple. In your view in your context dictionary create a variable for
date. Import timezone and date = timezone.now(). You can declared "date"
like {{ date }} in any of your template and you will get date coming up.

On Sun, Nov 27, 2016 at 8:50 AM, Elias Coutinho 
wrote:

>
>
> 
>
>
>
> 
>
> Good afternoon people,
>
> I would like to display my date field outside the admin in the same way it
> displays, ie an option for date and another for time, as in the figure
> below.
>
> 
>
>
>
> 
>
>
>
> 
>
>
> 
>
>
>
>
> I looked in the documentation but I did not understand much, I searched
> the webmas not found anything without using other libraries.
>
> A friend sent a tip and also did not work because it presents the error:
>
> 'Str' object has no attribute 'input_formats'
>
> Finally I found an ancient good:
>
> Open on page 198 onwards.
> 
>
> But even so he does not even carry the field.
>
> Can someone show me an example of how I would do this?
>
> If possible post as would be the model, the form and the hrml.
>
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/47f0afd0-c988-4924-9c37-a9c4254f969b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts5rctEkp%3D7qrCLNwPhK5ftbYH8bXv4JP-8PP8HMSv8z0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: WOrking with checkbox Multiple Select FIeld - Django Admin

2016-10-29 Thread M Hashmi
Form ModelForm if you need to check a single field then you set it as
BooleanField in your models.py but if you need to use kind of condition
that requires multiple checkboxes to be True. Then its better to define
condition in your view like

models.py
a = models.BooleanField(default=False)
b = models.BooleanField(default=False)
c = models.BooleanField(default=False)

Views.py
if a and b == True
return "correct".

Makes sense?

Regards,
Mudassar

On Sat, Oct 29, 2016 at 3:43 PM, Bernardo Garcia  wrote:

> HI, friends.
>
> Someone know how to work with a field that allow perform a multiple
> selection in a field?, like a checkbox. In django admin,
>
> 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/670c3379-cea2-4819-91e8-5fbe804d1c88%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts7E%2BTPngOpz4D6YBdsK9j5XopXNpmR-zEzZLe%2BJ8zrZjw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django menu and submenus

2016-10-26 Thread M Hashmi
Make sure you've included all the js/css ID/Class selectors in your newly
created submenu. Reason might be that old code is rendering something from
JS and your code missed it out. You can send code from before and after for
better understanding.

Regards,
Mudassar

On Wed, Oct 26, 2016 at 4:24 AM, Tetchi Boris Armel Kena <
kena.tet...@gmail.com> wrote:

> i'm coding a geonode app based on django and python architecture but also
> bootstrap. i change the boot strap navigation menu with a simple html and
> css but my probleme is that the submenu do not appear on the page please
> help me.
>
> --
> 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/313cc973-16fd-4244-bb2f-707524f8ab83%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Importing contacts from email/social

2016-10-14 Thread M Hashmi
This is outdated but let me see if I can port it to upgraded version and
make it useful for others as well.

Thanks,

Regards,
Mudassar

On Fri, Oct 14, 2016 at 3:37 PM, Asad Jibran Ahmed 
wrote:

> Thanks! It's nice to hear my book is useful to someone out there! :)
>
> Back to your question, have you tried this: https://github.com/
> mengu/django_contact_importer
>
> Asad Jibran Ahmed 
> http://blog.asadjb.com
>
> On Sat, Oct 15, 2016 at 2:25 AM, M Hashmi  wrote:
>
>>
>> I was hoping to find a combine platform where at least variables are same
>> for POP/IMAP mail servers such as hotmail, yahoo, gmail and few others.
>> Idea is to let user import their contacts.
>>
>> *Between congrats on success for your new book "Django Project
>> Blueprints" as it is been part of curriculum by two IT institutes known to
>> me those teach Django. I am reading it and its nice. *
>>
>> If there is combine platform I would use that lib due to timing
>> constraints coz stuck in work.
>>
>> Thanks,
>> Regards,
>> Mudassar
>>
>> On Fri, Oct 14, 2016 at 9:42 AM, Asad Jibran Ahmed 
>> wrote:
>>
>>> That would depend on the source of the contacts. Do you want contacts
>>> from the users phone? I think those are in the vCard format, so you'll need
>>> a library to read that. If you're looking for something like importing
>>> contacts from Gmail, LinkedIn, etc, there are libraries for each of those
>>> sources as well.
>>>
>>> What's your source?
>>>
>>> Asad Jibran Ahmed 
>>> http://blog.asadjb.com
>>>
>>> On Fri, Oct 14, 2016 at 7:41 PM, M Hashmi  wrote:
>>>
>>>> Hi,
>>>>
>>>> Is there a library available to import user contact's list?
>>>>
>>>> If you have some piece of code as reference or a lib please guide.
>>>>
>>>> Regards,
>>>> Mudassar
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>>> gid/django-users/CANoUts7_1BTRcDOTFy1oHUYod2rU_sOZc9fOnin5uD
>>>> i9RBLSig%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CANoUts7_1BTRcDOTFy1oHUYod2rU_sOZc9fOnin5uDi9RBLSig%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/CA%2BYYaWet3gb3SZHGz0uJxm7tD4RmH%2BqA0LCUyw
>>> Kf3-0a1pHJYA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CA%2BYYaWet3gb3SZHGz0uJxm7tD4RmH%2BqA0LCUywKf3-0a1pHJYA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CANoUts5VVq357gQhVJQX6hPHeJA4CD61tFiASpasMC
>> iBcFmkmA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CANoUts5VVq357gQhVJQX6hPHeJA4CD61tFiASpasMCiBcFmkmA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>

Re: Importing contacts from email/social

2016-10-14 Thread M Hashmi
I was hoping to find a combine platform where at least variables are same
for POP/IMAP mail servers such as hotmail, yahoo, gmail and few others.
Idea is to let user import their contacts.

*Between congrats on success for your new book "Django Project Blueprints"
as it is been part of curriculum by two IT institutes known to me those
teach Django. I am reading it and its nice. *

If there is combine platform I would use that lib due to timing constraints
coz stuck in work.

Thanks,
Regards,
Mudassar

On Fri, Oct 14, 2016 at 9:42 AM, Asad Jibran Ahmed 
wrote:

> That would depend on the source of the contacts. Do you want contacts from
> the users phone? I think those are in the vCard format, so you'll need a
> library to read that. If you're looking for something like importing
> contacts from Gmail, LinkedIn, etc, there are libraries for each of those
> sources as well.
>
> What's your source?
>
> Asad Jibran Ahmed 
> http://blog.asadjb.com
>
> On Fri, Oct 14, 2016 at 7:41 PM, M Hashmi  wrote:
>
>> Hi,
>>
>> Is there a library available to import user contact's list?
>>
>> If you have some piece of code as reference or a lib please guide.
>>
>> Regards,
>> Mudassar
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CANoUts7_1BTRcDOTFy1oHUYod2rU_sOZc9fOnin5uD
>> i9RBLSig%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CANoUts7_1BTRcDOTFy1oHUYod2rU_sOZc9fOnin5uDi9RBLSig%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2BYYaWet3gb3SZHGz0uJxm7tD4RmH%
> 2BqA0LCUywKf3-0a1pHJYA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2BYYaWet3gb3SZHGz0uJxm7tD4RmH%2BqA0LCUywKf3-0a1pHJYA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Importing contacts from email/social

2016-10-14 Thread M Hashmi
Hi,

Is there a library available to import user contact's list?

If you have some piece of code as reference or a lib please guide.

Regards,
Mudassar

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


Re: Django app crashes with out of memory

2016-10-07 Thread M Hashmi
These are all memory hungry applications. Please provide some detail that
how many worker processes initialized by the gunicorn and how do you bind
it with Nginx. Nginx configurations also required to see details. Plus use
"free -m" to see how much memory you've got allocated to all services. Use
"df -h" to see hard drive space available. Finally if you have a swap file
then what's the size.

You can create swapfile with "sudo fallocate -l 4G /swapfile" but after
getting this message it might not be good idea to do it now. Or if you have
feeling that swapping might solve the is issue  you can backup the code and
re-create your droplet and manage swapping from the start. 4GB swapzie in
total will be enough I guess.

If I were you I would comment out redis and see if that solves problem. Not
sure what other applications you may have but remember that Python consumes
a lot of memory and using redis for cache management is really a good tool.
But in some cases depending on your settings it needs some good processing
power with memory to manage cache. This is why it is suitable for large
scale projects and for middle size projects cache is managed within Django.

I cannot pin point the solution for you right away because according to the
scenario there could be multiple reasons. You can also configure Nginx for
browser based cache at user end to minimize load.

For piece of code you've provided looks like no issue there as per my
limited understanding. I had issues with PHP based CMS but never had issue
with Django/Bottle/Pyramid.

Hope something might point you to the right direction but for now that's
all I can say with provided information. But if solution is different than
one of the above reasons please share with group as well. It is difficult
to recreate the error using your exact scenario so hard to come up with
exact solution.

Good Luck!

Regards,
Mudassar

On Fri, Oct 7, 2016 at 1:21 AM, Горобец Дмитрий  wrote:

> Hello.
>
> I have VPS with 2Gb RAM with django, gunicorn, mysql, nginx and redis.
>
> My app crashes with out of memory error, when I run django command on
> model, which has approximately 7 million records. It takes each premise
> object and updates one field by checking value with regular expression.
> Please, help optimize that command.
>
> class Command(BaseCommand):
> help = 'Updates premise.number_order'
>
> def handle(self, *args, **options):
> for premise in Premise.objects.iterator():
> premise.number_order = premise.set_number_order()
> premise.save()
>
> self.stdout.write('Finished')
>
>
> # Method of Premise model
> def set_number_order(self):
> tr = {
> 'А': '.10',
> 'A': '.10',
> 'Б': '.20',
> 'В': '.30',
> 'Г': '.40',
> 'Д': '.50',
> 'Е': '.60',
> 'Ж': '.70',
> 'З': '.80',
> 'И': '.90',
> }
>
> only_digit = re.compile(r'^(?P[0-9]{1,9})$')
> digit_with_separator = re.compile(r'^(?P[0-9]
> {1,9})(?P[-|/])(?P\w+)$')
> digit_with_letter = re.compile(r'^(?P[0-9]
> {1,9})(?P[А-Яа-я]+)')
> result = 0
> title = self.title.strip().upper()
>
> if only_digit.match(title):
> number = only_digit.match(title).group('number')
> result = number + '.00'
>
> elif digit_with_separator.match(title):
> number = digit_with_separator.match(title).group('number')
> rest = digit_with_separator.match(title).group('rest')
> if rest[0].isalpha():
> floating = tr.get(rest[0], '.90')
> result = number + floating
>
> elif rest[0].isdigit():
> try:
> if rest[1].isdigit():
> result = number + '.{}'.format(rest[:2])
> else:
> result = number + '.0{}'.format(rest[0])
> except IndexError:
> result = number + '.0{}'.format(rest[0])
>
> elif digit_with_letter.match(title):
> number = digit_with_letter.match(title).group('number')
> letter = digit_with_letter.match(title).group('letter')[0]
>
> floating = tr.get(letter, '.90')
> result = number + floating
>
> return Decimal(result)
>
> --
> 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/6ccbf103-c24b-4e3a-982d-4e5db0f01972%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message b

Re: Advanced search with aggregations

2016-10-05 Thread M Hashmi
Kindly provide some details like what are your models so people can
understand what you are trying to do according to the available models.



On Wed, Oct 5, 2016 at 8:38 AM, Raffa  wrote:

> Hi all
> I have to create a page where I insert some cascade combobox  that fill
> dynamically through which I perform aggregations on the db records.
> For example I want to know how many pants I still have in all Italian
> stores. I select from the combobox that contains the field "area" the
> "Italia" value, then I click on "Calculate pants":  the result I get is the
> sum of the pants of all records with area = Italy.
> How can I perform that?
> Thank in advance
>
> Raffaella
>
> --
> 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/98495fe4-258a-41c8-a57d-f1e1cecc63cf%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts4skezctxy77%2B6Qqc9FLB%2BS8pb%3DdNb5_sX%3Djh3KiT5tnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django form converter to PDF

2016-10-03 Thread M Hashmi
You are a rockstar in the group man. Let me try it and I will let you know
about the results. I didn't get a change to look at Weasy_print.

Regards,
Mudassar

On Mon, Oct 3, 2016 at 5:26 AM, ludovic coues  wrote:

> the xhtml2pdf doc point to weasyprint [1]. After a quick look at the
> doc [2], it look like a simple way to generate pdf from html file.
> If you already have a url on your django app rendering the quote, I
> would use weasyprint like that:
>
>
> from io import BytesIO
> from django.http.response import HttpResponse
> from django.urls import reverse
> from weasyprint import HTML
>
> def view(request):
> pdf = BytesIO()
> HTML(url=reverse("app:quote").write_pdf(pdf)
> return HttpResponse(pdf.getvalue(), content_type="application/pdf"
> )
>
>
> I haven't tested the code, but It should work, assuming "app:quote"
> resolve to an actual url :)
>
> [1] http://weasyprint.org/
> [2] http://weasyprint.readthedocs.io/en/latest/tutorial.html#as-
> a-python-library
>
> 2016-10-03 14:05 GMT+02:00 M Hashmi :
> > Hi,
> >
> > I need some simple library to convert a simple quote form to PDF. I tried
> > xhtml2pdf and few others but need really simple process to use but
> creating
> > a fancy pdf.
> >
> > If anyone knows please let me know.
> >
> > Regards,
> > Mudassar
> >
> > --
> > 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/CANoUts5Bz-bWq7vr%
> 2BJtBOnDKj9EzkpnxYE5z2T9CV1TAN2Nr%2Bw%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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/CAEuG%2BTbinwRLBA0ZDafvoTww-MD%
> 2Bejmhpj2KcPNpZuKkT0tdnQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


django form converter to PDF

2016-10-03 Thread M Hashmi
Hi,

I need some simple library to convert a simple quote form to PDF. I tried
xhtml2pdf and few others but need really simple process to use but creating
a fancy pdf.

If anyone knows please let me know.

Regards,
Mudassar

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


Re: nginx configuration to cache all endpoints but one

2016-10-02 Thread M Hashmi
Hi, I've checked all the logs and as per my limited understanding you need
to open up a ticket with Nginx support.

Or may be I am not able to understand it right.

As I've done it during my practice that I would create two blocks. The
upper block will contain urls/files that are not to be accessed. But in
your case if this is not working then this is something I can't help you
with due to limited time to research the issue. I tried to create your
problem at my end but couldn't.

Please open up issue with Nginx support team and they will get you a fix in
24 hours.

Note: This escaped from my mind due to a lot of work and I humbly apologize
if you kept waiting for my answer. As per the code of conduct for this
group everybody will try to help you out with whatever knowledge or
information they have otherwise.

Good luck. :-)

Thanks.
Regards,
Mudassar

On Sun, Oct 2, 2016 at 9:58 AM, gg4u  wrote:

> Hi M,
>
> have you had possibility to take a closer look to setting files and logs?
>
>
> Il giorno domenica 25 settembre 2016 15:48:57 UTC+2, gg4u ha scritto:
>>
>> Hi M :)
>>
>> thank you for helping out!
>> Here a .txt version of settings.
>>
>> For logs, I will send it in PVT!
>>
>> thank you.
>>
>> Il giorno domenica 25 settembre 2016 13:40:13 UTC+2, M Hashmi ha scritto:
>>>
>>> Send me settings of /etc/nginx/nginx.conf and then
>>> /etc/sites-available/app.
>>> The format of the file is not opening up on my system as I am on windows
>>> right now.
>>>
>>> Also if you have some logs that would be great.
>>> Regards,
>>> M (call me M)
>>>
>>> On Sun, Sep 25, 2016 at 3:50 AM, gg4u  wrote:
>>>
>>>> Hi Hashmi,
>>>>
>>>> thank you for your suggestion.
>>>>
>>>> I tried to set proxy_pass for the location I don't want to cache, but I
>>>> don't see caching working properly on my browser.
>>>>
>>>> Could you give a look?
>>>> I will attach a mockup of settings,may you want to comment or edit it
>>>> there so that is more readable to me and also other people?
>>>>
>>>> I want to cache all /api location, except /api/search
>>>>
>>>> In attachment what I tried (I removed from settings things not relevant
>>>> to this).
>>>>
>>>> thank you,
>>>> Luigi
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Il giorno venerdì 23 settembre 2016 21:45:45 UTC+2, M Hashmi ha scritto:
>>>>>
>>>>> Create a separate block to exclude certain endpoint above others.
>>>>>
>>>>> You can also try following approach.
>>>>>
>>>>> https://groups.google.com/forum/embed/#!topic/openresty-en/apyaHbqJetU
>>>>> Regrads,
>>>>> Mudassar
>>>>>
>>>>> On Fri, Sep 23, 2016 at 12:26 PM, gg4u  wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I want to cache all api endpoints except of one: /api/search endpoint.
>>>>>> Do I need to specify settings for each of the endpoints?
>>>>>>
>>>>>> My configuration use nginx as server on port 8000 and port 80 as
>>>>>> virtual proxy server.
>>>>>> Please not I removed settings not related to question to minify the
>>>>>> post!
>>>>>>
>>>>>> server {
>>>>>> listen 8000 default_server;
>>>>>>
>>>>>> # Set Cache for my Json api
>>>>>> # I want to cache everything but /api/search endpoint
>>>>>> location ~* \.(?:json)$ {
>>>>>>  expires 1M;
>>>>>>  access_log off;
>>>>>>  add_header Cache-Control "public";
>>>>>> }
>>>>>>
>>>>>>
>>>>>> location /api {
>>>>>> include uwsgi_params;
>>>>>> uwsgi_pass unix:/var/www/awesome3-gamma/app.sock;
>>>>>> allow [MY DNS];
>>>>>> deny all;
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> # Set cache dir
>>>>>> proxy_cache_path /tmp/nginx levels=1:2 keys_zone=my_zone:10m
>>>>>> inactive=60m;
>>>>>> proxy_cache_key "$scheme$request_method$host$request_uri";
>>>>>

Re: Django not saving form in DB from frontend

2016-09-30 Thread M Hashmi
*Please change*

def contact_form(request):
template = 'contact.html'
if request.method == 'POST':
   form = ContactForm(request.POST or None, request.Files or
None)
   if form.is_valid():
 new_form = form
 new_form.save(commit=True)


return redirect('/')
   else:
  form = ContactForm
return render(request, template, context={"form":form})

*To*
def contact_form(request):
template = 'contact.html'
form = ContactForm(request.POST or None, request.Files or None)
   if form.is_valid():
 form.save()
   else:
  do something here
   return render(request, template, context={"form":form})

You are saving a form but calling back variable that holds unsaved version
of the form.

Regards,
Mudassar



On Thu, Sep 29, 2016 at 2:18 PM, ludovic coues  wrote:

> I would try to replace
>
> if form.is_valid():
> new_form = form
> new_form.save(commit=True)
>
> with :
>
> if form.is_valid():
> print("Form is valid")
> form.save(commit=True)
> else:
> print("Invalid form")
>
>
> Pretty sure you will get an invalid form, due to a missing field
> send_quote field. For the form to send the file, you need to add an
> enctype=multipart or something related.
>
> 2016-09-29 21:06 GMT+02:00 Ali khan :
> > Appologies. In my view after else clause its ContactForm.
> >
> > On Thu, Sep 29, 2016 at 11:52 AM, Ali khan 
> > wrote:
> >>
> >> Hi,
> >>
> >> I am newbie so I must be doing some stupid mistake here.
> >>
> >> I am trying to save a contact form with ModelForm. But its not saving in
> >> DB from the frontend form.
> >>
> >> model.py
> >>
> >> class Contact(models.Model):
> >>  name = models.CharField(max_length=100, null=True, blank=True)
> >>  email = models.EmailField()
> >>  send_quote = models.FileField(upload_to='/contacts')
> >>
> >>   def __unicode__(self)
> >>return self.name
> >>
> >> forms.py
> >>
> >> from .models import Contact
> >> from djagno import forms
> >> from django.forms import ModelForm
> >>
> >> class ContactForm(forms.ModelForm):
> >> class Meta:
> >> model = Contact
> >> fields = ['name', 'email', 'send_quote']
> >>
> >> views.py:
> >>
> >> from Django.shortcuts import render, redirect
> >> from .forms import ContactForm
> >>
> >> def contact_form(request):
> >> template = 'contact.html'
> >> if request.method == 'POST':
> >>form = ContactForm(request.POST or None, request.Files or
> >> None)
> >>if form.is_valid():
> >>  new_form = form
> >>  new_form.save(commit=True)
> >>
> >>
> >> return redirect('/')
> >>else:
> >>   form = RFPForm
> >> return render(request, template, context={"form":form})
> >>
> >>
> >> contact.html:
> >>
> >> 
> >> {% csrf_token %}
> >> {{ form }}
> >> 
> >> 
> >>
> >> Please advise.
> >>
> >
> > --
> > 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/CAAXvsYkTe_LU03ErF%3Dz%
> 3DbNfM3LapOsyQywzKxUP3tm5pxHh28Q%40mail.gmail.com.
> >
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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/CAEuG%2BTaKjumkUsT_6Y4WVKkZqtG%
> 3DyPE6G6bazDJu39WewtaZrA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

Re: [Kind Attention Requested] Django Zinnia blog error for entries

2016-09-27 Thread M Hashmi
Try registering django_comments after zinnia in the INSTALLED_APPS setting
not before.

INSTALLED_APPS = (
  'django.contrib.auth',
  'django.contrib.admin',
  'django.contrib.sites',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  'django.contrib.contenttypes',
  'mptt',
  'tagging',
  'zinnia',
  'django_comments',)

Got this solution from the owner of repo. Check the issue on Github.

On Tue, Sep 27, 2016 at 12:27 AM, Shazia Nusrat 
wrote:

> I am trying to fix issue with Zinnia blog application and its popping up
> error related to aggregator and entries. Following is the code if someone
> have a suggestion:
>
> def get_authors(context, template='zinnia/tags/authors.html'):
> """
> Return the published authors.
> """
> entries = Entry.objects.all()
> return {'template': template,
> 'authors': Author.published.all().annotate(
> count_entries_published=Count('entries')),
> 'context_author': context.get('author')}
>
> Above I don't think causing any issue but below is the code that might be
> causing all the fuss in second last line.
>
> def get_queryset(self):
> """
> Return a queryset containing published entries.
> """
> now = timezone.now()
> return super(
> EntryRelatedPublishedManager, self).get_queryset().filter(
> models.Q(entries__start_publication__lte=now) |
> models.Q(entries__start_publication=None),
> models.Q(entries__end_publication__gt=now) |
> models.Q(entries__end_publication=None),
> entries__status=PUBLISHED,
> entries__sites=Site.objects.get_current()
> ).distinct()
>
> Please suggest a solution because overall Zinnia is an impressive app but
> with one error its almost useless. Owner of the repo already got plenty of
> users with same complain. Error is same with both Python2 and PYthon3.
>
> For generous coders willing to work on this, repo is located at
> https://github.com/Fantomas42/django-blog-zinnia/issues.
>
>
> Traceback:
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\core\handlers\exception.py"
>  in inner
>   39. response = get_response(request)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\core\handlers\base.py"
>  in _legacy_get_response
>   249. response = self._get_response(request)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\core\handlers\base.py"
>  in _get_response
>   217. response = self.process_exception_by_middleware(e, 
> request)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\core\handlers\base.py"
>  in _get_response
>   215. response = response.render()
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\response.py"
>  in render
>   109. self.content = self.rendered_content
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\response.py"
>  in rendered_content
>   86. content = template.render(context, self._request)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\backends\django.py"
>  in render
>   66. return self.template.render(context)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\base.py"
>  in render
>   208. return self._render(context)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\base.py"
>  in _render
>   199. return self.nodelist.render(context)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\base.py"
>  in render
>   994. bit = node.render_annotated(context)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\base.py"
>  in render_annotated
>   961. return self.render(context)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\loader_tags.py"
>  in render
>   174. return compiled_parent._render(context)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\base.py"
>  in _render
>   199. return self.nodelist.render(context)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\base.py"
>  in render
>   994. bit = node.render_annotated(context)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\base.py"
>  in render_annotated
>   961. return self.render(context)
> File 
> "C:\Users\Shazia\zinblog\lib\site-packages\django-1.10.1-py2.7.egg\django\template\loader_tags.py"
>  in render
>   174. return compiled_pa

Re: nginx configuration to cache all endpoints but one

2016-09-25 Thread M Hashmi
Send me settings of /etc/nginx/nginx.conf and then /etc/sites-available/app.
The format of the file is not opening up on my system as I am on windows
right now.

Also if you have some logs that would be great.
Regards,
M (call me M)

On Sun, Sep 25, 2016 at 3:50 AM, gg4u  wrote:

> Hi Hashmi,
>
> thank you for your suggestion.
>
> I tried to set proxy_pass for the location I don't want to cache, but I
> don't see caching working properly on my browser.
>
> Could you give a look?
> I will attach a mockup of settings,may you want to comment or edit it
> there so that is more readable to me and also other people?
>
> I want to cache all /api location, except /api/search
>
> In attachment what I tried (I removed from settings things not relevant to
> this).
>
> thank you,
> Luigi
>
>
>
>
>
> Il giorno venerdì 23 settembre 2016 21:45:45 UTC+2, M Hashmi ha scritto:
>>
>> Create a separate block to exclude certain endpoint above others.
>>
>> You can also try following approach.
>>
>> https://groups.google.com/forum/embed/#!topic/openresty-en/apyaHbqJetU
>> Regrads,
>> Mudassar
>>
>> On Fri, Sep 23, 2016 at 12:26 PM, gg4u  wrote:
>>
>>> Hello,
>>>
>>> I want to cache all api endpoints except of one: /api/search endpoint.
>>> Do I need to specify settings for each of the endpoints?
>>>
>>> My configuration use nginx as server on port 8000 and port 80 as virtual
>>> proxy server.
>>> Please not I removed settings not related to question to minify the post!
>>>
>>> server {
>>> listen 8000 default_server;
>>>
>>> # Set Cache for my Json api
>>> # I want to cache everything but /api/search endpoint
>>> location ~* \.(?:json)$ {
>>>  expires 1M;
>>>  access_log off;
>>>  add_header Cache-Control "public";
>>> }
>>>
>>>
>>> location /api {
>>> include uwsgi_params;
>>> uwsgi_pass unix:/var/www/awesome3-gamma/app.sock;
>>> allow [MY DNS];
>>> deny all;
>>> }
>>> }
>>>
>>>
>>>
>>> # Set cache dir
>>> proxy_cache_path /tmp/nginx levels=1:2 keys_zone=my_zone:10m
>>> inactive=60m;
>>> proxy_cache_key "$scheme$request_method$host$request_uri";
>>>
>>> # Virtualhost/server configuration
>>> server {
>>> listen   80  default_server;
>>>
>>> # here I cache /api
>>> # how to avoid caching /api/search ?
>>>
>>> location /api {
>>> add_header X-Proxy-Cache $upstream_cache_status;
>>> proxy_cache my_zone;
>>> proxy_cache_use_stale updating;
>>> proxy_cache_lock on;
>>> proxy_cache_valid 30d;
>>> proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
>>>   proxy_pass [my site route api]
>>> }
>>> }
>>>
>>>
>>> I am looking at:
>>> http://stackoverflow.com/questions/29466494/nginx-turn-off-
>>> cache-for-a-specific-file
>>> http://stackoverflow.com/questions/29466494/nginx-turn-off-
>>> cache-for-a-specific-file
>>>
>>> tried with following block on server listening on port 8000
>>>
>>> location /api/search {
>>> expires off;
>>> }
>>>
>>>
>>> but got error 500.
>>>
>>> Must it go before /api location, afterwards, or it does not matter the
>>> order?
>>> Any idea of what I am missing ?
>>>
>>> I would like to avoid specify same settings for all API endpoints
>>>
>>> --
>>> 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/ms
>>> gid/django-users/2a459135-89fa-45d5-8b4e-79b5377c11a8%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/2a459135-89fa-45d5-8b4e-79b5377c11a8%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django u

Re: nginx configuration to cache all endpoints but one

2016-09-23 Thread M Hashmi
Create a separate block to exclude certain endpoint above others.

You can also try following approach.

https://groups.google.com/forum/embed/#!topic/openresty-en/apyaHbqJetU
Regrads,
Mudassar

On Fri, Sep 23, 2016 at 12:26 PM, gg4u  wrote:

> Hello,
>
> I want to cache all api endpoints except of one: /api/search endpoint.
> Do I need to specify settings for each of the endpoints?
>
> My configuration use nginx as server on port 8000 and port 80 as virtual
> proxy server.
> Please not I removed settings not related to question to minify the post!
>
> server {
> listen 8000 default_server;
>
> # Set Cache for my Json api
> # I want to cache everything but /api/search endpoint
> location ~* \.(?:json)$ {
>  expires 1M;
>  access_log off;
>  add_header Cache-Control "public";
> }
>
>
> location /api {
> include uwsgi_params;
> uwsgi_pass unix:/var/www/awesome3-gamma/app.sock;
> allow [MY DNS];
> deny all;
> }
> }
>
>
>
> # Set cache dir
> proxy_cache_path /tmp/nginx levels=1:2 keys_zone=my_zone:10m inactive=60m;
> proxy_cache_key "$scheme$request_method$host$request_uri";
>
> # Virtualhost/server configuration
> server {
> listen   80  default_server;
>
> # here I cache /api
> # how to avoid caching /api/search ?
>
> location /api {
> add_header X-Proxy-Cache $upstream_cache_status;
> proxy_cache my_zone;
> proxy_cache_use_stale updating;
> proxy_cache_lock on;
> proxy_cache_valid 30d;
> proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
>   proxy_pass [my site route api]
> }
> }
>
>
> I am looking at:
> http://stackoverflow.com/questions/29466494/nginx-turn-
> off-cache-for-a-specific-file
> http://stackoverflow.com/questions/29466494/nginx-turn-
> off-cache-for-a-specific-file
>
> tried with following block on server listening on port 8000
>
> location /api/search {
> expires off;
> }
>
>
> but got error 500.
>
> Must it go before /api location, afterwards, or it does not matter the
> order?
> Any idea of what I am missing ?
>
> I would like to avoid specify same settings for all API endpoints
>
> --
> 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/2a459135-89fa-45d5-8b4e-79b5377c11a8%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django Ticketing Application

2016-09-12 Thread M Hashmi
Hello Alexandra,

You are at the right forum. But chatting as ticket needs some workout. Each
message needs to be contain with all ticketing properties and upon
selection of a message it should act as ticket. Now for that simply If you
can, start with DjangoSocketIO
at https://djangopackages.org/grids/g/chat/. After you've created and
integrated in your project then extend this with submodel of Tickets. Then
in view you can define that if you select a particular message to be
treated as ticket then how should that particular message behave.

Or you simply can use two packages like DjangoSocketIO and DjangoHelpDesk
and create a sublayer model that combines feature of both the packages and
then you iterate the behaviour in your view.

It may look complicated but to keep it simple I hope this will be a good
start. Craft your app with a visual work process or mockup and then
everybody will start helping you.

With generic question It will be hard for anyone to help you and yes you
can treat a chat as ticket.

Looking forward you start working on it so this group can help you create
it.
Hope this is helpful.

Regards,
Mudassar

On Mon, Sep 12, 2016 at 4:18 AM, Alexandra 
wrote:

> Hi, could you please suggest other forums where I can find this
> information?
> Thank you in advance!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/fe028722-d44a-40ff-b26d-d9813268213c%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


django symlink error for windows

2016-09-03 Thread M Hashmi
How to create a symbolic link in windows for error below using mlink?
Please advise.

Template error:
In template
C:\Python27\lib\site-packages\oscar\templates\oscar\dashboard\catalogue\product_row_image.html,
error at line 2
   'module' object has no attribute 'symlink'

   1 : {% load thumbnail %}



   2 :  {% if record.primary_image.original.url %}



   3 : {% with image=record.primary_image %}



   4 : {% thumbnail image.original "70x70" upscale=False as thumb %}



   5 : 



   6 : 



   7 : 



   8 : {% endthumbnail %}



   9 : {% endwith %}



   10 : {% else %}



   11 : —



   12 : {% endif %}


Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
get_response
  164. response = response.render()
File "C:\Python27\lib\site-packages\django\template\response.py" in render
  158. self.content = self.rendered_content
File "C:\Python27\lib\site-packages\django\template\response.py" in
rendered_content
  135. content = template.render(context, self._request)
File "C:\Python27\lib\site-packages\django\template\backends\django.py" in
render
  74. return self.template.render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in render
  210. return self._render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in _render
  202. return self.nodelist.render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in render
  905. bit = self.render_node(node, context)
File "C:\Python27\lib\site-packages\django\template\debug.py" in render_node
  79. return node.render(context)
File "C:\Python27\lib\site-packages\django\template\loader_tags.py" in
render
  135. return compiled_parent._render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in _render
  202. return self.nodelist.render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in render
  905. bit = self.render_node(node, context)
File "C:\Python27\lib\site-packages\django\template\debug.py" in render_node
  79. return node.render(context)
File "C:\Python27\lib\site-packages\django\template\loader_tags.py" in
render
  135. return compiled_parent._render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in _render
  202. return self.nodelist.render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in render
  905. bit = self.render_node(node, context)
File "C:\Python27\lib\site-packages\django\template\debug.py" in render_node
  79. return node.render(context)
File "C:\Python27\lib\site-packages\django\template\loader_tags.py" in
render
  135. return compiled_parent._render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in _render
  202. return self.nodelist.render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in render
  905. bit = self.render_node(node, context)
File "C:\Python27\lib\site-packages\django\template\debug.py" in render_node
  79. return node.render(context)
File "C:\Python27\lib\site-packages\django\template\loader_tags.py" in
render
  65. result = block.nodelist.render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in render
  905. bit = self.render_node(node, context)
File "C:\Python27\lib\site-packages\django\template\debug.py" in render_node
  79. return node.render(context)
File "C:\Python27\lib\site-packages\django\template\loader_tags.py" in
render
  65. result = block.nodelist.render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in render
  905. bit = self.render_node(node, context)
File "C:\Python27\lib\site-packages\django\template\debug.py" in render_node
  79. return node.render(context)
File "C:\Python27\lib\site-packages\django\template\loader_tags.py" in
render
  65. result = block.nodelist.render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in render
  905. bit = self.render_node(node, context)
File "C:\Python27\lib\site-packages\django\template\debug.py" in render_node
  79. return node.render(context)
File "C:\Python27\lib\site-packages\django\template\defaulttags.py" in
render
  329. return nodelist.render(context)
File "C:\Python27\lib\site-packages\django\template\base.py" in render
  905. bit = self.render_node(node, context)
File "C:\Python27\lib\site-packages\django\template\debug.py" in render_node
  79. return node.render(context)
File "C:\Python27\lib\site-packages\django\template\loader_tags.py" in
render
  65. result = block.nodelist.render(context)
File "C:

Re: Filtering models by user or by items

2016-09-01 Thread M Hashmi
What did you get with:
products = Product.objects.filter(account=user)
As it is inheriting user from get_shopaccount method.

Regards,
Mudassar

On Thu, Sep 1, 2016 at 8:45 AM, Shamaila Moazzam  wrote:

> am making a shops dashboard view .in that view i have used a mixin as
> mentioned belowmy issue is i want to get products related to a specific
> account or user . i have products m2m in shop model and also have user f.k
> in Shop model. In get_shopproducts() function in ShopAccountMixin()..i am
> unable to filter products of a requested account. please reply...
> shops/models.py
>
>
> class Shop(models.Model):
> user = models.ForeignKey(settings.AUTH_USER_MODEL)
> product = models.ManyToManyField(Product)
> ..
> def __unicode__(self):
> return str(self.user.username)
>
>
>   products/models.py
> class Product(models.Model):
>
>   title = models.CharField(max_length=120)
>   description = models.TextField(blank=True, null=True)
>   price = models.DecimalField(decimal_places=2, max_digits=20)
>   publish_date = models.DateTimeField(auto_now=False, 
> auto_now_add=False,
> ...
>def __unicode__(self): #def __str__(self):
>return self.title
>
>
>  shops/mixins.py
>
>class ShopAccountMixin(LoginRequiredMixin, object):
> def get_shopaccount(self):
> user = self.request.user
> shopaccount = Shop.objects.filter(user=user)
> if shopaccount.exists():
>return shopaccount
> else:
> return None
>
>  def get_shopproducts(self):
> account = self.get_shopaccount()
> ## this is the problem area..
>   here i want to filter like
>   products = Product.objects.all(account???)???
>
> return products
>
>
>   class shopsDashBoard(ShopAccountMixin, FormMixin, View):
>  model = Shop
> form_class = SellerForm
> template_name = "shops/seller.html"
>  def get(self, request, *args, **kwargs):
>
> apply_form = self.get_form()
> account = self.get_shopaccount()
> exists = account
> active = None
> context = {}
> if exists:
> active = account.active
> context["active"] = active
> if not exists and not active:
> context["title"] = "Apply for Account"
> context["apply_form"] = apply_form
> elif exists and not active:
> context["title"] = "Account Pending"
>  elif exists and active:
> context["title"] = "Shops Dashboard"
>
>
>
> #products = Product.objects.filter(seller=account)
> context["products"] = self.get_shopproducts()
>
> return render(request, "shops/dashboard.html", context)
>
> --
> 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/CAFimi6wB1Ycnz2On4EALzvM5b0M-
> a17sB4PXpKFA5KdCiFK4WQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Pygame

2016-09-01 Thread M Hashmi
Lets divide the answer in two different segments knowledge and information.
1. Information:

No you cannot.

2.Knowledge:
Every framework works with basic request based structure comprising on
requests of GET and POST.
When you are interacting with a website from browser all that is working at
background services is GET, POST.
In django views you have a "request" as main component to define the way
your function will be used. Request is a Meta class that further divides
into two more segments of request.GET and request.POST. Both contains bunch
of information such as session, context variables, IP addresses, users etc.
Pygame is devised for Desktop or even Mobile architectures to an extent and
Django request structure is alien for it.

Having said that...there is no limitations in programming and you can do
anything you want. However to achieve an objective you need to define
shortest possible path. In this case if you will try to work with PyGame on
Django you can do it but its like reinventing the wheel. You will have to
write integration mechanism for PyGame to Django. There are other options
available and you can google it to find the best one that suits you.

Just remember! I didn't said its not possible I just told you can't do it
with current available architecture of both as far as I know of it.
Impossible just takes a longer while for things to happen.
:-)
Cheers.

On Thu, Sep 1, 2016 at 5:19 AM, DB32  wrote:

> Is Django able to support pygame? For example am I able to display
> somethings made in pygame onto a web page?
> The pygame will have a lot of different assets, images ect which are
> imported from my files
>
> --
> 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/f89cdc4b-e4b2-4a21-8ff2-0408ffacc659%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: 1.7.9 deployment stubbornly won't create a test database

2016-08-30 Thread M Hashmi
My bad...missed the version in original question.

You are right.

On Tue, Aug 30, 2016 at 4:59 PM, Andromeda Yelton <
andromeda.yel...@gmail.com> wrote:

> What are do the relevant parts of your settings file say? In particular,
> https://docs.djangoproject.com/en/1.7/topics/testing/overview/#the-
> test-database says "If you want to use a different database name, specify
> NAME in the TEST dictionary for any given database in DATABASES." - I would
> check there to see if someone has overridden the default. There's also a
> little section in the docs labeled "Finding data from your production
> database when running tests?" that might be relevant to you.
>
> (--keepdb is a great flag but sadly irrelevant as it was not introduced
> until 1.8.)
>
> On Mon, Aug 29, 2016 at 6:26 PM, Adam Hirsch 
> wrote:
>
>> I've been handed a fairly large and built-up django 1.7.9 installation
>> with several dozen pre-existing in-house modules and a lot of history.
>>
>> For some reason, any attempt to * manage.py test * any of the existing
>> modules runs tests against the live database specified in 
>> *DATABASES['default']
>> *rather than attempting to create a new test database.  I've written a
>> couple of simple unit tests for a given module, generated a small fixture
>> of data to apply to a blank schema for testing ... but I can't for the life
>> of me find why this installation isn't creating a test_db. No errors, no
>> failures ... just tests run against the production db.
>>
>> Anyone have a pointer to what might be going on, or concepts to look up?
>> A simple Hello World install using the same django version on the same
>> machine works exactly as the docs suggest it should: I see
>>
>> Creating test database for alias 'default' (':memory:')...
>> [...]
>> Destroying test database for alias 'default' (':memory:')...
>>
>>
>> ... but there are no such lines in my real installation.  I'm baffled.
>>
>> Adam
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/ea373ba9-9c9e-4358-9c71-b3c0d1c4b3d9%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Andromeda Yelton
> Vice President/President-Elect, Library & Information Technology
> Association: http://www.lita.org
> http://andromedayelton.com
> @ThatAndromeda 
>
> --
> 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/CAFE1XCbL_cm1pYGMpo-gv%3D3z0WkmeYaQZTsvLzHMR56gHpM7_
> A%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: 1.7.9 deployment stubbornly won't create a test database

2016-08-30 Thread M Hashmi
Try this:

python manage.py test --keepdb


On Mon, Aug 29, 2016 at 3:26 PM, Adam Hirsch 
wrote:

> I've been handed a fairly large and built-up django 1.7.9 installation
> with several dozen pre-existing in-house modules and a lot of history.
>
> For some reason, any attempt to * manage.py test * any of the existing
> modules runs tests against the live database specified in 
> *DATABASES['default']
> *rather than attempting to create a new test database.  I've written a
> couple of simple unit tests for a given module, generated a small fixture
> of data to apply to a blank schema for testing ... but I can't for the life
> of me find why this installation isn't creating a test_db. No errors, no
> failures ... just tests run against the production db.
>
> Anyone have a pointer to what might be going on, or concepts to look up? A
> simple Hello World install using the same django version on the same
> machine works exactly as the docs suggest it should: I see
>
> Creating test database for alias 'default' (':memory:')...
> [...]
> Destroying test database for alias 'default' (':memory:')...
>
>
> ... but there are no such lines in my real installation.  I'm baffled.
>
> Adam
>
>
>
> --
> 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/ea373ba9-9c9e-4358-9c71-b3c0d1c4b3d9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts4gRa9tdroug%2BcGk-36iv_GHFT1HpUQxZtiW-WekPN_PA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: help designing a fallback django paralel server

2016-08-30 Thread M Hashmi
Not sure what exactly you want because why would you want your workers to
access server on speed of internet when you have them locally connected.

However, as far as I understood is that you can have one machine setup as
remote with some firewall that will open up ports based on local IP
addresses. If you mean you have multiple django projects then you can
assign separate ports to each project and use gunicorn or any other same
functionality based application. What gunicorn do is that it associates
your internal port to a socket that can be accessed from local network or
web. You can then let the django admin/authorization system handle
authentication based on provided credentials.

Again I have no idea what architecture you are using but let's assume to
keep it simple you have NT implemented network, then you can set profilings
attached to connection states after implementing any firewall software.

For a precise answer please send some diagram with information about your
network architecture.

Regards,
Mudassar

On Tue, Aug 30, 2016 at 1:02 AM, Marco Silva 
wrote:

> Hello,
>
> I have several critical systems, each run a django server witch users use
> trough the local network(192.168.xxx.xxx)  to control and monitor the
> system. The goal would be to create a more powerfull remote server, that
> could unify several local servers, so that regular use would be only trough
> this remote server, and local access should be only available for when
> internet connection would fail.
>
> How should i implement this systems? how would the DB sync?
> Also, some services should run on the local server, like some celery based
> scheduled tasks.
>
> --
> 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/de599153-2adc-4fd4-a5f4-b04f5149b4fd%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to create a database for my website in Django

2016-08-30 Thread M Hashmi
Hi,

First of all as far as creation of database is concerned there is
comprehensive documentation at djagnoproject.com in tutorial section. Once
you've created database then you can use "forms" to get data from the front
end to save it in db. Before you go through all this exercise I would
suggest you to choose a tutorial of small app on youtube.com to build some
basic djagno application. You will learn it quickly this way because with
posting messages for each step it will take  a lot time for you to
understand things.

Pick up a tutorial of your choice video or documented tutorial and repeat
it at least thrice for the first time.

Next if you can't understand some sections of tutorial you can post on this
group and people will love to help you out. Same tutorial might fit your
exact needs and a video tutorial won't take long to get you up to the point
you intend to raise yourself.

Regards,
Mudassar

On Tue, Aug 30, 2016 at 3:23 PM, Jeff Goes 
wrote:

> I have little knowledge when it comes to the creation of databases. I
> would like to know if someone can help me set a database for my website
> step by step since I have a deadline due to next month to finish a project
> that requires that kind of knowledge. The idea is to input information on
> the website and save them into an internal database. I already have MySql
> and Sequel Pro installed but don't know how to link them to my website.
>
> I appreciate it.
>
> --
> 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/500d5d57-6c92-4f3e-947d-cfb5d74092d9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Redis error on initial migration

2016-08-27 Thread M Hashmi
I did nothing in code yet just installed the app from repo and
dependencies. But this error doesn't make sense to me so I thought somebody
might had gone through this.

Author has same question about this in "issue" are at github. Question is
not answered yet.
Regards,
Mudassar

On Sat, Aug 27, 2016 at 2:03 PM, James Schneider 
wrote:

> On Aug 27, 2016 1:49 PM, "M Hashmi"  wrote:
> >
> > Hi,
> > I am trying to setup "saleor" e-commerce on windows and getting this
> error.
> >
> > (saleorpro) C:\Users\Mudassar\saleorpro\saleor>manage.py makemigrations
> > SystemCheckError: System check identified some issues:
> >
> > CRITICALS:
> > userprofile.User: (auth.C009)  User'>.is_anonym
> > ous must be an attribute or property rather than a method. Ignoring this
> is a se
> > curity issue as anonymous users will be treated as authenticated!
> > userprofile.User: (auth.C010)  User'>.is_authen
> > ticated must be an attribute or property rather than a method. Ignoring
> this is
> > a security issue as anonymous users will be treated as authenticated!
> >
>
> What does the saleor.userprofile.models.User look like? I'd looks like you
> are overriding is_anonymous and is_authenticated as methods, rather than
> keeping them as attributes or even properties.
>
> Perhaps you forgot to decorate those methods as properties?
>
> The Redis reference is simply a suggestion as a method for handling global
> caching.
>
> Is this a 3rd party package? If so perhaps the author's documentation has
> something about this?
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciUa%3DcEWQRzt8HOeYBk81QYM7wEN_CD_
> JfWqGXcTuD1F8Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUa%3DcEWQRzt8HOeYBk81QYM7wEN_CD_JfWqGXcTuD1F8Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Redis error on initial migration

2016-08-27 Thread M Hashmi
Hi,
I am trying to setup "saleor" e-commerce on windows and getting this error.

(saleorpro) C:\Users\Mudassar\saleorpro\saleor>manage.py makemigrations
SystemCheckError: System check identified some issues:

CRITICALS:
userprofile.User: (auth.C009) .is_anonym
ous must be an attribute or property rather than a method. Ignoring this is
a se
curity issue as anonymous users will be treated as authenticated!
userprofile.User: (auth.C010) .is_authen
ticated must be an attribute or property rather than a method. Ignoring
this is
a security issue as anonymous users will be treated as authenticated!

WARNINGS:
saleor.W001: Session caching cannot work with locmem backend
HINT: User sessions need to be globally shared, use a cache server
like
Redis.

Any Idea?
Regards,
Mudassar

-- 
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/CANoUts6RPfHLRmjQmACs4dtU3E0T_rb%3D%2BRxjitMW_n%3D11Yj%3DNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hi. i'm new to django, i have lot of doubts about AD

2016-08-25 Thread M Hashmi
What is your code and what you are trying to achieve?

On Thu, Aug 25, 2016 at 5:18 AM, rajeshkmr9583 
wrote:

> Hi guys,
> i'm new to django framework and now my doubt id how to create AD for
> login page
>
> 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/b866-4026-4f3d-9b0f-1840ab90a57a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts5tB%2B4E9yuyzHowB%2BXFkSx6rEQJkrFgkTt6np2v58L%2BzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django-drip not working

2016-08-20 Thread M Hashmi
Yeah I know that but I thought it would be easy to get it ported manually
but after reading code twice I guess I can wait till owner of repo do so.
Thanks for help.

Regards,
Mudassar

On Sat, Aug 20, 2016 at 9:15 AM, Simon Charette 
wrote:

> It looks like django-drip has not been ported to Django 1.8 yet.
>
>
> Le samedi 20 août 2016 09:41:06 UTC-4, M Hashmi a écrit :
>
>> Now I am getting another error:
>>
>> Traceback:
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
>> in get_response
>>
>>   132. response = wrapped_callback(request,
>> *callback_args, **callback_kwargs)
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
>> in wrapper
>>
>>   616. return self.admin_site.admin_view(view)(*args,
>> **kwargs)
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
>> in _wrapped_view
>>
>>   110. response = view_func(request, *args, **kwargs)
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
>> in _wrapped_view_func
>>
>>   57. response = view_func(request, *args, **kwargs)
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
>> in inner
>>
>>   233. return view(request, *args, **kwargs)
>>
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
>> add_view
>>
>>   83. request, extra_context=self.build_extra
>> _context(extra_context))
>>
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
>> build_extra_context
>>
>>   78. extra_context['field_data'] = json.dumps(get_simple_fields(U
>> ser))
>>
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
>> get_simple_fields
>>
>>   118. return [[f[0], f[3].__name__] for f in get_fields(Model,
>> **kwargs)]
>>
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
>> get_fields
>>
>>   95. RelModel = field.related.parent_model
>>
>>
>> Exception Type: AttributeError at /admin/drip/drip/add/
>>
>> Exception Value: 'ManyToManyRel' object has no attribute 'parent_model'
>>
>> However at line 95 "RelModel = field.related.*parent_model*" is
>> referencing to following:
>>
>> patent_model{InlineModelAdmin in}
>> patent_model{InlineModelAdmin in django.contrib.admin.options}
>> patent_model{InlineModelAdmin in django_common.admin}
>>
>> Regards,
>> Mudassar
>>
>> On Sat, Aug 20, 2016 at 5:52 AM, Tim Graham  wrote:
>>
>>> Looks like it could be a bug in django-drip because:
>>>
>>> Model._meta.fields + Model._meta.many_to_many +
>>> Model._meta.get_all_related_objects()
>>> (tuple) + (tuple) + (list)
>>>
>>> A possible fix could be: ... + tuple(Model._meta.get_all_rela
>>> ted_objects())
>>>
>>>
>>> On Saturday, August 20, 2016 at 7:56:46 AM UTC-4, M Hashmi wrote:
>>>>
>>>> Hi Guys,
>>>>
>>>> I am having trouble with Django-drip and couldn't search a solution and
>>>> hard to figure out. The error pops up when I try to add a Drip. My
>>>> settings.py has "DRIP_FROM_MAIL" field and EMAIL_HOST field both. I've
>>>> added django-drip and migrated for django==1.8.13 it worked fine but now
>>>> stuck at "get_fields" error.
>>>>
>>>> Following is the traceback:
>>>>
>>>> Traceback:
>>>> File 
>>>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
>>>> in get_response
>>>>   132. response = wrapped_callback(request,
>>>> *callback_args, **callback_kwargs)
>>>> File 
>>>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
>>>> in wrapper
>>>>   616. return self.admin_site.admin_view(view)(*args,
>>>> **kwargs)
>>>> File 
>>>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
>>>> in 

Re: Django-drip not working

2016-08-20 Thread M Hashmi
Now I am getting another error:

Traceback:

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
in get_response

  132. response = wrapped_callback(request,
*callback_args, **callback_kwargs)

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
in wrapper

  616. return self.admin_site.admin_view(view)(*args,
**kwargs)

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
in _wrapped_view

  110. response = view_func(request, *args, **kwargs)

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func

  57. response = view_func(request, *args, **kwargs)

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
in inner

  233. return view(request, *args, **kwargs)

File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
add_view

  83. request,
extra_context=self.build_extra_context(extra_context))

File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
build_extra_context

  78. extra_context['field_data'] =
json.dumps(get_simple_fields(User))

File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
get_simple_fields

  118. return [[f[0], f[3].__name__] for f in get_fields(Model,
**kwargs)]

File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
get_fields

  95. RelModel = field.related.parent_model


Exception Type: AttributeError at /admin/drip/drip/add/

Exception Value: 'ManyToManyRel' object has no attribute 'parent_model'

However at line 95 "RelModel = field.related.*parent_model*" is referencing
to following:

patent_model{InlineModelAdmin in}
patent_model{InlineModelAdmin in django.contrib.admin.options}
patent_model{InlineModelAdmin in django_common.admin}

Regards,
Mudassar

On Sat, Aug 20, 2016 at 5:52 AM, Tim Graham  wrote:

> Looks like it could be a bug in django-drip because:
>
> Model._meta.fields + Model._meta.many_to_many +
> Model._meta.get_all_related_objects()
> (tuple) + (tuple) + (list)
>
> A possible fix could be: ... + tuple(Model._meta.get_all_
> related_objects())
>
>
> On Saturday, August 20, 2016 at 7:56:46 AM UTC-4, M Hashmi wrote:
>>
>> Hi Guys,
>>
>> I am having trouble with Django-drip and couldn't search a solution and
>> hard to figure out. The error pops up when I try to add a Drip. My
>> settings.py has "DRIP_FROM_MAIL" field and EMAIL_HOST field both. I've
>> added django-drip and migrated for django==1.8.13 it worked fine but now
>> stuck at "get_fields" error.
>>
>> Following is the traceback:
>>
>> Traceback:
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
>> in get_response
>>   132. response = wrapped_callback(request,
>> *callback_args, **callback_kwargs)
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
>> in wrapper
>>   616. return self.admin_site.admin_view(view)(*args,
>> **kwargs)
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
>> in _wrapped_view
>>   110. response = view_func(request, *args, **kwargs)
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
>> in _wrapped_view_func
>>   57. response = view_func(request, *args, **kwargs)
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
>> in inner
>>   233. return view(request, *args, **kwargs)
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
>> add_view
>>   83. request, extra_context=self.build_extra
>> _context(extra_context))
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
>> build_extra_context
>>   78. extra_context['field_data'] = json.dumps(get_simple_fields(U
>> ser))
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
>> get_simple_fields
>>   118. return [[f[0], f[3].__name__] for f in get_fields(Model,
>> **kwargs)]
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
>> get_fields
>>   48. fields = Model._meta.fields + Model.

Django-drip not working

2016-08-20 Thread M Hashmi
Hi Guys,

I am having trouble with Django-drip and couldn't search a solution and
hard to figure out. The error pops up when I try to add a Drip. My
settings.py has "DRIP_FROM_MAIL" field and EMAIL_HOST field both. I've
added django-drip and migrated for django==1.8.13 it worked fine but now
stuck at "get_fields" error.

Following is the traceback:

Traceback:
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
in get_response
  132. response = wrapped_callback(request,
*callback_args, **callback_kwargs)
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
in wrapper
  616. return self.admin_site.admin_view(view)(*args,
**kwargs)
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
in _wrapped_view
  110. response = view_func(request, *args, **kwargs)
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  57. response = view_func(request, *args, **kwargs)
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
in inner
  233. return view(request, *args, **kwargs)
File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
add_view
  83. request,
extra_context=self.build_extra_context(extra_context))
File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
build_extra_context
  78. extra_context['field_data'] =
json.dumps(get_simple_fields(User))
File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
get_simple_fields
  118. return [[f[0], f[3].__name__] for f in get_fields(Model,
**kwargs)]
File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
get_fields
  48. fields = Model._meta.fields + Model._meta.many_to_many +
Model._meta.get_all_related_objects()

Exception Type: TypeError at /admin/drip/drip/add/
Exception Value: can only concatenate tuple (not "list") to tuple

I've also searched issues opened in past with "
https://github.com/zapier/django-drip/issues"; and was able to solve few
problems but can't solve this one.Please advise.

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


Re: Implementing django auth system with relational models

2016-08-18 Thread M Hashmi
Ludovic,

Shouldn't she be using model managers for this?

Just curious.

Regards,
Mudassar






On Wed, Aug 17, 2016 at 2:37 PM, ludovic coues  wrote:

> Ok, sorry, I made a off by one error on the link :)
>
> Try that:
>
> # shops/admin.py
> from django.contrib import admin
> from products.models import Product
> from .models import Shop
>
> class ShopAdmin(admin.ModelAdmin):
> def formfield_for_manytomany(self, db_field, request, **kwargs):
> if db_field.name == "product":
> kwargs["queryset"] = Product.objects.filter(user=request.user)
> return super(ShopAdmin,
> self).formfield_for_manytomany(db_field, request, **kwargs)
>
> admin.site.register(Shop, ShopAdmin)
>
> ###
>
> It should give you the desired result
>
> 2016-08-17 19:31 GMT+02:00 Shamaila Moazzam :
> >
> > shops/admin.py
> > from .models import Shop
> >
> > admin.site.register(Shop)
> >
> >
> > products/admin.py
> >
> >
> > from .models import Product, Variation, ProductImage, Category,
> > ProductFeatured, color_product, size_product
> >
> >
> >
> > class ProductImageInline(admin.TabularInline):
> > model = ProductImage
> > extra = 0
> > max_num = 10
> >
> > class VariationInline(admin.TabularInline):
> > model = Variation
> > extra = 0
> > max_num = 10
> >
> >
> > class ProductAdmin(admin.ModelAdmin):
> > list_display = ['__unicode__', 'price',]
> > inlines = [
> > ProductImageInline,
> > VariationInline,
> >
> >
> > ]
> > class Meta:
> > model = Product
> >
> >
> > admin.site.register(Product, ProductAdmin)
> >
> >
> >
> >
> > #admin.site.register(Variation)
> >
> > admin.site.register(ProductImage)
> >
> >
> > admin.site.register(Category)
> >
> >
> > admin.site.register(ProductFeatured)
> >
> > admin.site.register(color_product)
> >
> > admin.site.register(size_product)
> >
> > On Wednesday, August 17, 2016 at 9:23:31 PM UTC+5, ludovic coues wrote:
> >>
> >> Could you share your admin.py file ?
> >>
> >> You might be interested into this part of the documentation:
> >>
> >> https://docs.djangoproject.com/en/1.10/ref/contrib/admin/
> #django.contrib.admin.ModelAdmin.formfield_for_foreignkey
> >>
> >> 2016-08-17 17:20 GMT+02:00 Shamaila Moazzam :
> >> > @Ludovic there is no error. Just I don't want to get all the products
> >> > pre-populated. I need empty products field and only when user uploads
> >> > products then it should show me products. Please advise
> >> >
> >> > On Wednesday, August 17, 2016 at 6:37:51 PM UTC+5, Shamaila Moazzam
> >> > wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> I am a beginner and please forgive me if my question is not up to the
> >> >> standard. I've got two models one is Product which is saved in db
> >> >> already
> >> >> and another one is Shop. I am trying to related both models with
> >> >> following
> >> >> code.
> >> >>
> >> >> class Product(models.Model):
> >> >> user = models.ForeignKey(settings.USER_AUTH_MODEL)
> >> >> title = models.CharField(max_length=120)
> >> >> description = models.TextField(blank=True, null=True)
> >> >> price = models.DecimalField(decimal_places=2, max_digits=20)
> >> >> publish_date = models.DateTimeField(auto_now=False,
> >> >> auto_now_add=False, null=True, blank= True)
> >> >> expire_date = models.DateTimeField(auto_now=False,
> >> >> auto_now_add=False,
> >> >> null=True, blank=True)
> >> >> active = models.BooleanField(default=True)
> >> >> categories = models.ManyToManyField('Category', blank=True)
> >> >> default = models.ForeignKey('Category',
> >> >> related_name='default_category', null=True, blank=True)
> >> >> hitcounts = GenericRelation(HitCount,
> >> >> content_type_field='content_type', object_id_field='object_pk',)
> >> >>
> >> >>
> >> >> objects = ProductManager()
> >> >>
> >> >>
> >> >> class Meta:
> >> >> ordering = ["-title"]
> >> >>
> >> >>
> >> >> def __unicode__(self):
> >> >> return self.title
> >> >>
> >> >>
> >> >> class Shop(models.Model):
> >> >> product = models.ManyToManyField(Product)
> >> >>
> >> >> title = models.CharField(max_length=120, null=False)
> >> >> image = models.ImageField(upload_to=image_upload_to_shop,
> >> >> null=True)
> >> >> location = models.CharField(max_length=120)
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> def __unicode__(self):
> >> >> return str(self.title)
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> With above I've got it added in my admin.py for Shop app and now I
> have
> >> >> a
> >> >> problem. When I add a shop it shows all the past products
> prepopulated
> >> >> in my
> >> >> "products" field.
> >> >> I just need to add the products that shop account holder has
> uploaded.
> >> >> I
> >> >> wish to use django\s built-in auth model to register shop holders.
> >> >> Again the
> >> >> confusion is that where should I add
> >> >> USER_AUTH_MODEL in "Shop" or in "Products". If I added it shop app
> then
> >> >> for beginner like me it will be easy to use querysets. Please advise
> >> >> the
> >>

Re: Implementing django auth system with relational models

2016-08-17 Thread M Hashmi
So what you are saying is that you don't need to get all the products
instead only products uploaded by a particular user?
This makes sense because you are getting the whole model called with the
key so if I am getting your question right you just need to apply some sort
of filter to get user related products. Which means by default first time
user gets registered it shouldn't show any products but same time if
product is added by the shop owner he should be able to see that.

Respond please.

On Wed, Aug 17, 2016 at 6:44 AM, ludovic coues  wrote:

> Do you have any error with the code you posted ?
> It look like you already have a foreign key to your user.
>
> 2016-08-17 15:33 GMT+02:00 Shamaila Moazzam :
> > Hi,
> >
> > I am a beginner and please forgive me if my question is not up to the
> > standard. I've got two models one is Product which is saved in db already
> > and another one is Shop. I am trying to related both models with
> following
> > code.
> >
> > class Product(models.Model):
> > user = models.ForeignKey(settings.USER_AUTH_MODEL)
> > title = models.CharField(max_length=120)
> > description = models.TextField(blank=True, null=True)
> > price = models.DecimalField(decimal_places=2, max_digits=20)
> > publish_date = models.DateTimeField(auto_now=False,
> auto_now_add=False,
> > null=True, blank= True)
> > expire_date = models.DateTimeField(auto_now=False,
> auto_now_add=False,
> > null=True, blank=True)
> > active = models.BooleanField(default=True)
> > categories = models.ManyToManyField('Category', blank=True)
> > default = models.ForeignKey('Category', related_name='default_
> category',
> > null=True, blank=True)
> > hitcounts = GenericRelation(HitCount, content_type_field='content_
> type',
> > object_id_field='object_pk',)
> >
> >
> > objects = ProductManager()
> >
> >
> > class Meta:
> > ordering = ["-title"]
> >
> >
> > def __unicode__(self):
> > return self.title
> >
> >
> > class Shop(models.Model):
> > product = models.ManyToManyField(Product)
> >
> > title = models.CharField(max_length=120, null=False)
> > image = models.ImageField(upload_to=image_upload_to_shop, null=True)
> > location = models.CharField(max_length=120)
> >
> >
> >
> >
> > def __unicode__(self):
> > return str(self.title)
> >
> >
> >
> >
> > With above I've got it added in my admin.py for Shop app and now I have a
> > problem. When I add a shop it shows all the past products prepopulated
> in my
> > "products" field.
> > I just need to add the products that shop account holder has uploaded. I
> > wish to use django\s built-in auth model to register shop holders. Again
> the
> > confusion is that where should I add
> > USER_AUTH_MODEL in "Shop" or in "Products". If I added it shop app then
> for
> > beginner like me it will be easy to use querysets. Please advise the best
> > practice for above scenario.
> >
> > --
> > 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/bf649b76-
> 0a5e-4e48-b54c-dfdcd0ae1a16%40googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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/CAEuG%2BTaAb_nooX2bzMT_mrnRLD--
> keYP9SM_v7BTLj6fdw_owg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: nginx+uwsgi, cache somewhere but I don't know where

2016-08-16 Thread M Hashmi
Reload Nginx and see if still its loading cached query.

On Tue, Aug 16, 2016 at 8:18 AM, 술욱  wrote:

> Hello
>
> I'm running (in production) and app that uses raw queries, something like:
>
> query = """
> select table1.field1, table2.field3
> from table1 left join table2
>on test1.field1 = test2.field1
>and test1.field2 = test2.field2
> where table1.field1 = %(param1)s
> """
>
> cursor = connections['database'].cursor()
> cursor.execute(query, {'param1': param1-value})
> data = cursor.fetchall()
>
>
> My problem is, somewhere, Django, uwsgi, or nginx, is caching this query.
>
> How do I find who's caching?
>
>
> Thanks,
> Norberto
>
> --
> 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/CADut3oCG%2Bc%3D8CFm5Mf0YiBtK3RMa-
> 0KrZZG6wb0_ihDwkDmqkQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts63A-mGo-KOYJHBFJtOut9gasWX3A8dso3%3Dv0myFwgAgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Strange bug with form errors

2016-08-15 Thread M Hashmi
Ok great.

Take care.

On Mon, Aug 15, 2016 at 3:10 AM, Nestor Burma  wrote:

> Oh I just have found the trick !
> It comes from a django bug in some earlier version of django 1.9. in
> FormeMixinBase.form_invalid()
>
> I had:
> def form_invalid(self, form):
> return self.render_to_response(self.get_context_data())
>
> in place of:
> def form_invalid(self, form):
> return self.render_to_response(self.get_context_data(form=form))
>
> so parameters wasn't transfered. Probably my pip did'nt install last
> version, and my production version was not exactly the same as my
> development one... An upgrade solved the problem.
>
> Ouf ! I believed I was going to come crazy !
>
> Thank's for your answer.
>
> *Envoyé:* lundi 15 août 2016 à 08:59
> *De:* "M Hashmi" 
> *À:* django-users@googlegroups.com
> *Objet:* Re: Strange bug with form errors
> Can you paste the full traceback from production server?
>
> On Sun, Aug 14, 2016 at 11:53 PM, Nestor Burma 
> wrote:
>>
>> I have a very strange bug with fom errors. *On my development site, my
>> code works fine*. But on my production site (apache + mod-wgsi +
>> posgresql), the form errors I defined in is_valid() method of my ModelForm
>> (in a generic CreateView) are not product by the template. Have you already
>> seen such a thing ?
>>
>> Here is my code :
>>
>>
>> *views.py:*
>> class UserCreate(CreateView):
>> model = User
>> template_name = 'base/userCreate.html'
>> success_url = '/utilisateurs/nouveau/success/{id}'
>> form_class = UtilisateurCreateForm
>>
>> *forms.py:*
>> class UtilisateurCreateForm(forms.ModelForm):
>> class Meta:
>> model = User
>> fields = ['first_name', 'last_name', 'email']
>> def is_valid(self):
>> valid =  super().is_valid()
>> if email != '' and User.objects.filter(email = email).exists():
>> self.add_error('email', 'Il existe déjà un utilisateur avec
>> cet email.')
>> valid = False
>> return valid
>>
>> *userCreate.html:*
>> {% extends "base/base.html" %}
>> {% block contenu %}
>> Nouvel utilisateur :
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>> {% endblock %}
>>
>> Thank's for your 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/trinity-68cd841e-22eb-421b-95ea-
>> 2b94ca00a28b-1471243983623%403capp-mailcom-bs11
>> <https://groups.google.com/d/msgid/django-users/trinity-68cd841e-22eb-421b-95ea-2b94ca00a28b-1471243983623%403capp-mailcom-bs11?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CANoUts4VJ61snPG3M%3DNHKn5mhfnQ8G_
> FOZNs3XeYoV8yhmJc0Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANoUts4VJ61snPG3M%3DNHKn5mhfnQ8G_FOZNs3XeYoV8yhmJc0Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/trinity-8a769b2c-ae6e-412e-9a23-
> 0d8a855897ce-1471255

Re: how to integrate django framework in android app ????

2016-08-15 Thread M Hashmi
If you need to expose your django application for other platforms then you
must be looking for Django RestFramework. Read the docs and you will
understand.

M

On Sun, Aug 14, 2016 at 1:30 AM, ludovic coues  wrote:

> Could you detail a bit more what you are trying to achieve ?
>
> What do you mean by "integrating" ? What step have you tried ? Are you
> new as in "have never read a single page of the documentation" or new
> as in "have only done a pair of small test site" ?
>
> I have trouble do understand what you are trying to do and if that's
> possible at all. I assume I'm not the only one in this situation.
>
> If you want a short and fast answer based on the information you have
> given, here is:
> Django can't run on android.
> Django run on server and your android app will integrate with your
> django application, which is a website, through HTTP(S). You can do
> that with a simple webview and displaying page from the django app or
> using an API and transfering JSON data or be creative.
>
> 2016-08-13 21:31 GMT+02:00 Techart Team :
> > i am new to django and i want to integrate my django framework to my
> android
> > studio. how to do it ? please tell me fast.
> >
> > --
> > 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/0b5ecdc3-
> fe9f-4cde-861e-c70ee71a0d99%40googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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/CAEuG%2BTb7OtWfRTyzn-0R6V-VU_r3vtghFXX1vnV6nBMXsMCz9A%
> 40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Strange bug with form errors

2016-08-15 Thread M Hashmi
Can you paste the full traceback from production server?

On Sun, Aug 14, 2016 at 11:53 PM, Nestor Burma  wrote:

> I have a very strange bug with fom errors. *On my development site, my
> code works fine*. But on my production site (apache + mod-wgsi +
> posgresql), the form errors I defined in is_valid() method of my ModelForm
> (in a generic CreateView) are not product by the template. Have you already
> seen such a thing ?
>
> Here is my code :
>
>
> *views.py:*
> class UserCreate(CreateView):
> model = User
> template_name = 'base/userCreate.html'
> success_url = '/utilisateurs/nouveau/success/{id}'
> form_class = UtilisateurCreateForm
>
> *forms.py:*
> class UtilisateurCreateForm(forms.ModelForm):
> class Meta:
> model = User
> fields = ['first_name', 'last_name', 'email']
> def is_valid(self):
> valid =  super().is_valid()
> if email != '' and User.objects.filter(email = email).exists():
> self.add_error('email', 'Il existe déjà un utilisateur avec
> cet email.')
> valid = False
> return valid
>
> *userCreate.html:*
> {% extends "base/base.html" %}
> {% block contenu %}
> Nouvel utilisateur :
> {% csrf_token %}
> {{ form.as_p }}
> 
> 
> {% endblock %}
>
> Thank's for your 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/trinity-68cd841e-22eb-421b-95ea-
> 2b94ca00a28b-1471243983623%403capp-mailcom-bs11
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to create Xlm file in specific folder ?

2016-08-10 Thread M Hashmi
I apologize for my message but it reminded me the last question from asad 
and frustration due to absence of code. Hope Asad will make it a practice 
and what Ludovic suggested makes sense. 
Hope it works.

On Wednesday, August 10, 2016 at 3:46:32 AM UTC-7, Asad ur Rehman wrote:
>
> I want to create xlm file in django in this path 
> "etc/freeswitch/sip_profiles/external" .
>
> Gateway.objects.values_list('name')
>
> this should be included in file. How can i create function for it. 
>
> Can anyone help me ? If you don't understand tell i will explain you more 
> but please help me.
>
>
> Thanks in advance !
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/102a01ac-d51c-43f9-9368-2899867a5cc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create Xlm file in specific folder ?

2016-08-10 Thread M Hashmi
Don't take it personal but if someone is offering you time to help...you
also need to be precise with questions. I did solved your problem by
suggesting you the correct way to do it. Do you want me to write code for
you as well?? Try the solution and then let the group know about error.

On Wed, Aug 10, 2016 at 4:45 AM, Asad ur Rehman 
wrote:

> M hashmi if someone is not doing question up to the mark you have to guide
> him/her. We are here for learning not for criticize each other.
>
> --
> 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/dde7b2d7-ff2e-4d2a-b626-d1056c6018dc%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/dde7b2d7-ff2e-4d2a-b626-d1056c6018dc%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to create Xlm file in specific folder ?

2016-08-10 Thread M Hashmi
Dear Asad,

Google is trying to build such a technology that can help transmit brain
waves connected via neurons to some media such as wifi or wire.

Till the time its not a reality...you have to paste your complete code
to get help because no one can read your mind without you telling or
explaining in email.

In your last question as I've noticed you even ask questions without
posting code at all and it took 7 questions to get some code sent from you.

For above question simply you can write or create an xml file via python
using ElementTree XML API.
You also can join a query result with the xml.

For details see:
https://docs.python.org/3/library/xml.etree.elementtree.html


Post your complete code if you are not doing some cold tests (nuclear tests
on your PC) so at least readers can understand the problem.

Regards,
Mudassar

On Wed, Aug 10, 2016 at 4:01 AM, Asad ur Rehman 
wrote:

> Sir whats its solution ?
>
> --
> 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/aabaa7b0-4ff2-42c0-8f82-3e6b76569b4a%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Launching websites

2016-08-10 Thread M Hashmi
It completely depends on nature of your site or business you intend to
manifest virtually. So I would keep it generic and to the point that is
required for most of business models.

General Checklist:

Terms of use
Contact page
About page
Transactional emails setup
SMTP setup
Google analytics setup
Strong passwords on server, backend, etc
Google webmaster setup
Server monitoring setup
Server backups setup
Server security
Minify JavaScript, css, html, svg, etc
SSL setup
Setup conversion goal tracking in google analytics for sign up, buy, etc
Change nameservers
Add sitelinks search box schema to Homepage
Cross browser tested
Create social network accounts
Logging
Security (you may have different layers like, django security, Web server
security for Apache, Nginx or whatever you choose to work with)

SEO related CheckList:

Sitemap
Robot.txt
Meta title tags
Meta description tags
Image alt tags
Image title tags
H1 tag
SEO friendly URLs
No follow tags
Google pagespeed insights
Category names
Duplicate pages
Canonical tags
Redirect www to non-www
Redirect http to https


For high level deployment checklist related to Django please see:
 https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

You can add more depending on nature of your site but again that depends
what you are doing.



Regards,
Mudassar



On Tue, Aug 9, 2016 at 4:13 AM, Andreas Kuhne 
wrote:

> Hi,
>
> I don't know what level you are interested in, but I think this course
> will be interesting:
> https://www.kickstarter.com/projects/mikeckennedy/python-
> for-entrepreneurs-video-course
>
> It'll probably contain some of the items you are requesting.
>
> Regards,
>
> Andréas
>
> 2016-08-09 12:59 GMT+02:00 :
>
>> Hi Serge,
>>
>> Thanks for the reply.
>>
>> I agree it is a mix of different tasks, but they are all needed when
>> starting a new business/product/service website. As it happens it is
>> something I had to do on quite a few occasions lately for some of my
>> customers.
>>
>> I'm trying to find out if there is a better way to do this (as it feels
>> that it always the same process) and see if it is a problem that other
>> people are facing (and how they are solving it if they are). This is mostly
>> when launching the site to the public. I can and have done all the steps
>> multiple times. However, it feels like there should be quicker way to do
>> it. It can easily take up to a full day when adding all of them.
>>
>> Thanks
>>
>> Arnaud
>>
>> On Monday, August 8, 2016 at 7:02:08 PM UTC+1, Sergiy Khohlov wrote:
>>>
>>> Hello David,
>>> You have mixed different tasks. I have a question for you.
>>> What kind of goal do you have?
>>> Are you planing to have mail server, web server, dev box etc?
>>> How much money are you going to spend?
>>> Do you have sysadmin ?
>>> Of course first question has high priority.
>>>
>>> Thanks.,
>>> Serge
>>>
>>> 8 серп. 2016 18:20  пише:
>>>
 Hi,

 This is slightly off topic, but I can imagine some of you might have
 faced this situation. I've been launching quite a few websites lately. It
 usually involves at least the following for me:
 - Domain registration and DNS setup
 - Server/Host configuration: Heroku setup (registration, environment
 variables for some of the steps above) or Docker setup
 - Deployment
 - Security aspects: TLS certificates, HTTPS setup, HTTP security
 headers, etc
 - Legal aspects: cookie policy, T&Cs, privacy, etc (implications from
 other steps)
 - Email: basic setup, SPF/DKIM for the spam, create RFC email
 addresses, etc
 - Mailing list setup (MailChimp or others)
 - Social media: signup to a few social networks, add "social sharing"
 buttons
 - Analytics/instrumentation/monitoring (Google Analytics, New Relic,
 etc)
 - Search engine registration/indexation (Google, Bing)
 - etc

 Some of these steps are interlinked and that's only for fairly "basic
 website" without any payment, A/B testing, user feedback or advertising
 requirements.

 None of it is particularly complex, although it does require some
 knowledge/experience, but it takes quite a lot of time and feels 
 repetitive.

 There are lots of great products/services for the individual steps
 involved, but I can't find anything to streamline the whole (or at least
 part of the) process.

 Does anyone know any good tool, product, checklist or website for this?
 Do you have the same problem? How do you handle this yourself?

 Thanks for your help.

 David

 --
 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 thi

Re: associating save link with button

2016-08-09 Thread M Hashmi
Great Larry.
Good luck.

On Tue, Aug 9, 2016 at 8:12 AM, Larry Martell 
wrote:

> I figured this out. I just had to add 'download' to the  tag:
>
>  class="btn btn-primary" download>Export
>
>
> On Tue, Aug 9, 2016 at 3:04 AM, M Hashmi  wrote:
> > Please paste code.
> >
> >
> > On Monday, August 8, 2016 at 12:18:45 PM UTC-7, larry@gmail.com
> wrote:
> >>
> >> Not really a django question but I'm hoping someone can help me here.
> >>
> >> I have a django app but the html is not displayed in a browser -
> >> render_to_string is called and the html is returned in a response to
> >> custom app that displays the page. On the page I have a button that
> >> sends a request back to the server. When I click the button in the
> >> page within the custom app app the request is sent, but the app does
> >> not wait for the reply. However if I right click on the button and
> >> select "Save link ...' then the app does wait for the reply and it all
> >> works as I want.
> >>
> >> Is there some way I can associate the "Save link ...' action with the
> >> button so that clicking on it will function the same as when right
> >> click save link is selected?
>
> --
> 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/CACwCsY63wUzckeckOsR3wU7htezHq
> QVBoLdKUgahe-0AGutBwQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: associating save link with button

2016-08-09 Thread M Hashmi
Please paste code.

On Monday, August 8, 2016 at 12:18:45 PM UTC-7, larry@gmail.com wrote:
>
> Not really a django question but I'm hoping someone can help me here. 
>
> I have a django app but the html is not displayed in a browser - 
> render_to_string is called and the html is returned in a response to 
> custom app that displays the page. On the page I have a button that 
> sends a request back to the server. When I click the button in the 
> page within the custom app app the request is sent, but the app does 
> not wait for the reply. However if I right click on the button and 
> select "Save link ...' then the app does wait for the reply and it all 
> works as I want. 
>
> Is there some way I can associate the "Save link ...' action with the 
> button so that clicking on it will function the same as when right 
> click save link is selected? 
>

-- 
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/8ab1c634-729e-4155-a7a1-f9568c0beae7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please Can Some one Help me To get my static files load my default CSS files

2016-08-08 Thread M Hashmi
You will better understand it with following link:

https://www.codingforentrepreneurs.com/projects/try-django-18/
Regards,
Mudassar

On Mon, Aug 8, 2016 at 5:26 AM, Timothy Steele 
wrote:

> M Hashmi
> Thanks
> For the response it work for me.
> I will like you to also give me a step by step process on how to add a
> template downloaded
> so that i can change the default template
>
> On Mon, Aug 8, 2016 at 11:49 AM, M Hashmi  wrote:
>
>> You need to set your static in settings.py and I am giving you simplest
>> idea you can implement with no issues.
>>
>> STATIC_URL = '/static/'
>> STATIC_ROOT = os.path.join(BASE_DIR, 'static', 'static-only')
>> MEDIA_URL = '/media/'
>> MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media')
>> STATICFILES_DIRS = [
>>os.path.join(BASE_DIR, 'static', 'static'),
>> ]
>>
>> Now in your project source folder create a new folder named 'static'
>> which will refer to values in blue.
>> In your 'static' in blue folder create subfolders with names 'media',
>> static-only', 'templates' and 'static' again. So hierarchy should look like
>> this:
>>
>> static
>> static
>> media
>> static-only
>> templates
>>
>> In your settings.py in "TEMPLATE" section find simalr line like below and
>> change it as I did.
>>
>> 'DIRS': [os.path.join(BASE_DIR, 'static', 'templates')],
>>
>> Now go to your terminal (command shell) and run following command.
>> ./manage.py collectstatic
>>
>> It will ask you are you sure you want to do this. Type "yes" and press
>> enter.
>>
>> .manage.py runserver and refresh your page.
>>
>> You will get all the css loaded.
>>
>> Furthermore you can create three new folders in your /static/static/.
>>
>> static
>> static
>>  |
>>  ---css
>>  |
>>  ---js
>>  |
>>  ---images
>> media
>> static-only
>> templates
>>
>> In your static/static folder you can keep the project template related
>> css/js/images. All your html based code will go to /static/templates
>> folder. Read the link below thorough and in case of issues you can post
>> another question or to same thread.
>>
>> https://docs.djangoproject.com/en/1.10/howto/static-files/
>>
>> Regards,
>> Mudassar
>>
>> On Mon, Aug 8, 2016 at 1:58 AM, Timothy Steele <
>> steeletimothy2...@gmail.com> wrote:
>>
>>>
>>>
>>> On Monday, August 8, 2016 at 1:16:57 AM UTC+1, Timothy Steele wrote:
>>>>
>>>> Please any time i try to load my Django admin panel the default CSS
>>>> files does not load and even i have to refresh several time before i can
>>>>  the css file will load, and even if i log in still the interface become
>>>> different, it does not load the CSS files. I believe this is coming form
>>>> the static files which i have not loaded but i did what ever i could and it
>>>> did not work for me so i need  a help please.
>>>> Please below is an attach file of screen shots i took
>>>>
>>>> Any way i am still a beginner
>>>>
>>>> THANKS
>>>>
>>>
>>> (any way this is the best group i have join so far thanks to all of you)
>>>
>>> PLEASE MY FRIENDS I BEG
>>> can you give me a step by step process to do this
>>> thanks very mach
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/7f5ae2e5-11f7-429b-b4a3-78a8d36ef787%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/7f5ae2e5-11f7-429b-b4a3-78a8d36ef787%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>

Re: Using non-ASCII app name via Apache server

2016-08-08 Thread M Hashmi
Oh Great!

It was great learning for me as well while searching out the solution.
Take care Goran,

Regards,

Mudassar

On Mon, Aug 8, 2016 at 9:57 AM, Göran Uddeborg  wrote:

> For the benefit of anyone following this thread.  I've found some
> relevant information, even if I don't understand the entire picture.
>
> The important point seems to be the locale in which the Apache server
> is running.  The default Fedora configuration sets LANG=C for the
> httpd server.  Apparently, that affects a lot of how Python behaves.
>
> By adding some configuration to set LANG to a UTF-8 locale, sv_SE.utf8
> in my case, things started to work.  I can now access both ascii and
> appåäö, and everything seems fine.  Remains to be seen if I have
> changed some other behaviour of my server in some way.
>
> Even if I don't fully understand the interactions between the locale
> setting and the Python interpreter, it works for me now.  I can
> continue my work on my original app.
>
> Thanks for the 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/22440.47636.729258.491836%40gargle.gargle.HOWL.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts7YMtdpLZZoKaR%3DQmO%2BZFVr5qBTst5FvBTT4%2BABnx6MHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using non-ASCII app name via Apache server

2016-08-08 Thread M Hashmi
I am sorry but I need some time for R&D coz few things about
encoding/decoding are confusing. I've tried to recreate error on my apache
live server but I couldn't create this error. Kindly wait for others to
reply or I will search it out after some time.
I am trying to add a new app on one of my prototype dressika.com. Can you
also try apt-get update/upgrade to get build releases.
Regards,

Mudassar

On Mon, Aug 8, 2016 at 5:52 AM, Göran Uddeborg  wrote:

> M Hashmi:
> > http://stackoverflow.com/questions/728891/correct-way-
> to-define-python-source-code-encoding
>
> I'm using UTF-8 in Python 3 where it is the default.  So that is
> probably not the issue.
>
> http://stackoverflow.com/questions/14083111/should-i-
> use-encoding-declaration-in-python3
>
> --
> 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/22440.32902.459446.548379%40gargle.gargle.HOWL.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Using non-ASCII app name via Apache server

2016-08-08 Thread M Hashmi
http://stackoverflow.com/questions/728891/correct-way-to-define-python-source-code-encoding

On Mon, Aug 8, 2016 at 4:41 AM, M Hashmi  wrote:

> In traceback the error is in last line. Somehow it is trying to import
> something that is returning response as string.
> Can you kindly post your installed apps again and root urls.py in project
> directory. So I can compare urls and app imports side by side.
>
> You said you have nothing in your app models so is there nothing at all in
> app?
>
> Regards,
> Mudassar
>
>
> On Mon, Aug 8, 2016 at 4:32 AM, Göran Uddeborg  wrote:
>
>> > Please makemigrations/migrate and restart server. It says its not
>> getting
>> > proper data from wsgi.py.
>>
>> As my models.py is empty, I thought I didn't need to do any
>> migration.  But I've done so now just in case.  It doesn't seem to
>> change anything.
>>
>> > wsgi.py is not able to stream data to httpd because it has internal
>> issues.
>>
>> Yes, I understand it fails with a traceback.  What I don't understand
>> is why it fails.
>>
>> > Also to see if project is working fine please always use runserver so
>> you can
>> > see django related errors.
>>
>> I briefly mentioned that.  It works fine with runserver.  No error
>> message, and the page is served fine.  There is obviously something
>> different in the WSGI case.  But what, I wonder.
>>
>> Most recent traceback from the httpd log:
>>
>> [Mon Aug 08 13:27:36.777315 2016] [wsgi:info] [pid 14003] [client
>> 62.65.125.225:51998] mod_wsgi (pid=14003, process='', application='
>> www.uddeborg.se|/dyn'): Loading WSGI script
>> '/var/www/dyn/dynsite/wsgi.py'.
>> [Mon Aug 08 11:27:37.084022 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998] mod_wsgi (pid=14003): Target WSGI script
>> '/var/www/dyn/dynsite/wsgi.py' cannot be loaded as Python module.
>> [Mon Aug 08 11:27:37.084100 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998] mod_wsgi (pid=14003): Exception occurred processing
>> WSGI script '/var/www/dyn/dynsite/wsgi.py'.
>> [Mon Aug 08 11:27:37.084961 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998] Traceback (most recent call last):
>> [Mon Aug 08 11:27:37.085025 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998]   File "/var/www/dyn/dynsite/wsgi.py", line 16, in
>> 
>> [Mon Aug 08 11:27:37.085030 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998] application = get_wsgi_application()
>> [Mon Aug 08 11:27:37.085041 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998]   File 
>> "/usr/lib/python3.5/site-packages/django/core/wsgi.py",
>> line 13, in get_wsgi_application
>> [Mon Aug 08 11:27:37.085046 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998] django.setup()
>> [Mon Aug 08 11:27:37.085055 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998]   File 
>> "/usr/lib/python3.5/site-packages/django/__init__.py",
>> line 18, in setup
>> [Mon Aug 08 11:27:37.085060 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998] apps.populate(settings.INSTALLED_APPS)
>> [Mon Aug 08 11:27:37.085070 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998]   File 
>> "/usr/lib/python3.5/site-packages/django/apps/registry.py",
>> line 85, in populate
>> [Mon Aug 08 11:27:37.085075 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998] app_config = AppConfig.create(entry)
>> [Mon Aug 08 11:27:37.085084 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998]   File 
>> "/usr/lib/python3.5/site-packages/django/apps/config.py",
>> line 116, in create
>> [Mon Aug 08 11:27:37.085089 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998] mod = import_module(mod_path)
>> [Mon Aug 08 11:27:37.085098 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998]   File "/usr/lib64/python3.5/importlib/__init__.py",
>> line 126, in import_module
>> [Mon Aug 08 11:27:37.085103 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998] return _bootstrap._gcd_import(name[level:],
>> package, level)
>> [Mon Aug 08 11:27:37.085112 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998]   File "", line 986,
>> in _gcd_import
>> [Mon Aug 08 11:27:37.085121 2016] [wsgi:error] [pid 14003] [client
>> 62.65.125.225:51998]   File "", line 969,
>> in _find_and_load
>> [Mo

Re: How o run shell command in Django ?

2016-08-08 Thread M Hashmi
Send your root urls.py code.

On Mon, Aug 8, 2016 at 4:42 AM, Asad ur Rehman 
wrote:

> tail -f /var/log/newfies/gunicorn_newfies_dialer.log
>
>
> when i try to find error through this always give no module named urls.
> Debug is already = True
>
> On Monday, August 8, 2016 at 2:33:12 PM UTC+5, Asad ur Rehman wrote:
>>
>> I want to run *fs_cli -x *command in django . Can anybody help me ?
>> How can i create function in django to execute this command ?
>>
> --
> 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/c7848c6a-2031-4cb2-bab1-2c3dfc609b77%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Using non-ASCII app name via Apache server

2016-08-08 Thread M Hashmi
In traceback the error is in last line. Somehow it is trying to import
something that is returning response as string.
Can you kindly post your installed apps again and root urls.py in project
directory. So I can compare urls and app imports side by side.

You said you have nothing in your app models so is there nothing at all in
app?

Regards,
Mudassar


On Mon, Aug 8, 2016 at 4:32 AM, Göran Uddeborg  wrote:

> > Please makemigrations/migrate and restart server. It says its not getting
> > proper data from wsgi.py.
>
> As my models.py is empty, I thought I didn't need to do any
> migration.  But I've done so now just in case.  It doesn't seem to
> change anything.
>
> > wsgi.py is not able to stream data to httpd because it has internal
> issues.
>
> Yes, I understand it fails with a traceback.  What I don't understand
> is why it fails.
>
> > Also to see if project is working fine please always use runserver so
> you can
> > see django related errors.
>
> I briefly mentioned that.  It works fine with runserver.  No error
> message, and the page is served fine.  There is obviously something
> different in the WSGI case.  But what, I wonder.
>
> Most recent traceback from the httpd log:
>
> [Mon Aug 08 13:27:36.777315 2016] [wsgi:info] [pid 14003] [client
> 62.65.125.225:51998] mod_wsgi (pid=14003, process='', application='
> www.uddeborg.se|/dyn'): Loading WSGI script '/var/www/dyn/dynsite/wsgi.py'
> .
> [Mon Aug 08 11:27:37.084022 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] mod_wsgi (pid=14003): Target WSGI script
> '/var/www/dyn/dynsite/wsgi.py' cannot be loaded as Python module.
> [Mon Aug 08 11:27:37.084100 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] mod_wsgi (pid=14003): Exception occurred processing
> WSGI script '/var/www/dyn/dynsite/wsgi.py'.
> [Mon Aug 08 11:27:37.084961 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] Traceback (most recent call last):
> [Mon Aug 08 11:27:37.085025 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "/var/www/dyn/dynsite/wsgi.py", line 16, in
> 
> [Mon Aug 08 11:27:37.085030 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] application = get_wsgi_application()
> [Mon Aug 08 11:27:37.085041 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File 
> "/usr/lib/python3.5/site-packages/django/core/wsgi.py",
> line 13, in get_wsgi_application
> [Mon Aug 08 11:27:37.085046 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] django.setup()
> [Mon Aug 08 11:27:37.085055 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File 
> "/usr/lib/python3.5/site-packages/django/__init__.py",
> line 18, in setup
> [Mon Aug 08 11:27:37.085060 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] apps.populate(settings.INSTALLED_APPS)
> [Mon Aug 08 11:27:37.085070 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "/usr/lib/python3.5/site-
> packages/django/apps/registry.py", line 85, in populate
> [Mon Aug 08 11:27:37.085075 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] app_config = AppConfig.create(entry)
> [Mon Aug 08 11:27:37.085084 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "/usr/lib/python3.5/site-
> packages/django/apps/config.py", line 116, in create
> [Mon Aug 08 11:27:37.085089 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] mod = import_module(mod_path)
> [Mon Aug 08 11:27:37.085098 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "/usr/lib64/python3.5/importlib/__init__.py",
> line 126, in import_module
> [Mon Aug 08 11:27:37.085103 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] return _bootstrap._gcd_import(name[level:],
> package, level)
> [Mon Aug 08 11:27:37.085112 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "", line 986, in
> _gcd_import
> [Mon Aug 08 11:27:37.085121 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "", line 969, in
> _find_and_load
> [Mon Aug 08 11:27:37.085131 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "", line 944, in
> _find_and_load_unlocked
> [Mon Aug 08 11:27:37.085140 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "", line 222, in
> _call_with_frames_removed
> [Mon Aug 08 11:27:37.085149 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "", line 986, in
> _gcd_import
> [Mon Aug 08 11:27:37.085158 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "", line 969, in
> _find_and_load
> [Mon Aug 08 11:27:37.085168 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998]   File "", line 956, in
> _find_and_load_unlocked
> [Mon Aug 08 11:27:37.085189 2016] [wsgi:error] [pid 14003] [client
> 62.65.125.225:51998] ImportError: No module named
> 'app\xc3\xa5\xc3\xa4\xc3\xb6'
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users

Re: How o run shell command in Django ?

2016-08-08 Thread M Hashmi
Send error.

On Mon, Aug 8, 2016 at 4:14 AM, Asad ur Rehman 
wrote:

> Internal server error is coming..
>
> On Monday, August 8, 2016 at 2:33:12 PM UTC+5, Asad ur Rehman wrote:
>>
>> I want to run *fs_cli -x *command in django . Can anybody help me ?
>> How can i create function in django to execute this command ?
>>
> --
> 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/f67108a7-ccab-4f66-897b-821096df7498%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Using non-ASCII app name via Apache server

2016-08-08 Thread M Hashmi
Please makemigrations/migrate and restart server. It says its not getting
proper data from wsgi.py.
wsgi.py is not able to stream data to httpd because it has internal issues.
Also to see if project is working fine please always use runserver so you
can see django related errors. Otherwise you will struggle to seprate httpd
erros from djagno erros.

Regards,
Mudassar

On Mon, Aug 8, 2016 at 4:01 AM, Göran Uddeborg  wrote:

> M Hashmi:
> > Reply me back I am waiting. Apologies if my assumption caused your time.
>
> No need to apologize!  You are trying to help me.  I'm grateful.
>
> In doing my simplified test case, I forgot to add the new app to
> INSTALLED_APP.  Thanks for the pointer!
>
> But after fixing that, I get an "Internal Server Error" instead, and
> the log files contains the traceback below.  Some of the time stamps
> are in local time (UTC+2) and some are in UTC.  I guess that is just
> some idiosyncrasy of Apache httpd and mod_wsgi.
>
> The test server, "./manage.py runserver" still works fine.
>
> (I also attach the updated site tree.  There is just a small change,
> but the entire site is so small so I thought it was ok.)
>
> [Mon Aug 08 12:49:59.214434 2016] [core:notice] [pid 12016] SELinux
> policy enabled; httpd running as context system_u:system_r:httpd_t:
> SystemLow
> [Mon Aug 08 12:49:59.215009 2016] [ssl:info] [pid 12016] AH01887: Init:
> Initializing (virtual) servers for SSL
> [Mon Aug 08 12:49:59.215550 2016] [ssl:info] [pid 12016] AH01876:
> mod_ssl/2.4.23 compiled against Server: Apache/2.4.23, Library:
> OpenSSL/1.0.2h
> [Mon Aug 08 12:49:59.216226 2016] [suexec:notice] [pid 12016] AH01232:
> suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
> [Mon Aug 08 12:49:59.252466 2016] [auth_digest:notice] [pid 12016]
> AH01757: generating secret for digest authentication ...
> [Mon Aug 08 12:49:59.252819 2016] [socache_shmcb:info] [pid 12016]
> AH00830: Shared memory socache initialised
> [Mon Aug 08 12:49:59.252826 2016] [ssl:info] [pid 12016] AH01887: Init:
> Initializing (virtual) servers for SSL
> [Mon Aug 08 12:49:59.253247 2016] [ssl:info] [pid 12016] AH01876:
> mod_ssl/2.4.23 compiled against Server: Apache/2.4.23, Library:
> OpenSSL/1.0.2h
> [Mon Aug 08 12:49:59.253272 2016] [http2:info] [pid 12016] AH03090:
> mod_http2 (v1.5.11, feats=CHPRIO+SHA256, nghttp2 1.7.1), initializing...
> [Mon Aug 08 12:49:59.254005 2016] [lbmethod_heartbeat:notice] [pid 12016]
> AH02282: No slotmem from mod_heartmonitor
> [Mon Aug 08 12:49:59.279641 2016] [wsgi:info] [pid 12021] mod_wsgi
> (pid=12021): Initializing Python.
> [Mon Aug 08 12:49:59.281769 2016] [mpm_prefork:notice] [pid 12016]
> AH00163: Apache/2.4.23 (Fedora) OpenSSL/1.0.2h-fips PHP/5.6.23
> mod_wsgi/4.4.8 Python/3.5.1 configured -- resuming normal operations
> [Mon Aug 08 12:49:59.281802 2016] [mpm_prefork:info] [pid 12016] AH00164:
> Server built: Jul 18 2016 15:38:14
> [Mon Aug 08 12:49:59.281815 2016] [core:notice] [pid 12016] AH00094:
> Command line: '/usr/sbin/httpd -D FOREGROUND'
> [Mon Aug 08 12:49:59.282035 2016] [wsgi:info] [pid 12020] mod_wsgi
> (pid=12020): Initializing Python.
> [Mon Aug 08 12:49:59.284088 2016] [wsgi:info] [pid 12027] mod_wsgi
> (pid=12027): Initializing Python.
> [Mon Aug 08 12:49:59.291791 2016] [wsgi:info] [pid 12022] mod_wsgi
> (pid=12022): Initializing Python.
> [Mon Aug 08 12:49:59.312125 2016] [wsgi:info] [pid 12043] mod_wsgi
> (pid=12043): Initializing Python.
> [Mon Aug 08 12:49:59.317964 2016] [wsgi:info] [pid 12020] mod_wsgi
> (pid=12020): Attach interpreter ''.
> [Mon Aug 08 12:49:59.320378 2016] [wsgi:info] [pid 12027] mod_wsgi
> (pid=12027): Attach interpreter ''.
> [Mon Aug 08 12:49:59.321265 2016] [wsgi:info] [pid 12020] mod_wsgi
> (pid=12020): Adding '/var/www/dyn' to path.
> [Mon Aug 08 12:49:59.323805 2016] [wsgi:info] [pid 12027] mod_wsgi
> (pid=12027): Adding '/var/www/dyn' to path.
> [Mon Aug 08 12:49:59.327720 2016] [wsgi:info] [pid 12022] mod_wsgi
> (pid=12022): Attach interpreter ''.
> [Mon Aug 08 12:49:59.330202 2016] [wsgi:info] [pid 12022] mod_wsgi
> (pid=12022): Adding '/var/www/dyn' to path.
> [Mon Aug 08 12:49:59.331290 2016] [wsgi:info] [pid 12021] mod_wsgi
> (pid=12021): Attach interpreter ''.
> [Mon Aug 08 12:49:59.334499 2016] [wsgi:info] [pid 12021] mod_wsgi
> (pid=12021): Adding '/var/www/dyn' to path.
> [Mon Aug 08 12:49:59.344669 2016] [wsgi:info] [pid 12043] mod_wsgi
> (pid=12043): Attach interpreter ''.
> [Mon Aug 08 12:49:59.347136 2016] [wsgi:info] [pid 12043] mod_wsgi
> (pid=12043): Adding '/var/www/dyn' to path.
> [Mon Aug 08 12:50:09.731008 2016] [wsgi:info] [pid 12020] mod_wsgi
>

Re: How o run shell command in Django ?

2016-08-08 Thread M Hashmi
Install sh with pip.
http://amoffat.github.io/

On Mon, Aug 8, 2016 at 3:54 AM, Asad ur Rehman 
wrote:

>  from sh import fs_cli
> this is also not working ...
>
>
>
>
> On Monday, August 8, 2016 at 2:33:12 PM UTC+5, Asad ur Rehman wrote:
>>
>> I want to run *fs_cli -x *command in django . Can anybody help me ?
>> How can i create function in django to execute this command ?
>>
> --
> 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/17d5d75e-12a3-4dfd-843f-22ad7cab1dce%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts4c-%2BtAAo%3DTEw5fFes5bHYwuywEcK9ef%2Bci2SYb%3D0bs6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please Can Some one Help me To get my static files load my default CSS files

2016-08-08 Thread M Hashmi
You need to set your static in settings.py and I am giving you simplest
idea you can implement with no issues.

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static', 'static-only')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media')
STATICFILES_DIRS = [
   os.path.join(BASE_DIR, 'static', 'static'),
]

Now in your project source folder create a new folder named 'static' which
will refer to values in blue.
In your 'static' in blue folder create subfolders with names 'media',
static-only', 'templates' and 'static' again. So hierarchy should look like
this:

static
static
media
static-only
templates

In your settings.py in "TEMPLATE" section find simalr line like below and
change it as I did.

'DIRS': [os.path.join(BASE_DIR, 'static', 'templates')],

Now go to your terminal (command shell) and run following command.
./manage.py collectstatic

It will ask you are you sure you want to do this. Type "yes" and press
enter.

.manage.py runserver and refresh your page.

You will get all the css loaded.

Furthermore you can create three new folders in your /static/static/.

static
static
 |
 ---css
 |
 ---js
 |
 ---images
media
static-only
templates

In your static/static folder you can keep the project template related
css/js/images. All your html based code will go to /static/templates
folder. Read the link below thorough and in case of issues you can post
another question or to same thread.

https://docs.djangoproject.com/en/1.10/howto/static-files/

Regards,
Mudassar

On Mon, Aug 8, 2016 at 1:58 AM, Timothy Steele 
wrote:

>
>
> On Monday, August 8, 2016 at 1:16:57 AM UTC+1, Timothy Steele wrote:
>>
>> Please any time i try to load my Django admin panel the default CSS files
>> does not load and even i have to refresh several time before i can  the css
>> file will load, and even if i log in still the interface become different,
>> it does not load the CSS files. I believe this is coming form the static
>> files which i have not loaded but i did what ever i could and it did not
>> work for me so i need  a help please.
>> Please below is an attach file of screen shots i took
>>
>> Any way i am still a beginner
>>
>> THANKS
>>
>
> (any way this is the best group i have join so far thanks to all of you)
>
> PLEASE MY FRIENDS I BEG
> can you give me a step by step process to do this
> thanks very mach
>
>
>
> --
> 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/7f5ae2e5-11f7-429b-b4a3-78a8d36ef787%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Using non-ASCII app name via Apache server

2016-08-08 Thread M Hashmi
I am sorry bad assumption on my side. I saw your full traceback and all it
says that in your project urls.py and it cannot resolve following url.

url(r'^appåäö/', include('appåäö.urls')),

Its picking up the this url but no app related to this urls exists. Either
you need to check if this app is listed in your INSTALLED_APP section or
even if it is installed at all in your project.

In simplest theory your url is not communicating your app 'appåäö'. Rest of
the settings are fine.

Reply me back I am waiting. Apologies if my assumption caused your time.

Regards,
Mudassar

On Mon, Aug 8, 2016 at 2:24 AM, Göran Uddeborg  wrote:

> M Hashmi:
> > List down your "civ.apps.CivConfig" also restart Gunicorn, and reload
> Nginx.
>
> I'm not sure exactly what you mean by "list down".  Do you want me to
> comment it out?
>
> In any case, to make an even more clean test case, I replaced my
> Django site with one I built from scratch.  I.e. I started by doing
>
>python3-django-admin startproject dynsite dyn
>
> And then the same steps as in my original message.  (I'm not running
> Gunicorn or Nginx, I'm using Apache following the instructions on
> https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/modwsgi/
> So httpd was what I restarted.)
>
> I attach the complete file tree after these steps.  I still get the
> same backtrace as before.  I believe I've made the site visible from
> the outside, so you should see the same if you point a browser to
> http://www.uddeborg.se/dyn/app%C3%A5%C3%A4%C3%B6/
>
> --
> 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/22440.20419.305454.59808%40gargle.gargle.HOWL.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts7DFhwAucuVC4KghYHze-B8i8-k2tsg8mRwpq-dBa-eSA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How o run shell command in Django ?

2016-08-08 Thread M Hashmi
There are better ways to cut short your time to execute or even schedule
tasks or commands.

It won't take you more than an hour to understand Django-celery for
scheduling tasks. You need to create a bash script and it should include
all the steps in case you need virtualenv loaded while command runs. This
way you can schedule tasks for multiple django projects on same machine.

mybashscript.sh:

cd /var/www/website/
source myenv/bin/activate
/var/www/website/manage.py $1 --settings$2

Then in your contrab for cronjobs you can set it up like:

MAILTO=youradminacco...@yourwebsite.com
SETTINGSMODULE=yourwebsite.settings_production
5 * * * * /var/www/yourwebsite/mybashscript.sh fs_cli -x $SETTINGSMODULE >>
/dev/null

Each time your script runs you will get notified by email about the
schedule process.

Otherwise if you still want to get it executed by the python script. I
would suggest you to create a script.py at place of your settings.py and
import timezone. Then you can write the way or when you want to get it
executed by shell. You can search the best and simplest scheduling script
that fits your need.

Hope answer was helpful.

Regards,
Mudassar

On Mon, Aug 8, 2016 at 2:33 AM, Asad ur Rehman 
wrote:

> I want to run *fs_cli -x *command in django . Can anybody help me ?
> How can i create function in django to execute this command ?
>
> --
> 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/0f9ea28d-37c9-40f2-b67a-b566c3691998%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Please Can Some one Help me To get my static files load my default CSS files

2016-08-07 Thread M Hashmi
In your settings.py how did you setup your STATIC_URL and STATIC_FILEDIRS?
Copy paste your settings.py code below STATIC_URL with your DB engine 
settings. DB looks working fine because your page is showing up so we can 
use same BASE_DIR conventions for setting up your static.

On Sunday, August 7, 2016 at 5:16:57 PM UTC-7, Timothy Steele wrote:
>
> Please any time i try to load my Django admin panel the default CSS files 
> does not load and even i have to refresh several time before i can  the css 
> file will load, and even if i log in still the interface become different, 
> it does not load the CSS files. I believe this is coming form the static 
> files which i have not loaded but i did what ever i could and it did not 
> work for me so i need  a help please.
> Please below is an attach file of screen shots i took 
>
> Any way i am still a beginner
>
> 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/660507f4-231e-4f6c-8162-701cf8bb5c1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using non-ASCII app name via Apache server

2016-08-07 Thread M Hashmi
List down your "civ.apps.CivConfig" also restart Gunicorn, and reload 
Nginx. 

On Sunday, August 7, 2016 at 4:59:40 PM UTC-7, Göran Uddeborg wrote:
>
> I'm new to Django, so this is probably some kind of beginner's mistake.
>
> Django is set up to run via Apache and WSGI.  It uses Python 3.  The first 
> app I wrote works fine.  When I got to the second I wanted to use an app 
> name that contained non-ASCII letters.  But I can't get that to work at 
> all.  Can anyone explain what I'm doing wrong?  I've failed to find the 
> solution using Google.
>
> To isolate the problem, I tried to make a test app following the 
> instructions in https://docs.djangoproject.com/en/1.9/intro/tutorial01/ 
> but using the app name "appåäö".  But trying to access the page gives me an 
> error message:
>
> ImportError at /appåäö/
> No module named 'appåäö'
>
> On the other hand, if I copy the file tree for my project, remove the 
> SECURE_SSL_REDIRECT=True directive from settings.py, and run using 
> "manage.py runserver", *then* it works just fine.  It is somehow related 
> to the WSGI environment.  But how can I make it work?
>
> To give a bit more details, this is what I have done:
>
>
>1. Added 
>url(r'^appåäö/', include('appåäö.urls'))
>to urlpatterns in dynsite/urls.py (dynsite is the name of the 
>directory with settings.py and similar files).
>2. Run "./manage.py startapp appåäö" to create an initial app tree.
>3. Created a file appåäö/urls.py with the contents 
>from django.conf.urls import url
>
>from . import views
>
>urlpatterns = [
>url(r'^$', views.index, name='index'),
>]
>4. Edited appåäö/views.py to look like this 
>from django.http import HttpResponse
>
>def index(request):
>return HttpResponse("Hej världen!")
>5. Restarted httpd
>6. Point my browser to appåäö in my 
>
> I attach the complete traceback I get.
>

-- 
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/26c5b510-de0e-4a80-b12e-b31ee3fe089c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: OperationalError at /checkout/ table orders_order has no column named order_id

2016-08-07 Thread M Hashmi
This is strange in Django 1.8.5 that it is not creating all DB fields.
I've just commented out order_id field and 1. manage.py makemigrations, 2. 
manage.py migrate. Then again removed comment sign and it got added in db. 

Anyone knows why this happened? If I delete all my db with migrations there 
will be one or two fields not getting added in new db. I am using sqlite3 
as database in dev.

My problem is solved though.

Regards,
Mudassar

On Sunday, August 7, 2016 at 5:55:13 AM UTC-7, M Hashmi wrote:
>
> *I have two apps "orders" and "carts". In my models for carts I got:*
>
> class CartItem(models.Model):
> cart = models.ForeignKey("Cart")
> item = models.ForeignKey(Variation)
> quantity = models.PositiveIntegerField(default=1)
> line_item_total = models.DecimalField(max_digits=10, decimal_places=2)
>
> def __unicode__(self):
> return self.item.title
>
> def remove(self):
> return self.item.remove_from_cart()
>
>
> def cart_item_pre_save_receiver(sender, instance, *args, **kwargs):
> qty = instance.quantity
> if qty >= 1:
> price = instance.item.get_price()
> line_item_total = Decimal(qty) * Decimal(price)
> instance.line_item_total = line_item_total
>
> pre_save.connect(cart_item_pre_save_receiver, sender=CartItem)
>
> def cart_item_post_save_receiver(sender, instance, *args, **kwargs):
> instance.cart.update_subtotal()
> post_save.connect(cart_item_post_save_receiver, sender=CartItem)
>
> post_delete.connect(cart_item_post_save_receiver, sender=CartItem)
>
> class Cart(models.Model):
> user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, 
> blank=True)
> items = models.ManyToManyField(Variation, through=CartItem)
> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
> updated = models.DateTimeField(auto_now_add=False, auto_now=True)
> subtotal = models.DecimalField(max_digits=50, decimal_places=2, 
> default=25.00)
> tax_percentage  = models.DecimalField(max_digits=10, decimal_places=5, 
> default=0.085)
> tax_total = models.DecimalField(max_digits=50, decimal_places=2, 
> default=25.00)
> total = models.DecimalField(max_digits=50, decimal_places=2, 
> default=25.00)
>
> def __unicode__(self):
> return str(self.id)
>
> def update_subtotal(self):
> print "updating..."
> subtotal = 0
> items = self.cartitem_set.all()
> for item in items:
> subtotal += item.line_item_total
> self.subtotal = "%.2f" %(subtotal)
> self.save()
>
> def do_tax_and_total_receiver(sender, instance, *args, **kwargs):
> subtotal = Decimal(instance.subtotal)
> tax_total = round(subtotal * Decimal(instance.tax_percentage), 2) #8.5%
> print instance.tax_percentage
> total = round(subtotal + Decimal(tax_total), 2)
> instance.tax_total = "%.2f" %(tax_total)
> instance.total = "%.2f" %(total)
> 
> pre_save.connect(do_tax_and_total_receiver, sender=Cart)
>
> *In my carts Views.py:*
>
> from orders.forms import GuestCheckoutForm
> from orders.mixins import CartOrderMixin
> from orders.models import UserCheckout, Order, UserAddress
> from products.models import Variation
> from .models import Cart, CartItem
>
> if settings.DEBUG:
> braintree.Configuration.configure(braintree.Environment.Sandbox,
> merchant_id=settings.BRAINTREE_MERCHANT_ID,
> public_key=settings.BRAINTREE_PUBLIC,
> private_key=settings.BRAINTREE_PRIVATE)
>
> class ItemCountView(View):
> def get(self, request, *args, **kwargs):
> if request.is_ajax():
> cart_id = self.request.session.get("cart_id")
> if cart_id == None:
> count = 0
> else:
> cart = Cart.objects.get(id=cart_id)
> count = cart.items.count()
> request.session["cart_item_count"] = count
> return JsonResponse({"count": count})
> else:
> raise Http404
>
> class CartView(SingleObjectMixin, View):
> model = Cart
> template_name = "carts/view.html"
>
> def get_object(self, *args, **kwargs):
> self.request.session.set_expiry(0) #5 minutes
> cart_id = self.request.session.get("cart_id")
> if cart_id == None:
> cart = Cart()
> cart.tax_percentage = 0.075
> cart.save()
> cart_id = cart.id
> self.request.session["cart_id"] = cart_id
> cart = Cart.objects.get(id=cart_id)
&

OperationalError at /checkout/ table orders_order has no column named order_id

2016-08-07 Thread M Hashmi
*I have two apps "orders" and "carts". In my models for carts I got:*

class CartItem(models.Model):
cart = models.ForeignKey("Cart")
item = models.ForeignKey(Variation)
quantity = models.PositiveIntegerField(default=1)
line_item_total = models.DecimalField(max_digits=10, decimal_places=2)

def __unicode__(self):
return self.item.title

def remove(self):
return self.item.remove_from_cart()


def cart_item_pre_save_receiver(sender, instance, *args, **kwargs):
qty = instance.quantity
if qty >= 1:
price = instance.item.get_price()
line_item_total = Decimal(qty) * Decimal(price)
instance.line_item_total = line_item_total

pre_save.connect(cart_item_pre_save_receiver, sender=CartItem)

def cart_item_post_save_receiver(sender, instance, *args, **kwargs):
instance.cart.update_subtotal()
post_save.connect(cart_item_post_save_receiver, sender=CartItem)

post_delete.connect(cart_item_post_save_receiver, sender=CartItem)

class Cart(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True,
blank=True)
items = models.ManyToManyField(Variation, through=CartItem)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated = models.DateTimeField(auto_now_add=False, auto_now=True)
subtotal = models.DecimalField(max_digits=50, decimal_places=2,
default=25.00)
tax_percentage  = models.DecimalField(max_digits=10, decimal_places=5,
default=0.085)
tax_total = models.DecimalField(max_digits=50, decimal_places=2,
default=25.00)
total = models.DecimalField(max_digits=50, decimal_places=2,
default=25.00)

def __unicode__(self):
return str(self.id)

def update_subtotal(self):
print "updating..."
subtotal = 0
items = self.cartitem_set.all()
for item in items:
subtotal += item.line_item_total
self.subtotal = "%.2f" %(subtotal)
self.save()

def do_tax_and_total_receiver(sender, instance, *args, **kwargs):
subtotal = Decimal(instance.subtotal)
tax_total = round(subtotal * Decimal(instance.tax_percentage), 2) #8.5%
print instance.tax_percentage
total = round(subtotal + Decimal(tax_total), 2)
instance.tax_total = "%.2f" %(tax_total)
instance.total = "%.2f" %(total)

pre_save.connect(do_tax_and_total_receiver, sender=Cart)

*In my carts Views.py:*

from orders.forms import GuestCheckoutForm
from orders.mixins import CartOrderMixin
from orders.models import UserCheckout, Order, UserAddress
from products.models import Variation
from .models import Cart, CartItem

if settings.DEBUG:
braintree.Configuration.configure(braintree.Environment.Sandbox,
merchant_id=settings.BRAINTREE_MERCHANT_ID,
public_key=settings.BRAINTREE_PUBLIC,
private_key=settings.BRAINTREE_PRIVATE)

class ItemCountView(View):
def get(self, request, *args, **kwargs):
if request.is_ajax():
cart_id = self.request.session.get("cart_id")
if cart_id == None:
count = 0
else:
cart = Cart.objects.get(id=cart_id)
count = cart.items.count()
request.session["cart_item_count"] = count
return JsonResponse({"count": count})
else:
raise Http404

class CartView(SingleObjectMixin, View):
model = Cart
template_name = "carts/view.html"

def get_object(self, *args, **kwargs):
self.request.session.set_expiry(0) #5 minutes
cart_id = self.request.session.get("cart_id")
if cart_id == None:
cart = Cart()
cart.tax_percentage = 0.075
cart.save()
cart_id = cart.id
self.request.session["cart_id"] = cart_id
cart = Cart.objects.get(id=cart_id)
if self.request.user.is_authenticated():
cart.user = self.request.user
cart.save()
return cart

def get(self, request, *args, **kwargs):
cart = self.get_object()
item_id = request.GET.get("item")
delete_item = request.GET.get("delete", False)
flash_message = ""
item_added = False
if item_id:
item_instance = get_object_or_404(Variation, id=item_id)
qty = request.GET.get("qty", 1)
try:
if int(qty) < 1:
delete_item = True
except:
raise Http404
cart_item, created = CartItem.objects.get_or_create(cart=cart,
item=item_instance)
if created:
flash_message = "Successfully added to the cart"
item_added = True
if delete_item:
flash_message = "Item removed successfully."
cart_item.delete()
else:
if not created:
flash_message = "Quantity has been updated
successfully."
cart_item.quantity = qty
cart_item.save()
  

Re: Trying to set up a website using Django but something went wrong

2016-08-06 Thread M Hashmi
1. Type "python" in your terminal and if it open ups Python interpreter
that means path is setup for Python.

2. If confirmed that Python is installed you might want to install
setuptools.

3. With setuptools a small app "pip" which is programmed to bring packages
upon request from pypi or Djangoproejcts official repositories for reusable
apps.

4. Learn to create Virtualenv for your proejct its simply 3 commands but I
am not sure what OS you are at so see docs for related OS.

5. Anytime if you are not getting response from a package command or in
your case django-admin.py is not recoginized...you need to check installed
packages by "pip freeze" command in terminal without quotes. It will show
you all installed packages.

In your case terminal is not able to communicate with your python based
app. There are only two reasons for it...you haven't configured pythonpath
for OS or Django is not installed.

Go by checklist and if you are still stuck I will help you.
Regards,
Mudassar

On Sat, Aug 6, 2016 at 10:18 AM, Huy T  wrote:

> Is it in your path?
>
> On Aug 6, 2016, at 11:42 AM, owen  wrote:
>
> I downloaded Django recently and I have all the necessary files (Or at least 
> I think I do )
>
>
> However when I try to set up a project through this line of code:
>
>
> $ django-admin startproject mysite
>
>
> In the command prompt it returns the following message.
>
>
> 'django-admin' is not recognized as an internal or external command, operable 
> program or batch file.'
>
>
> I know django-admin is there because I searched for it...Can someone please 
> help
>
>
> Regards,
>
> Owen
>
> --
> 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/d445e0a6-bb06-423f-b50b-f48b51a214ff%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/54C2F42E-D0B2-4F79-846B-CB3BE24E99C5%40gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: QuerySet for related models

2016-08-05 Thread M Hashmi
Thanks Todor/Constantine for your help,

I've added a field in my Product models with generic relations like:
hitcounts = GenericRelation(HitCount, content_type_field='content_type',
object_id_field='object_pk',)

In my view:
object_list = Product.objects.order_by('-hitcounts__hits')[:6]

In my template:


Trending Now!
{% load hitcount_tags %}
{% for product in object_list %}

   {{ product.title
}}
{% if product.get_image_url %}

{% endif %}
Views:{% get_hit_count for product %}
 {% if price == 'True' %}
{{ product.variation_set.first.get_html_price|safe }}
{% endif %}

{% endfor %}


It worked for me.

I did it with joins as well but Django joins are perhaps not the best way
instead Django encourages object based approach to keep it simple and rapid.

Regards,
Mudassar

On Fri, Aug 5, 2016 at 10:23 AM, M Hashmi  wrote:

> Todor,
>
> You have access to my complete repo but still I will post answer here for
> others to learn.
>
> Regards,
> Mudassar
>
> On Fri, Aug 5, 2016 at 6:06 AM, Todor Velichkov <
> todorvelichko...@gmail.com> wrote:
>
>> Honestly, now Idea why you get this error, can you paste some more code?
>> And maybe some stack trace?
>>
>> On Friday, August 5, 2016 at 2:20:25 PM UTC+3, M Hashmi wrote:
>>>
>>> 1.8.13 as its LTS.
>>>
>>> On Fri, Aug 5, 2016 at 3:54 AM, Todor Velichkov 
>>> wrote:
>>>
>>>> Whats your Django version?
>>>>
>>>> On Friday, August 5, 2016 at 1:42:48 PM UTC+3, M Hashmi wrote:
>>>>>
>>>>> I did the same thing while working with the contenttype except I did
>>>>> used default filters .all(), .filter(), .get(), annotations and
>>>>> aggregations etc. Todor each product shows multiple hits if I log out and
>>>>> hit it and login back to hit it shows more than one hits. Hits are being
>>>>> recoreded for each session. It shows the same error as it is showing now
>>>>> after implementing GenericRelations:
>>>>>
>>>>> AttributeError at / 'GenericForeignKey' object has not attribute
>>>>> 'get_lookup'.
>>>>>
>>>>> If I mix it with .aggregate(Max, Count, Avg or Sum) queryset options
>>>>> it will pop up "unhashable type".
>>>>>
>>>>> I am working on joins methods in django with hope that it will make it
>>>>> work. I really appreciate your help guys. You both rock and I've learned a
>>>>> lot with your directions. Still if you have ideas please let me know I 
>>>>> will
>>>>> try those too.
>>>>>
>>>>> Regards,
>>>>> Mudassar
>>>>>
>>>>> On Fri, Aug 5, 2016 at 1:04 AM, Todor Velichkov >>>> > wrote:
>>>>>
>>>>>> Constantine Covtushenko,
>>>>>>
>>>>>> HitCount is a model from a 3rd party app, so the OP can't change it.
>>>>>>
>>>>>> However the way HitCount is implemented I don't think one there is a
>>>>>> way for one product to have more than one `HitCount` objects.
>>>>>> So I don't think any aggregations are needed.
>>>>>>
>>>>>> Lets the Product class look like this:
>>>>>>
>>>>>> class Product(models.Model):
>>>>>> #im changing this on purpose, because it points to HitCount
>>>>>> class.
>>>>>> hitcounts = GenericRelation(HitCount, content_type_field=
>>>>>> 'content_object', object_id_field='object_pk',)
>>>>>>
>>>>>> Now `HitCount` has a separate `Hit` class  which hold all individual
>>>>>> hits for a `product`.
>>>>>>
>>>>>> The app model structure is here.
>>>>>> <https://github.com/thornomad/django-hitcount/blob/master/hitcount/models.py>
>>>>>>
>>>>>> So to get top products by overall hits you can use `HitCount.hits`
>>>>>> field, without any `aggregations`, `annotations` or whatsoever.
>>>>>>
>>>>>> top_products_by_total_hits = Product.objects.order_by('hitc
>>>>>> ounts__hits')[:6]
>>>>>>
>>>>>> Now if you want to get the number of hits for a product for some
>>>>&g

Re: QuerySet for related models

2016-08-05 Thread M Hashmi
Todor,

You have access to my complete repo but still I will post answer here for
others to learn.

Regards,
Mudassar

On Fri, Aug 5, 2016 at 6:06 AM, Todor Velichkov 
wrote:

> Honestly, now Idea why you get this error, can you paste some more code?
> And maybe some stack trace?
>
> On Friday, August 5, 2016 at 2:20:25 PM UTC+3, M Hashmi wrote:
>>
>> 1.8.13 as its LTS.
>>
>> On Fri, Aug 5, 2016 at 3:54 AM, Todor Velichkov 
>> wrote:
>>
>>> Whats your Django version?
>>>
>>> On Friday, August 5, 2016 at 1:42:48 PM UTC+3, M Hashmi wrote:
>>>>
>>>> I did the same thing while working with the contenttype except I did
>>>> used default filters .all(), .filter(), .get(), annotations and
>>>> aggregations etc. Todor each product shows multiple hits if I log out and
>>>> hit it and login back to hit it shows more than one hits. Hits are being
>>>> recoreded for each session. It shows the same error as it is showing now
>>>> after implementing GenericRelations:
>>>>
>>>> AttributeError at / 'GenericForeignKey' object has not attribute
>>>> 'get_lookup'.
>>>>
>>>> If I mix it with .aggregate(Max, Count, Avg or Sum) queryset options it
>>>> will pop up "unhashable type".
>>>>
>>>> I am working on joins methods in django with hope that it will make it
>>>> work. I really appreciate your help guys. You both rock and I've learned a
>>>> lot with your directions. Still if you have ideas please let me know I will
>>>> try those too.
>>>>
>>>> Regards,
>>>> Mudassar
>>>>
>>>> On Fri, Aug 5, 2016 at 1:04 AM, Todor Velichkov 
>>>> wrote:
>>>>
>>>>> Constantine Covtushenko,
>>>>>
>>>>> HitCount is a model from a 3rd party app, so the OP can't change it.
>>>>>
>>>>> However the way HitCount is implemented I don't think one there is a
>>>>> way for one product to have more than one `HitCount` objects.
>>>>> So I don't think any aggregations are needed.
>>>>>
>>>>> Lets the Product class look like this:
>>>>>
>>>>> class Product(models.Model):
>>>>> #im changing this on purpose, because it points to HitCount class.
>>>>> hitcounts = GenericRelation(HitCount, content_type_field=
>>>>> 'content_object', object_id_field='object_pk',)
>>>>>
>>>>> Now `HitCount` has a separate `Hit` class  which hold all individual
>>>>> hits for a `product`.
>>>>>
>>>>> The app model structure is here.
>>>>> <https://github.com/thornomad/django-hitcount/blob/master/hitcount/models.py>
>>>>>
>>>>> So to get top products by overall hits you can use `HitCount.hits`
>>>>> field, without any `aggregations`, `annotations` or whatsoever.
>>>>>
>>>>> top_products_by_total_hits = Product.objects.order_by('hitc
>>>>> ounts__hits')[:6]
>>>>>
>>>>> Now if you want to get the number of hits for a product for some
>>>>> period of range (lets say a week). Then we need to use the `Hit`
>>>>> model.
>>>>>
>>>>> top_products_by_last_week_hits = Product.objects.filter(
>>>>> hitcounts__hit__created__gte=today-timedelta(days=7)
>>>>> ).annotate(
>>>>> last_week_hits=Count('hitcounts__hit')
>>>>> ).order_by('-last_week_hits')[:6]
>>>>>
>>>>> Hope this helps and things get clear now.
>>>>>
>>>>> On Friday, August 5, 2016 at 8:44:02 AM UTC+3, Constantine Covtushenko
>>>>> wrote:
>>>>>>
>>>>>> Hi M Hashmi,
>>>>>>
>>>>>> I believe that you are looking a way to use aggregation on related
>>>>>> model.
>>>>>> You should try the following snitppet:
>>>>>> `trending_products = Product.objects.aggregate(hit=Max(
>>>>>> 'hits__hits'))[:6]` (see more info here
>>>>>> <https://docs.djangoproject.com/en/1.9/topics/db/aggregation/>)
>>>>>>
>>>>>> This will give you list of products where each product will have
>>>>>> 'hit' is the MAX valu

Re: QuerySet for related models

2016-08-05 Thread M Hashmi
1.8.13 as its LTS.

On Fri, Aug 5, 2016 at 3:54 AM, Todor Velichkov 
wrote:

> Whats your Django version?
>
> On Friday, August 5, 2016 at 1:42:48 PM UTC+3, M Hashmi wrote:
>>
>> I did the same thing while working with the contenttype except I did used
>> default filters .all(), .filter(), .get(), annotations and aggregations
>> etc. Todor each product shows multiple hits if I log out and hit it and
>> login back to hit it shows more than one hits. Hits are being recoreded for
>> each session. It shows the same error as it is showing now after
>> implementing GenericRelations:
>>
>> AttributeError at / 'GenericForeignKey' object has not attribute
>> 'get_lookup'.
>>
>> If I mix it with .aggregate(Max, Count, Avg or Sum) queryset options it
>> will pop up "unhashable type".
>>
>> I am working on joins methods in django with hope that it will make it
>> work. I really appreciate your help guys. You both rock and I've learned a
>> lot with your directions. Still if you have ideas please let me know I will
>> try those too.
>>
>> Regards,
>> Mudassar
>>
>> On Fri, Aug 5, 2016 at 1:04 AM, Todor Velichkov 
>> wrote:
>>
>>> Constantine Covtushenko,
>>>
>>> HitCount is a model from a 3rd party app, so the OP can't change it.
>>>
>>> However the way HitCount is implemented I don't think one there is a
>>> way for one product to have more than one `HitCount` objects.
>>> So I don't think any aggregations are needed.
>>>
>>> Lets the Product class look like this:
>>>
>>> class Product(models.Model):
>>> #im changing this on purpose, because it points to HitCount class.
>>> hitcounts = GenericRelation(HitCount, content_type_field='content_ob
>>> ject', object_id_field='object_pk',)
>>>
>>> Now `HitCount` has a separate `Hit` class  which hold all individual
>>> hits for a `product`.
>>>
>>> The app model structure is here.
>>> <https://github.com/thornomad/django-hitcount/blob/master/hitcount/models.py>
>>>
>>> So to get top products by overall hits you can use `HitCount.hits`
>>> field, without any `aggregations`, `annotations` or whatsoever.
>>>
>>> top_products_by_total_hits = Product.objects.order_by('hitcounts__hits'
>>> )[:6]
>>>
>>> Now if you want to get the number of hits for a product for some period
>>> of range (lets say a week). Then we need to use the `Hit` model.
>>>
>>> top_products_by_last_week_hits = Product.objects.filter(
>>> hitcounts__hit__created__gte=today-timedelta(days=7)
>>> ).annotate(
>>> last_week_hits=Count('hitcounts__hit')
>>> ).order_by('-last_week_hits')[:6]
>>>
>>> Hope this helps and things get clear now.
>>>
>>> On Friday, August 5, 2016 at 8:44:02 AM UTC+3, Constantine Covtushenko
>>> wrote:
>>>>
>>>> Hi M Hashmi,
>>>>
>>>> I believe that you are looking a way to use aggregation on related
>>>> model.
>>>> You should try the following snitppet:
>>>> `trending_products = Product.objects.aggregate(hit=Max(
>>>> 'hits__hits'))[:6]` (see more info here
>>>> <https://docs.djangoproject.com/en/1.9/topics/db/aggregation/>)
>>>>
>>>> This will give you list of products where each product will have 'hit'
>>>> is the MAX value of all hits set for this product.
>>>>
>>>> Also I do not see any reason to use 'ContentType' relation from your
>>>> HitCount model at all.
>>>> If your origin intent was to have hits with any Model in your
>>>> system(project) then you should built 'joins with aggregation' queries
>>>> based on Reverse Generic Relation as said Todor. But in this case Product
>>>> hits field becomes unnecessary as it duplicates relations.
>>>>
>>>> On Fri, Aug 5, 2016 at 5:59 AM, M Hashmi  wrote:
>>>>
>>>>> Hello Todor,
>>>>>
>>>>> I followed your directions and used https://docs.djangoprojec
>>>>> t.com/ja/1.9/ref/contrib/contenttypes/ for reference but I got stuck
>>>>> at error 'GenericForeignKey' object has not attribute 'get_lookup'. I 
>>>>> tried
>>>>> Product.objects.aggregate(Count('hits

Re: QuerySet for related models

2016-08-05 Thread M Hashmi
I did the same thing while working with the contenttype except I did used
default filters .all(), .filter(), .get(), annotations and aggregations
etc. Todor each product shows multiple hits if I log out and hit it and
login back to hit it shows more than one hits. Hits are being recoreded for
each session. It shows the same error as it is showing now after
implementing GenericRelations:

AttributeError at / 'GenericForeignKey' object has not attribute
'get_lookup'.

If I mix it with .aggregate(Max, Count, Avg or Sum) queryset options it
will pop up "unhashable type".

I am working on joins methods in django with hope that it will make it
work. I really appreciate your help guys. You both rock and I've learned a
lot with your directions. Still if you have ideas please let me know I will
try those too.

Regards,
Mudassar

On Fri, Aug 5, 2016 at 1:04 AM, Todor Velichkov 
wrote:

> Constantine Covtushenko,
>
> HitCount is a model from a 3rd party app, so the OP can't change it.
>
> However the way HitCount is implemented I don't think one there is a way
> for one product to have more than one `HitCount` objects.
> So I don't think any aggregations are needed.
>
> Lets the Product class look like this:
>
> class Product(models.Model):
> #im changing this on purpose, because it points to HitCount class.
> hitcounts = GenericRelation(HitCount, content_type_field='content_
> object', object_id_field='object_pk',)
>
> Now `HitCount` has a separate `Hit` class  which hold all individual hits
> for a `product`.
>
> The app model structure is here.
> <https://github.com/thornomad/django-hitcount/blob/master/hitcount/models.py>
>
> So to get top products by overall hits you can use `HitCount.hits` field,
> without any `aggregations`, `annotations` or whatsoever.
>
> top_products_by_total_hits = Product.objects.order_by('hitcounts__hits')[:
> 6]
>
> Now if you want to get the number of hits for a product for some period of
> range (lets say a week). Then we need to use the `Hit` model.
>
> top_products_by_last_week_hits = Product.objects.filter(
> hitcounts__hit__created__gte=today-timedelta(days=7)
> ).annotate(
> last_week_hits=Count('hitcounts__hit')
> ).order_by('-last_week_hits')[:6]
>
> Hope this helps and things get clear now.
>
> On Friday, August 5, 2016 at 8:44:02 AM UTC+3, Constantine Covtushenko
> wrote:
>>
>> Hi M Hashmi,
>>
>> I believe that you are looking a way to use aggregation on related model.
>> You should try the following snitppet:
>> `trending_products = Product.objects.aggregate(hit=Max('hits__hits'))[:6]`
>> (see more info here
>> <https://docs.djangoproject.com/en/1.9/topics/db/aggregation/>)
>>
>> This will give you list of products where each product will have 'hit' is
>> the MAX value of all hits set for this product.
>>
>> Also I do not see any reason to use 'ContentType' relation from your
>> HitCount model at all.
>> If your origin intent was to have hits with any Model in your
>> system(project) then you should built 'joins with aggregation' queries
>> based on Reverse Generic Relation as said Todor. But in this case Product
>> hits field becomes unnecessary as it duplicates relations.
>>
>> On Fri, Aug 5, 2016 at 5:59 AM, M Hashmi  wrote:
>>
>>> Hello Todor,
>>>
>>> I followed your directions and used https://docs.djangoprojec
>>> t.com/ja/1.9/ref/contrib/contenttypes/ for reference but I got stuck at
>>> error 'GenericForeignKey' object has not attribute 'get_lookup'. I tried
>>> Product.objects.aggregate(Count('hits'))[:6]. In my models.py I got
>>> following code:
>>>
>>> hits = GenericRelation(HitCount, content_type_field='content_object',
>>> object_id_field='object_pk',)
>>>
>>> class Meta:
>>> ordering = ["-title"]
>>> Removed the -hits from ordering section and rest of the code is same. I
>>> searched it on google but it showed some Django based bugs.
>>> Any suggestions?
>>> Thanks,
>>>
>>>
>>>
>>> On Thursday, August 4, 2016 at 2:07:53 PM UTC-7, Todor Velichkov wrote:
>>>>
>>>> My field hits=models.ForeignKey(Hitcount) means that my Product model
>>>>> has a related  model with multiple fields and all the products in Product
>>>>> model will have one or more hit records. Instance of Product model will
>>>>> save a hit from

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Thanks for reply and I tried this before same exact code but I got stuck at 
"unhashable type" error.
I searched it thoroughly but then I gave up on it to have some guidance 
from kind people like you.

If you believe this is how it should work then please provide me some quick 
ref for the error. I also changed it like:
trending_products = list(Product.objects.aggregate(hit=Max('hits__hits')))
It didn't work.

Thanks again.



On Thursday, August 4, 2016 at 10:44:02 PM UTC-7, Constantine Covtushenko 
wrote:
>
> Hi M Hashmi,
>
> I believe that you are looking a way to use aggregation on related model.
> You should try the following snitppet:
> `trending_products = Product.objects.aggregate(hit=Max('hits__hits'))[:6]` 
> (see more info here 
> <https://docs.djangoproject.com/en/1.9/topics/db/aggregation/>)
>
> This will give you list of products where each product will have 'hit' is 
> the MAX value of all hits set for this product.
>
> Also I do not see any reason to use 'ContentType' relation from your 
> HitCount model at all.
> If your origin intent was to have hits with any Model in your 
> system(project) then you should built 'joins with aggregation' queries 
> based on Reverse Generic Relation as said Todor. But in this case Product 
> hits field becomes unnecessary as it duplicates relations.
>
> On Fri, Aug 5, 2016 at 5:59 AM, M Hashmi 
> > wrote:
>
>> Hello Todor,
>>
>> I followed your directions and used 
>> https://docs.djangoproject.com/ja/1.9/ref/contrib/contenttypes/ for 
>> reference but I got stuck at error 'GenericForeignKey' object has not 
>> attribute 'get_lookup'. I tried 
>> Product.objects.aggregate(Count('hits'))[:6]. In my models.py I got 
>> following code:
>>
>> hits = GenericRelation(HitCount, content_type_field='content_object', 
>> object_id_field='object_pk',)
>>
>> class Meta:
>> ordering = ["-title"]
>> Removed the -hits from ordering section and rest of the code is same. I 
>> searched it on google but it showed some Django based bugs.
>> Any suggestions?
>> Thanks,
>>
>>
>>
>> On Thursday, August 4, 2016 at 2:07:53 PM UTC-7, Todor Velichkov wrote:
>>>
>>> My field hits=models.ForeignKey(Hitcount) means that my Product model 
>>>> has a related  model with multiple fields and all the products in Product 
>>>> model will have one or more hit records. Instance of Product model will 
>>>> save a hit from end user by session/ip/user etc.
>>>
>>> Honestly, I don't understand that. 
>>>
>>> The HitCount class already has a GenericForeignKey, maybe you are 
>>> looking for a Reverse Generic Relation 
>>> <https://docs.djangoproject.com/ja/1.9/ref/contrib/contenttypes/#reverse-generic-relations>
>>>  
>>> class in order to get the Hits for a product.
>>>
>>> On Thursday, August 4, 2016 at 10:42:58 PM UTC+3, M Hashmi wrote:
>>>>
>>>> My field hits=models.ForeignKey(Hitcount) means that my Product model 
>>>> has a related  model with multiple fields and all the products in Product 
>>>> model will have one or more hit records. Instance of Product model will 
>>>> save a hit from end user by session/ip/user etc.
>>>>
>>> -- 
>> 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/2a7be23a-c227-460d-89f2-d7ffd52d4123%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/2a7be23a-c227-460d-89f2-d7ffd52d4123%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8896d210-1e8f-40d5-8580-cc5b15db51d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Hello Todor,

I followed your directions and 
used https://docs.djangoproject.com/ja/1.9/ref/contrib/contenttypes/ for 
reference but I got stuck at error 'GenericForeignKey' object has not 
attribute 'get_lookup'. I tried 
Product.objects.aggregate(Count('hits'))[:6]. In my models.py I got 
following code:

hits = GenericRelation(HitCount, content_type_field='content_object', 
object_id_field='object_pk',)

class Meta:
ordering = ["-title"]
Removed the -hits from ordering section and rest of the code is same. I 
searched it on google but it showed some Django based bugs.
Any suggestions?
Thanks,



On Thursday, August 4, 2016 at 2:07:53 PM UTC-7, Todor Velichkov wrote:
>
> My field hits=models.ForeignKey(Hitcount) means that my Product model has 
>> a related  model with multiple fields and all the products in Product model 
>> will have one or more hit records. Instance of Product model will save a 
>> hit from end user by session/ip/user etc.
>
> Honestly, I don't understand that. 
>
> The HitCount class already has a GenericForeignKey, maybe you are looking 
> for a Reverse Generic Relation 
> <https://docs.djangoproject.com/ja/1.9/ref/contrib/contenttypes/#reverse-generic-relations>
>  
> class in order to get the Hits for a product.
>
> On Thursday, August 4, 2016 at 10:42:58 PM UTC+3, M Hashmi wrote:
>>
>> My field hits=models.ForeignKey(Hitcount) means that my Product model has 
>> a related  model with multiple fields and all the products in Product model 
>> will have one or more hit records. Instance of Product model will save a 
>> hit from end user by session/ip/user etc.
>>
>

-- 
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/2a7be23a-c227-460d-89f2-d7ffd52d4123%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Thank you Constantine,

I got this mistake fixed and this was really bad mistake from my side. Now 
with your proposed scenario I am trying to get it work with 
"trending_products = Product.objects.all().order_by('hits__hits')[:6]" but 
still it isn't giving me sort by max hits as I used annotate method with Max
as well. Also did count for hits. Any suggestions on this now.

Thank you for your response.

On Thursday, August 4, 2016 at 2:10:48 PM UTC-7, Constantine Covtushenko 
wrote:
>
> Please check my notes below:
>
> On Thu, Aug 4, 2016 at 10:42 PM, M Hashmi  > wrote:
>
>> My field hits=models.ForeignKey(Hitcount) means that my Product model has 
>> a related  model with multiple fields and all the products in Product model 
>> will have one or more hit records. 
>>
> Sorry but I do not see how Product model will have many hit records.
> May be you should change it on:
>
> hits = models.ManyToMany(Hitcount)
>
>  
>
>> Instance of Product model will save a hit from end user by 
>> session/ip/user etc.
>>
>> -- 
>> 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/81557c06-29ac-44d0-b76c-b3fea37c83f2%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/81557c06-29ac-44d0-b76c-b3fea37c83f2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/57953851-750f-4592-8fe3-515bae3ab03f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Thanks Todor as this make senseall I need is to get the Hitcount's hits 
presented as local variable to Product model so in queryset I can set 
order_by. I will try this and will post results.

On Thursday, August 4, 2016 at 2:07:53 PM UTC-7, Todor Velichkov wrote:
>
> My field hits=models.ForeignKey(Hitcount) means that my Product model has 
>> a related  model with multiple fields and all the products in Product model 
>> will have one or more hit records. Instance of Product model will save a 
>> hit from end user by session/ip/user etc.
>
> Honestly, I don't understand that. 
>
> The HitCount class already has a GenericForeignKey, maybe you are looking 
> for a Reverse Generic Relation 
> <https://docs.djangoproject.com/ja/1.9/ref/contrib/contenttypes/#reverse-generic-relations>
>  
> class in order to get the Hits for a product.
>
> On Thursday, August 4, 2016 at 10:42:58 PM UTC+3, M Hashmi wrote:
>>
>> My field hits=models.ForeignKey(Hitcount) means that my Product model has 
>> a related  model with multiple fields and all the products in Product model 
>> will have one or more hit records. Instance of Product model will save a 
>> hit from end user by session/ip/user etc.
>>
>

-- 
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/79f9bb72-363d-40c2-848d-3b3dc9ca9bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: QuerySet for related models

2016-08-04 Thread M Hashmi
My field hits=models.ForeignKey(Hitcount) means that my Product model has a 
related  model with multiple fields and all the products in Product model 
will have one or more hit records. Instance of Product model will save a 
hit from end user by session/ip/user etc.

-- 
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/81557c06-29ac-44d0-b76c-b3fea37c83f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


QuerySet for related models

2016-08-04 Thread M Hashmi


I know that count only can be applied for an IntegerField or FloatField but 
I've created a ForeignKey to another model which contains hitcounts. Now I 
need to filter results by max count from related model and I couldn't dot 
it.


models.py:


class Product(models.Model):
title = models.CharField(max_length=120)
description = models.TextField(blank=True, null=True)
price = models.DecimalField(decimal_places=2, max_digits=20)
active = models.BooleanField(default=True)
categories = models.ManyToManyField('Category', blank=True)
default = models.ForeignKey('Category', related_name='default_category', 
null=True, blank=True)
hits = models.ForeignKey(HitCount)

objects = ProductManager()

class Meta:
ordering = ["-title", '-hits']


The idea is to access Hitcount field hits to count max value and sort
 list by max count. Below is Hitcount model installed as third party 
reusable app djagno-hitcount.

 HitCount(models.Model):
hits = models.PositiveIntegerField(default=0)
modified = models.DateTimeField(auto_now=True)
content_type = models.ForeignKey(ContentType, 
related_name="content_type_set_for_%(class)s", on_delete=models.CASCADE)
object_pk = models.PositiveIntegerField('object ID')
content_object = GenericForeignKey('content_type', 'object_pk')

objects = HitCountManager()

class Meta:
ordering = ('-hits',)
get_latest_by = "modified"
verbose_name = _("hit count")
verbose_name_plural = _("hit counts")
unique_together = ("content_type", "object_pk")
db_table = "hitcount_hit_count"


I need to call products in multiple apps with different list and in 
my mainpage views I am trying to use filter option like below:

from django.db.models import Max, Sum, Count
product1 = Product.objects.all().annotate(hits=Count('-hits__hits'))[:6]

or

product1 = Product.objects.all().order_by('-hits__hits')[:6]

and with few different filter options. I couldn't make it work so advise 
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/39e610bf-0558-4a8d-8491-f9324d8986f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to set Callback URL for facebook OAuth

2016-07-10 Thread M Hashmi
I am trying to implement django-allauth on local server. I need help to 
figure out how to set callback url for FaceBook Auth.

Regards,

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/b2a5613d-5bfa-458c-be8d-1716c3e95df0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: IntegrityError column email is not unique

2016-07-02 Thread M Hashmi
@James

As per my understanding I did following. Now it is not adding email if it 
exists but also its not giving me any error.

class GuestCheckoutForm(forms.Form):
email = forms.EmailField()
email2 = forms.EmailField(label='Verify Email')

def clean_email(self):
email = self.cleaned_data["email"]
if UserCheckout.objects.filter(email=email).exists():
raise forms.ValidationError("Please confirm emails addresses 
are the same.")
return email

def clean(self):
cleaned_data = super(GuestCheckoutForm, self).clean()
email = cleaned_data.get('email')
email2 = cleaned_data.get('email2')

if email and email2 and email != email2:
self.add_error('email2', forms.ValidationError('Please confirm 
emails addresses.'))

Rest of the code is same.

-- 
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/a63b8508-063d-405c-a7a2-67ab428bea21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: IntegrityError column email is not unique

2016-07-02 Thread M Hashmi
@James

As per my understanding I did following. Now it is not adding email if it 
exists but also its not giving me any error.

class GuestCheckoutForm(forms.Form):
email = forms.EmailField()
email2 = forms.EmailField(label='Verify Email')

def clean_email(self):
email = self.cleaned_data["email"]
if UserCheckout.objects.filter(email=email).exists():
raise forms.ValidationError("Please confirm emails addresses 
are the same.")
return email

def clean(self):
cleaned_data = super(GuestCheckoutForm, self).clean()
email = cleaned_data.get('email')
email2 = cleaned_data.get('email2')

if email and email2 and email != email2:
self.add_error('email2', forms.ValidationError('Please confirm 
emails addresses.'))

Rest of the code is same.

-- 
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/12116f4b-01b5-4a33-9397-20819d11557d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: IntegrityError column email is not unique

2016-07-02 Thread M Hashmi
Thanks james for your kind response.
Intention is to set a single identifier for guest user account email. If 
that email exists then user can login or if doesn't he will have to get 
registered.
However let me implement your suggested code and I will respond you back.

Thanks 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-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/a9ffd1b7-cd56-4cf6-853f-66409c700074%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


IntegrityError column email is not unique

2016-07-02 Thread M Hashmi
I am working on my Checkout view with regular/guest user but getting hard 
time to come around the integrity error. Idea is to let guest users 
register with email only to checkout and I need to set the user email 
unique. 

models.py

*from django.conf import settings
from django.db import models

class UserCheckout(models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL, null=True, blank=True)
email = models.EmailField(unique=True)

def __unicode__(self):
return self.email*


forms.py




*from django import forms
from django.contrib.auth import** get_user_model*
*User=get_user_model()
class GuestCheckoutForm(forms.Form):
email = forms.EmailField()
email2 = forms.EmailField(label='Verify Email')
def clean_email2(self):
email = self.cleaned_data.get("email")
email2 = self.cleaned_data.get("email2")
if email == email2:
user_exists = User.objects.filter(email=email).count()
if user_exists != 0:
raise forms.ValidationError("User already exists. Please login 
instead")
return email2
else:
raise forms.ValidationError("Please confirm emails addresses are 
the same.")*


In my cart views this is how I've rendered my form.


*def post(self, request, *args, **kwargs):
self.object = self.get_object()
form = self.get_form()
if form.is_valid():
email = form.cleaned_data.get("email")
user_checkout = UserCheckout.objects.create(email=email)
return self.form_valid(form)
else:
return self.form_invalid(form)*


I've registered the model with admin and in admin it shows the error for 
duplication perfectly fine but from frontend I am getting error below:


*IntegrityError at /checkout/
column email is not unique
Request Method: POST
Request URL:http://localhost:8000/checkout/
Django Version: 1.8.13
Exception Type: IntegrityError
Exception Value:
column email is not unique
Exception Location: 
C:\Users\Ali\ecomm\lib\site-packages\django\db\backends\sqlite3\base.py in 
execute, line 318
Python Executable:  C:\Users\Ali\ecomm\Scripts\python.EXE
Python Version: 2.7.9*


Please advise.

-- 
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/b85b393e-1164-4d81-9269-5db4b287d64f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: sub accounts in django

2016-05-19 Thread M Hashmi
Can you explain one of those approaches or provide a web reference with 
complete A to Z implementaiton?

On Thursday, May 19, 2016 at 2:19:04 AM UTC-7, Javier Guerra wrote:
>
> On 18 May 2016 at 17:02, Mehdy M. Haghy > 
> wrote: 
> > Creating sub accounts is a pretty common scenario. 
> > you have clients like (copmany1, company2, ..., company N) 
> > and they have their own users, roles and permissions. 
> > any recommendation on how to implement this or any package 
> recommendation? 
>
> that's commonly known as "multitenant" applications.  there are 
> several approaches to do it, and quite a few packages to help with 
> either. 
>
>
>
> -- 
> Javier 
>

-- 
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/6be76ebf-0d6b-4d53-97d3-3bf8a0c3cdb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


elasticsearch for django with haystack

2016-05-19 Thread M Hashmi
My code is similar to like this if not exactly like in the link provided. 
But I am not able to search products added via products models.

The link is 
http://stackoverflow.com/questions/37314696/djanog-elasticsearch-implementation-issue?noredirect=1#comment62151898_37314696.

In this link user has explained every aspect of detail and I guess we both 
are following the same set of examples.

Please advise.

Regards,
Mudassar

-- 
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/928b7c39-015e-4fbd-a360-50c74d469f71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ProgrammingError django_content_type already exists

2016-02-03 Thread M Hashmi
I've been stuck on this issue for a while now. If anyone have concrete 
solution please let me know.
I subscribed for a VPS on DigitalOcean.com Ubuntu with OneClickDjango 
installation. Pre-loaded installation is 1.6.1 and when I upgrade it I get 
Programming Error django_content_type already exists. No matter what I do 
but issue still persists. 

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/1416e5e6-e90e-41e7-8107-0ec6fea7ce1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.