Re: Trying to print data containing a space in html

2017-01-10 Thread Asad Jibran Ahmed
Can you try moving the templatetags directory to be underneath the webpage
directory. I think that templatetags should be a part of an app.

Right now your templatetags are under the mysite folder, which if I'm not
wrong isn't considered an app.
Regards,

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Tue, Jan 10, 2017 at 12:43 PM, Anjali Mk -X (anmk - WIPRO LIMITED at
Cisco) <a...@cisco.com> wrote:

> Asad,
>
>
>
>
>
> My Application directory hierarchy is like this:
>
> Project  is “mysite”, Application within the project mysite is “webpage”
>
> mysite
>
>   |_ webpage
>
>   |_  __init__.py
>
>   |_  views.py
>
>   |_   urls.py
>
>   |_   models.py
>
>   |_  static
>
>   |_  templates
>
>   |_ mysite
>
>   |_ __init__.py
>
>   |_ settings.py
>
>   |_ urls.py
>
>   |_ admin.py
>
>   |_ templatetags
>
>|_ __init__.py
>
>|_ nbsp.py
>
>
>
>
>
> Regards,
>
>
>
> [image: banner7]
>
>
>
> *Anjali Mk*
>
> Engineer - Software
>
> a...@cisco.com
>
> Tel: *8 066 3356*
>
> *Cisco Systems, Inc.*
>
> No: 72 & 73, Keonics Electronics City Hosur Main Road
> BANGALORE
> 560100
> India
> cisco.com
>
>
>
> [image: http://www.cisco.com/assets/swa/img/thinkbeforeyouprint.gif]Think
> before you print.
>
> This email may contain confidential and privileged material for the sole
> use of the intended recipient. Any review, use, distribution or disclosure
> by others is strictly prohibited. If you are not the intended recipient (or
> authorized to receive for the recipient), please contact the sender by
> reply email and delete all copies of this message.
>
> Please click here
> <http://www.cisco.com/web/about/doing_business/legal/cri/index.html> for
> Company Registration Information.
>
>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *Asad Jibran Ahmed
> *Sent:* Tuesday, January 10, 2017 1:09 PM
> *To:* django-users@googlegroups.com
> *Subject:* Re: Trying to print data containing a space in html
>
>
>
> Hi Anjali,
>
>  Where inside your project are you storing the nbsp.py file?
>
> Regards,
>
>
> Asad Jibran Ahmed <surfer...@gmail.com>
>
> http://blog.asadjb.com
>
>
>
> On Tue, Jan 10, 2017 at 11:09 AM, <anjalim...@gmail.com> wrote:
>
> I have a data attached with multiple spaces, I want to print the data on
> html page along with spaces but in html spaces are getting stripped off. I
> found a solution of creating a package as nbsp and use that in template. I
> tried that but it is throwing error as "
>
> 'nbsp' is not a registered tag library
>
> I am able to import nbsp package which I have kept in templatetags
> directory explicitly in python interactive mode "python manage.py shell".
>
> Below is the code details:
>
> nbsp.py:
>
> from django import template
> from django.utils.safestring import mark_safe
>
> register = template.Library()
>
> @register.filter()
> def nbsp(value):
> return mark_safe("".join(value.split(' ')))
>
> html:
>
> {% load nbsp %}
>
> {% for x in data %}
>
>   {{ x | nbsp }}
>
> {% endfor %}
>
>
>
> Pleas let me know ur suggestions where I am going wrong.
>
>
>
>
>
> 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/75478ccd-feed-4835-9e67-4474a2bfc246%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/75478ccd-feed-4835-9e67-4474a2bfc246%40googlegroups.com?utm_medium=email_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.
>

Re: Trying to print data containing a space in html

2017-01-09 Thread Asad Jibran Ahmed
Hi Anjali,
 Where inside your project are you storing the nbsp.py file?
Regards,

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Tue, Jan 10, 2017 at 11:09 AM, <anjalim...@gmail.com> wrote:

> I have a data attached with multiple spaces, I want to print the data on
> html page along with spaces but in html spaces are getting stripped off. I
> found a solution of creating a package as nbsp and use that in template. I
> tried that but it is throwing error as "
> 'nbsp' is not a registered tag library
> I am able to import nbsp package which I have kept in templatetags
> directory explicitly in python interactive mode "python manage.py shell".
> Below is the code details:
> nbsp.py:
> from django import template
> from django.utils.safestring import mark_safe
> register = template.Library()
> @register.filter()
> def nbsp(value):
> return mark_safe("".join(value.split(' ')))
> html:
> {% load nbsp %}
> {% for x in data %}
>   {{ x | nbsp }}
> {% endfor %}
>
> Pleas let me know ur suggestions where I am going wrong.
>
>
> 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/75478ccd-feed-4835-9e67-4474a2bfc246%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/75478ccd-feed-4835-9e67-4474a2bfc246%40googlegroups.com?utm_medium=email_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%2BYYaWc%2Bsq6eARE%3DXz2UKEG4pEVC3x9vkM4G2jd7FNpCUyrJLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with runserver

2016-11-19 Thread Asad Jibran Ahmed
Do you have debugging turned on (DEBUG=True in settings.py) in Django? If
you do, you should see a pretty detailed stack trace and not just this.
Also, in the console you should see a stack trace with the details of the
error. Do you see those?

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Sun, Nov 20, 2016 at 4:58 AM, NS <heliotrope.dra...@gmail.com> wrote:

> When I run python manage.py runserver, I get this shown on localhost:8000
>
> {"status": "fail",  "method": "", "error":""}
>
>
>
> What happened?
>
> --
> 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/24a87f66-8799-489b-acc4-db779eb811df%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/24a87f66-8799-489b-acc4-db779eb811df%40googlegroups.com?utm_medium=email_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%2BYYaWfw6LXNqGasMc72QfuXSY5hD_HxO02gmSyqxZQZAv-YFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Methods in Models

2016-10-24 Thread Asad Jibran Ahmed
Any method that works *only* with the model data and is used in multiple
places in the application should be a part of the model.

Next, if you have functions that operate on multiple pieces of data (or
more than 1 model instances) you should put them in the view where they are
used. But if these functions are needed from multiple views, then
personally I create a helper class to hold them, and the helper class is
outside the view and model files.

Of course in the end, none of these are hard and fast rules. Just go with
whatever you feel is more maintainable, and use these as general guidelines.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Mon, Oct 24, 2016 at 11:47 AM, Deep Shah <deepshah...@gmail.com> wrote:

> What kind of methods should be part of the models and what should be in
> the views? Can anyone give me an example of a method which should be in a
> Model than the views file?
>
> --
> 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/3ccf6df1-aaa2-42a7-b5dc-ecb8f2390bf5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3ccf6df1-aaa2-42a7-b5dc-ecb8f2390bf5%40googlegroups.com?utm_medium=email_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%2BYYaWekXL_Qveb1xUeM1fFdNdpmNu9fvoYO9_zJUBn4qOGk3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple Types of Account with Abstract User

2016-10-23 Thread Asad Jibran Ahmed
In that case I suggest you create multiple models, one for each type of
user. For example, you could have a SupplierProfile, DesignerProfile, etc...

The reason I suggest multiple profile models, instead of just one model
with a configurable account type field, is that I assume each of these user
types will have it's own data. For example the SupplierProfile might need a
bank account details field, whereas a designer probably does not.

So create multiple models, named similar to SupplierProfile,
DesignerProfile, etc and have each of those link to the Django user model
via a OneToOne key. This is similar to what you're doing with your
UserDetails models.

Hope that helps.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Mon, Oct 24, 2016 at 7:18 AM, Shazia Nusrat <shazianu...@gmail.com>
wrote:

> I've deleted DB and migrations I had previously.
> But still can't figure this out. What I need isthat multiple shops
> needs to get registered with my ecommerce store as well as designers and as
> well as referrers to sell products and then simple registration while
> checkout is in progress.
>
> I have simple idea that I need to somehow create submodel from built-in
> User model with abstract model. Then I want that if user selects Customer
> then customer form should appear, if user says Designer it should present
> designer and so on except the checkout user that I figured out to complete
> the order with guest user by catching session ID and user's email upon
> checkout.
>
> This part I can't figure out. Moreover all these account should have
> access to relevant content. Like Supplier should be able to manage
> inventory or his/her products. Designer only should sell their products in
> bulk etc. So if I fix this issue then I can move forward otherwise its a
> dead lock for me from 4 last hours.
>
> Please advise.
>
> Regards,
>
> Shazia
>
> On Sun, Oct 23, 2016 at 7:53 PM, Asad Jibran Ahmed <surfer...@gmail.com>
> wrote:
>
>> Did you change the AUTH_USER_MODEL setting *after *you had already run python
>> manage.py migrate once (or more) before? From the error I guess what's
>> happening is that you already have a User model in place. It was
>> probably created when you first ran Django migrations without specifying a
>> custom user model.
>>
>> If that is the case, and you *really *want a custom user model, you'll
>> have to ensure that the user model is the first model create in your app.
>> For details look at the warning given at https://docs.djangoproject.
>> com/en/1.10/topics/auth/customizing/#substituting-a-custom-user-model.
>>
>> From what I'm seeing of your models, you only seem to want to add extra
>> fields to each user. You can also do that by just pointing your
>> UserDetails model to the existing django.contrib.auth.models.User model,
>> and adding the type information in your UserDetails model instead. That
>> might work for you. Otherwise you'll have to remove your existing database
>> and run migrations from start.
>>
>> Asad Jibran Ahmed <surfer...@gmail.com>
>> http://blog.asadjb.com
>>
>> On Mon, Oct 24, 2016 at 4:37 AM, Shazia Nusrat <shazianu...@gmail.com>
>> wrote:
>>
>>> Hi,
>>> I am trying to create multiple types of users in my django e-commerce
>>> project by extending built-in Django user model but I am having issue.
>>>
>>> Would appreciate if someone can guide me to right direction.
>>> Following is the code in my "accounts" app.
>>>
>>> from __future__ import unicode_literals
>>> from django.db import models
>>> from django.contrib.auth.models import AbstractUser
>>>
>>> class CustomUser(AbstractUser):
>>> type_choices = (
>>> ('Supplier', 'Supplier'),
>>> ('Designer', 'Designer'),
>>> ('Shop', 'Shop'),
>>> ('Referrer', 'Referrer'),
>>> ('User', 'User'),
>>> )
>>> user_type = models.CharField(max_length=2,
>>>  choices=type_choices,
>>>  default='User')
>>>
>>> class UserDetails(models.Model):
>>> type = models.OneToOneField(CustomUser)
>>> extra_info = models.CharField(max_length=200)
>>>
>>> My settings.py includes 'accounts' in installed app and variable
>>> included for extending models in settings.py:
>>>
>>> AUTH_USER_MODEL = 'accounts.Customer'
>>>
>>> Error:
>>>
>>>
>>> ERRORS:
>>> accounts.CustomUser.groups: (fields.E304) Reve

Re: Multiple Types of Account with Abstract User

2016-10-23 Thread Asad Jibran Ahmed
Did you change the AUTH_USER_MODEL setting *after *you had already run python
manage.py migrate once (or more) before? From the error I guess what's
happening is that you already have a User model in place. It was probably
created when you first ran Django migrations without specifying a custom
user model.

If that is the case, and you *really *want a custom user model, you'll have
to ensure that the user model is the first model create in your app. For
details look at the warning given at
https://docs.djangoproject.com/en/1.10/topics/auth/customizing/#substituting-a-custom-user-model
.

>From what I'm seeing of your models, you only seem to want to add extra
fields to each user. You can also do that by just pointing your UserDetails
model to the existing django.contrib.auth.models.User model, and adding the
type information in your UserDetails model instead. That might work for
you. Otherwise you'll have to remove your existing database and run
migrations from start.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Mon, Oct 24, 2016 at 4:37 AM, Shazia Nusrat <shazianu...@gmail.com>
wrote:

> Hi,
> I am trying to create multiple types of users in my django e-commerce
> project by extending built-in Django user model but I am having issue.
>
> Would appreciate if someone can guide me to right direction.
> Following is the code in my "accounts" app.
>
> from __future__ import unicode_literals
> from django.db import models
> from django.contrib.auth.models import AbstractUser
>
> class CustomUser(AbstractUser):
> type_choices = (
> ('Supplier', 'Supplier'),
> ('Designer', 'Designer'),
> ('Shop', 'Shop'),
> ('Referrer', 'Referrer'),
> ('User', 'User'),
> )
> user_type = models.CharField(max_length=2,
>  choices=type_choices,
>  default='User')
>
> class UserDetails(models.Model):
> type = models.OneToOneField(CustomUser)
> extra_info = models.CharField(max_length=200)
>
> My settings.py includes 'accounts' in installed app and variable included
> for extending models in settings.py:
>
> AUTH_USER_MODEL = 'accounts.Customer'
>
> Error:
>
>
> ERRORS:
> accounts.CustomUser.groups: (fields.E304) Reverse accessor for
> 'CustomUser.group
> s' clashes with reverse accessor for 'User.groups'.
> HINT: Add or change a related_name argument to the definition for
> 'Custo
> mUser.groups' or 'User.groups'.
> accounts.CustomUser.user_permissions: (fields.E304) Reverse accessor for
> 'Custom
> User.user_permissions' clashes with reverse accessor for
> 'User.user_permissions'
> .
> HINT: Add or change a related_name argument to the definition for
> 'Custo
> mUser.user_permissions' or 'User.user_permissions'.
> auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes
> with
> reverse accessor for 'CustomUser.groups'.
> HINT: Add or change a related_name argument to the definition for
> 'User.
> groups' or 'CustomUser.groups'.
> auth.User.user_permissions: (fields.E304) Reverse accessor for
> 'User.user_permis
> sions' clashes with reverse accessor for 'CustomUser.user_permissions'.
> HINT: Add or change a related_name argument to the definition for
> 'User.
> user_permissions' or 'CustomUser.user_permissions'.
>
> Please advise.
>
> 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/CAD83tOxKnQCeWyWjYmbxo7iaxmsys
> k8WJs-zy44GZbDXr93iEg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAD83tOxKnQCeWyWjYmbxo7iaxmsysk8WJs-zy44GZbDXr93iEg%40mail.gmail.com?utm_medium=email_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%2BYYaWfEdFhBjv0M%2BC3XApq1z2-k1tGG6orwwDdcOwn2JezOrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Compiling/packing Django to one binary

2016-10-18 Thread Asad Jibran Ahmed
Hi,
 While I haven't personally dealt with such a situation with my Django
code, I have worked with people who had this issue (un-deterministic
production servers). They used Docker to solve this issue. Essentially
you're looking for deterministic deploys, and Docker is the first thing
that jumps to my mind for something like this.

Is that a possibility that you can consider? If not, then I'm sure there
will be better answers to your question from other people in this group.
Regards,

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Tue, Oct 18, 2016 at 10:45 PM, Александр Христюхин <robosl...@gmail.com>
wrote:

> Hi!
>
>
> I would like to ask community about methods of shipping Django in
> production.
>
>
> I do have some limitations, one of which is I don't know what packages are
> installed on production server (for example, postgres dev libraries or
> specific version of python).
>
>
> Right now my method is to create venv with specific version of Python,
> make venv relocatable, copy missing libraries into venv/lib, pack it into
> archive and ship to production servers.
>
>
> On application launch server has to unpack archive and run it somewhat
> like that:
>
>> $ LD_LIBRARY_PATH=venv/lib venv/bin/python venv/bin/gunicorn -c
>> gunicorn.conf myapp.wsgi:application
>
>
> In my case LD_LIBRARY_PATH is required for libpython and libpq (PostgreSQL
> query library).
>
>
> This does work, but I have to go through a lot of stuff.
>
>
> What I want to do is pack my application with specific python and
> libraries into one binary (on build server) and only ship this binary to
> production server. So application launch will look somewhat like that:
>
>> $ my-awesome-python-bin gunicorn -c gunicorn.conf myapp.wsgi:application
>
>
> Or if I could go even further and describe some startup logic:
>
>>
>> def startup():
>> ...
>> args = argparser.parse()
>> config = args.config
>> gunicorn.server(config, myapp.wsgi, 'application').run()
>
> ...and then:
>
>> $ my-awesome-bin -c myapp.conf
>
>
> Is there any way of doing that?
>
> Or could you suggest any easier (well, more convenient) way of shipping
> Django?
>
>
> I did ask practically the same question on StackOverflow
> <http://stackoverflow.com/questions/39913847/is-there-a-way-to-compile-python-application-into-static-binary/>
>  couple
> weeks ago, but none of given answers provide simple solution for my
> problem. I've tried nuitka, pyinstalled and cx_freeze with no success.
>
> --
> 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/51a3ef5f-800a-48db-9697-03d069238834%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/51a3ef5f-800a-48db-9697-03d069238834%40googlegroups.com?utm_medium=email_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%2BYYaWcYQRQARWWVarMuvFnMnrQBkuiv03J3w12hp6F%2ByPVL_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use Django forms for surveys

2016-10-17 Thread Asad Jibran Ahmed
Hi,
 This is a complicated question and I'll do my best to answer it well, but
please forgive me if I miss somethings or say something inaccurate. I had a
similar project a while back and I did think about a possible solution,
something that might be of use to you.

If you want to use something pre-built, I suggest you take a look at
https://github.com/eldest-daughter/ed-questionnaire.

If you want something custom, read on.

Firstly, I'd present each question to the user on a separate page. I'd have
one Django view called QuestionView. I'd have a URL config similar to this:

url(r'^question/(?P(\d+))/$', QuestionView.as_view(), name='question')

Next I would come up with a data structure to hold the form configuration.
I don't mean a data structure like the ones you see in CS courses (trees,
maps, lists, etc). I mean a way to structure your data in a meaningful way.
For the scenario you describe, something like this might be a good starting
point:

QUESTIONS = [
 {
  "id": 1,
  "question": "Are you a programmer?",
  "options": ["No", "Yes"]
 },

 {
  "id": 2,
  "question": "Which operating system do you use?",
  "options": ["Windows", "Linux", "macOS"]
 },

 {
 "id": 3,
  "question": "Which editor do you use for writing code?",
  "show_if": {"question_id": 1, "answer": "Yes"}
  "options": ["Vim", "Emacs", "Sublime Text", "Other"]
 }
]

In this scenario, question id 3 is only shown if the user selected *Yes*
for question 1. Which means that you'll need to keep track of the answers
the user has already taken. Using the session storage for that is one good
option.

So each request to the Django app returns a page with a simple HTML page
with just one form. The form only has the widgets for the question being
answered. The view would take a look at the question it has to present, and
then generate a dynamic form based on that. Check out this post for a good
description of how to generate dynamic forms:
https://jacobian.org/writing/dynamic-form-generation/.

For question 1 in this case, the page would have a form with just 2 radio
buttons. When the user submits that form, you'll save their answer
somewhere (may the session storage) and then redirect the user to the URL
for the next question. To keep it simple, *always* redirect the user to the
next question.

Now comes the conditional logic of whether the user has to answer the
question or not. Let's say the user selected *No *for question 1, then
answered question 2 and was redirected to the URL for question 3. At this
point, your view looks at the config for question 3. The config says to
show this question only if the answer to question 1 was *Yes*. You check
the session storage and see that the user answered *No* for the first
question. So the user shouldn't have to answer this question. You simply
redirect the user to question 4, and this entire logic is checked again.

Of course this is only the starting point. An application like this is
going to get complicated, and you seem to indicate there is more
complicated logic involved than just the simple "Only show this question if
that question had and answer matching X". But this is a reasonable starting
point for something like this. As you develop your application further
you'll learn much more about the specific problem you're solving and come
up with much better ways of solving it.

Hopefully this large wall of text made some sense! Let me know if I can
explain something more. Hopefully this will be of some use to you.
Regards,

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Mon, Oct 17, 2016 at 6:37 AM, Diego De La Vega <aiwilfa...@gmail.com>
wrote:

> Hi. This is my first question in this group.
>
> My problem is that I have to program a survey application and I would like
> to have a hint about forms.
>
> The survey is +200 questions long and is divided in multiple subjects
> (every subject is independent from the others) and mainly consists of
> numeric (implemented as combo boxes) and text fields..
>
> The main problem is how to do for showing the relevant fields and not the
> unwanted.
>
> Let me explan this: suppose that when the answer to question 1 is 1, the
> survey continues with question 2, but if the answer is 2, then the survey
> continues with question 16 and all the in between questions are skipped.
>
> This is a very simple scenario, but almost all the flow of the survey goes
> like this, making it complex to follow the order. Sometimes one must skip a
> few questions but some others, one must skip only one, or a full section of
> the questions, depending on the answer.
>
> Is there a recommended way to do so? Thanks in advance an

Re: Importing contacts from email/social

2016-10-14 Thread Asad Jibran Ahmed
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 <surfer...@gmail.com>
http://blog.asadjb.com

On Sat, Oct 15, 2016 at 2:25 AM, M Hashmi <mhashmi1...@gmail.com> 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 <surfer...@gmail.com>
> 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 <surfer...@gmail.com>
>> http://blog.asadjb.com
>>
>> On Fri, Oct 14, 2016 at 7:41 PM, M Hashmi <mhashmi1...@gmail.com> 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_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_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/CANoUts5VVq357gQhVJQX6hPHeJA4C
> D61tFiASpasMCiBcFmkmA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANoUts5VVq357gQhVJQX6hPHeJA4CD61tFiASpasMCiBcFmkmA%40mail.gmail.com?utm_medium=email_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%2BYYaWe9LJwskRc%3DZ85VtuHbgSiqDa%3DsMOb9mGq-HX8DqudLTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: HELP - Writing your first Django app, part 1

2016-10-14 Thread Asad Jibran Ahmed
Just save the file inside the *poll *folder. That creates the file.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Fri, Oct 14, 2016 at 9:55 PM, 'Nick Bansal' via Django users <
django-users@googlegroups.com> wrote:

> I tried to create a new file (im using sublime text) but it just gave me a
> new tab...
>
> How do I create a new file in an app?
>
> On Friday, 14 October 2016 17:41:43 UTC+1, Asad Jibran Ahmed wrote:
>>
>> Just create a new file in whatever text editor you're using (I suggest
>> Sublime Text if you're looking for options) and save the file as urls.py
>> inside the polls directory.
>>
>> Asad Jibran Ahmed <surf...@gmail.com>
>> http://blog.asadjb.com
>>
>> On Fri, Oct 14, 2016 at 8:00 PM, 'Nick Bansal' via Django users <
>> django...@googlegroups.com> wrote:
>>
>>> Hi,
>>>
>>> I'm struggling to figure out how to do the following command:
>>>
>>> "To create a URLconf in the polls directory, create a file called
>>> urls.py. Your app directory should now look like:"
>>>
>>> How do I create a file called urls.py in the app directory? am I missing
>>> something completely obvious?
>>>
>>> Any help would be appreciated
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@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/4ca2fd83-cf96-45d6-9fd1-5721de06247c%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/4ca2fd83-cf96-45d6-9fd1-5721de06247c%40googlegroups.com?utm_medium=email_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/512287a4-e411-4438-b131-38ab9ffad239%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/512287a4-e411-4438-b131-38ab9ffad239%40googlegroups.com?utm_medium=email_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%2BYYaWeg__%3DN2az--7iSYMSwJfYPuwSEjS8k_A2KpKGBKX3zTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Importing contacts from email/social

2016-10-14 Thread Asad Jibran Ahmed
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 <surfer...@gmail.com>
http://blog.asadjb.com

On Fri, Oct 14, 2016 at 7:41 PM, M Hashmi <mhashmi1...@gmail.com> 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/
> msgid/django-users/CANoUts7_1BTRcDOTFy1oHUYod2rU_
> sOZc9fOnin5uDi9RBLSig%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANoUts7_1BTRcDOTFy1oHUYod2rU_sOZc9fOnin5uDi9RBLSig%40mail.gmail.com?utm_medium=email_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.
For more options, visit https://groups.google.com/d/optout.


Re: HELP - Writing your first Django app, part 1

2016-10-14 Thread Asad Jibran Ahmed
Just create a new file in whatever text editor you're using (I suggest
Sublime Text if you're looking for options) and save the file as urls.py
inside the polls directory.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Fri, Oct 14, 2016 at 8:00 PM, 'Nick Bansal' via Django users <
django-users@googlegroups.com> wrote:

> Hi,
>
> I'm struggling to figure out how to do the following command:
>
> "To create a URLconf in the polls directory, create a file called urls.py.
> Your app directory should now look like:"
>
> How do I create a file called urls.py in the app directory? am I missing
> something completely obvious?
>
> Any help would be appreciated
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/4ca2fd83-cf96-45d6-9fd1-5721de06247c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4ca2fd83-cf96-45d6-9fd1-5721de06247c%40googlegroups.com?utm_medium=email_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%2BYYaWf%3DCLDViVZMHH_YEWH89jZ%3DyvnWpYQhp07AkXdHr5ChSA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-20 Thread Asad Jibran Ahmed
I'd need to see the full Cart model to confirm, but try something like this
to get all products for Orders with the paid status:

def get_products(self):
 orders = Order.objects.filter(user=self.user, status='paid')
 products_list = list()
 for o in orders:
  for p in o.cart.products:
   products_list.append(p)

 return products_list

This depends on their being a ManyToMany relationship to Product in the
Cart model.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Tue, Sep 20, 2016 at 10:12 AM, Shamaila Moazzam <
shamaila.moaz...@gmail.com> wrote:

> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>
> this user is a F.K in products model, orders model , carts model right.
> cart is also a F.K in orders like this
>
> class Order(models.Model):
> status = models.CharField(max_length=120,
> choices=ORDER_STATUS_CHOICES, default='created')
> cart = models.ForeignKey(Cart)
> user = models.ForeignKey(UserCheckout, null=True)
> billing_address = models.ForeignKey(UserAddress,
> related_name='billing_address', null=True)
> shipping_address = models.ForeignKey(UserAddress,
> related_name='shipping_address', null=True
> ..
> seller = models.ForeignKey(SellerAccount, null=True)..i have
> added this field now to relate sellers app with orders...
>
> now advise me
> how to filter orders of products with status of paid .( of a logged in
> user )
>
> :)
>
>
>
>
>
>
>
>
> On Tuesday, September 20, 2016 at 10:44:19 AM UTC+5, Asad Jibran Ahmed
> wrote:
>>
>> Can you share the Cart model? The Order has a foreign key to Cart. I
>> think that may be the model holding details of the products.
>>
>> On Tuesday, September 20, 2016 at 9:32:12 AM UTC+4, Asad Jibran Ahmed
>> wrote:
>>>
>>> How are you associating a product with an order? Is there a way to get a
>>> list of products sold for each order?
>>>
>>> Asad Jibran Ahmed <surf...@gmail.com>
>>> http://blog.asadjb.com
>>>
>>> On Tue, Sep 20, 2016 at 9:24 AM, Shamaila Moazzam <shamaila...@gmail.com
>>> > wrote:
>>>
>>>> Thanks for you kind response ...I am stuck in it :(
>>>>
>>>> I have seller as a foreign key in Product model..
>>>>
>>>> *products/models.py*
>>>>
>>>> class Product(models.Model):
>>>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>>>> seller = models.ForeignKey(SellerAccount)
>>>>
>>>> title = models.CharField(max_length=120)
>>>> description = models.TextField(blank=True, null=True)
>>>> price = models.DecimalField(decimal_places=2, max_digits=20)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Tuesday, September 20, 2016 at 10:09:01 AM UTC+5, Asad Jibran Ahmed
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>  While you didn't show us the Product model, I assume it has a
>>>>> ForeignKey to the Order model. To filter for Products that have an
>>>>> Order with a sold status, you should look at the documentation for
>>>>> filtering on relationships at https://docs.djangoproject.com
>>>>> /en/1.10/topics/db/queries/#lookups-that-span-relationships.
>>>>> Regards,
>>>>> Jibran
>>>>>
>>>>> On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam
>>>>> wrote:
>>>>>>
>>>>>> hi
>>>>>> I am a beginner in django/python * :(*
>>>>>>
>>>>>> I am making a dashboard of sellers App.
>>>>>> I am stuck in filtering orders of the products according to the
>>>>>> logged in user(seller)
>>>>>>
>>>>>> *sellers/models.py*
>>>>>>
>>>>>> from django.conf import settings
>>>>>> from django.core.urlresolvers import reverse
>>>>>> from django.db import models
>>>>>> from django.contrib.auth.models import User
>>>>>>
>>>>>>
>>>>>>
>>>>>> class SellerAccount(models.Model):
>>>>>> user = models.ForeignKey(User)
>>>>>> managers = models.ManyToManyField(settings.AUTH_USER_MODEL,
>>>>>> related_name="manager_sellers", blank=True)
>>>>>> active = models.BooleanField(default=False)
>>>>>> timestamp = models.DateTimeField(aut

Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Asad Jibran Ahmed
Can you share the Cart model? The Order has a foreign key to Cart. I think 
that may be the model holding details of the products.

On Tuesday, September 20, 2016 at 9:32:12 AM UTC+4, Asad Jibran Ahmed wrote:
>
> How are you associating a product with an order? Is there a way to get a 
> list of products sold for each order?
>
> Asad Jibran Ahmed <surfer...@gmail.com>
> http://blog.asadjb.com
>
> On Tue, Sep 20, 2016 at 9:24 AM, Shamaila Moazzam <
> shamaila.moaz...@gmail.com> wrote:
>
>> Thanks for you kind response ...I am stuck in it :(
>>
>> I have seller as a foreign key in Product model..
>>
>> *products/models.py*
>>
>> class Product(models.Model):
>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>> seller = models.ForeignKey(SellerAccount)
>>
>> title = models.CharField(max_length=120)
>> description = models.TextField(blank=True, null=True)
>> price = models.DecimalField(decimal_places=2, max_digits=20)
>>
>>
>>
>>
>>
>> On Tuesday, September 20, 2016 at 10:09:01 AM UTC+5, Asad Jibran Ahmed 
>> wrote:
>>>
>>> Hi,
>>>  While you didn't show us the Product model, I assume it has a 
>>> ForeignKey to the Order model. To filter for Products that have an Order 
>>> with a sold status, you should look at the documentation for filtering on 
>>> relationships at 
>>> https://docs.djangoproject.com/en/1.10/topics/db/queries/#lookups-that-span-relationships
>>> .
>>> Regards,
>>> Jibran
>>>
>>> On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam 
>>> wrote:
>>>>
>>>> hi
>>>> I am a beginner in django/python * :(*
>>>>
>>>> I am making a dashboard of sellers App.
>>>> I am stuck in filtering orders of the products according to the logged 
>>>> in user(seller)
>>>>
>>>> *sellers/models.py*
>>>>
>>>> from django.conf import settings
>>>> from django.core.urlresolvers import reverse
>>>> from django.db import models
>>>> from django.contrib.auth.models import User
>>>>
>>>>
>>>>
>>>> class SellerAccount(models.Model):
>>>> user = models.ForeignKey(User)
>>>> managers = models.ManyToManyField(settings.AUTH_USER_MODEL, 
>>>> related_name="manager_sellers", blank=True)
>>>> active = models.BooleanField(default=False)
>>>> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
>>>>
>>>>
>>>> def __unicode__(self):
>>>> return str(self.user.username)
>>>>
>>>> def get_absolute_url(self):
>>>> return reverse("products:vendor_detail", kwargs={"vendor_name": 
>>>> self.user.username})
>>>>
>>>>
>>>> *orders/models.py*
>>>>
>>>> class Order(models.Model):
>>>> status = models.CharField(max_length=120, 
>>>> choices=ORDER_STATUS_CHOICES, default='created')
>>>> cart = models.ForeignKey(Cart)
>>>> user = models.ForeignKey(UserCheckout, null=True)
>>>> billing_address = models.ForeignKey(UserAddress, 
>>>> related_name='billing_address', null=True)
>>>> shipping_address = models.ForeignKey(UserAddress, 
>>>> related_name='shipping_address', null=True)
>>>> shipping_total_price = models.DecimalField(max_digits=50, 
>>>> decimal_places=2, default=5.99)   
>>>> order_total = models.DecimalField(max_digits=50, decimal_places=2, )
>>>> order_id = models.CharField(max_length=20, null=True, blank=True)
>>>> paymethod = models.CharField(max_length=120, choices=CHOICES, 
>>>> default='CreditCard')
>>>> 
>>>>
>>>> def __unicode__(self):
>>>> return str(self.cart.id)
>>>>
>>>>
>>>> *sellers/mixins.py*
>>>>
>>>>
>>>> import datetime
>>>>
>>>> from django.db.models import Count, Min, Sum, Avg, Max
>>>>
>>>> from dress.mixins import LoginRequiredMixin
>>>> from orders.models import Transaction, Order
>>>> from products.models import Product
>>>>
>>>> from .models import SellerAccount
>>>>
>>>>
>>>>
>>>> class SellerAccountMixin(Logi

Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Asad Jibran Ahmed
How are you associating a product with an order? Is there a way to get a
list of products sold for each order?

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Tue, Sep 20, 2016 at 9:24 AM, Shamaila Moazzam <
shamaila.moaz...@gmail.com> wrote:

> Thanks for you kind response ...I am stuck in it :(
>
> I have seller as a foreign key in Product model..
>
> *products/models.py*
>
> class Product(models.Model):
> user = models.ForeignKey(settings.AUTH_USER_MODEL)
> seller = models.ForeignKey(SellerAccount)
>
> title = models.CharField(max_length=120)
> description = models.TextField(blank=True, null=True)
> price = models.DecimalField(decimal_places=2, max_digits=20)
>
>
>
>
>
> On Tuesday, September 20, 2016 at 10:09:01 AM UTC+5, Asad Jibran Ahmed
> wrote:
>>
>> Hi,
>>  While you didn't show us the Product model, I assume it has a ForeignKey
>> to the Order model. To filter for Products that have an Order with a
>> sold status, you should look at the documentation for filtering on
>> relationships at https://docs.djangoproject.com
>> /en/1.10/topics/db/queries/#lookups-that-span-relationships.
>> Regards,
>> Jibran
>>
>> On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam
>> wrote:
>>>
>>> hi
>>> I am a beginner in django/python * :(*
>>>
>>> I am making a dashboard of sellers App.
>>> I am stuck in filtering orders of the products according to the logged
>>> in user(seller)
>>>
>>> *sellers/models.py*
>>>
>>> from django.conf import settings
>>> from django.core.urlresolvers import reverse
>>> from django.db import models
>>> from django.contrib.auth.models import User
>>>
>>>
>>>
>>> class SellerAccount(models.Model):
>>> user = models.ForeignKey(User)
>>> managers = models.ManyToManyField(settings.AUTH_USER_MODEL,
>>> related_name="manager_sellers", blank=True)
>>> active = models.BooleanField(default=False)
>>> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
>>>
>>>
>>> def __unicode__(self):
>>> return str(self.user.username)
>>>
>>> def get_absolute_url(self):
>>> return reverse("products:vendor_detail", kwargs={"vendor_name":
>>> self.user.username})
>>>
>>>
>>> *orders/models.py*
>>>
>>> class Order(models.Model):
>>> status = models.CharField(max_length=120,
>>> choices=ORDER_STATUS_CHOICES, default='created')
>>> cart = models.ForeignKey(Cart)
>>> user = models.ForeignKey(UserCheckout, null=True)
>>> billing_address = models.ForeignKey(UserAddress,
>>> related_name='billing_address', null=True)
>>> shipping_address = models.ForeignKey(UserAddress,
>>> related_name='shipping_address', null=True)
>>> shipping_total_price = models.DecimalField(max_digits=50,
>>> decimal_places=2, default=5.99)
>>> order_total = models.DecimalField(max_digits=50, decimal_places=2, )
>>> order_id = models.CharField(max_length=20, null=True, blank=True)
>>> paymethod = models.CharField(max_length=120, choices=CHOICES,
>>> default='CreditCard')
>>>
>>>
>>> def __unicode__(self):
>>> return str(self.cart.id)
>>>
>>>
>>> *sellers/mixins.py*
>>>
>>>
>>> import datetime
>>>
>>> from django.db.models import Count, Min, Sum, Avg, Max
>>>
>>> from dress.mixins import LoginRequiredMixin
>>> from orders.models import Transaction, Order
>>> from products.models import Product
>>>
>>> from .models import SellerAccount
>>>
>>>
>>>
>>> class SellerAccountMixin(LoginRequiredMixin, object):
>>> account = None
>>> products = []
>>> transactions = []
>>> orders = []
>>>
>>> def get_account(self):
>>> user = self.request.user
>>> accounts = SellerAccount.objects.filter(user=user)
>>> if accounts.exists() and accounts.count() == 1:
>>> self.account = accounts.first()
>>> return accounts.first()
>>> return None
>>>
>>> def get_products(self):
>>> account = self.get_account()
>>> products = Product.objects.filter(seller=acc

Re: Issue in filtering .....(want to show only the products that are sold and have status of paid in orders App)

2016-09-19 Thread Asad Jibran Ahmed
Hi,
 While you didn't show us the Product model, I assume it has a ForeignKey 
to the Order model. To filter for Products that have an Order with a sold 
status, you should look at the documentation for filtering on relationships 
at 
https://docs.djangoproject.com/en/1.10/topics/db/queries/#lookups-that-span-relationships.
Regards,
Jibran

On Tuesday, September 20, 2016 at 9:04:18 AM UTC+4, Shamaila Moazzam wrote:
>
> hi
> I am a beginner in django/python * :(*
>
> I am making a dashboard of sellers App.
> I am stuck in filtering orders of the products according to the logged in 
> user(seller)
>
> *sellers/models.py*
>
> from django.conf import settings
> from django.core.urlresolvers import reverse
> from django.db import models
> from django.contrib.auth.models import User
>
>
>
> class SellerAccount(models.Model):
> user = models.ForeignKey(User)
> managers = models.ManyToManyField(settings.AUTH_USER_MODEL, 
> related_name="manager_sellers", blank=True)
> active = models.BooleanField(default=False)
> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
>
>
> def __unicode__(self):
> return str(self.user.username)
>
> def get_absolute_url(self):
> return reverse("products:vendor_detail", kwargs={"vendor_name": 
> self.user.username})
>
>
> *orders/models.py*
>
> class Order(models.Model):
> status = models.CharField(max_length=120, 
> choices=ORDER_STATUS_CHOICES, default='created')
> cart = models.ForeignKey(Cart)
> user = models.ForeignKey(UserCheckout, null=True)
> billing_address = models.ForeignKey(UserAddress, 
> related_name='billing_address', null=True)
> shipping_address = models.ForeignKey(UserAddress, 
> related_name='shipping_address', null=True)
> shipping_total_price = models.DecimalField(max_digits=50, 
> decimal_places=2, default=5.99)   
> order_total = models.DecimalField(max_digits=50, decimal_places=2, )
> order_id = models.CharField(max_length=20, null=True, blank=True)
> paymethod = models.CharField(max_length=120, choices=CHOICES, 
> default='CreditCard')
> 
>
> def __unicode__(self):
> return str(self.cart.id)
>
>
> *sellers/mixins.py*
>
>
> import datetime
>
> from django.db.models import Count, Min, Sum, Avg, Max
>
> from dress.mixins import LoginRequiredMixin
> from orders.models import Transaction, Order
> from products.models import Product
>
> from .models import SellerAccount
>
>
>
> class SellerAccountMixin(LoginRequiredMixin, object):
> account = None
> products = []
> transactions = []
> orders = []
>
> def get_account(self):
> user = self.request.user
> accounts = SellerAccount.objects.filter(user=user)
> if accounts.exists() and accounts.count() == 1:
> self.account = accounts.first()
> return accounts.first()
> return None
>
> def get_products(self):
> account = self.get_account()
> products = Product.objects.filter(seller=account)
> self.products = products
> return products
>
>def get_sold_products(self):
> products = self.get_products()
> **
>   THIS IS THE PROBLEM AREA ? i want to show orders of the 
> products i got from (products = self.get_products()).
> keeping this thing in mind that order is completed if its status 
> set to be 'paid'
> OR
> In other words i want to show products of the user that is logged 
> in if the status of that products are paid.
> *
> sold = Order.objects.all().filter('products')
> return sold
>
>
> *sellers/views.py*
>
> class SellerDashboard(SellerAccountMixin, FormMixin, View):
> form_class = NewSellerForm
> success_url = "/seller/"
> context["products"] = self.get_products()
>
> context["sold_products"] = self.get_sold_products()
>
> *sellers/dashboard.html*
>
> {{ sold_products }}
>
> i hope someone will definitely figure out my problem
> regards
>

-- 
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/457d2aa1-3893-4737-8fdf-a55ed08c06d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: multiple django installation in one server

2016-09-07 Thread Asad Jibran Ahmed
Hi,
 I have a similar setup for my projects. What I do is:

   1. Create a new virtual environment for the project (
   https://virtualenv.pypa.io/en/stable/). Virtual environments make sure
   that each project that you deploy can have it's own set of dependencies
   that do not conflict with the other projects.
   2. Install your required libraries in the virtual environment
   3. Use uwsgi in the Emperor mode to configure and run each app. Within
   the uwsgi config you can give it the virtual environment to use.

With this way I run multiple Django apps, each with different requirements,
on the same server without any issues. This involves a bit of
configuration, which may be daunting if this is the first time you're doing
this. If so, please do ask and I'm sure we can guide you further as well.

The number of projects that can be run on one server is very much dependent
on what kind of projects you are running, and the kind of traffic your
applications handle. My suggestion is to slowly add 1 or 2 projects at a
time and monitor the server to make sure it isn't overloaded. If not,
repeat. Otherwise get another server and setup the rest of the projects on
that.

Regards,

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Wed, Sep 7, 2016 at 5:28 PM, miarisoa sandy <sandymiari...@gmail.com>
wrote:

> Hi guys,
>
> I hope you are doing fine.
> I have googled it but no fruitful results.
> I am a newbie in django and I wonder what is the number maximum django
> that I can install in one server??
> I have a lot of projects that I would like to check with django ( one
> project -> one django) to avoid some confusion with each project (PHP
> project).
> Or what is the best way for me??
>
> The server is: Ubuntu 12.04, intel core i5 3.2Ghz, 4Go of RAM
>
> Waiting to hear from you, thanks for your help.
>
> Best
>
>
> --
> 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/33008438-92bf-4283-ab52-b6909eb81193%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/33008438-92bf-4283-ab52-b6909eb81193%40googlegroups.com?utm_medium=email_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%2BYYaWc3DiJ_jsww38p8kDtfktaWN354V64WOKntXkTeRraktQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django template iterating through two dictionaries/variables

2016-08-29 Thread Asad Jibran Ahmed
Unfortunately without knowing your project layout I can't show you exactly
how to load the filters, but you should give this a read:
https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/.

Your template should look like the example from Ludovic.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Mon, Aug 29, 2016 at 8:39 PM, Aaron Weisberg <aaron.m.weisb...@gmail.com>
wrote:

> I hate to be thick but could you explain to me how to load the filters and
> also how the template should look with the updated function?  Solving this
> will unlock a ton of functionality for my app.
>
> Thanks,
>
> Aaron
>
> On Aug 29, 2016 12:34 PM, "Asad Jibran Ahmed" <surfer...@gmail.com> wrote:
>
>> No problem. The most probable reason why you're getting the invalid
>> filter error is because you forgot to load the filters.
>>
>> Your explanation of the workflow is correct, with one small correction.
>> The template will handoff the search for the correct *Score* to the
>> filter function. Whatever the filter function returns will then be inserted
>> in place of the {scores|from_player:person} part in your template. One
>> way of getting the correct score would be to loop over the items in your
>> scores dictionary, and find the one where the identification numbers match.
>> One suggestion, instead of returning a dictionary from your filter
>> function, you should return the value you want to display. So maybe your
>> filter can look something like:
>> def get_score_for_person(scores, person):
>>  for s in scores:
>>   if s['Number'] == p.Number:
>>return s['Score']
>>
>>
>> And you're right, maybe you can rename the filter to be
>> get_score_for_person if that is more clear for your application.
>>
>> On Monday, August 29, 2016 at 8:12:56 PM UTC+4, Aaron Weisberg wrote:
>>>
>>> Thanks Asad. Is that why I'm getting errors saying invalid filter name?
>>>
>>> Also I'm having a difficult time thinking my way through the workflow.
>>> I'm defining a new function that requires scores(my URL based dictionary)
>>> and person (my database dictionary). The function then asks to return the
>>> scores of the corresponding game number. Then the template is looking for
>>> the correct value in the scores dictionary that has the same Number
>>> identification as the existing person.Number?
>>>
>>> I think what is confusing me is the use of "player" in ludovics example
>>>
>>> Thanks
>>>
>>> Aaron
>>>
>>> On Aug 29, 2016 11:53 AM, "Asad Jibran Ahmed" <surf...@gmail.com> wrote:
>>>
>>>> No need to change the context, since the variable names the example
>>>> here uses are the same as your existing context. It should work as long as
>>>> you remember to {% load APPNAME %} your filters in the template first.
>>>> ​
>>>>
>>>> Asad Jibran Ahmed <surf...@gmail.com>
>>>> http://blog.asadjb.com
>>>>
>>>> On Mon, Aug 29, 2016 at 6:50 PM, Aaron Weisberg <aaron.m@gmail.com>
>>>> wrote:
>>>>
>>>>> Thanks ludovic,
>>>>>
>>>>> I'm trying to write that python code presently- would I have to also
>>>>> change the context?  how would that look?
>>>>>
>>>>> Thanks
>>>>>
>>>>> On Fri, Aug 26, 2016 at 10:40 AM, ludovic coues <cou...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> You could write a filter [1]. It would be used like {{
>>>>>> scores|from_player:person }} and look like that:
>>>>>>
>>>>>> def from_player (scores, player):
>>>>>> return scores[player.Number]
>>>>>>
>>>>>> You might want to adjust to your actual code, check that you got the
>>>>>> right arguments and that kind of things.
>>>>>>
>>>>>> [1] https://docs.djangoproject.com/en/1.10/howto/custom-template
>>>>>> -tags/
>>>>>>
>>>>>> 2016-08-26 15:50 GMT+02:00 Aaron Weisberg <aaron.m@gmail.com>:
>>>>>> > I didn't really know how to label this question, but I think it's an
>>>>>> > interesting concept and I haven't seen a resolution anywhere else.
>>>>>> >
>>>>>> > I currently have two different dictionaries as context for a
>>>>>

Re: Django template iterating through two dictionaries/variables

2016-08-29 Thread Asad Jibran Ahmed
No problem. The most probable reason why you're getting the invalid filter 
error is because you forgot to load the filters.

Your explanation of the workflow is correct, with one small correction. The 
template will handoff the search for the correct *Score* to the filter 
function. Whatever the filter function returns will then be inserted in 
place of the {scores|from_player:person} part in your template. One way of 
getting the correct score would be to loop over the items in your scores 
dictionary, and find the one where the identification numbers match. One 
suggestion, instead of returning a dictionary from your filter function, 
you should return the value you want to display. So maybe your filter can 
look something like:
def get_score_for_person(scores, person):
 for s in scores:
  if s['Number'] == p.Number:
   return s['Score']


And you're right, maybe you can rename the filter to be get_score_for_person 
if that is more clear for your application.

On Monday, August 29, 2016 at 8:12:56 PM UTC+4, Aaron Weisberg wrote:
>
> Thanks Asad. Is that why I'm getting errors saying invalid filter name?
>
> Also I'm having a difficult time thinking my way through the workflow. I'm 
> defining a new function that requires scores(my URL based dictionary) and 
> person (my database dictionary). The function then asks to return the 
> scores of the corresponding game number. Then the template is looking for 
> the correct value in the scores dictionary that has the same Number 
> identification as the existing person.Number?
>
> I think what is confusing me is the use of "player" in ludovics example
>
> Thanks
>
> Aaron
>
> On Aug 29, 2016 11:53 AM, "Asad Jibran Ahmed" <surf...@gmail.com 
> > wrote:
>
>> No need to change the context, since the variable names the example here 
>> uses are the same as your existing context. It should work as long as you 
>> remember to {% load APPNAME %} your filters in the template first.
>> ​
>>
>> Asad Jibran Ahmed <surf...@gmail.com >
>> http://blog.asadjb.com
>>
>> On Mon, Aug 29, 2016 at 6:50 PM, Aaron Weisberg <aaron.m@gmail.com 
>> > wrote:
>>
>>> Thanks ludovic,
>>>
>>> I'm trying to write that python code presently- would I have to also 
>>> change the context?  how would that look?
>>>
>>> Thanks
>>>
>>> On Fri, Aug 26, 2016 at 10:40 AM, ludovic coues <cou...@gmail.com 
>>> > wrote:
>>>
>>>> You could write a filter [1]. It would be used like {{
>>>> scores|from_player:person }} and look like that:
>>>>
>>>> def from_player (scores, player):
>>>> return scores[player.Number]
>>>>
>>>> You might want to adjust to your actual code, check that you got the
>>>> right arguments and that kind of things.
>>>>
>>>> [1] https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/
>>>>
>>>> 2016-08-26 15:50 GMT+02:00 Aaron Weisberg <aaron.m@gmail.com 
>>>> >:
>>>> > I didn't really know how to label this question, but I think it's an
>>>> > interesting concept and I haven't seen a resolution anywhere else.
>>>> >
>>>> > I currently have two different dictionaries as context for a template:
>>>> >
>>>> > Enter code here...context ={
>>>> >  'person':person,
>>>> >  'scores':scores,
>>>> >}
>>>> >
>>>> >
>>>> > Each of these dictionaries has a common key (person.Number),
>>>> > (scores.Number), however the person dictionary is based off of a 
>>>> model in my
>>>> > django database, while scores comes from a json feed that I parse 
>>>> through:
>>>> >
>>>> > I currently run through a table in a template that looks like this:
>>>> >
>>>> > Enter code here...
>>>> >   
>>>> >   
>>>> >   Person
>>>> > Person Number
>>>> > First Name
>>>> > Last Name 
>>>> >  City 
>>>> >  Score
>>>> >   
>>>> >   
>>>> >   
>>>> >{% for person in persons %}
>>>> >   
>>>> >   {{ person.Number }}
>>>> >   {{ person.firstName }}
>>

Re: Django template iterating through two dictionaries/variables

2016-08-29 Thread Asad Jibran Ahmed
Since the example given by Ludovic uses the same variable names that are 
already present in your context, you won't need to change anything in the 
context dictionary. Just use 
{% load APP_NAME %}
on top of the template file to load the filter and you should be good to go.


On Monday, August 29, 2016 at 6:51:08 PM UTC+4, Aaron Weisberg wrote:
>
> Thanks ludovic,
>
> I'm trying to write that python code presently- would I have to also 
> change the context?  how would that look?
>
> Thanks
>
> On Fri, Aug 26, 2016 at 10:40 AM, ludovic coues  > wrote:
>
>> You could write a filter [1]. It would be used like {{
>> scores|from_player:person }} and look like that:
>>
>> def from_player (scores, player):
>> return scores[player.Number]
>>
>> You might want to adjust to your actual code, check that you got the
>> right arguments and that kind of things.
>>
>> [1] https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/
>>
>> 2016-08-26 15:50 GMT+02:00 Aaron Weisberg > >:
>> > I didn't really know how to label this question, but I think it's an
>> > interesting concept and I haven't seen a resolution anywhere else.
>> >
>> > I currently have two different dictionaries as context for a template:
>> >
>> > Enter code here...context ={
>> >  'person':person,
>> >  'scores':scores,
>> >}
>> >
>> >
>> > Each of these dictionaries has a common key (person.Number),
>> > (scores.Number), however the person dictionary is based off of a model 
>> in my
>> > django database, while scores comes from a json feed that I parse 
>> through:
>> >
>> > I currently run through a table in a template that looks like this:
>> >
>> > Enter code here...
>> >   
>> >   
>> >   Person
>> > Person Number
>> > First Name
>> > Last Name 
>> >  City 
>> >  Score
>> >   
>> >   
>> >   
>> >{% for person in persons %}
>> >   
>> >   {{ person.Number }}
>> >   {{ person.firstName }}
>> >  
>>  {{
>> > person.lastName }}
>> >  
>>  {{
>> > person.city }}
>> >
>> > ??'''scores.score1 goes here'''
>> >
>> >  {% endfor %}
>> >
>> >   
>> >
>> > What I'm trying to figure out to do is figure out how to get that final
>> > detail loaded into the table where we would find the score specific to 
>> that
>> > person.Number.  In other words how to go through my scores dictionary in
>> > this template and find the corresponding score1 using the person.Number 
>> from
>> > the other dictionary as the value.
>> >
>> >
>> > Let me know if you have any ideas.
>> >
>> > 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...@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/d05c8fc4-706b-422b-bc11-b656f1950dea%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 a topic in the 
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/django-users/UlgghbsoqYI/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/CAEuG%2BTatGSwstRkfEDpZdeB6yMv2BobiaQ_Zb3CEL7ZXr5kE-g%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/def07ee1-b176-4724-8162-bd7c3ed20734%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django template iterating through two dictionaries/variables

2016-08-29 Thread Asad Jibran Ahmed
No need to change the context, since the variable names the example here
uses are the same as your existing context. It should work as long as you
remember to {% load APPNAME %} your filters in the template first.
​

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Mon, Aug 29, 2016 at 6:50 PM, Aaron Weisberg <aaron.m.weisb...@gmail.com>
wrote:

> Thanks ludovic,
>
> I'm trying to write that python code presently- would I have to also
> change the context?  how would that look?
>
> Thanks
>
> On Fri, Aug 26, 2016 at 10:40 AM, ludovic coues <cou...@gmail.com> wrote:
>
>> You could write a filter [1]. It would be used like {{
>> scores|from_player:person }} and look like that:
>>
>> def from_player (scores, player):
>> return scores[player.Number]
>>
>> You might want to adjust to your actual code, check that you got the
>> right arguments and that kind of things.
>>
>> [1] https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/
>>
>> 2016-08-26 15:50 GMT+02:00 Aaron Weisberg <aaron.m.weisb...@gmail.com>:
>> > I didn't really know how to label this question, but I think it's an
>> > interesting concept and I haven't seen a resolution anywhere else.
>> >
>> > I currently have two different dictionaries as context for a template:
>> >
>> > Enter code here...context ={
>> >  'person':person,
>> >  'scores':scores,
>> >}
>> >
>> >
>> > Each of these dictionaries has a common key (person.Number),
>> > (scores.Number), however the person dictionary is based off of a model
>> in my
>> > django database, while scores comes from a json feed that I parse
>> through:
>> >
>> > I currently run through a table in a template that looks like this:
>> >
>> > Enter code here...
>> >   
>> >   
>> >   Person
>> > Person Number
>> > First Name
>> > Last Name 
>> >  City 
>> >  Score
>> >   
>> >   
>> >   
>> >{% for person in persons %}
>> >   
>> >   {{ person.Number }}
>> >   {{ person.firstName }}
>> >
>>  {{
>> > person.lastName }}
>> >
>>  {{
>> > person.city }}
>> >
>> > ??'''scores.score1 goes here'''
>> >
>> >  {% endfor %}
>> >
>> >   
>> >
>> > What I'm trying to figure out to do is figure out how to get that final
>> > detail loaded into the table where we would find the score specific to
>> that
>> > person.Number.  In other words how to go through my scores dictionary in
>> > this template and find the corresponding score1 using the person.Number
>> from
>> > the other dictionary as the value.
>> >
>> >
>> > Let me know if you have any ideas.
>> >
>> > 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/d05c8fc4-706b
>> -422b-bc11-b656f1950dea%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 a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/django-users/UlgghbsoqYI/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/CAEuG%2BTatGSwstR

Re: Hi, i'm new to django i need some mini project which contain atleast 4 page for go through how it works

2016-08-29 Thread Asad Jibran Ahmed
You could create a simple blogging application. Allow the user to create,
edit, and delete blog posts. And have a list page (home page) to show those
posts and a details page for the post.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Mon, Aug 29, 2016 at 3:29 PM, rajeshkmr9583 <rajeshkmr9...@gmail.com>
wrote:

>  And the UI should created by your self. not the admin site because
> i've already created with help of admin but i need a new look of how it
> works with Customized(newly created) UI.. Thanks
>
> On Monday, 29 August 2016 16:56:33 UTC+5:30, rajeshkmr9583 wrote:
>>
>> Hi,
>>
>>  i'm new to Django i need some mini project which contain at least 4
>> page for go through how it works..
>>
>> 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/94bbade3-374c-4d47-b4e6-3d8747e5d23c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/94bbade3-374c-4d47-b4e6-3d8747e5d23c%40googlegroups.com?utm_medium=email_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%2BYYaWfmb1zoVQ5M23RiBFGzvWOXaA9YdTJnCdFROUcnZL0o%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: is it possible to manipulate image in PIL after uploading directly by its "request.FILES.GETLIST(FORMFIELD)" address not the saved picture on hard disk

2016-08-26 Thread Asad Jibran Ahmed
Hi,
 Every object in `request.FILES` is actually a file *liike* object that you
can use for processing. I guess you can use something like
`PIL.Image.frombytes` with the `request.FILES[filename].read()` data.

Django Doc for the `request.FILES`:
https://docs.djangoproject.com/en/1.10/ref/files/uploads/#django.core.files.uploadedfile.UploadedFile
Pillow (PIL Fork) documentation for the `frombytes` method:
https://pillow.readthedocs.io/en/3.3.x/reference/Image.html#PIL.Image.frombytes

Hope that helps.
Regards,

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Fri, Aug 26, 2016 at 7:46 PM, ali Eblice <aliebl...@gmail.com> wrote:

> Hello Friends
> is it possible to manipulate image in PIL after uploading directly by its "
> *request.FILES.GETLIST(FORMFIELD)*"  address not the saved picture on
> hard disk?
>
> I wrote a function for manipulating  but its only working with  "
> *Image.open('a.jpg')* " but i don't want to save image after uploading
> and then opening it for manipulating , is it possible to manipulate image
> with its "request.FILES" object address?
>
> --
> 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/9b6734c8-4530-42b3-b791-99bbce020b32%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9b6734c8-4530-42b3-b791-99bbce020b32%40googlegroups.com?utm_medium=email_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%2BYYaWeTsyGvKeZ8uo_veyg_YrzQtR3y1Hsr8q37GGhXvGEcPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running Django Project Locally

2016-08-24 Thread Asad Jibran Ahmed
One thing I'd add to this is that I could never work without runserver
because I tend to use ipdb a *lot* while debugging any problems. For me the
best way to debug is to put import ipdb; ipdb.set_trace() in my code and
just start debugging from the command line. Having uwsgi or any other kind
of server running my Django code takes away that ability, and I'd be in
hell trying to figure out errors without that.

Just my 2 cents.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Wed, Aug 24, 2016 at 9:24 PM, Andreas Kuhne <andreas.ku...@suitopia.com>
wrote:

>
> 2016-08-24 17:54 GMT+02:00 Michael Macdonald <mmacdonaldsilvercity@gmail.
> com>:
>
>> Interestingly enough, just this morning, after a couple times being
>> bitten with differences in behavior between use of runserver in development
>> vs. wsgi in production, I've decided to do all development on my local
>> machine under lighttpd.  In the process of (mis?)configuring it now.
>>
>> I'm pretty thoroughly convinced that using runserver isn't such a good
>> idea, nor is it particularly useful.  Development I've done under Eclipse
>> and MS VisualStudio in the past did initial local unit testing on a local
>> server; there is ample precedent for this approach.  And, it is best
>> practice to make the development environment as close to the same as the
>> production environment as possible.
>>
>> In retrospect, I'm surprised I ever used runserver...
>>
>> On Wednesday, August 24, 2016 at 12:25:52 AM UTC-7, Lekan Wahab wrote:
>>>
>>> Good morning,
>>> I was recently given  a django project to manage at work.
>>> However, i noticed the project has neither a django-admin.py or a
>>> manage.py file.
>>> Is that normal?
>>> If it is, how do i run the project on my local machine for testing
>>> purposes?
>>>
>>> The file structure is something like this:
>>> Project Name
>>> app1
>>> app2
>>> app3
>>> app4
>>> app5
>>> models.py
>>> forms.py
>>> __init__.py
>>> urls.py
>>> views.py
>>> admin.py
>>>
>>>
>>> Each app contains the following:
>>> models.py
>>> forms.py
>>> __init__.py
>>> urls.py
>>> views.py
>>> admin.py
>>>
>> --
>> 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/f72d16e6-eb11-4a48-a89e-b51a6006d24e%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/f72d16e6-eb11-4a48-a89e-b51a6006d24e%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> What you get with runserver is automatic reloading - you don't get that
> running the application behind a webserver. If you run a django app behind
> anything else except runserver, you will need to restart the server every
> time you change your code. You will still need to try the application in a
> production environment, but that is why you have a staging environment (or
> test). You also need to have a place where QA can test everything (or the
> product owner) - this environment should be as close to the production
> environment as possible - so that discrepancies can be found there.
>
> Regards,
>
> Andréas
>
> --
> 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/CALXYUb%3DsXv2xtVW2Bet6jwLQRaQgV1DB9Eb
> iUAHdF43tKPKRZA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALXYUb%3DsXv2xtVW2Bet6jwLQRaQgV1DB9EbiUAHdF43tKPKRZA%40mail.gmail.com?utm_medium=email_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%2BYYaWe%2BHQaW3WMRnqb4x4nCuHgYvEwnDUCG_6OkM2g7V8jOMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running Django Project Locally

2016-08-24 Thread Asad Jibran Ahmed
Hi,
 It's definitely weird to not have a manage.py since all new Django 
projects should have it by default. But the manage.py file is pretty 
simple, and you can just paste this inside a new manage.py:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

Hope that helps.
Regards,
Jibran

On Wednesday, August 24, 2016 at 11:25:52 AM UTC+4, Lekan Wahab wrote:
>
> Good morning,
> I was recently given  a django project to manage at work.
> However, i noticed the project has neither a django-admin.py or a 
> manage.py file.
> Is that normal?
> If it is, how do i run the project on my local machine for testing 
> purposes?
>
> The file structure is something like this:
> Project Name
> app1
> app2
> app3
> app4
> app5
> models.py
> forms.py
> __init__.py
> urls.py
> views.py
> admin.py
>
>
> Each app contains the following:
> models.py
> forms.py
> __init__.py
> urls.py
> views.py
> admin.py
>

-- 
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/8d13403f-1f45-43b5-959a-af082e670d22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Models of Speedy Net

2016-08-18 Thread Asad Jibran Ahmed
Sorry, I just checked and I'm wrong about the ordering of elements in a 
class. The reason the constants need to be first is because you are using 
them when defining your fields. But other than that, the order doesn't 
matter.

Here's the code that I used to check this:

def get_const():
print 'get_const()'
return 1

def make_list(i):
return [i]


class A(object):
attr = make_list(CONST)
CONST = get_const()


print A.attr

When I tried to execute it I got NameError: name 'CONST' is not defined. If 
you change the class definition so that the CONST declaration comes first, 
it works.


On Thursday, August 18, 2016 at 4:08:33 PM UTC+4, Asad Jibran Ahmed wrote:
>
> The ordering of your attributes and methods inside the model class doesn't 
> have to do with Django, it has to do with Python. Inside a class, the 
> ordering doesn't matter as far as I understand. All of these documents you 
> will find are thus just conventions to follow.
>
> You could come up with your own if you want, but it's usually a good idea 
> to stick to something already out there are used by a lot of people, as it 
> makes it easy for new comers to your code to quickly navigate the code. 
> Since this is an open source project using the Django style guide you have 
> linked to sounds like a good option.
>
> On Thursday, August 18, 2016 at 4:04:06 PM UTC+4, uri wrote:
>>
>> By the way, I found this document 
>> <https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/>
>>  
>> and I changed the order of elements in our models accordingly. But what 
>> about def __init__? And this document is for Django developers, what about 
>> Django users? Is there another document for us?
>>
>> Thanks,
>> Uri.
>>
>>
>> *Uri Even-Chen*   
>> [image: photo] Phone: +972-54-3995700
>> Email: u...@speedy.net
>> Website: http://www.speedysoftware.com/uri/en/
>> <http://www.facebook.com/urievenchen>  
>> <http://plus.google.com/+urievenchen>  
>> <http://www.linkedin.com/in/urievenchen>  
>> <http://twitter.com/urievenchen>
>>
>> On Thu, Aug 18, 2016 at 2:41 PM, Uri Even-Chen <u...@speedy.net> wrote:
>>
>>> To django-users,
>>>
>>> We are developing Speedy Net, a new social networks with apps (Speedy 
>>> Match and Speedy Composer). Speedy Net is using Django (the previous 
>>> version is written in PHP). I would like to ask you about the models, in 
>>> https://github.com/urievenchen/speedy-net/blob/master/speedy/net/accounts/models.py
>>>  
>>> (it's an open source project; there are other models too), is the order of 
>>> elements in the models correct? Currently the constants are first, then 
>>> class Meta, then fields, then managers, then methods and properties (in 
>>> arbitrary order). What is the common order of elements in Django projects? 
>>> Does it matter at all? I read something about it in Django documentation, 
>>> but I don't remember exactly where. I know the constants must be first in 
>>> the model, before the fields, but what about class Meta? Any help will be 
>>> appreciated.
>>>
>>> Thanks,
>>> Uri.
>>>
>>> *Uri Even-Chen*   
>>> [image: photo] Phone: +972-54-3995700
>>> Email: u...@speedy.net
>>> Website: http://www.speedysoftware.com/uri/en/
>>> <http://www.facebook.com/urievenchen>  
>>> <http://plus.google.com/+urievenchen>  
>>> <http://www.linkedin.com/in/urievenchen>  
>>> <http://twitter.com/urievenchen>
>>>
>>
>>

-- 
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/96b45bfe-ff5f-4eae-a119-b0fa473a7c6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Models of Speedy Net

2016-08-18 Thread Asad Jibran Ahmed
The ordering of your attributes and methods inside the model class doesn't 
have to do with Django, it has to do with Python. Inside a class, the 
ordering doesn't matter as far as I understand. All of these documents you 
will find are thus just conventions to follow.

You could come up with your own if you want, but it's usually a good idea 
to stick to something already out there are used by a lot of people, as it 
makes it easy for new comers to your code to quickly navigate the code. 
Since this is an open source project using the Django style guide you have 
linked to sounds like a good option.

On Thursday, August 18, 2016 at 4:04:06 PM UTC+4, uri wrote:
>
> By the way, I found this document 
> 
>  
> and I changed the order of elements in our models accordingly. But what 
> about def __init__? And this document is for Django developers, what about 
> Django users? Is there another document for us?
>
> Thanks,
> Uri.
>
>
> *Uri Even-Chen*   
> [image: photo] Phone: +972-54-3995700
> Email: u...@speedy.net 
> Website: http://www.speedysoftware.com/uri/en/
>   
>   
>   
>
> On Thu, Aug 18, 2016 at 2:41 PM, Uri Even-Chen  > wrote:
>
>> To django-users,
>>
>> We are developing Speedy Net, a new social networks with apps (Speedy 
>> Match and Speedy Composer). Speedy Net is using Django (the previous 
>> version is written in PHP). I would like to ask you about the models, in 
>> https://github.com/urievenchen/speedy-net/blob/master/speedy/net/accounts/models.py
>>  
>> (it's an open source project; there are other models too), is the order of 
>> elements in the models correct? Currently the constants are first, then 
>> class Meta, then fields, then managers, then methods and properties (in 
>> arbitrary order). What is the common order of elements in Django projects? 
>> Does it matter at all? I read something about it in Django documentation, 
>> but I don't remember exactly where. I know the constants must be first in 
>> the model, before the fields, but what about class Meta? Any help will be 
>> appreciated.
>>
>> Thanks,
>> Uri.
>>
>> *Uri Even-Chen*   
>> [image: photo] Phone: +972-54-3995700
>> Email: u...@speedy.net 
>> Website: http://www.speedysoftware.com/uri/en/
>>   
>>   
>>   
>> 
>>
>
>

-- 
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/743db8ee-73d4-4f9e-96a1-7fea49aafecf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django on apache server

2016-08-18 Thread Asad Jibran Ahmed
Not being able to load CSS points to an Apache config issue. Did you setup 
apache so your static root configured to serve files from your static 
folder? Your apache config might be helpful here.

Also, what you have pasted here seems like a warning, so while you should 
fix it, this is probably not the cause of your CSS loading error.

On Thursday, August 18, 2016 at 3:44:14 PM UTC+4, hirok biswas wrote:
>
> while i have configuring django app on apchhe basically it works almost 
> well but shows this error log and css not work
> what can i do now???
> i am using 
> #apache2
> #django 1.9.6
> `
> [Wed Aug 17 14:54:12.747345 2016] [wsgi:error] [pid 17910:tid 
> 139970848413440] 
> /home/hirok/apachetest/venv/lib/python2.7/site-packages/django/template/utils.py:37:
>  
> RemovedInDjango110Warning: You haven't defined a TEMPLATES setting. You 
> must do so before upgrading to Django 1.10. Otherwise Django will be unable 
> to load templates.
> [Wed Aug 17 14:54:12.747414 2016] [wsgi:error] [pid 17910:tid 
> 139970848413440]   "unable to load templates.", RemovedInDjango110Warning)
> [Wed Aug 17 14:54:12.747423 2016] [wsgi:error] [pid 17910:tid 
> 139970848413440] 
> `
>

-- 
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/13c18a07-aedb-4560-b10b-bc21ac54de0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Send mail after x hours

2016-08-17 Thread Asad Jibran Ahmed
Personally, I'd setup a simple cronjob on my machine that runs a Django 
management command. The command would get a list of users who are eligible 
to receive emails and send it to them.

I would have just used the send_mail directly from my management command, 
but if you already have a RQ setup for that, just go ahead and use the same.

This approach is simple and doesn't require using the rq-scheduler. But if 
you really want, using rq-scheduler is basically the same and the end 
result is similar.

On Wednesday, August 17, 2016 at 3:10:27 PM UTC+4, Kishan Mehta wrote:
>
> Thanks but I already have django rq adn rq-scheduler configured and 
> running so I was thinking to use it and avoid celery.
>
>
> On Wed, Aug 17, 2016 at 4:37 PM, Dheerendra Rathor  > wrote:
>
>> I’ll suggest you to use some background task runner. Celery will work 
>> great for you as it is developed for Python and work on multiple platform 
>> with multiple types of message queues.
>>
>>  
>>
>> Sent from Mail  for 
>> Windows 10
>>
>>  
>>
>> *From: *Kishan Mehta 
>> *Sent: *Wednesday, August 17, 2016 4:35 PM
>> *To: *django...@googlegroups.com 
>> *Subject: *Send mail after x hours
>>
>>  
>>
>> Hi guys,
>>
>>  
>>
>> I am using django 1.9. I am working on requirement where we need to send 
>> users reminder to activate their account by email after x hours h/she has 
>> signed on our platform.
>>
>>  
>>
>> I have send_mail task and I have configured 
>> https://github.com/ui/django-rq to send mails. 
>>
>>  
>>
>> One way I can think of is to set up a cron job using 
>> https://github.com/ui/rq-scheduler which runs every 5 mins to check for 
>> users who signed up 6 hours before. 
>>
>>  
>>
>> Is there any better way to do this ?
>>
>>  
>>
>> Thanks,
>>
>> Kishan
>>
>> -- 
>> 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/CAC5ThKGOFyWObnZTV8VpT57eyWqEq5%2B-OaMj7L%3Dr%3Dh41bJVWXA%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/d82c93a3-0ca3-4774-8b14-1c08f21ce916%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Back button in a SessionWizardView

2014-02-02 Thread Asad Jibran Ahmed
We had a similar requirement in one of our products. We solved it by assigning 
the user a unique transaction id when they start the process, and saving all 
data in a temp db (redis) until the user completed the process. And whenever 
the user accessed a page with the transaction id in the get params, the data 
was autofilled in the form.

Maybe you can do something similar by saving data for each part of the wizard 
in a temp db under one key and using that to pre-populate the forms?

Also, we used keys that woyld expire after some time, thus if the user didn't 
complete the process, our db would start filling up with stale transaction data.

Hope that helps.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/50e1303a-0ad8-4ec9-9e41-85729c4b8b02%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.