Re: Django user model. 1 admin account, 1 customer account with the same email and different password

2020-04-13 Thread Bill Freeman
Many e-mail systems allow you to add a suffix to the username portion of
the address, separated by something like a "-", or, last time I checked for
gmail, by a "+", and it will still be delivered to the same mailbox.  For
example, I expect mail sent to
 ks.kennysoh+ad...@gmail.com
will still reach you.  But username match in Django probably won't treat
these the same, so you could have two accounts: custo...@email.com, and
customer-zy...@email.com which, being separate Django accounts, could have
separate passwords.

That's not ideal because there are almost certainly some email providers
who don't follow this convention, and will treat the two addresses as
different, making it impossible to get activation emails, password reset
emails, and anything else that you want the Django instance to send you.

If you are willing to crawl down inside the Django code and make changes,
you can rework user so that, for example, username isn't unique, but
username and admin flag are "unique_together" (providing that the database
that you are using supports it), in which case these can be separate
accounts.  Or you could add decorations to the user field that are
impossible to type because your login code doesn't allow the separator,
which can be something not allowed in email addresses, like the nul
character, but you then also have to modify email sending to drop any such
decorator when producing the "to" part of a message.

But modifying the core code means re-applying the patch whenever you take
an update, and if things have changed in the area(s) that you modified,
recoding may be required, so changing the core code is considered fragile.

It might be (I'll let you investigate for yourself) that the supported
custom User model scheme lets you override user lookup at login in a
suitable way, decorating the username with, for example, a leading A for
admins and a leading U for normal users, but keep the undecorated email
address in a separate email field.  So long as whatever method you have to
override is part of the formal custom user model mechanism, it should be
pretty stable.

Good luck

On Mon, Apr 13, 2020 at 4:17 AM Carsten Fuchs  wrote:

> Hello,
>
> Am 13.04.20 um 02:59 schrieb Kenny Soh:
> >   * An admin account must not share the same password as the customer
> account.
>
> Your entire problem would become much easier if you just dropped that
> requirement. Whatever you want to achieve with forcing a single user to
> keep two passwords, I'm sure that you're better off with a different
> approach.
>
> Importantly, dropping this requirement gives you the option to follow the
> advice in the article that you linked (
> https://simpleisbetterthancomplex.com/tutorial/2018/01/18/how-to-implement-multiple-user-types-with-django.html
> )
>
> Best regards,
> Carsten
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bccdd94d-2344-b1c2-0478-c4e0d47d0d51%40cafu.de
> .
>

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


Re: filter objects dynamically on page render based on button click (beginner question)

2020-02-13 Thread Bill Freeman
Note that Vue is one option among many and could either be overkill or not
helpful enough for your specific use case OR BOTH.  It's just modern, and
may be useful for projects beyond this one.

It doesn't hurt to be familiar with the grand daddy of them all: jQuery
(though many sneer at it today).

On Thu, Feb 13, 2020 at 7:38 AM Phil Kauffman 
wrote:

> Bill,
>
> Thank You for taking the time to respond. I will definitely need to read
> up on the options you presented. My first inclination was to get familiar
> with the first option as it seems easiest. However, now that you mention
> VueJS I will look into that as well.
>
> On Wednesday, February 12, 2020 at 6:46:42 PM UTC-5, ke1g wrote:
>
>> What happens in the browser stays in the browser, unless you do something
>> about it.
>>
>> Forgive me if I'm being too basic below:
>>
>> There are three approaches to click and see a filtering change, with
>> trade offs in performance, complexity, and the impact if the user's browser
>> is on a humble box.
>>
>>1. When the user clicks, it's on a link, and you reload the page with
>>the filter applied.  No JavaScript required.  Pretty slow.  more network
>>load, more browser load, and more load on the server.  (I'm not going into
>>the old approach of having an iframe and the link reloads the iframe
>>because iframes are tricky, and if you're showing a big table, it's most 
>> of
>>the page anyway.)  Do be sure that your images, CSS files, and JavaScript
>>files are set to encourage the browser and/or the network to cache them,
>>but the HTML will load every time, and the URL will likely show the filter
>>settings (though you can do things with cookies and/or session store, but
>>you will surprise your users someday.
>>2. Load all the data in the first place, and use JavaScript in
>>combination with CSS to hide the stuff that's filtered out.  If you go 
>> this
>>way, do arrange to use CSS controlled by a class on a single containing
>>element to control visibility, because doing big DOM modifications in
>>JavaScript performs poorly.  This is the snappiest approach, but you have
>>to have loaded everything, at cost of network and server load, even if you
>>expect the user to filter later, and at the cost of RAM in the browser.  
>> If
>>the data's not that big, this is fine.  But if it's the catalog of a
>>hardware chain or something else huge, you probably be doing it in pages.
>>Sometimes it's natural.  For example, I once did and event calendar for a
>>school system.  I loaded a month at a time, and filtering within the month
>>was peppy, but to go to a different month required a reload, and you
>>couldn't show stuff from multiple months at one time.
>>3. Use an AJAX request to replace part of the DOM with filtered
>>data.  (The iframe hack is very much like this.)  If the data is most of
>>your page, this isn't much more light weight than option 1, but the user
>>doesn't see the page reload, which seems to count for style points.
>>
>> There are JavaScript "frameworks" (e.g. VueJS) that will help you with 2
>> and especially 3, but you have to learn how to use the framework, and how
>> to connect it to Django.  Those are useful things to learn, but they're not
>> overnight reads, and can have performance pitfalls.
>>
>> Good luck, Bill
>>
>> On Wed, Feb 12, 2020 at 3:17 PM Phil Kauffman 
>> wrote:
>>
>>> Hello, I am struggling with trying to filter child objects based on
>>> parent object selection on index.html (sites.html in example). On my
>>> sites.html, I list the office sites and a button to click for each, upon
>>> clicking I want to load the profile list for users only at that site,
>>> presently it's loading all profiles for all sites, which I assume is
>>> because the profiles are loaded statically no matter which button is
>>> clicked on sites.html.
>>>
>>> I'm thinking I need a JS onclick event?
>>>
>>> models.py:
>>> class Site(models.Model):
>>>
>>> name = models.CharField(max_length=50)
>>> date = models.DateField()
>>> manager = models.CharField(max_length=50)
>>>
>>> def save(self, *args, **kwargs):
>>> super(Site, self).save(*args, **kwargs)
>>>
>>> class Profile(models.Model):
>>> Days = '1st'
>>> Mids = '2nd'
>>> Nights = '3rd'
>>> Work_Schedule_Choices = [
>>>   (Days, 'Day Shift'),
>>>   (Mids, 'Mid Shift'),
>>>   (Nights, 'Night Shift'),
>>> ]
>>> sitename = models.ForeignKey(Site, on_delete=models.CASCADE)
>>> title = models.CharField(max_length=100)
>>> schedule = models.CharField(max_length=3,choices=
>>> Work_Schedule_Choices,default=Days)
>>> totalusers = models.PositiveSmallIntegerField(default=1, validators
>>> =[MinValueValidator(1), MaxValueValidator(50)])
>>>
>>>
>>>
>>> views.py:
>>> def sites(request):
>>> sitelist = Site.objects.all()
>>> return render (request, 'App/sites.html', 

Re: filter objects dynamically on page render based on button click (beginner question)

2020-02-12 Thread Bill Freeman
What happens in the browser stays in the browser, unless you do something
about it.

Forgive me if I'm being too basic below:

There are three approaches to click and see a filtering change, with trade
offs in performance, complexity, and the impact if the user's browser is on
a humble box.

   1. When the user clicks, it's on a link, and you reload the page with
   the filter applied.  No JavaScript required.  Pretty slow.  more network
   load, more browser load, and more load on the server.  (I'm not going into
   the old approach of having an iframe and the link reloads the iframe
   because iframes are tricky, and if you're showing a big table, it's most of
   the page anyway.)  Do be sure that your images, CSS files, and JavaScript
   files are set to encourage the browser and/or the network to cache them,
   but the HTML will load every time, and the URL will likely show the filter
   settings (though you can do things with cookies and/or session store, but
   you will surprise your users someday.
   2. Load all the data in the first place, and use JavaScript in
   combination with CSS to hide the stuff that's filtered out.  If you go this
   way, do arrange to use CSS controlled by a class on a single containing
   element to control visibility, because doing big DOM modifications in
   JavaScript performs poorly.  This is the snappiest approach, but you have
   to have loaded everything, at cost of network and server load, even if you
   expect the user to filter later, and at the cost of RAM in the browser.  If
   the data's not that big, this is fine.  But if it's the catalog of a
   hardware chain or something else huge, you probably be doing it in pages.
   Sometimes it's natural.  For example, I once did and event calendar for a
   school system.  I loaded a month at a time, and filtering within the month
   was peppy, but to go to a different month required a reload, and you
   couldn't show stuff from multiple months at one time.
   3. Use an AJAX request to replace part of the DOM with filtered data.
   (The iframe hack is very much like this.)  If the data is most of your
   page, this isn't much more light weight than option 1, but the user doesn't
   see the page reload, which seems to count for style points.

There are JavaScript "frameworks" (e.g. VueJS) that will help you with 2
and especially 3, but you have to learn how to use the framework, and how
to connect it to Django.  Those are useful things to learn, but they're not
overnight reads, and can have performance pitfalls.

Good luck, Bill

On Wed, Feb 12, 2020 at 3:17 PM Phil Kauffman 
wrote:

> Hello, I am struggling with trying to filter child objects based on parent
> object selection on index.html (sites.html in example). On my sites.html, I
> list the office sites and a button to click for each, upon clicking I want
> to load the profile list for users only at that site, presently it's
> loading all profiles for all sites, which I assume is because the profiles
> are loaded statically no matter which button is clicked on sites.html.
>
> I'm thinking I need a JS onclick event?
>
> models.py:
> class Site(models.Model):
>
> name = models.CharField(max_length=50)
> date = models.DateField()
> manager = models.CharField(max_length=50)
>
> def save(self, *args, **kwargs):
> super(Site, self).save(*args, **kwargs)
>
> class Profile(models.Model):
> Days = '1st'
> Mids = '2nd'
> Nights = '3rd'
> Work_Schedule_Choices = [
>   (Days, 'Day Shift'),
>   (Mids, 'Mid Shift'),
>   (Nights, 'Night Shift'),
> ]
> sitename = models.ForeignKey(Site, on_delete=models.CASCADE)
> title = models.CharField(max_length=100)
> schedule = models.CharField(max_length=3,choices=Work_Schedule_Choices
> ,default=Days)
> totalusers = models.PositiveSmallIntegerField(default=1, validators=[
> MinValueValidator(1), MaxValueValidator(50)])
>
>
>
> views.py:
> def sites(request):
> sitelist = Site.objects.all()
> return render (request, 'App/sites.html', {'sitelist' : sitelist})
>
> def sitedetail(request):
> site = Site.objects.filter()
> if request.method == 'GET':
> return render(request, 'App/site-detail.html', {'site': site,
> 'profile_set': Profile.objects.all()})
>
>
> sites.html (index)
> {% extends 'App\base.html' %}
> {% load crispy_forms_tags %}
> {% block title %}Site Home{% endblock %}
> {% block content %}
> {% for Site in sitelist %}
> 
> 
> {{ Site.name }}
> View
>   
> 
> {% empty %}
> 
>   Sorry, you haven't created any sites yet.
>   
> Add Site
> Add Site
>   
> 
> {% endfor %}
>   
> {% endblock %}
>
>
> site-detail.html
> {% extends 'App\base.html' %}
> {% load crispy_forms_tags %}
> {% block title %}Site Detail{% endblock %}
> {% block content %}
> This web form sucks
>  
>   {% for profile in profile_set  %}
>   {{ profile.title }}
>   {% endfor %}
>  
> {% endblock 

Re: is there a WYSIWYG for Django

2020-02-08 Thread Bill Freeman
That's the plan.  It's what I though you meant by WYSIWYG.  Fiber is nice
because they don't have to understand a back end interface; you just edit
from the page that you want to change, edit a particular element of it,
which client's have an easier time with.  But there still has to be
something that lets you edit HTML straightforwardly, and that needs to run
in the browser for responsiveness.

On Sat, Feb 8, 2020 at 11:52 AM johnf  wrote:

> Thanks Fiber looks better.  But you did say you use mostly TinyMCE.  I can
> develop the site (it's just as straight forward with some pictures, menu
> and a few pages) then hand that over to the owners to maintain using
> TinyMCE??  What about mobile etc...?
>
> Johnf
>
> On 2/8/20 8:36 AM, Bill Freeman wrote:
>
> I have used Django Fiber:   http://ridethepony.org/
> And several other CMS.  I mostly used TinyMCE.
> The world may have moved on.
>
> On Sat, Feb 8, 2020 at 11:02 AM johnf  wrote:
>
>> Thanks that is a start.  I would also like something that will help with
>> design of the pages/views.
>>
>> Johnf
>>
>> On 2/8/20 7:51 AM, Andrew C. wrote:
>>
>> Try Quill.js. If you google Quill.js and Quill.js Django, I believe
>> you'll find the Django package that goes along with that text editor.
>> Really, you only need the Quill.js code for your template. WYSIWYG is
>> just a user typing in HTML without realizing it. Just save the HTML
>> (because the rest is escaped while the user is typing).
>>
>> It's also useful if you escape all instances of a script tag in case
>> someone inputs an unescaped . Your server wouldn't be
>> destroyed necessarily, but there could be some XSS that you want to
>> avoid.
>>
>> On 2/8/20, john   wrote:
>>
>> Hi,
>>
>> I realize that Django does not have a frontend but is there a
>> tool/package that works well for WYSIWYG a simple website?
>>
>> Johnf
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web 
>> visithttps://groups.google.com/d/msgid/django-users/da5f5c36-0bca-4a47-d91d-5c67b657c7a5%40jfcomputer.com.
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/2cdcf4aa-07db-446e-8597-585b5c571639%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/2cdcf4aa-07db-446e-8597-585b5c571639%40gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAB%2BAj0tdqykbk5YyXkx_Axo-3MuyM%3DS_86qJWpzXan%2B-whfNfg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAB%2BAj0tdqykbk5YyXkx_Axo-3MuyM%3DS_86qJWpzXan%2B-whfNfg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d194dd78-88e0-eb32-f2bf-035c6a740e1a%40gmail.com
> <https://groups.google.com/d/msgid/django-users/d194dd78-88e0-eb32-f2bf-035c6a740e1a%40gmail.com?utm_medium=email_source=footer>
> .
>

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


Re: is there a WYSIWYG for Django

2020-02-08 Thread Bill Freeman
I have used Django Fiber:   http://ridethepony.org/
And several other CMS.  I mostly used TinyMCE.
The world may have moved on.

On Sat, Feb 8, 2020 at 11:02 AM johnf  wrote:

> Thanks that is a start.  I would also like something that will help with
> design of the pages/views.
>
> Johnf
>
> On 2/8/20 7:51 AM, Andrew C. wrote:
>
> Try Quill.js. If you google Quill.js and Quill.js Django, I believe
> you'll find the Django package that goes along with that text editor.
> Really, you only need the Quill.js code for your template. WYSIWYG is
> just a user typing in HTML without realizing it. Just save the HTML
> (because the rest is escaped while the user is typing).
>
> It's also useful if you escape all instances of a script tag in case
> someone inputs an unescaped . Your server wouldn't be
> destroyed necessarily, but there could be some XSS that you want to
> avoid.
>
> On 2/8/20, john   wrote:
>
> Hi,
>
> I realize that Django does not have a frontend but is there a
> tool/package that works well for WYSIWYG a simple website?
>
> Johnf
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web 
> visithttps://groups.google.com/d/msgid/django-users/da5f5c36-0bca-4a47-d91d-5c67b657c7a5%40jfcomputer.com.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2cdcf4aa-07db-446e-8597-585b5c571639%40gmail.com
> 
> .
>

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


Re: Getting the first item in a dict

2020-01-27 Thread Bill Freeman
Note that these give the only value.  This won't work if you have more than
one value in the dict, since you won't know which you will get.  Where d is
the dict:

list(d.values())[0]

or

for i in d.values():
# use i here
print(i)

or

d[list(d)[0]]

I'm sure that there are other ways.  There is certainly at least a way to
play with the iterator protocol without using "for", but it may be harder
to read.  You could put break at the end of the loop above to make it more
apparent that it only runs once.

On Mon, Jan 27, 2020 at 6:58 AM S D  wrote:

> I have a dictionary which contains one item (“current_location”, which is
> a nested dict) and I would like to access that nested dict. However, I
> cannot use the key as the code will break if a different key is passed,
> e.g. “different_location”.
>
> How can I access the first item in a dictionary without using a key? The
> dict looks like this:
>
> `
> {'current_location': {'date': '2020-01-27T10:28:24.148Z', 'type_icon':
> 'partly-cloudy-day', 'description': 'Mostly Cloudy', 'temperature': 68.28,
> 'wind': {'speed': 10.48, 'bearing': 178, 'gust': 12.47}, 'rain_prob': 0.02,
> 'latitude': '-33.927407', 'longitude': '18.415747', 'request_id': 31364,
> 'request_location': 'Current location'}}
> `
>
> Kind regards,
> - SD
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAH-SnCBnnOsoTURnSzCrqqXsCWF5EEjghm9Q1UTQKrnTBAJ3iA%40mail.gmail.com
> 
> .
>

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


Re: Which Cloud Service Provider should be chosen to host Django Application

2019-12-03 Thread Bill Freeman
That sounds like a good choice. Do pay attention to any security procedures
that they suggest in their documentation.  And do keep backups of at least
the basic system and configuration files, if not occasional database dumps,
that are local to you.

Good luck, and have fun.

Bill

On Tue, Dec 3, 2019 at 2:30 AM Debabrata Chakraborty <
debobroto.c...@gmail.com> wrote:

> Many thanks Bill,
>
> I am starting to see the bigger picture now. My site is just a basic blog
> for a non-profit. It's gonna be low traffic with no payment method
> attached. I checked out AWS and it's a bit overwhelming for a beginner like
> me. Guess I'll do a test run with Heroku's free account to get a feel of
> the process.
>
> Anyway, thanks again for all the efforts man!
>
> Cheers!
>
> Deb
>
> On Mon, Dec 2, 2019 at 8:41 PM Bill Freeman  wrote:
>
>> Deployment for a production environment is never without complications.
>>  And that is affected by how much you choose to configure yourself.  I
>> can't speak for Heroku, Digital Ocean, or Python Anywhere, because I
>> haven't used them.  Perhaps some of their users will comment.
>>
>> Even with virtual hosting it is best to pick one of the kernels that they
>> have customized to work well with their virtualization mechanisms.  (If you
>> had a physical host you would need to do kernel configuration yourself.)  I
>> know that AWS and Linode keep their eye on kernel security updates and will
>> offer new versions promptly, but you will need to keep your eyes open and
>> install the upgraded versions when they become available.  They may or may
>> not include application updates as part of these packages, particularly
>> database, but also perhaps http server and python version, though if you
>> want to pick your own version of these then you will be reinstalling them
>> when the kernel upgrades happen.  And you must watch for security updates
>> of the packages that you choose to hand install, which will include
>> Django.  (One of the attractions of shared hosting is that the provider
>> takes care of more of these things.)
>>
>> But as far as picking your own version goes, you really want to stay
>> close to the latest stable version, rather than having to back port
>> security patches yourself.  You also don't want to go with versions so old
>> that they are unsupported, or the people finding new exploits will be
>> limited to the bad guys.  Doing the work right along to stay close to
>> current best practices is valuable so that you don't have a large panic
>> update to do when your version becomes unsupported, needs a security fix,
>> and some old, previously deprecated, way of doing something has been
>> dropped.
>>
>> You will want to learn how to use one of the automated deployment tools,
>> since setting things up by had every time gets old, and is error prone.  As
>> a python guy, I've had fun with fabric, but there are other fine open
>> source and free tools.  In addition to running pip for your, they can
>> remotely run apt, rpm, etc., build your database, http server, python
>> version (including plugging the http server into the desired python using
>> modwsgi, for example).
>>
>> (Note that it is not difficult to have multiple versions of python
>> installed on a Linux system without them getting in one another's way.  So
>> the kernel scripts can run with the version for which they have been
>> designed and tested, and you can still have your favorite running behind
>> your http server, running Django.
>>
>> I'm unaware of AWS pricing.  Last I checked Linode can be as cheap as
>> $5/mo (I pay closer to $20), depending on how big a server you need.
>> Linode, and I presume AWS and others, provides a base amount of bandwidth
>> to the outside world, and if your site has a lot of users (including DDOS
>> attacks) you may have to pay for extra.  Having them run backups for you is
>> an extra cost option (at least for Linode, and probably for most others).
>> Otherwise your bandwidth to storage at your house or office counts against
>> your bandwidth allotment.  (And you should back up this way, at least
>> occasionally, even if your regular backups are handled by the provider.)
>>
>> Linode will host DNS records for your VPS.  I presume the others will
>> too, though there may be differences as to whether there is extra cost.
>>
>> If you're going to accept money, don't do it on your server:  Hook up
>> with PayPal and/or one of the other credit card service providers.  You
>> don't want sensitive customer financial (or medical) records on your site.
>> (You 

Re: Which Cloud Service Provider should be chosen to host Django Application

2019-12-02 Thread Bill Freeman
Deployment for a production environment is never without complications.
 And that is affected by how much you choose to configure yourself.  I
can't speak for Heroku, Digital Ocean, or Python Anywhere, because I
haven't used them.  Perhaps some of their users will comment.

Even with virtual hosting it is best to pick one of the kernels that they
have customized to work well with their virtualization mechanisms.  (If you
had a physical host you would need to do kernel configuration yourself.)  I
know that AWS and Linode keep their eye on kernel security updates and will
offer new versions promptly, but you will need to keep your eyes open and
install the upgraded versions when they become available.  They may or may
not include application updates as part of these packages, particularly
database, but also perhaps http server and python version, though if you
want to pick your own version of these then you will be reinstalling them
when the kernel upgrades happen.  And you must watch for security updates
of the packages that you choose to hand install, which will include
Django.  (One of the attractions of shared hosting is that the provider
takes care of more of these things.)

But as far as picking your own version goes, you really want to stay close
to the latest stable version, rather than having to back port security
patches yourself.  You also don't want to go with versions so old that they
are unsupported, or the people finding new exploits will be limited to the
bad guys.  Doing the work right along to stay close to current best
practices is valuable so that you don't have a large panic update to do
when your version becomes unsupported, needs a security fix, and some old,
previously deprecated, way of doing something has been dropped.

You will want to learn how to use one of the automated deployment tools,
since setting things up by had every time gets old, and is error prone.  As
a python guy, I've had fun with fabric, but there are other fine open
source and free tools.  In addition to running pip for your, they can
remotely run apt, rpm, etc., build your database, http server, python
version (including plugging the http server into the desired python using
modwsgi, for example).

(Note that it is not difficult to have multiple versions of python
installed on a Linux system without them getting in one another's way.  So
the kernel scripts can run with the version for which they have been
designed and tested, and you can still have your favorite running behind
your http server, running Django.

I'm unaware of AWS pricing.  Last I checked Linode can be as cheap as $5/mo
(I pay closer to $20), depending on how big a server you need.  Linode, and
I presume AWS and others, provides a base amount of bandwidth to the
outside world, and if your site has a lot of users (including DDOS attacks)
you may have to pay for extra.  Having them run backups for you is an extra
cost option (at least for Linode, and probably for most others).  Otherwise
your bandwidth to storage at your house or office counts against your
bandwidth allotment.  (And you should back up this way, at least
occasionally, even if your regular backups are handled by the provider.)

Linode will host DNS records for your VPS.  I presume the others will too,
though there may be differences as to whether there is extra cost.

If you're going to accept money, don't do it on your server:  Hook up with
PayPal and/or one of the other credit card service providers.  You don't
want sensitive customer financial (or medical) records on your site.  (You
would need full time security staff, and probably private physical servers
to do that safely.)

If you have a very high traffic site, then most providers, including Linode
and certainly AWS, can offer geographic diversity of server location, which
helps with responsiveness, and the ability to continue to conduct business
if a natural disaster takes one of the provider's server farms off line for
a while.  (Most of us don't need this.  And if you have backups not
collocated with the failed farm, you can bring up an alternate instance
quickly.)

There is no substitute for doing your own research into costs, features,
restrictions, and reputation of the various possible providers.

Bill



On Sat, Nov 30, 2019 at 1:54 PM Debabrata Chakraborty <
debobroto.c...@gmail.com> wrote:

> Thanks a million ke1g!
>
> That was really helpful. I am definitely going to use PostgreSQL now.
>
> Only one question remains. I'm willing to deploy my site in any reasonably
> priced virtual server hosting. You mentioned using VPS means I can install
> what I want.
>
> So does that mean - it doesn't matter *which version of Django (i.e.
> Django 2.2.5) I use for the site development,* they will all be equally
> supported inside a VPS hosting plan?
>
> Also, what is the least complicated, least technically challenging Django
> hosting option for a beginner like me?
>
> Thanks again
>
> Deb
>
>
> *On Saturday, November 30, 2019 

Re: Which Cloud Service Provider should be chosen to host Django Application

2019-11-30 Thread Bill Freeman
SQLite is fine for development, but, unless things have changed, it is
single threaded, and unsuitable for a production environment.  Most folks
seem to go for MySQL, though the fork MariaDB is usually preferred no that
Oracle owns MySQL.  I prefer PostgreSQL (or just Postgres) because I think
that it comes closest to the SQL standard and is competitive in other
respects.  Any of these have to be "administered" (though is many cases the
provider helps with this), so if this is for a toy installation, SQLite may
be OK.

SQLite, however, is built into Python these days, and even in older Python
versions it was just a pop install, so providers can't squawk about the
version.  But shared hosting (as opposed to virtual server) will mean that
a particular python version is installed, and the SQLite version in that
version of Python is what you are going to get.  But SQLite handles queries
written for older versions well, and you will wind up with a quite recent
version, so you are unlikely to be using any features that are too new for
the installed version.

Virtual server hosting means that you can install what you want, but does
mean that you will be administering the whole OS as well as the database,
the http server, and even the version of Python, installing new versions
when there are security updates, etc.

I, personally, haven't used any of the providers that you mentioned.  The
last time I deployed on a shared host I used WebFaction, and was quite
satisfied.  Today I use Linode, who provide a virtual server, and are also
quite satisfactory (though you must, last time I checked, use Linux, which
I consider a plus).

On Sat, Nov 30, 2019 at 9:02 AM Debabrata Chakraborty <
debobroto.c...@gmail.com> wrote:

> Hi everyone,
>
> I'm a beginner Django developer. So my apologies in advance for newbie
> like questions.
>
> I am building my site with *" *Django version 2.2.5 *"* and *" *SQLite
> 3.30 *" *in back-end. My question is -
>
> *#* Do services like "Heroku", "Digital Ocean", "Python Anywhere" and
> "AWS" - have limitation on *which version of Django*  or *which DBMS* I
> can use?
>
> I've seen this before with PHP/MySQL hosting where some hosting companies
> will limit *which version *of PHP or MySQL one can use. Is the same
> applicable to Django hosting in the above mentioned hosting platforms as
> well?
>
> I will very much grateful if you can help me out with this confusion.
>
> Best
>
> Deb
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c55f1dae-8fc9-4fbe-85df-f6ee86ce9b53%40googlegroups.com
> 
> .
>

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


Re: text data types

2019-10-08 Thread Bill Freeman
TextField()

On Tue, Oct 8, 2019 at 12:42 PM Mohsen Pahlevanzadeh <
m.pahlevanza...@gmail.com> wrote:

> I need to create text data type in model.py, CharField() has max_len as
> mandatory, What do you recommend instead of CharField() ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bf337998-5544-4be6-b197-0a11eccdbe53%40googlegroups.com
> 
> .
>

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


Re: SESSION_EXPIRE_AT_BROWSER_CLOSE

2019-07-15 Thread Bill Freeman
Once there was no such thing as a cookie that expired at browser close.
Note that such must be implemented by the user agent (browser), since
that's the only thing that knows if it has been closed.  (And, in fact, if
you want it to be closed if the browser crashes, or if it is hard killed by
the OS, or if the machine crashes, it doesn't get an opportunity to delete
cookies.  Probably this is implemented at start up, when it can toss
anything in the cookie store marked as close at end of browser session.
Cookies in RAM only is another approach, but there can be security exploits
through having cookies push the size of process RAM.)  You would have to
check whether the user agent (as claimed) supports this, since not all
browsers (I'll bet) support the feature, and choose a different mechanism
otherwise.  Probably best to just use that other mechanism.

One approach comes to mind.  Have JavaScript implementing a heart beat
poll, and have the cookie invalidated on the Django side if the last
access, poll or normal, was "too long' ago.  Two issues with involve what
constitutes "too long".  Sometimes people have bad connections, and "too
long" may elapse during their network latency of the moment.  And if "too
long" is too long,  you can easily close and restart the browser before it
elapses.

Another that may or may not be possible in all user agents is to access the
timestamp at which the browser was started and include that with each
request (possibly by having the JavaScript that runs when the page load
modify the cooking to include that timestamp.  Then Django session code
would have to consider a non-matching cookie invalid, but accept that
timestamp when accepting a log in.

This has long been a tough problem.  Further, I'm not sure that you are
doing your users any favors by training them to believe that closing the
browser logs them out.  There will be plenty of sites where this doesn't
work.

On Sun, Jul 14, 2019 at 11:33 AM M. Farhan Zia 
wrote:

> Im facing the same problem, How did you solve this problem?
>
>
> On Sunday, January 22, 2017 at 1:21:04 PM UTC+5, ADEWALE ADISA wrote:
>>
>> Good day;
>> Please i need help on the issues am facing on
>> SESSION_EXPIRE_AT_BROWSER_CLOSE django settings.py. In my setting file i
>> have:
>>
>> SESSION_EXPIRE_AT_BROWSER_CLOSE = True
>>
>> but unfortunately, whenever my users close there browsers and open it
>> again, they are login automatically, which shows that the session did not
>> expire.
>> Am facing this issue on all browers.
>> On chrome, when i went to the settings and manually choose to expire
>> cookies, the  SESSION_EXPIRE_AT_BROWSER_CLOSE worked.
>> In deployed application, i can not be asking my users to be changing
>> cookies setting in their browsers.
>> Please how can i achieve session expire after closing browser
>> irrespective of user browser settings. Or if there is javasctipt snippet i
>> can use to control this.
>>
>> Thanks in advance.
>> soliu - fxSoftlogix
>>
> --
> 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/add560a7-21ee-4971-98fd-8e8dc66c6b13%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: why i need to download pycharm , why python ide is not sufficient to write code .

2019-03-27 Thread Bill Freeman
Like many tools, it will take longer to learn to use it well than it takes
to code a small project, though it will start to help along the way.  As an
emacs user, I already had what I needed and more, so it was hard to justify
the extra effort, but I was working where everyone else used it, and it
helped for everyone to be able to type effectively at one another's
keyboards.  It is popular enough that even if you aren't in such a
situation now, you man find yourself in one in the future.

On Wed, Mar 27, 2019 at 3:39 PM Pedro Folch  wrote:

> It really helps try it
>
> On Wed, Mar 27, 2019, 1:11 PM Phako Perez <13.phak...@gmail.com> wrote:
>
>> Isn’t required, it depends on you as PyCharm has more functionalities
>>
>> Sent from my iPhone
>>
>> On Mar 27, 2019, at 12:49 PM, goodresults 
>> wrote:
>>
>> --
>>
>> --
>> 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/337bb1f9-3880-41b9-8e60-5786ec14743c%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/6B05757A-741F-4C00-B4A2-35912CE5E361%40gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGG-qpfdvhy0LbTL3sv8KEzMf%2BgmHEUzxB6ENP%3DJopcxF_oxPw%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/CAB%2BAj0uoZP0RCwLvZxO5u%3DNeObq8%3DbejGwpdPD8YVgNV2buvng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Create project in windows, but run it in Ubuntu

2019-03-22 Thread Bill Freeman
Using git does not require github.  You can use any accessible machine to
serve a git repository, to which you can push, and from which you can pull,
using, for example, git+ssh (you could also use an ssh tunnel, but git
supports ssh transport directly).  Do set up ssh to require keys and not
allow password access, for security.  You can make a user for each
developer to limit access.  git supports all the necessary features that
you get with github.  Any machine that all developers plus the deployment
machine can reach is OK, but something like the $5/mo linode plan means
that you can work remotely if traveling (as opposed to a box on your local
network that's not accessible from outside).

It is also possible to run a private instance of github, but I don't know
the costs and management effort involved.

On Fri, Mar 22, 2019 at 8:28 AM Chafid Ahmad  wrote:

> Hi, I have a client who wanted to run a Django project that can run in
> Ubuntu. As I don't have a UX machine to developed it, is it possible to
> developed the project in Windows, but later export it to Ubuntu? My initial
> plan is:
> - Developed the project with pycharm in windows
> - Upload the project to github
> - retrieve the project from github to an ubuntu virtual machine and test it
> The reason I don't want to developed the project in virtual machine is
> that my hardware resource is limited, I don't want to share it if I don't
> absolutely have to.
> Is this possible? If not can anyone help me with another alternative
> solution?
>
> Cheers
> Chafid
> --
>
> --
> 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/CADf88xmVSz9s8Rpg0gGL1Pmswb-DF8Fz_OEo-EDQgaK7F65hAg%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/CAB%2BAj0u5rf8Ni4vj77A-2Ae_pHp0giUbHxCjTb31tHPkJ1NNdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: rsync vs git for Django development? + Project directory location?

2019-03-15 Thread Bill Freeman
I'm sure that you'll get many opinions, but:

I've had success with git, presuming that filesystem space is not very
tight on the remote server.  You arrange your deployment scripts to run on
the remote (there are several tools to help with that, or for small scale
operations, ssh in and run them directly.  These scripts do a pull from
your central git repository (if you've got that on something other than
your development box, such as github, then your code and version history
are now redundantly in 3 places, at least), and then check out the revision
that has passed continuous integration (you will want to eventually) and
code review (buddy up with someone in the same boat if need be - I don't
care how good you are, a second set of eyes is a treasure).  And if it
bombs, or a problem shows up, rollback to the previous version is just
another checkout, your typed commands being the only things that must cross
the network.  If you had migrations with the new version, you may have to
run reverse migrations (a DB backup on the remote or DB server just before
installing a update is a good idea).

As to the security of the user account on the server box, that depends on
whether the user does anything else, and how automagically someone cracking
your development box can leverage that into access on the server.  Worse
that having stuff in a random user account also used for other things is
having this stuff under root.  It means that you have to get into root way
too often, and also a bug that tries to blow things away has the root
access to do it.  I've often deployed with apache, and made the /www
directory belong to apache.  Nothing there is served by apache except by
being explicitly listed in the apache configuration, such as directories
for CSS and js that are populated by running django's collectstatic
management command, which your scripts should run, among other things,
after checkout of a different revision..  The project directory and
probably a venv directory are there for convenience, but can't be served by
apache.  I presume that Nginx is similarly competent.  It was used at a few
places I worked, but I didn't have to deploy it, so I've not learned the
details.

Bill

On Fri, Mar 15, 2019 at 7:42 PM drone4four  wrote:

> Have two questions.
>
> To manage development of a Django project, when interfacing local changes
> and mirroring them to my remote webserver, would you people recommend using
> rsync or git? I have a little experience with both. I've been using rsync
> to mirror basic HTML and CSS changes from my local host to my remote Apache
> public_html directory for a while now. I was thinking of using rsync for
> transferring changes to my webserver but in one of the courses I am taking,
> the instructor uses git and GitHub. I’m not sure if using git is overkill
> or not best practices. What would you people recommend?
>
> Whether I go with git or rsync, I also need to make a decision about where
> to place my Django project folder on my VPS. One of the guides I am using,
> titled, “How To Set Up Django with Postgres, Nginx, and Gunicorn on
> Ubuntu 18.04
> ”
> suggests putting it inside the user’s home folder. I gather this isn’t the
> most secure option. It’s also not a good idea to place the Django project
> folder inside the Apache public_html folder, am I right? I read both these
> things somewhere a while ago but I can’t recall exactly where. Anyways, to
> set the record straight, where would you people recommend I place my Django
> project folder on my VPS?
>
> --
> 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/994e80b8-0c4d-439c-b0e3-636b8e4f00e2%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: order_by function gets error if the field name or json key, has a dash.

2019-01-14 Thread Bill Freeman
At least on 2.7,  python has no trouble with this:

d={'x-y': 4}
>>> import json
>>> json.dumps(d)
'{"x-y": 4}'
>>>

So that leave's Django's parsing of the order_by string, or just possibly
the database connector.

It probably won't work, but you could try:

MyTable.objects.all().order_by("'myfield__en-us'")

(Single quotes inside double quotes, of vice versa.)

It would be instructive if you would post the original error.

There are problems with using internal interfaces, but you might climb down
inside the order_by to find something that is called after Django has
finished parsing, and substitute the version with the hyphen/minus in
arguments below.  Of once it has build the query, but before you evaluate
it, you could find the order key in the generated SQL (or the string that
will be used at generation time if that doesn't happen until evaluation)
and edit in the hyphen.  I don't promise that there actually are points
where you can do either of these things.  And whatever you do may break at
the next Django version (or the next revision of the database connector.

The better alternative is to figure out where the problem occurs, using
code inspection, or by single stepping in with the debugger (PDB directly
if you're not using something like PyCharm), then design and test an
alternate implementation that is only sensitive to hyphens where required,
and propose that code as an enhancement to the Django team (though if the
problem is somewhere deeper in the database connector, or heaven forbid, in
the DB itself, you may have a harder time finding a sympathetic ear).

Or, at a performance cost, you could skip the order_by clause, and do the
sorting in python.

Raw SQL is a possibility.

Good luck.


On Sun, Jan 13, 2019 at 9:11 PM Jason  wrote:

> I think the easiest way would be to convert the dash to an underscore to
> follow python standards when it comes to naming.  reason being, a dash is
> analogous to the subtraction mathematical operation so you're requiring
> python to know the difference in the usage of this character in names and
> operations.
>
> --
> 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/607c1021-bde0-4dbd-ac16-415eca8606c8%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to hide the password of postgresql in settings.py

2018-11-30 Thread Bill Freeman
You should be keeping settings.py secure.  There's other stuff that
shouldn't be public. That's why the django project directories are not
included in the pages that the front end web server is allowed to serve,
among other things.  Security is tough.  There's no magic answer.

On Fri, Nov 30, 2018 at 12:51 PM Sandip Nath  wrote:

> I am a newbie to Django. Using Postgresql for CRUD operations. Although
> its working but I need to write the password of my Postgresql server in the
> settings.py. How can I hide that without hampering the operation?
>
> --
> 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/ea8bc539-a3be-44b4-af2f-e1b7f11d1539%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re:

2018-08-11 Thread Bill Freeman
A context contains the variables that you want your template to be able to
access.  It is common to want to access stuff from the request.  You could
copy those things that you need into the dict that you pass to the Context
constructor or define an element of the dict to hold the Request object and
let the template dig that stuff out..  RequestContext initializes the
Context according to the dictionary you pass, but also runs you configured
set of context processors, which can paw through the Request object and add
values to your Context's dictionary(s).  See:
https://docs.djangoproject.com/en/2.1/ref/templates/api/

render() turns your template (and context) into a string representing the
body of the response.  render_to_response() does that and uses it to
initialize an HttpResponse object that contains that, plus all suitable
response headers, some defaulted, like content type and content length,
override-able by you, and any additional headers you choose to add, and
also the response status, 200 by default, and corresponding status string,
which you can override if needed.  You need an HttpResponse object to
return from a view so that Django can build the whole response.

Of course, all this is in the documentation.

On Fri, Aug 10, 2018 at 5:37 PM shivam sharma <
talk2shivamsharma19...@gmail.com> wrote:

> Can someone explain me difference between Context object and
> RequestContext obj.
> And also difference between
> render_to_response() and render()
>
> --
> 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/CAKd5AUUPToxjMeg%2B47ENB3T5KQ%2BXyRVb%2BNKnGLKsGz10OyRFPg%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/CAB%2BAj0vxXEOg%3DY7Y-9GCBcVbwfaU9eHdG%3D91emsRi0JWUUqcXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clarification on Foreign Keys requested

2018-03-06 Thread Bill Freeman
When all is as usual, you don't play with pk in your code.  You put the
foreign object in the field of the referring object.  (In python that's
just a reference, so don't worry about copies, etc.)  When the referring
object is saved, django saves the pk of the object in the field in the db
in a field called foo_id, if the field itself is called foo. Later when
you fetch the referrer, say as bar, then when you refer to bar,foo django
makes sure the foo object has been fetched, so bar.foo.ugh get's you the
ugh field of the foo object referred to by bar.

I suggest that with this in mind, you go back of the part of the tutorial
example that talks about foreign keys and see how many of the things that
you're doing aren't required, and are just opportunities to confuse things.

On Mon, Mar 5, 2018 at 6:21 PM, Malik Rumi <malik.a.r...@gmail.com> wrote:

> I tried the to_field argument, that was a mistake, and I put it back.
>
> I was just inserting the pk of the foreign object. However, as things are
> moving through the pipeline, I used uuid.uuid4() to create additional pks
> as needed at it went along.
>
> Example:
>
> def process_item(self, item, spiders):
> itemcasebycase['case_arrow'] = item['uniqid']
> itemcasebycase['uniqid'] = get_u
>
> But this is what works in the pipeline:
>
> scotus = Jurisdiction.objects.get(
> uniqid='5e4dd0c2-5cc9-4d08-ab43-fcf0e84dfc44')
> item['jurisdiction'] = scotus
>
> And this is the error message I got:
>
> ValueError: Cannot assign "UUID('5e4dd0c2-5cc9-4d08-ab43-fcf0e84dfc44')":
> "Case.jurisdiction" must be a "Jurisdiction" instance
>
> Finally, yes, under normal circumstances, my pk uuids are made
> automatically. Thanks
>
> *“None of you has faith until he loves for his brother or his neighbor
> what he loves for himself.”*
>
> On Mon, Mar 5, 2018 at 2:16 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>> Are you specifying the to_field argument, or are you letting it default?
>>
>> And is the pk of the other model made by Django by default, or are you
>> explicitly specifying a foreign key constraint on some field of your own.
>>
>> Things might be better in 2.0, but I've had my troubles with pk that
>> isn't an AutoField (such as made by default).
>>
>> If you're only doing the standard (defaulted) stuff, it's a mystery.
>> Either way folks probably need to see some of your code to help out.
>>
>> On Mon, Mar 5, 2018 at 5:06 PM, Malik Rumi <malik.a.r...@gmail.com>
>> wrote:
>>
>>> Hello all,
>>>
>>> Up to now, (admittedly not long - I'm not a total newbie but I still
>>> have a LOT to learn) when making a foreign key I would just put the pk of
>>> that instance in the fk field, as the docs suggest:
>>>
>>> By default ForeignKey will target the pk of the remote model but this 
>>> behavior
>>> can be changed by using the ``to_field`` argument.
>>>
>>> *https://docs.djangoproject.com/en/2.0/_modules/django/db/models/fields/related/#ForeignKey
>>> <https://docs.djangoproject.com/en/2.0/_modules/django/db/models/fields/related/#ForeignKey>
>>> *
>>>
>>> However, recently while working with a scrapy pipeline, these fields
>>> started catching errors, which told me
>>>
>>> "...must be an instance of ...(foreign object)"
>>>
>>> And sure enough, if I did a get queryset for the one specific instance
>>> in question, that worked. My question is why, or maybe it should be, what's
>>> the difference, or maybe even, what's going on here, or wtf?
>>>
>>> Any light you can shed on this for me would, as always, be greatly
>>> 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/ms
>>> gid/django-users/5f9399d4-6a48-450a-b2bd-2e33a296b1b5%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/5f9399d4-6a48-450a-b2bd-2e33a296b1b5%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message b

Re: Clarification on Foreign Keys requested

2018-03-05 Thread Bill Freeman
Are you specifying the to_field argument, or are you letting it default?

And is the pk of the other model made by Django by default, or are you
explicitly specifying a foreign key constraint on some field of your own.

Things might be better in 2.0, but I've had my troubles with pk that isn't
an AutoField (such as made by default).

If you're only doing the standard (defaulted) stuff, it's a mystery.
Either way folks probably need to see some of your code to help out.

On Mon, Mar 5, 2018 at 5:06 PM, Malik Rumi  wrote:

> Hello all,
>
> Up to now, (admittedly not long - I'm not a total newbie but I still have
> a LOT to learn) when making a foreign key I would just put the pk of that
> instance in the fk field, as the docs suggest:
>
> By default ForeignKey will target the pk of the remote model but this behavior
> can be changed by using the ``to_field`` argument.
>
> *https://docs.djangoproject.com/en/2.0/_modules/django/db/models/fields/related/#ForeignKey
> 
> *
>
> However, recently while working with a scrapy pipeline, these fields
> started catching errors, which told me
>
> "...must be an instance of ...(foreign object)"
>
> And sure enough, if I did a get queryset for the one specific instance in
> question, that worked. My question is why, or maybe it should be, what's
> the difference, or maybe even, what's going on here, or wtf?
>
> Any light you can shed on this for me would, as always, be greatly
> 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/5f9399d4-6a48-450a-b2bd-2e33a296b1b5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [Help] Advanced tutorial: How to install my Python package with Virtualenv

2016-09-27 Thread Bill Freeman
I don't do development in Windows, so take this with a grain of salt, but
under the directory in which you created your virtualenv, there should be a
directory called "bin".  In that there will be a couple of files whose
names begin with "activate".  There may be one with an obvious Windows
extension, such as ".bat".  Try running that, which should leave you at a
command prompt, possibly decorated with the name of the virtualenv (but
that might be a *nix thing).  Your PATH environment variable probably will
have been modified to include this directory early, so that the python
executable there will be found first.  There is also a pip there, but I
don't know if just typing "pip install package-i-want" will work, but
typing "python pip install package-i-want" while cd'ed to that directory
should.  There are probably ways to avoid having to cd to the directory.
Hopefully someone who develops on Windows can provide a better answer.

On Tue, Sep 27, 2016 at 3:00 PM, Aline C. R. Souza 
wrote:

> Hello ke1g and gary719_list1,
>
> Thank you for your time.
>
> Hi, I am using windows and the cmd terminal. I do not know what you mean
> by activate the virtual env. I created one virtual enviroment called
> 'poll-tutorial' and used the command 'workon poll-tutorial' to work on this
> enviroment.
>
> I think you didn't understand my doubt. I think I was not very clear. The
> thing is:
>
> I followed this tutorial: https://docs.djangoproject.com/en/1.10/
> intro/reusable-apps/
>
> At the 'Using your own package' step, there is a choice:  install
> django-polls as a user library or with virtualenv
>
> The tutorial does not explain how to install with virtualenv, so I am
> trying to figure it out.
>
> I saw on a blog post that I should use the pip command as installing a
> user library but whitout the '--user':
>
> pip install django-polls/dist/django-polls-0.1.tar.gz
>
> But did not work, it can not find the file.
>
> I think I am using this command at the wrong directory.
>
> So, suppose that I am at 'mysite' directory, working on the
> 'poll-tutorial' virtual environment. What would be the correct pip command
> to install my package that is inside the folder django-polls/dist outside
> of my project directory?
>
> I think my problem maybe is just about localization of the files. I am
> little bit lost.
>
>
>
> Em terça-feira, 27 de setembro de 2016 08:21:54 UTC-3, Aline C. R. Souza
> escreveu:
>>
>> Hello Guys,
>>
>> I need some help to install my Python package with virtualenv. I follow
>> the 'Advanced tutorial: How to write reusable apps' and moved the polls
>> directory out of the project. Now I want to install my package using
>> virtualenv and pip, but I don't know how.
>>
>> Consider I am inside of my project diretory (where the manage.py is) and
>> I am working on a virtual environment. What would be the right pip command
>> to install my package, considering that the polls directory is out of the
>> project.
>>
>> Please help!
>>
>>
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/04d283f6-4ba3-41e2-b192-d3ba55ebd866%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [Help] Advanced tutorial: How to install my Python package with Virtualenv

2016-09-27 Thread Bill Freeman
You don't say what OS/platform you are using, and I don't know if what I
say below applies to Windows, but should be valid elsewhere.

Note, too, that I presume that you are using a command line (e.g.;
xterm/bash).

I also presume that you have managed to install virtualenv on your system.

If  your virtualenv is activated (see virtualenv documentation), and you
should activate it when working on your project, then just saying

   pip

should be enough.  Try saying

   which pip

if that works at all, it should report a pip withing the bin directory of
your virtualenv.  On the other hand, if it reports the pip in a system
directory, then your virtualenv has not been activated, or somethign is
broken.

On Tue, Sep 27, 2016 at 7:19 AM, Aline C. R. Souza 
wrote:

> Hello Guys,
>
> I need some help to install my Python package with virtualenv. I follow
> the 'Advanced tutorial: How to write reusable apps' and moved the polls
> directory out of the project. Now I want to install my package using
> virtualenv and pip, but I don't know how.
>
> Consider I am inside of my project diretory (where the manage.py is) and I
> am working on a virtual environment. What would be the right pip command to
> install my package, considering that the polls directory is out of the
> project.
>
> Please help!
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/bb3167a4-61c3-4006-994d-c2b226636401%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


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

2016-08-16 Thread Bill Freeman
Cached in browser, maybe?

On Tue, Aug 16, 2016 at 11:43 AM, Avraham Serour  wrote:

> How do you know the query is cached?
>
> On Aug 16, 2016 6:33 PM, "술욱"  wrote:
>
>> I forgot to say I reloaded (and restarted) nginx and uwsgi, but the query
>> is still cached
>>
>>
>> Thanks anyway!
>>
>>
>>
>>
>> 2016-08-16 12:24 GMT-03:00 M Hashmi :
>>
>>> Reload Nginx and see if still its loading cached query.
>>>
>>> On Tue, Aug 16, 2016 at 8:18 AM, 술욱  wrote:
>>>
 Hello

 I'm running (in production) and app that uses raw queries, something
 like:

 query = """
 select table1.field1, table2.field3
 from table1 left join table2
on test1.field1 = test2.field1
and test1.field2 = test2.field2
 where table1.field1 = %(param1)s
 """

 cursor = connections['database'].cursor()
 cursor.execute(query, {'param1': param1-value})
 data = cursor.fetchall()


 My problem is, somewhere, Django, uwsgi, or nginx, is caching this
 query.

 How do I find who's caching?


 Thanks,
 Norberto

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

>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/CANoUts63A-mGo-KOYJHBFJtOut9gasWX3A8dso3%3D
>>> v0myFwgAgg%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/ms
>> gid/django-users/CADut3oBoqHS7JCV8vs2o2Z%2BHDsr5LQeTDnGm34bd
>> PTJbcOkhDg%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/CAFWa6tKMSQ077%2BuRm-Kp1iGNS%
> 2BUbGLcZihpE%3Dphwc69KNhJEVg%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/CAB%2BAj0sMGbzCcAT_9ksuOc7iKE_bU_hHmCRaskbUB%3Dsvssa0Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Test fails when run in whole test suite - but not stand-alone?

2016-06-25 Thread Bill Freeman
I have no immediate clue.

I know that, using nosetest, I can add -s and -v to the command line,
making it possible to drive pdb from the test, using:

import pdb;pdb.set_trace()

inserted in the code to get into pdb at the relevant point(s).

Evan if you're not running under nosetest, there may be an equivalent to -s
-v .

Clearly something interesting is going on.  If the framework uses a new
process for the second test, then the import would actually happen twice,
but the environment should be pristine, unless you have left crud in a file
or database that is written during the test.

If the same process is used, the second import doesn't actually import, but
just gives you a reference to the already loaded module (at least that's
the way it is in python 2.x, where I still live).

I would start with a set_trace() at the top of the imported module, to see
if it is reached before the failure.  If it is, you can single step along
in hope of insight.

On Sat, Jun 25, 2016 at 5:17 AM, Derek  wrote:

> Hi Adam
>
> I have narrowed the issue right down.  As soon as I have even *one* other
> test that imports *anything* from the app's admin file, the test crashes.
> So for example, if the test sequence is group of test files - one of which
> is my one in the OP and one which contains:
>
> import unittest
> from trees.admin import AnyModelAdmin
>
> class TestDummy(unittest.TestCase):
>
> def setUp(self):
> pass
>
> def test_dummy(self):
> pass
>
> def tearDown(self):
> pass
>
> Then I get errors.  Do you know why an import statement would interfere
> with a test?
>
> Thanks,
> Derek
>
>
>
> On Thursday, 2 June 2016 21:47:00 UTC+2, Adam wrote:
>>
>> When I've had that happen before, it's because some previous test changed
>> something (like a setting value or the site domain) that influenced the
>> test that failed. To narrow it down, I would run all the tests up to and
>> including the failed one. That should fail, then I start taking out half
>> the tests before. If the test still fails, I keep cutting in half until I
>> can determine which previous test is causing issues. If, after cutting out
>> tests, the problem test passes, then I need to put back in what I took out
>> since it was one of those.
>>
>> Once I figure out which previous test it was, I can start removing the
>> individual tests to finally get to the code causing the problem. Usually,
>> it's a case that a test changed something and I just have to add in the
>> teardown function to restore the state of whatever was changed.
>>
>> On Thu, 2016-06-02 at 21:33 +0200, Derek wrote:
>>
>> I have a test that is failing when the file it is in is run as part of
>> all the other test files by the test runner.
>>
>> If I just run only the file that contains this test -  then it passes.
>>
>> (pass/fail refers to the very last assert in the code below.)
>>
>> I'd appreciate any ideas or insights from anyone who can spot an obvious
>> mistake - or suggest some options to explore.
>>
>> Thanks
>> Derek
>>
>>
>> # THIS IS AN EXTRACT OF RELEVANT CODE (not all of it...)
>> from django.contrib.messages.storage.fallback import FallbackStorage
>> from django.core.urlresolvers import reverse
>> from django.test import TestCase, Client
>> # ... various app-related imports ...
>>
>>
>> class MockRequest(object):
>> """No code needed."""
>> pass
>>
>>
>> REQUEST = MockRequest()
>> # see: https://stackoverflow.com/queI
>> stions/11938164/why-dont-my-django-\
>> #  unittests-know-that-messagemiddleware-is-installed
>> setattr(REQUEST, 'session', 'session')
>> MESSAGES = FallbackStorage(REQUEST)
>> setattr(REQUEST, '_messages', MESSAGES)
>> setup_test_environment()
>>
>>
>> class PersonAdminTest(TestCase):
>>
>> def setUp(self):
>> self.user, password = utils.user_factory(model=None)
>> self.client = Client()
>> login_status = self.client.login(username=self.user.email,
>> password=password)
>> self.assertEqual(login_status, True)
>>
>> def test_action_persons_make_unreal(self):
>> try:
>> change_url = reverse('admin:persons_realpersons_changelist')
>> except NoReverseMatch:
>> change_url = '/admin/persons/realpersons/'
>> sys.stderr.write('\n   WARNING: Unable to reverse URL! ... ')
>> response = self.client.get(change_url)
>> self.assertEqual(response.status_code, 200)
>>
>> --
>> 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
>> 

Re: Stuck on tutorial your first Django app part 2

2016-06-09 Thread Bill Freeman
What is the definition of your __str__() method?

On Thu, Jun 9, 2016 at 4:11 PM, Neil Hunt  wrote:

> Hello,
>
> I'm enjoying the tutorial and now I'm stuck on the second page (writing
> your first Django app part 2), shortly after this paragraph.
>
> 'It’s important to add __str__()
> 
> methods to your models, not only for your own convenience when dealing with
> the interactive prompt, but also because objects’ representations are used
> throughout Django’s automatically-generated admin.'
>
> The tutorial says to go into the interactive shell again.
>
> This line runs without error.
>
> 'from polls.models import Question, Choice'
>
> The next line Question.objects.all() results in
>
> '[]' instead of
>
> '[]'
>
> Any help would be much 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/3154675a-5749-434e-9fce-3aae49014959%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Why don't I see my category ForeignKey field in related Model

2016-05-13 Thread Bill Freeman
If you use a ManyToManyField, Django creates the join table for you.  In
the rare case that you need to store additional data on the join table, you
can create your own and use ManyToManyField.through


On Fri, May 13, 2016 at 5:00 AM, Bruce Whealton <
futurewavewebdevelopm...@gmail.com> wrote:

> You are absolutely right.  So, I just need to figure out how to change
> things in the models.py.  I'm not sure if django
> needs a third model or not.
> Thanks for helping where something should have been easier for me,
> Bruce
>
> --
> 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/1a4b5a83-8b2d-4e5f-8b7e-4b6bb6341f78%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Why don't I see my category ForeignKey field in related Model

2016-05-11 Thread Bill Freeman
This is a many to many relation.  One contact can have multiple relations,
according to your text, but clearly, more than one contact can be family,
etc.

And if, instead, each contact can have only one relation, then the
ForeignKey goes in the Resource (contact) model, not the Relationship
(category) model.

On Wed, May 11, 2016 at 7:17 AM, Bruce Whealton <
futurewavewebdevelopm...@gmail.com> wrote:

> Hello all,
>I think that my problem here is Django specific and not
> necessarily a reflection on
> my understanding of relational databases (hopefully).
> I did post about this previously and thought I had figured out what to
> do.
> I have a Django app that stores information on Contacts.
> With that one table things seemed to work fine.  When I wanted to
> categorize
> the type of relationship - is this a professional relationship, family,
> friends, etc.
> That's when things didn't show up like I wanted.  I finally got the
> migration to work
> with the new table.
> I'm using python 3 with the latest version of django.  I have a
> mysql
> database.  I want a one to many relationship, where one contact can
> be characterized by many categories.  When I work with the django admin
> and try to enter a contact, I'm not seeing a field for entering
> relationship categories.
>
> So, here is my models.py for the contacts app.
>
> from django.db import models
>
>
> class Resource(models.Model):
> first_name = models.CharField(max_length=40)
> last_name = models.CharField(max_length=40)
> organization = models.CharField(max_length=60, null=True, blank=True)
> street_line1 = models.CharField("Street Line 1", max_length=50,
> null=True, blank=True)
> street_line2 = models.CharField("Street Line 2", max_length=50,
> null=True, blank=True)
> city = models.CharField(max_length=40, null=True, blank=True)
> state = models.CharField(max_length=40, null=True, blank=True)
> zipcode = models.CharField(max_length=20, blank=True, null=True)
> phone1 = models.CharField(max_length=20, null=True, blank=True)
> phone2 = models.CharField(max_length=20, null=True, blank=True)
> email = models.EmailField(max_length=60, null=True, blank=True)
> website = models.URLField(max_length=90, null=True, blank=True)
>
> def __str__(self):
> return "%s %s \t%s" % (self.first_name, self.last_name,
> self.organization)
>
> class Meta:
> ordering = ('last_name',)
>
>
> class Relationship(models.Model):
> category = models.CharField(max_length=120)
> resource = models.ForeignKey(Resource, related_name='category')
>
> def __str__(self):
> return self.category
>
> class Meta:
> ordering = ('category',)
>
> Thanks in advance for any help,
> Bruce
>
> --
> 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/ab683e85-6945-4387-acd2-0ae3357db268%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How displaying text as code?

2016-03-25 Thread Bill Freeman
Consider the  tag.

On Fri, Mar 25, 2016 at 4:47 PM, Seti Volkylany 
wrote:

>
> I had text in database on TextField. I am using this field in my template
> applying tag *linebreaksbr* but text displaying simple plain.
>
> In console I have next result:
>
> Out[60]: 'class UpdateAccountInfo(LoginRequiredMixin, View):\n"""\n
>  View for update information about account of user\n"""\n\ndef
> post(self, request, *args, **kwargs):\nif request.is_ajax():\n
>result = dict()\nstatus = 200\ntry:\n
>  if request.FILES:\ncoordinates_x1 =
> int(request.POST.get(\'coordinates[x1]\'))\n
>  coordinates_y1 = int(request.POST.get(\'coordinates[y1]\'))\n
>coordinates_x2 = int(request.POST.get(\'coordinates[x2]\'))\n
>  coordinates_y2 = int(request.POST.get(\'coordinates[y2]\'))\n
>field = \'account_user_info-picture\'\n
>value = request.FILES[field]\nnew = {field: value}\n
>account_info =
> AccountUserInfo.objects.get(account=self.request.user)\n
>  account_info.picture = value\n
>  account_info.full_clean()\naccount_info.save()\n
>  picture_file = Image.open(account_info.picture.path)\n
>cropped_picture = picture_file.crop([coordinates_x1,
> coordinates_y1, coordinates_x2, coordinates_y2])\n
>  cropped_picture.save(account_info.picture.path)\n
>  result[\'new_image_url\'] = account_info.picture.url\n
>  else:\nfield = self.request.POST[\'field\']\n
>value = self.request.POST[\'value\']\nif
> field == \'datetimepicker_for_birthday_account\':\n
>  correct_field = \'birthday\'\nelse:\n
>correct_field = field.replace(\'account_user_info-\', \'\')\n
>  new = {correct_field: value}\naccount_info
> = AccountUserInfo.objects.filter(account=self.request.user)\n
>  AccountUserInfo(**new).full_clean(exclude=[\'account\'])\n
>account_info.update(**new)\naccount_info =
> AccountUserInfo.objects.get(account=self.request.user)\n
>  result[\'new_value_progresbar_filling_account_info\'] =
> account_info.filling_account_info()\nexcept BaseException as
> errors:\nresult = dict(errors)\nstatus =
> 400\nreturn JsonResponse(data=result, status=status)'
>
> In template I have next results (with tag *linebreaksbr*):
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *class UpdateAccountInfo(LoginRequiredMixin, View):"""View for update
> information about account of user"""def post(self, request, *args,
> **kwargs):if request.is_ajax():result = dict()status = 200try:if
> request.FILES:coordinates_x1 =
> int(request.POST.get('coordinates[x1]'))coordinates_y1 =
> int(request.POST.get('coordinates[y1]'))coordinates_x2 =
> int(request.POST.get('coordinates[x2]'))coordinates_y2 =
> int(request.POST.get('coordinates[y2]'))field =
> 'account_user_info-picture'value = request.FILES[field]new = {field: value}*
>
> but I need right displaying as in terminal with function print():
>
> In [61]: print(a.code)
> class UpdateAccountInfo(LoginRequiredMixin, View):
> """
> View for update information about account of user
> """
>
> def post(self, request, *args, **kwargs):
> if request.is_ajax():
> result = dict()
> status = 200
> try:
> if request.FILES:
> coordinates_x1 =
> int(request.POST.get('coordinates[x1]'))
> coordinates_y1 =
> int(request.POST.get('coordinates[y1]'))
> coordinates_x2 =
> int(request.POST.get('coordinates[x2]'))
> coordinates_y2 =
> int(request.POST.get('coordinates[y2]'))
> field = 'account_user_info-picture'
> value = request.FILES[field]
> new = {field: value}
> account_info =
> AccountUserInfo.objects.get(account=self.request.user)
> account_info.picture = value
> account_info.full_clean()
> account_info.save()
> picture_file = Image.open(account_info.picture.path)
> cropped_picture = picture_file.crop([coordinates_x1,
> coordinates_y1, coordinates_x2, coordinates_y2])
> cropped_picture.save(account_info.picture.path)
> result['new_image_url'] = account_info.picture.url
> else:
> field = self.request.POST['field']
> value = self.request.POST['value']
> if field == 'datetimepicker_for_birthday_account':
> correct_field = 'birthday'
> else:
> correct_field =
> field.replace('account_user_info-', '')
> 

Re: Django Newbie - Tutorial Recommendations?

2016-03-19 Thread Bill Freeman
As far as learning python goes, especially if you already program in
another language, the tutorials at docs.python.org are quite good.  If you
are using python 2 instead of python 3, note the "Docs for other versions"
section in the top of the left hand column.  If you don't already program
in some other language, you might consider a book for python beginners.

On Fri, Mar 18, 2016 at 10:40 AM, Stanislav Vasko  wrote:

> Hello,
>
> i found very usefull general tutorial at Django site:
> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
>
> But you can try DjangoGirls (dont worry, its not just for girls):
> http://tutorial.djangogirls.org
>
> Good Luck!
>
> --
> 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/e62fffa8-a35d-4e66-a392-15e35566ab87%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: partial database restoration

2016-03-10 Thread Bill Freeman
That's a good question.  I'd rather write it in python, but if it runs
daily on non-trivial tables, I suspect that performance is better with a
script that gets the DB to produce the dump files, maybe onto a NAS.  The
restore part should be a lot less frequent, so performance is probably less
important.  You may have to clean up old DB content for that user before
the restore.  So I might write the restore in python.  But then, I've never
written DB PL, so I could be missing a bet.

On Thu, Mar 10, 2016 at 12:15 AM, Mike Dewhirst <mi...@dewhirst.com.au>
wrote:

> On 10/03/2016 11:15 AM, Bill Freeman wrote:
>
>> The only problem I can think of with a DB script is that it may have to
>> be recoded at unpleasant times, such as when you run a migration to take
>> a new version with a security fix.
>>
>> If you are going to do it in Django, it would be by saving stuff out to
>> a fixture, maybe with a custom management command, and that still
>> suffers from the need to re-write at schema changes.
>>
>
> If you were going to do it, which approach would you take?
>
> Thanks Bill
>
> M
>
>
>> On Wed, Mar 9, 2016 at 6:24 PM, Mike Dewhirst <mi...@dewhirst.com.au
>> <mailto:mi...@dewhirst.com.au>> wrote:
>>
>> I have a Django project oriented around lots of companies and each
>> company enters its own data. I need to produce a separate individual
>> database backup or dump for each company.
>>
>> It will be used on request to perform an individual restoration
>> after user error has damaged a company's data.
>>
>> I presume this is a Postgres scripting task or is there a Django
>> recipe?
>>
>> Thanks for any pointers
>>
>> Mike
>>
>> --
>> 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
>> <mailto:django-users%2bunsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto: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/56E0B0A1.6000809%40dewhirst.com.au
>> .
>> 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
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto: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/CAB%2BAj0szPfR5KZM32R6EePgf%3D9B4gw-gnty2-yNO2O7AWCZG7Q%40mail.gmail.com
>> <
>> https://groups.google.com/d/msgid/django-users/CAB%2BAj0szPfR5KZM32R6EePgf%3D9B4gw-gnty2-yNO2O7AWCZG7Q%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/56E102FF.1020302%40dewhirst.com.au
> .
>
> 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/CAB%2BAj0vjVnA8Fmr%3DgvkEff7o%2ByTA8Ng95BA7Pss3vYcA8pQRAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: partial database restoration

2016-03-09 Thread Bill Freeman
The only problem I can think of with a DB script is that it may have to be
recoded at unpleasant times, such as when you run a migration to take a new
version with a security fix.

If you are going to do it in Django, it would be by saving stuff out to a
fixture, maybe with a custom management command, and that still suffers
from the need to re-write at schema changes.

On Wed, Mar 9, 2016 at 6:24 PM, Mike Dewhirst  wrote:

> I have a Django project oriented around lots of companies and each company
> enters its own data. I need to produce a separate individual database
> backup or dump for each company.
>
> It will be used on request to perform an individual restoration after user
> error has damaged a company's data.
>
> I presume this is a Postgres scripting task or is there a Django recipe?
>
> Thanks for any pointers
>
> Mike
>
> --
> 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/56E0B0A1.6000809%40dewhirst.com.au
> .
> 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/CAB%2BAj0szPfR5KZM32R6EePgf%3D9B4gw-gnty2-yNO2O7AWCZG7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: var1 = var2 = var3

2016-02-18 Thread Bill Freeman
The interesting thing is how chained assignment is implemented.  In C, the
following is an expression, and has a value:

   a = b

This leads to the compiler not being helpful for the famous =/== typo in
this like:

  if (a = b)  { ... }

In python the only expression in:

  a = b = c

only has one expression: c

The rest is syntax for the assignment statement, where trailing =
identifies each of the targets to which the value of c is to be assigned.

An assignment statement begins with a series of one or more target
specifiers and ends with a single expression.

(Targets can be more complex, e.g.; x, y = p = 0, 0)

On Wed, Feb 17, 2016 at 7:28 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

> The term is "chained assignment" (applied to other languages as well).
>
>
> https://en.wikipedia.org/wiki/Assignment_(computer_science)#Chained_assignment
>
> _Nik
>
> On Tuesday, February 16, 2016 at 12:06:10 PM UTC-8, anotherdjangonewby
> wrote:
>>
>> Hi,
>>
>> this may be a bit off-topic, but:
>>
>> How are expressions like:
>>
>> var1 = var2 = var3
>>
>> called Python. Without a hint I cannot goolge this.
>>
>> Thanks
>>
>> Kai
>>
> --
> 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/8c0392e7-a040-4d53-8e40-96aed5a41176%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Trying to upgrade Django using pip on CentOS results in segmentation fault

2016-02-17 Thread Bill Freeman
Or clone into a new virtualenv (you are using virtualenv, aren't you, and
you are using requires.txt and pip, and your code is in revision control,
right?), then change the Apache configuration to use the new VE and restart.

On Wed, Feb 17, 2016 at 7:00 AM, Mike Dewhirst 
wrote:

> Try stopping Apache during the upgrade. I need to do that on Ubuntu.
>
> Good luck
>
> *Connected by Motorola*
>
>
> Tanuka Dutta  wrote:
>
>
>
>
> down votefavorite
> 
>
> Hello,
>
> I have a Linux CentOS 6.7 installation on a VM. A few months ago, I had -
> compiled and installed Python 2.7.8 on it - installed virtualenv-13.1.2 in
> /usr/lib/python2.7/site-packages - installed Django 1.7 inside the
> virtualenv. - compiled and installed mod_wsgi 4.4.21 and used it to deploy
> Django on Apache
>
> I have been using this over the last few months with no issues.
>
> I am now trying to upgrade to Django 1.8.8. I activated the virtualenv and
> then executed the following command, but it encounters a segmentation fault
> each time.
>
> $pip2.7 install --upgrade django==1.8.8
> Collecting django==1.8.8
> /home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/sitepackages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90:
>  InsecurePlatformWarning: A true SSLContext object is not available. This 
> prevents urllib3 from configuring SSL appropriately and may cause certain SSL 
> connections to fail. For more information, see 
> https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.InsecurePlatformWarningDownloading
>  Django-1.8.8-py2.py3-none-any.whl (6.2MB)99% 
> |### | 6.2MB 9.1MB/s eta 0:00:01Segmentation fault
>
> If I preface the command with sudo, there is no segmentation fault, but it
> does not proceed to install the new version of Django at all.
>
> Output of verbose option given below
>
> pip2.7 install --upgrade django==1.8.8 -v
>
> Collecting django==1.8.8Getting page 
> https://pypi.python.org/simple/django/Starting new HTTPS connection (1): 
> pypi.python.org/home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/site-  
>   packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: 
> InsecurePlatformWarning: A true SSLContext object is not available. This 
> prevents urllib3 from configuring SSL appropriately and may cause certain SSL 
> connections to fail. For more information, see 
> https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.InsecurePlatformWarning"GET
>  /simple/django/ HTTP/1.1" 200 39851 location(s) to search for versions of 
> django:* https://pypi.python.org/simple/django/Getting page 
> https://pypi.python.org/simple/django/"GET /simple/django/ HTTP/1.1" 200 
> 3985Analyzing links from page https://pypi.python.org/simple/django/Found 
> link 
> https://pypi.python.org/packages/any/D/Django/Django-1.5.2-py2.py3-none-any.whl#md5=07f0d2d42162945d0ad031fc9737847d
>  (from https://pypi.python.org/simple/django/), version: 1.5.2Found link 
> https://pypi.python.org/packages/any/D/Django/Django-1.5.8-py2.py3-none-any.whl#md5=1e3418bd1d6f9725a3d1264c9352f2a1
>  (from https://pypi.python.org/simple/django/), version: 1.5.8Found link 
> https://pypi.python.org/packages/any/D/Django/Django-1.6.1-py2.py3-none-any.whl#md5=c7b7a4437b36400f1c23953e9700fd29
>  (from https://pypi.python.org/simple/django/), version: 1.6.1Found link 
> https://pypi.python.org/packages/any/D/Django/Django-1.6.2-py2.py3-none-any.whl#md5=3bd014923e85df771b34d12c0ab3c9e1
>  (from https://pypi.python.org/simple/django/), version: 1.6.2Found link 
> https://pypi.python.org/packages/any/D/Django/Django-1.6.5-py2.py3-none-any.whl#md5=2bcdb4729f9f358b0925b532eef0a8ff
>  (from https://pypi.python.org/simple/django/), version: 
> 1.6.5..Found link 
> https://pypi.python.org/packages/source/D/Django/Django-1.8.8.tar.gz#md5=08ecf83b7e9d064ed7e3981ddc3a8a15
>  (from https://pypi.python.org/simple/django/), version: 1.8.8Found link 
> https://pypi.python.org/packages/source/D/Django/Django-1.8.9.tar.gz#md5=49f6863b1c83825fb2f473c141c28e15
>  (from https://pypi.python.org/simple/django/), version: 1.8.9Found link 
> https://pypi.python.org/packages/source/D/Django/Django-1.8.tar.gz#md5=9a811faf67ca0f3e0d43e670a1cc503d
>  (from https://pypi.python.org/simple/django/), version: 1.8Found link 
> https://pypi.python.org/packages/source/D/Django/Django-1.9.1.tar.gz#md5=02754aa2d5c9c171dfc3f9422b20e12c
>  (from https://pypi.python.org/simple/django/), version: 1.9.1Found link 
> https://pypi.python.org/packages/source/D/Django/Django-1.9.2.tar.gz#md5=ee90280973d435a1a6aa01b453b50cd1
>  (from https://pypi.python.org/simple/django/), version: 1.9.2Found link 
> https://pypi.python.org/packages/source/D/Django/Django-1.9.tar.gz#md5=110389cf89196334182295165852e082
>  (from 

Re: Kind'a TL, but please DR - Need your thoughts

2016-02-01 Thread Bill Freeman
I suggest that you use Celery.

If people are making HTTP requests of you, that is reason enough to choose
Django.

But do not wait for long calculations to complete before returning an HTTP
result.  Instead redirect to a page containing simple JavaScript that will
poll for a result.

PostgreSQL is my favorite SQL DB, and I think that you are in good shape
there.  Another popular free DB is MariaDB, but I prefer PostgreSQL.

Record the request data in the DB invoke a Celery task to send the Primary
Key of the new entry to a worker process.  This simply queues a message in
RabbitMQ, so it is quite fast.  (Other MQs are possible, but RabbitMQ is
best tested with Celery.)  This lets you return the HTTP response very
quickly.

Any additional daemons needed to poll for or listen for request coming by
other than HTTP request can also store to the DB and call a Celery task.

Rather that polling the DB for work, the Celery worker system, when a
worker process is ready, takes a message from the queue (RabbitMQ) and
assigns it to that worker.  Multiple workers can be handling separate
messages in parallel, but do size the worker pool according to the size of
your machine.  The worker fetches the request from the DB, and can run for
as long as necessary to perform the calculation, even, if necessary,
reaching out to other resources over the net.  When it is done, it stores
the response in the DB, for the polling by the requester's JavaScript to
find. and/or send copies via other mechanisms, such as an SMS interface.
Then the worker becomes available to handle another message.

I can assure you that this works well on Linux (you don't mention the
platform).  I have not used Celery (or Django, for that matter) on Windows
or Mac, but I'll bet that it runs fine, modulo the usual surprises about
file system differences and the way that Windows processes are "special".

Pretty much you just code in Python.  The exception is startup scripts to
boot time start/manage  the celery works, Apache/nginx front end for
Django, and any additional required communications processes.  I guess
there is also that small JavaScript to poll for a result.

An alternative to the JavaScript is a button for the user to push to see if
the results are ready, and you should probably implement that anyway (and
use JavaScript to hide it) for those with JavaScript disabled.

On Mon, Feb 1, 2016 at 1:28 AM, Avraham Serour  wrote:

> if a process takes too long to complete it won't be able to process new
> requests, so you will be limited to the number of workers you told uwsgi to
> use.
>
> http requests should be short lived, if you have some heavy processing  to
> do the http request should return with something like 'accepted' and send
> the job to a queue (you can use celery)
>
> On Mon, Feb 1, 2016 at 6:51 AM, Mario R. Osorio 
> wrote:
>
>> I need comments on an application I have been recently proposed. The way
>> it is being envisioned at this moment is this:
>>
>>
>> One python daemon will be listening for different communications media
>> such as email, web and SMS (web also). IMHO, it is necessary to have a
>> daemon per each media. This daemon(s) will only make sure the messages are
>> received from a validated source and put such messages in a DB
>>
>>
>> A second(?) python daemon would be waiting for those messages to be in
>> the DB, process them, act accordingly to the objective of the application,
>> and update the DB as expected. This process(es) might included complicated
>> and numerous mathematical calculations, which might take seconds and even
>> minutes to process.
>>
>>
>> A third(?) python daemon would be in charge of replying to the original
>> message with the obtained results, but there might be other media channels
>> involved, eg the message was received from a given email or SMS user, but
>> the results have to be sent to multiple other email/SMS users.
>>
>>
>> The reason I want to do the application using Django is that all this HAS
>> to have multiple web interfaces and, at the end of the day most media will
>> come through web, and have to be processed as http requests. Also, Django
>> gives me a frame to make this work better organized and clean and I can
>> make the application(s) DB agnostic.
>>
>>
>> Wanting the application to be DB agnostic does not mean that I don't have
>> a choice: I know I have many options to communicate among different python
>> processes, but I prefer to leave that to the DBMS. Of the open source DBMS
>> I know of, only Firebird and PostgreSQL have event that can provide the
>> communication between all the processes involved. I was able to create a
>> very similar application in 2012 with Firebird, but this time I am being
>> restricted to PostgreSQL, which I don't to oppose at all. That application
>> did not involve http requests.
>>
>>
>> My biggest concern at this point is this:
>>
>> If most (if not all) requests to the application are going 

Re: Debugging Django with Debug set to False

2016-01-04 Thread Bill Freeman
You don't say what your front end is.  There are ways to use pdb with
apache, look for advise on the modwsgi site.

But if you are in production, rather than just bringing up the instance
that will be production, you may not want to interrupt.

Be sure that you can't reproduce the problem in the development server.
You can get debug turned off htere.

In the hard cases you need to increasing logging in the suspect code,
whether by use of Django's logging or by writing to a file with explicit
code.  Then you insert things in code that should have been reached, log
variables, including object attributes, that are interesting, and do a
binary search for the point where things differ from expectations.
(Actually, the first few logs, or even the planning of their placement,
will focus your attention sufficiently to see where the code doesn't meet
the design.)

On Mon, Jan 4, 2016 at 12:33 PM, Web Architect  wrote:

> Hi,
>
> Is there a way to debug Django when DEBUG is set to False in settings.py
> (for example on production)?
>
> The reason for asking the above is if we face any issue with DEBUG set to
> False and if we need to debug.
>
> We are new to Django and we are building an ecommerce platform based on
> Django.
>
> Would appreciate if anyone could help with the above?
>
> 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/c4f16aba-f0e0-4aae-a6c0-1513571c7a97%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Scanning for Wifi

2015-12-28 Thread Bill Freeman
Yes, though there probably isn't a slick app for the PC to do it.

You would have a web server running on the Pi, maybe Django, that displays
the available wireless networks.  You would want a button to re-scan.  This
works by trigering a shell command to run iwlist (or whatever the current
tool is), which would dump the results of the last scan in a file that the
web-server reads when composing the page (probably a RAM disk file on the
Pi, rather than consuming Flash write cycles).  The page would have
JavaScript to reload occasionally (or, of course, on demand) or use AJAX so
that you can see things picked up recently.  Clicking one of the listed
items (you would probably also want a text field to enter SSID for hidden
interfaces) would open a text field that lets you enter WPA or WEP key, for
SSIDs that are secured.  (Probably this is just JavaScript unhiding it - no
need to go to a new page.)  When you submit, Django spawns iwconfig or
equivalent to connect the interface.  You probably also want a disconnect
button, and maybe a reconnect button (using saved key so that you don't
have to re-enter it - you could get fancy by remembering keys for SSIDs
that you've connected to before).

It's probably safe enough to let anyone see the list, but the connect,
disconnect, any reconnect, and maybe even the rescan buttons should require
that you have logged in to Django with a password.  The default
configuration should be to only be accessible from the wired interface,
though I guess there is some value in being able to disconnect from the
WiFi connection.

Of course, Pis come with wired ethernet, but I believe that even the B+
still doesn't come with WiFi, so you will need a USB WiFi dongle.

On Mon, Dec 28, 2015 at 8:26 AM, Andrew Stringfield 
wrote:

> Hello all,
>
>I saw a really cool feature that D-link wireless cameras have.
> First you physically hook up the camera to the LAN and then access the
> camera via web interface.  While on the web interface you can scan for your
> wireless network and connect the camera, wirelessly, to your network.  That
> is what I would like to do with my Django project.  Is this possible?
>
> The host OS is Raspbian on Raspberry Pi B+.
>
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f74a348d-8f4d-4f98-8bea-33fe74c1c706%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Tests not passing in suite but pass individually

2015-12-02 Thread Bill Freeman
Did you see some documentation that said that the test framework will clear
the database?

I'm not sure that it's reasonable to ask a test framework to do that, given
the number of possible databases and interface layers, though it is
conceivable that django's variation on test could take care of this for the
ORM.

Still, explicit is better than implicit.

A common way to clean up, by the way, is to start a transaction in setUp()
and do a rollback in tearDown().

On Wed, Dec 2, 2015 at 11:21 AM, Siddhi Divekar 
wrote:

> Hi Ke1g,
> That is the last option but
> wanted to understand why database was not cleaned after first test.
>
> On Wednesday, December 2, 2015 at 7:56:26 AM UTC-8, ke1g wrote:
>>
>> Make test b clean up after itself, by deleting the test object.
>>
>> On Wed, Dec 2, 2015 at 9:28 AM, Tim Graham  wrote:
>>
>>> It will be easier to help if you can provide a sample project that
>>> reproduces the error.
>>>
>>> On Wednesday, December 2, 2015 at 3:01:31 AM UTC-5, Siddhi Divekar wrote:

 Hi,

 Am seeing that test case in suite are failing but passing when ran
 individually.
 I have gone through most of the thread on the internet but did not find
 any solution.

 Below is the snip of what am trying to do.

 class A(TestCase):
   def test_a():
create an obj in db
retrive obj list from db and check the length of the list (should be
 1)
update same obj in db
delte same obj in db

  def b():
   create an obj in db and check the length.

 When ran in suite test_a fails as the length of the list is 2.
 test_b() runs before test_a and leave the object in the database.

 From various threads suggested using 'django.test import TestCase'
 instead of 'from django.unittest import TestCase' which am already
 doing.

 Is there anything else i need to do here ?

>>> --
>>> 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 http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/f8ad70a1-4abf-406b-8668-a6d860a868bb%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fd9cfc5e-5c1c-450f-a91a-5cce46a9f6fd%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Tests not passing in suite but pass individually

2015-12-02 Thread Bill Freeman
Make test b clean up after itself, by deleting the test object.

On Wed, Dec 2, 2015 at 9:28 AM, Tim Graham  wrote:

> It will be easier to help if you can provide a sample project that
> reproduces the error.
>
> On Wednesday, December 2, 2015 at 3:01:31 AM UTC-5, Siddhi Divekar wrote:
>>
>> Hi,
>>
>> Am seeing that test case in suite are failing but passing when ran
>> individually.
>> I have gone through most of the thread on the internet but did not find
>> any solution.
>>
>> Below is the snip of what am trying to do.
>>
>> class A(TestCase):
>>   def test_a():
>>create an obj in db
>>retrive obj list from db and check the length of the list (should be 1)
>>update same obj in db
>>delte same obj in db
>>
>>  def b():
>>   create an obj in db and check the length.
>>
>> When ran in suite test_a fails as the length of the list is 2.
>> test_b() runs before test_a and leave the object in the database.
>>
>> From various threads suggested using 'django.test import TestCase'
>> instead of 'from django.unittest import TestCase' which am already doing.
>>
>> Is there anything else i need to do here ?
>>
> --
> 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/f8ad70a1-4abf-406b-8668-a6d860a868bb%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: custom setting provided by myapp

2015-09-23 Thread Bill Freeman
If you have a system based on Django (some CMS for example), rather than an
app for folks to add to a site that has a lot of unrelated stuff, then
sure, generate one, but don't replace one that may have hours of
customization work into it.  Let the site owner/tech do the merging.  If
there are no settings when you install, then, yes, you could create the
active settings file.  But you might find that difficult as Django versions
change, or if you are going to allow it to work with the user's choice of
Django version.  One possible approach is to read in the existing settings,
see what it doesn't have that you need, and produce a file that the main
settings file could import * from.

On Wed, Sep 23, 2015 at 5:12 PM, Luis Zárate <luisz...@gmail.com> wrote:

> Hi,
>
> Sure, but why not auto-generate the setting file?, for example I know
> various CMS than have an installer that provide a custom setting with
> auto-generate configuration file (I don't know how to do that).
>
> Other idea is that my app can add configuration if is not set explicitly,
> so the user have the possibility to change whatever he want and my app only
> guarantee that run well most of time.
>
> 2015-09-23 12:10 GMT-06:00 Bill Freeman <ke1g...@gmail.com>:
>
>> I would be upset to find an app that I installed fiddling with my project
>> settings.
>>
>> On Wed, Sep 23, 2015 at 12:53 PM, Luis Zárate <luisz...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> l have an app than need other apps to run well, I create a requirements
>>> file and setup file and insert the required apps in my settings, also
>>> include my custom configurations.
>>>
>>> I want to build the settings file automatically (with installer script)
>>> or when the user put my app in his installed_apps automatically update the
>>> project settings with my custom apps settings.
>>>
>>> So what is the best approach for do that.
>>>
>>>
>>>
>>> --
>>> "La utopía sirve para caminar" Fernando Birri
>>>
>>>
>>>
>>> --
>>> 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/CAG%2B5VyMutG68Dh2MuC1h7-uL%3DRzw6Y9v7RM33k5WN8qH-i3VAQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAG%2B5VyMutG68Dh2MuC1h7-uL%3DRzw6Y9v7RM33k5WN8qH-i3VAQ%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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAB%2BAj0s%3Det%2B7%2BvHVcGGz%2BAkbQNWykHoMqzX6gO-XxxRTE0xmLQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAB%2BAj0s%3Det%2B7%2BvHVcGGz%2BAkbQNWykHoMqzX6gO-XxxRTE0xmLQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> 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/CAG%2B5VyMX_YcXaJuyNQi%2BQhfv7cepG5t4WXVnWM3eoyzyf5rV8w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAG%2B5VyMX_YcXaJuyNQi%2BQhfv7cepG5t4WXVnWM3eoyzyf5rV8w%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0sDU80C3hPEr7YLyTE-LbtdjVuptn%2BTBBGq1eN0hMqZ%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django admin suitable for external users?

2015-09-23 Thread Bill Freeman
How technical are your users?
What are your security constraints?
How much work can you do to make it "pretty"?  (Believe me, someone will
ask.)
Are there fields that you want to administer internally but don't want to
expose to the users?
Will your users object if you decide to move to a newer Django version and
the interface changes/

You can make it work, but in many instances it will save you less effort
than you though (might even be harder).

A few custom views are pretty easy to roll out.

On Wed, Sep 23, 2015 at 4:00 PM, Joshua Pokotilow 
wrote:

> Hello! I just had a fairly lengthy conversation with my colleagues about
> whether or not Django admin is well-suited to external users outside our
> company. I took the position that for certain use-cases, exposing Django
> admin to third parties makes a lot of sense, given that the admin
> application has all kinds of features baked in that are well-suited to
> certain admin tasks (ACL, customizable templates, dynamically built CRUD
> forms, etc.). Unfortunately, I met with a lot of resistance on account of
> fears over ease of customizability, security, and technology lock-in.
> Furthermore, there was some concern that exposing Django admin to
> third-parties might send us off the beaten path, and that doing so could be
> an antipattern.
>
> I would appreciate knowing how other developers feel on this subject, and
> would love to hear about how some larger companies that use Django
> (Instagram, Disqus) think things through.
>
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/59231ea7-4bd1-41c2-97ef-f294a380bcb4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: custom setting provided by myapp

2015-09-23 Thread Bill Freeman
I would be upset to find an app that I installed fiddling with my project
settings.

On Wed, Sep 23, 2015 at 12:53 PM, Luis Zárate  wrote:

> Hi,
>
> l have an app than need other apps to run well, I create a requirements
> file and setup file and insert the required apps in my settings, also
> include my custom configurations.
>
> I want to build the settings file automatically (with installer script) or
> when the user put my app in his installed_apps automatically update the
> project settings with my custom apps settings.
>
> So what is the best approach for do that.
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
>
> --
> 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/CAG%2B5VyMutG68Dh2MuC1h7-uL%3DRzw6Y9v7RM33k5WN8qH-i3VAQ%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0s%3Det%2B7%2BvHVcGGz%2BAkbQNWykHoMqzX6gO-XxxRTE0xmLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Entry.objects.filter(pub_date__month=7) doesn't work with Django 1.8

2015-09-22 Thread Bill Freeman
What does the following say?

   Entry.objects.filter(pub_date__year=2015)[0].pub_date.month

If it says 7, then its time to delve into the generated SQL for the month
query.

On Tue, Sep 22, 2015 at 10:52 AM, lxm  wrote:

> I create a class named Entry,like this:
>
>> class Entry(models.Model):
>
> pub_date = models.DateTimeField()
>>
> this data table named Entry have one record:
>
>- pub_date = '2015-7-14 xx:xx:xx'
>
> then,I excute 'Entry.objects.filter(pub_date__year=2015)' in shell,this
> will return right result,
> but when I excute 'Entry.objects.filter(pub_date__month=7)',this return
> empty list.
>
> --
> 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/b29a0450-f0c6-421a-be33-770338f5965d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Why should I care to use YAML with Django?

2015-08-17 Thread Bill Freeman
One interesting feature of YAML is the ability to have custom operators.
For example, with YAML used as a fixture, you might have an operator that
turns a hex string into a MongoDB ObjectId on read, or a date string into a
datetime object, meaning that you don't have to post process the data
read.  Other serializers can obviously be extended as well, but it seems to
have been well provided for in YAML (at least in  PyYAML).

On Sun, Aug 16, 2015 at 2:44 AM, James Schneider 
wrote:

> Probably for the same reasons you might use XML, CSV, or JSON; data
> exchange and serialization between systems. YAML is just another
> standardized way to encapsulate data structures so that they can be passed
> between systems or statically archived consistently.
>
> You could also not care at all if you have no data requirements on other
> systems that use YAML.
>
> Without more context, though, there isn't really a proper way to answer
> your question.
>
> -James
> On Aug 15, 2015 9:10 PM, "Joshua Ellis"  wrote:
>
>> What purpose does it have? What kind of problem am I bound to solve in
>> using it?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/3fc97528-4f61-42b4-91c0-ef6f02e2e800%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWrdFi_KuYgpb0EJug1Fw_PTWEZE34XF0%2BRgHAejfCoeA%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0ucJHTojaO9LPWAjSwm8e%2Bk%2BzFDh_2LEnL%3D3qv8iDPtaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Writing a “circuit breaker” for use in Django

2015-08-10 Thread Bill Freeman
If you have your heart set on a circuit breaker pattern (patterns are
overrated, see http://www.paulgraham.com/icad.html), consider implementing
it in the client.

If you need a long poll solution, note that you can serve some urls from
uwsgi/Django and others from tornado or twisted.

If you are willing to actually poll, the result of a backend service
failing should be a 500 or maybe 400 or 300, series return code -- not
having the Django request wait.  One that your client will interpret as try
later: you can include a suggested wait time in the response.

You can keep it all in Django, but you are unlikely to find examples, since
most folks would have done it one of the other ways, so you are breaking
new ground on your own.  (I'm hoping to bee shown to be wrong by someone
who has implemented such a long poll solution, and who is free to talk
about it.)

On Mon, Aug 10, 2015 at 1:43 PM, Avraham Serour  wrote:

> > 1. What’s the most global, persisting, shared-across-requests type of
> data I can read & write to memory?
> Don't complicate your life, just store data in the database
>
> > 2. However I can do this, does this require using `threading.Lock()`?
> (looking around `dispatch.Signal` I see some use of it)
> If you use the ORM you won't need any of this, you can have many processes
> even on different machines
>
> > 3. If this data is shared per-process, what’s a good way to see how
> many processes it would be (for uwsgi is that just the # of worker
> processes)?
> Of course you can, the question is why? Each request should be isolated
> and it shouldn't make a difference on how many workers you have
>
> As per design, maybe you want an asynchronous processing, meaning the web
> request would just register that a request to calculate something was made,
> send the request to the jobs queue and return saying the request was
> received please come back later
>
> you can use celery for this, there are others but it is fairly popular
>
>
> On Mon, Aug 10, 2015 at 8:24 PM, Peter Coles 
> wrote:
>
>> Thank you for your input. I appreciate you trying to steer my away from
>> potentially terrible design, however, I am still interested in someone
>> addressing my main questions. Some level of service calls is inevitable in
>> any interesting web application—even a call to an in-memory cache, like
>> Redis or Memcached, counts as a service call that could fail (a truly
>> resilient web-site would not fall over if the cache disappeared from DNS
>> for 10 minutes). In fact one of the examples I linked to was a circuit
>> breaker for memcached.
>>
>> I could leverage something like the local memory cache
>>  to
>> store this very light-weight information for a service client (which maybe
>> would off-set that disclaimer in the docs about not using it in production)
>> or as seen in the other examples, try something like storing values on a
>> “global” class object or instance. I was curious if anyone who has worked
>> with stuff like this in Django might have some pointers. Maybe Django
>> Developers would be a better forum?
>>
>> My original questions:
>>
>>1. What’s the most global, persisting, shared-across-requests type of
>>data I can read & write to memory?
>>2. However I can do this, does this require using `threading.Lock()`?
>>(looking around `dispatch.Signal` I see some use of it)
>>3. If this data is shared per-process, what’s a good way to see how
>>many processes it would be (for uwsgi is that just the # of worker
>>processes)?
>>
>>
>>
>>
>> On Monday, August 10, 2015 at 12:59:19 PM UTC-4, ke1g wrote:
>>>
>>> In Django, requests should not wait, since the threads are relatively
>>> heavyweight in python, and need to be a limited resource.  The alternative
>>> is a large number of processes, which is also expensive.
>>>
>>> So you must design a scheme in which the client polls for a result,
>>> meaning that you cannot expect it to be handled by the same process, let
>>> alone thread.  So the success of a response (and its data) must be stored
>>> in a resource shared across processes and threads.  Most obviously, this is
>>> you database, whether by and ORM Model, or (if small enough) in session
>>> data.  But it is also possible to use a secondary, in RAM store, such as
>>> redis, or maybe memcached (or an ad hoc separate process, by why reinvent
>>> the wheel?).
>>>
>>> An alternative is to have these requests handled by something that does
>>> well with Websockets, such as tornado.  (Django may have work toward
>>> Websocket support, but I'm not aware of anything satisfying.)
>>>
>>> Or, in the non-browser case of the client being able to provide a
>>> response endpoint, a Celery task could retry, and wen successful could POST
>>> to that endpoint.
>>>
>>> Doing Websockets or long poll type interactions isn't what Django is
>>> designed to do well.  

Re: Writing a “circuit breaker” for use in Django

2015-08-10 Thread Bill Freeman
In Django, requests should not wait, since the threads are relatively
heavyweight in python, and need to be a limited resource.  The alternative
is a large number of processes, which is also expensive.

So you must design a scheme in which the client polls for a result, meaning
that you cannot expect it to be handled by the same process, let alone
thread.  So the success of a response (and its data) must be stored in a
resource shared across processes and threads.  Most obviously, this is you
database, whether by and ORM Model, or (if small enough) in session data.
But it is also possible to use a secondary, in RAM store, such as redis, or
maybe memcached (or an ad hoc separate process, by why reinvent the wheel?).

An alternative is to have these requests handled by something that does
well with Websockets, such as tornado.  (Django may have work toward
Websocket support, but I'm not aware of anything satisfying.)

Or, in the non-browser case of the client being able to provide a response
endpoint, a Celery task could retry, and wen successful could POST to that
endpoint.

Doing Websockets or long poll type interactions isn't what Django is
designed to do well.  Some machinations are appropriate if most of what you
have to do fits Django, but if all you need to do is drive a screw, don't
waste time filing a blade onto the face of a hammer.

On Fri, Aug 7, 2015 at 5:54 PM, Peter Coles  wrote:

> I’d like to write a circuit breaker wrapper to use with services that I
> call from inside a Django app, and I’d like to get some pointers on the
> following questions:
>
>1. What’s the most global, persisting, shared-across-requests type of
>data I can read & write to memory?
>2. However I can do this, does this require using `threading.Lock()`?
>(looking around `dispatch.Signal` I see some use of it)
>3. If this data is shared per-process, what’s a good way to see how
>many processes it would be (for uwsgi is that just the # of worker
>processes)?
>
> The term “circuit breaker” is referring to service clients that cut
> themselves off from making future requests to a service after the service
> has failed to connect or read/write after a certain error threshold. They
> can employ retries to eventually right themselves. If a service continues
> to fail, even despite strict timeouts, it can significantly slow down a
> site or even cause the webserver to run out of threads and it will
> effectively reach a DoS scenario. The clients are per-webserver (or maybe
> in this case, per-process) and all independently can open or close their
> “circuits” based on what they’re experiencing.
>
> To effectively track the effectiveness of service calls without having a
> performance impact on the webserver, it really needs to store this info in
> memory—which is the source of my original questions—and I assume this means
> I’m stuck with only info per-process? I’m OK with the info disappearing
> after server restarts, but might there be some gotchas around other
> configurations, like the `--harakiri` option for uwsgi? As stated above,
> I’m also a little unclear on when using threading locks would be required
> vs not, given that python uses the GIL—but maybe certain configurations do
> allow for non-thread-safe things to happen?
>
> I found 2 barebones approaches on github, but the
> correctness/effectiveness of each was quite unclear:
>
>-
>
> https://github.com/cuker/django-patchboard/blob/master/patchboard/circuitbreaker.py
>-
>
> https://github.com/globocom/memcached_memoize/blob/master/memcached_memoize/decorators/circuit_breaker.py
>
> Any help would be appreciated—whatever I build for this would definitely
> be open-sourced to the community!
>
> --
> 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/35f791f2-d857-44de-a9e7-e52e346728b9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 

Re: What Did I Do Right? (url and domain name change)

2015-08-06 Thread Bill Freeman
Look at "Sites" in the admin.

On Thu, Aug 6, 2015 at 5:03 PM, Malik Rumi  wrote:

> I have 1 model from my django project up and running on django. Before
> adding more models and content, I wanted to use my actual domain name,
> instead of whatever.herokuapp.com. So after I got that straight, I
> realized that while the home page was mysite.com, the links were still
> mystite.herokuapp.com, which I think is a problem. But I also thought
> there had to be an easy fix for this, especially after I saw a post while I
> was searching for solutions that said django only cares about the stuff
> that comes *after* the domain name. So the first thing I did was change a
> hardcoded link in my navbar from mysite.herokuapp/newpage to mysite/newpage
> in my dev site. But testing it the url still said
> mysite.herokuapp.com/newpage. Then I got an idea, and I just manually
> changed the url to mysite/newpage and what do you know, it came up
> correctly. then I clicked around and suddenly all the pages on my model are
> coming up that way, which they were not half an hour ago. So the question:
> What did I do right?
>
> Here are my working theories:
>
> 1. The dns change, which I also did half an hour ago, worked for the home
> page immediately (I tested it at the time) but needed to propagate more for
> the other pages to work, which they do now.
>
> 2. By changing the url manually, django just fed the pages as requested
> without concern about the domain part of the url. If I start from
> mysite.herokuapp.com home page, the links still come up with that domain
> name.
>
> But how do I make this both universal and permanent?
>
> A. I could change allowed hosts setting, taking the herokuapp part out
>
> B. Do nothing, it works now and I should leave well enough alone.
>
> C. ? Your answer here ...
>
>
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3ded9a89-b20f-489d-aadb-667ab62fdb53%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Need Django Help Again.

2015-07-22 Thread Bill Freeman
Unless it has changed, the tutorial at docs.djangoproject.com shows
creation of an app, use of templates, forms, etc.  All the building blocks
for the back end (which is what django is).  Those are the skills that have
been the base of several sites that I've built.  If your site wants to have
other features, like text search, or social auth, or blogs, or shopping
carts, there are add on apps for those things that you can find with
google, and which typically have reasonable example usage in their
documentation.  (That's not to say that you won't choose home grown over
some of them, if you needs are a bit different.)

The real trick is knowing what you want to do.  A toy site that you create
as a "learning exercise" is probably going to feel like a toy (like those
things they have you write in a collage level CS class).  If you have
something that you want to put before the world, you will figure out how to
make it feel sharper.  Having a real project in mind is, as always, the
hard part.

And, as mentioned, django is just the server side.  You need to understand
HTML, CSS, and, probably JavaScript and some of its frameworks, like jQuery
or D3.  Unless your project is non-browser, in which case you need to
understand HTTP anyway, and maybe Rest, and probably still HTML (since
that's what the request chain expects.

So, I'd suggest finishing the official tutorial, if you haven't already.
Then look at some add-ons like a blog, a CMS, or a shopping cart, mostly to
see how to add a third party app and configure it.  Then perhaps you'll
have though of something that you want to build for yourself.

On Wed, Jul 22, 2015 at 3:07 PM, Steve Burrus <steveburru...@gmail.com>
wrote:

> say do yoiu know of a handy series of tutorials I can use to actually do
> something in Django beyond merely connecting to the server and maybe
> configuring the admin? I am getting tired of just connecting to the server
> and then "calling it a day" if you know what I mean.
>
>
>
> On Wed, Jul 22, 2015 at 1:20 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>> That's actually a virtualenv mistake, rather than a django mistake.
>> Whenever things don't behave in a VE try "pip freeze" to see if things are
>> as you expect.
>>
>> On Wed, Jul 22, 2015 at 1:16 PM, Steve Burrus <steveburru...@gmail.com>
>> wrote:
>>
>>> *Okay it's a case of "my bad". I got it gpoing. I had just forgotten to
>>> do this command : "pip install django" in the "burrus" virtual environment
>>> inst ance! I still have the shakiest knowledge of django in general so
>>> little mistakes like this I am gonna have a little while longer.*
>>>
>>>
>>> *On Wed, Jul 22, 2015 at 12:03 PM, Bill Freeman <ke1g...@gmail.com
>>> <ke1g...@gmail.com>> wrote:*
>>>
>>>>
>>>> *I presume that you have actually checked for a django-admin.py file in
>>>> the Scripts directory?*
>>>>
>>>>
>>>> *On Wed, Jul 22, 2015 at 12:58 PM, Steve Burrus
>>>> <steveburru...@gmail.com <steveburru...@gmail.com>> wrote:*
>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>> *well I haVE tried both this "python .\Scripts\django-admin.py
>>>>> startproject me" and Bill's suggestion opf  "python django-admin.py
>>>>> startproject me" but both haVE failed! I'll try Bill's other suggestion of
>>>>> the forward slashes but I doubt it will work.On Wed, Jul 22, 2015 at 11:51
>>>>> AM, Steve Burrus <steveburru...@gmail.com <steveburru...@gmail.com>>
>>>>> wrote:well tom tjhanx for your  attempted help but it still didn't work
>>>>> after I took care of that space after "\Scripts\"!  here is my error
>>>>> message now : "python: can't open file '.\Scripts\django-admin.py': [Errno
>>>>> 2] No such file or directory".On Wed, Jul 22, 2015 at 11:34 AM, Tom
>>>>> Lockhart <tlockhart1...@gmail.com <tlockhart1...@gmail.com>> wrote:On Jul
>>>>> 22, 2015, at 09:11, Steve Burrus <steveburru...@gmail.com
>>&

Re: Need Django Help Again.

2015-07-22 Thread Bill Freeman
That's actually a virtualenv mistake, rather than a django mistake.
Whenever things don't behave in a VE try "pip freeze" to see if things are
as you expect.

On Wed, Jul 22, 2015 at 1:16 PM, Steve Burrus <steveburru...@gmail.com>
wrote:

> *Okay it's a case of "my bad". I got it gpoing. I had just forgotten to do
> this command : "pip install django" in the "burrus" virtual environment
> inst ance! I still have the shakiest knowledge of django in general so
> little mistakes like this I am gonna have a little while longer.*
>
>
> *On Wed, Jul 22, 2015 at 12:03 PM, Bill Freeman <ke1g...@gmail.com
> <ke1g...@gmail.com>> wrote:*
>
>>
>> *I presume that you have actually checked for a django-admin.py file in
>> the Scripts directory?*
>>
>>
>> *On Wed, Jul 22, 2015 at 12:58 PM, Steve Burrus <steveburru...@gmail.com
>> <steveburru...@gmail.com>> wrote:*
>>
>>>
>>>
>>>
>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>> *well I haVE tried both this "python .\Scripts\django-admin.py
>>> startproject me" and Bill's suggestion opf  "python django-admin.py
>>> startproject me" but both haVE failed! I'll try Bill's other suggestion of
>>> the forward slashes but I doubt it will work.On Wed, Jul 22, 2015 at 11:51
>>> AM, Steve Burrus <steveburru...@gmail.com <steveburru...@gmail.com>>
>>> wrote:well tom tjhanx for your  attempted help but it still didn't work
>>> after I took care of that space after "\Scripts\"!  here is my error
>>> message now : "python: can't open file '.\Scripts\django-admin.py': [Errno
>>> 2] No such file or directory".On Wed, Jul 22, 2015 at 11:34 AM, Tom
>>> Lockhart <tlockhart1...@gmail.com <tlockhart1...@gmail.com>> wrote:On Jul
>>> 22, 2015, at 09:11, Steve Burrus <steveburru...@gmail.com
>>> <steveburru...@gmail.com>> wrote:I find myself in ned of help yet again w.
>>> django. Just to say parenthetically I have had this problem before. just
>>> what am I doing wrong with the command "python .\Scripts\ django-admin.py
>>> startproject me" to consistently get this error message! Thanx to anyone
>>> who helps me.   "C:\Users\SteveB\Desktop\burrus>.\Scripts\activate(burrus)
>>> C:\Users\SteveB\Desktop\burrus>python .\Scripts\ django-admin.py
>>> startproject meC:\Users\SteveB\Desktop\burrus\Scripts\python.exe: can't
>>> find '__main__' module in '.\\Scripts\\’"You seem to have a space after the
>>> “\Scripts\”.hth- Tom -- 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/uxHvoccBiZc/unsubscribe
>>> <https://groups.google.com/d/topic/django-users/uxHvoccBiZc/unsubscribe>.
>>> To unsubscribe from this group and all its topics, send an email to
>>> django-users+unsubscr...@googlegroups.com
>>> <django-users+unsubscr...@googlegroups.com>. To post to this group, send
>>> email to django-users@googlegroups.com <django-users@googlegroups.com>.
>>> Visit this group at http://groups.google.com/group/django-users
>>> <http://groups.google.com/group/django-users>. To view this discussion on
>>> the web visit
>>> https://groups.google.com/d/msgid/django-users/9F05E056-A548-4EE4-89AE-0F3F14876503%40gmail.com
>>> <https://groups.google.com/d/msgid/django-users/9F05E056-A548-4EE4-89AE-0F3F14876503%40gmail.com?utm_medium=email_source=footer>.
>>> For more options, visit https://groups.google.com/d/optout
>>> <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
>>> <django-users+unsubscr...@googlegroups.com>. To post to this group, send
>>> email to django-users@googlegroups.com <django-users@googlegroups.com>

Re: Need Django Help Again.

2015-07-22 Thread Bill Freeman
I presume that you have actually checked for a django-admin.py file in the
Scripts directory?

On Wed, Jul 22, 2015 at 12:58 PM, Steve Burrus 
wrote:

>
> *well I haVE tried both this "python .\Scripts\django-admin.py
> startproject me" and Bill's suggestion opf  "python django-admin.py
> startproject me" but both haVE failed! I'll try Bill's other suggestion of
> the forward slashes but I doubt it will work.*
>
>
> *On Wed, Jul 22, 2015 at 11:51 AM, Steve Burrus  > wrote:*
>>
>> *well tom tjhanx for your  attempted help but it still didn't work after
>> I took care of that space after "\Scripts\"!  here is my error message now
>> : "python: can't open file '.\Scripts\django-admin.py': [Errno 2] No such
>> file or directory".*
>>
>>
>> *On Wed, Jul 22, 2015 at 11:34 AM, Tom Lockhart > > wrote:*
>>>
>>>
>>>
>>> *On Jul 22, 2015, at 09:11, Steve Burrus >> > wrote:*
>>> *I find myself in ned of help yet again w. django. Just to say
>>> parenthetically I have had this problem before. just what am I doing wrong
>>> with the command "**python .\Scripts\ django-admin.py startproject me"
>>> to consistently get this error message! Thanx to anyone who helps me. *
>>>
>>>
>>> *"C:\Users\SteveB\Desktop\burrus>.\Scripts\activate*
>>> *(burrus) C:\Users\SteveB\Desktop\burrus>python .\Scripts\
>>> django-admin.py startproject me*
>>> *C:\Users\SteveB\Desktop\burrus\Scripts\python.exe: can't find
>>> '__main__' module in '.\\Scripts\\’"*
>>>
>>>
>>> *You seem to have a space after the “\Scripts\”.*
>>>
>>> *hth*
>>>
>>> *- Tom*
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> * -- 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/uxHvoccBiZc/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 http://groups.google.com/group/django-users
>>> . To view this discussion on
>>> the web visit
>>> https://groups.google.com/d/msgid/django-users/9F05E056-A548-4EE4-89AE-0F3F14876503%40gmail.com
>>> .*
>>>
>>>
>>> * For more options, visit https://groups.google.com/d/optout
>>> . *
>>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABcoaSDY2f0hibB-i-KXd1s5eQvQPHk9cARORmzPMxffUbwUtg%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0sZm-wafWQ2CDhMRSrFKTu4KpWK82BrXBk-g8pGFde_MQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Find Django Source Files

2015-07-22 Thread Bill Freeman
Note that this is a limitation of you shell.  (I presume that you are using
cmd.exe.)  On linux in bash the tutorial version works fine.

You are likely to find a number of things that are different from the
experience of the document writers if you are using Windows.

On Wed, Jul 22, 2015 at 12:46 PM,  wrote:

> In Windows, where are the Django source files located?
>
> In the 2nd section of the Django tutorial (
> docs.djangoproject.com/en/1.8/intro/tutorial02/)  we find this:
>
> If you have difficulty finding where the Django source files are
> located on your system, run the following command:
>
>  $ python -c " import sys sys.path = sys.path[1:] import 
> django print(django.__path__)"
>
>
> Entering the above as written (separate lines) fails.  Entering everything
> on a single line fails.  So I did this at the DOS prompt:
>
>   python manage.py shell
>
>   >>>import sys
>
>   >>>sys.path = sys.path[1:]
>   >>>import django
>   >>>print(django.__path__)
>
> which returned:  ['C:\\Python34\\Lib\site-packages\\django']
>
> Q: How do inform the authors of the tutorial that something may need editing?
>
>  --
> 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/4862668e-25a9-418f-9baf-bab9e6a66edd%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Need Django Help Again.

2015-07-22 Thread Bill Freeman
Try no space between ".\Scripts\" and "django-admin.py"

You could also try forward slashes on the django-admin.py line (I think
that you need the back slashes on the activate line).

And I don't think that you need the ".\" on the django-admin.py line.

And, if that activate is activating a virtualenv (as the "(burrus)" might
seem to imply), then you might be able to just do:

python django-admin.py startproject me

(but I'm not that familiar with virtualenv on Windows.  On *nix it's all
about path modification, so the django-admin.py might just be found.)

Also worth trying is:

   django-admin.py startproject me

Perhaps someone who actually uses Windows for django development could
chime in?

On Wed, Jul 22, 2015 at 12:11 PM, Steve Burrus 
wrote:

> *I find myself in ned of help yet again w. django. Just to say
> parenthetically I have had this problem before. just what am I doing wrong
> with the command "**python .\Scripts\ django-admin.py startproject me" to
> consistently get this error message! Thanx to anyone who helps me. *
>
> *"C:\Users\SteveB\Desktop\burrus>.\Scripts\activate*
> *(burrus) C:\Users\SteveB\Desktop\burrus>python .\Scripts\ django-admin.py
> startproject me*
> *C:\Users\SteveB\Desktop\burrus\Scripts\python.exe: can't find '__main__'
> module in '.\\Scripts\\'"*
>
> --
> 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/98551cf6-475c-41f9-b7a1-1ce5eecc30ce%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Match multiple URLs to the same pattern

2015-07-14 Thread Bill Freeman
You will want a routing view, or a fallback cascade.  In either case, make
that urlpattern r'^([\w-]+)$'.  You don't need to escape the - because it's
the last char in the class.  You don want to restrict the urls to those in
which the entire url matches (^ and $), and the parentheses capture the
string as a positional argument to the view.  Your view could then call sub
views, something like this:

def router(request, key):
try:
return model1_view(request, key)
except django.http.Http404:
pass
and as many more try blocks as you need.

Don't put the last sub view in a try lock so that if it's not found
anywhere, the 404 takes its natural course.

Each view can use the get_object_or_404() shortcut, or whatever floats your
boat.  It's just that they should raise Http404, rather than formatting the
404 response themselves and returning it

The sub views can be class based, so long as they raise Http404 for no such
key, or be function views

Doing the outer, routing view, as a class based view is probably less clear
(less explicit), and is left as an exercise for the student, if you really
want it.

On Tue, Jul 14, 2015 at 9:26 AM, Avraham Serour  wrote:

> What do you mean by flat URL structure?
>
> In any case you may have a controller called by the URL dispatcher that
> decides which view to use to process the request.
>
> No need to complicate on writing you own dispatcher replacement
>
> On Tue, Jul 14, 2015, 4:20 PM Mathew Byrne 
> wrote:
>
>> I have an application that requires a flat URL structure for multiple
>> different views.  The single route r"^[\w\-]+" should start by looking at
>> slugs for one Model class, and move onto a Category Model class if no match
>> is found, then a Vendor model class, and lastly down to the flatpages app.
>>
>> I'd like to separate all these models into separate views, but regular
>> django urlpatterns wont work here since only the first match is followed.
>>
>> What's the best way to implement this requirement?  Is there a way I can
>> create my own URL matcher and dispatch to a view based on custom logic?  Is
>> there a way to re-dispatch a request after the point at which a match was
>> made?
>>
>> Thanks,
>>
>> Mat
>>
>> --
>> 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/4124aceb-0572-4ee9-ad11-63eb71f71c01%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFWa6tKunbukyag%3DNkO%3D-E2c61vQErnRqjSgXjnuvO4h1MNgWA%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0tqarv1v7Cz4dnV_f62gex_DUCJOxfifmerkFVH5Y%2BaaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to save base64 string in Python django

2015-07-14 Thread Bill Freeman
You don't show where the 'Image' object comes from (in Image.open), so I
can't be specific, but here are some generalities:

"Incorrect padding" is probably a message from the base 64 decoder.
Capture your request.POST[photo] to play with separately.  If you are doing
this under the development server you can add a pdb.set_trace() to get a
prompt where you can play with things.  Alternatively, put the decode and
the StringIO creation in separate statements so the the line generating the
error will be clear.

Are you sure that the image is base 64?  If it's coming from a file field
in an HTML form, it probably isn't, which would explain the decode error
(it I'm correct and it is a decoder error).

It is customary to store images on the file system, putting only the path
to the file in the database, as part of a model instance. That way the
front end server (Apache or nginx, etc.) can serve the images without
involving python and the database..  There are image oriented model fields
available in django to facilitate this, see the excellent documentation.

If, for whatever reason, you must store the image in the database, you can
store it as a (binary) string.  If your image object makes the data
available as a string, there will be no need to pump it through a StringIO
object.

On Mon, Jul 13, 2015 at 7:40 AM, ywaghmare5203 
wrote:

> Hello all,
>
> I am trying to save base64 string string image to database but I am not
> able to store. I am beginner for python django language.
>
> I am following these steps:--
>
> from base64 import b64decode
> from django.core.files.base import ContentFile
> from time import time
> import cStringIO
> import base64
>
>
> pic = cStringIO.StringIO()
> image_string =
> cStringIO.StringIO(base64.b64decode(request.POST['photo']))
> image = Image.open(image_string)
> image.save(pic, image.format, quality = 100)
> pic.seek(0)
> return HttpResponse(pic, content_type='image/jpeg')
>
> but I have error
>
> TypeError: Incorrect padding
>
> Please help me for store the base64 image string in the database.
>
>
> Thanks & Regards,
>
> Yogesh Waghnare
>
> --
> 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/54b12c7e-e9b0-4a47-85ce-988c897bbd11%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Can't Start Project.

2015-07-02 Thread Bill Freeman
SQLite persists your data in a file on the filesystem.  You get to choose
the name in settings.py.

Using other databases requires additional configuration, including getting
them installed, installing a python adapter that django supports, creating
a database user with suitable permissions, and more.  There's lots of fine
documentation on line at docs.djangoproject.com and elsewhere, and I'm not
going to attempt to duplicate it here.  Also, since I never run django (or
most things) anywhere but linux, I would probably run afoul of Windows nits
pretty quickly.

On Wed, Jul 1, 2015 at 9:08 PM, Steve Burrus <steveburru...@gmail.com>
wrote:

> "As long as you're happy with the default file name." What exactly are you
> referring to Bill? The database settings? Say how dpo you synch either
> mysql or the postgres database server into django anyway? I really haven't
> figured out yet how to do that I am afraid.
>
>
>
> On Wed, Jul 1, 2015 at 5:51 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>> As long as you're happy with the default file name.
>>
>> On Wed, Jul 1, 2015 at 6:06 PM, Gergely Polonkai <gerg...@polonkai.eu>
>> wrote:
>>
>>> No, Django does that for you. You only have to worry about DB settings
>>> if you want something else like MySQL or Postgres.
>>> On 1 Jul 2015 23:40, "Bill Freeman" <ke1g...@gmail.com> wrote:
>>>
>>>> Yes.  syncdb should work, assuming that sqlite is available (I think
>>>> that it's built in in all the python 3.x versions), and assuming that you
>>>> have a correctly configured settings.py (startproject makes one, but you
>>>> will still have things to enter, such as data base configuration info (like
>>>> the file to use to back sqlite), or to edit, such as your timezone.
>>>>
>>>> On Wed, Jul 1, 2015 at 5:35 PM, Steve Burrus <steveburru...@gmail.com>
>>>> wrote:
>>>>
>>>>> no django was not installed so I did a quick "pip install django" and
>>>>> installed django 1.8.2 into my ins tance of virualenv and was [finally]
>>>>> able to connect to the django server. I assume trhat I can easily do the
>>>>> "python manage.py syncdb" to connect to the sqllite3 server?
>>>>>
>>>>>
>>>>> On Wed, Jul 1, 2015 at 3:58 PM, Bill Freeman <ke1g...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> It sounds like django isn't on your path.  If you are running in a
>>>>>> virtualenv, was django pip installed while running in that same 
>>>>>> environment?
>>>>>>
>>>>>> On Wed, Jul 1, 2015 at 4:26 PM, Steve Burrus <steveburru...@gmail.com
>>>>>> > wrote:
>>>>>>
>>>>>>> cd to the directory containing manage.py (the project directory),
>>>>>>> then: "python manage.py runserver" Yeah I just now did exact;ly that but
>>>>>>> STILL got the error message : "(steve)
>>>>>>> C:\Users\SteveB\Desktop\steve\src>python manage.py runserver Traceback
>>>>>>> (most recent call last):  File "manage.py", line 8, in  from
>>>>>>> django.core.management import execute_from_command_line ImportError:
>>>>>>> No module named django.core.management" I r enamed my newly created 
>>>>>>> project
>>>>>>> to "src".
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Jul 1, 2015 at 3:14 PM, Bill Freeman <ke1g...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> cd to the directory containing manage.py (the project directory),
>>>>>>>> then:
>>>>>>>>
>>>>>>>>   python manage.py runserver
>>>>>>>>
>>>>>>>> On Wed, Jul 1, 2015 at 2:04 PM, Steve Burrus <
>>>>>>>> steveburru...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> well I was able to create a new project earlier however I am now
>>>>>>>>> having trouble with starting the django ser ver. when I ran this 
>>>>>>>>> cpommand
>>>>>>>>> "python .\Scripts\django-admin.py runserver" I always get this error
>>>>>>>>> message : "python: can't open file '.\Scripts\django-admin.py': 
>>>>&

Re: Can't Start Project.

2015-07-01 Thread Bill Freeman
As long as you're happy with the default file name.

On Wed, Jul 1, 2015 at 6:06 PM, Gergely Polonkai <gerg...@polonkai.eu>
wrote:

> No, Django does that for you. You only have to worry about DB settings if
> you want something else like MySQL or Postgres.
> On 1 Jul 2015 23:40, "Bill Freeman" <ke1g...@gmail.com> wrote:
>
>> Yes.  syncdb should work, assuming that sqlite is available (I think that
>> it's built in in all the python 3.x versions), and assuming that you have a
>> correctly configured settings.py (startproject makes one, but you will
>> still have things to enter, such as data base configuration info (like the
>> file to use to back sqlite), or to edit, such as your timezone.
>>
>> On Wed, Jul 1, 2015 at 5:35 PM, Steve Burrus <steveburru...@gmail.com>
>> wrote:
>>
>>> no django was not installed so I did a quick "pip install django" and
>>> installed django 1.8.2 into my ins tance of virualenv and was [finally]
>>> able to connect to the django server. I assume trhat I can easily do the
>>> "python manage.py syncdb" to connect to the sqllite3 server?
>>>
>>>
>>> On Wed, Jul 1, 2015 at 3:58 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>>>
>>>> It sounds like django isn't on your path.  If you are running in a
>>>> virtualenv, was django pip installed while running in that same 
>>>> environment?
>>>>
>>>> On Wed, Jul 1, 2015 at 4:26 PM, Steve Burrus <steveburru...@gmail.com>
>>>> wrote:
>>>>
>>>>> cd to the directory containing manage.py (the project directory),
>>>>> then: "python manage.py runserver" Yeah I just now did exact;ly that but
>>>>> STILL got the error message : "(steve)
>>>>> C:\Users\SteveB\Desktop\steve\src>python manage.py runserver Traceback
>>>>> (most recent call last):  File "manage.py", line 8, in  from
>>>>> django.core.management import execute_from_command_line ImportError:
>>>>> No module named django.core.management" I r enamed my newly created 
>>>>> project
>>>>> to "src".
>>>>>
>>>>>
>>>>> On Wed, Jul 1, 2015 at 3:14 PM, Bill Freeman <ke1g...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> cd to the directory containing manage.py (the project directory),
>>>>>> then:
>>>>>>
>>>>>>   python manage.py runserver
>>>>>>
>>>>>> On Wed, Jul 1, 2015 at 2:04 PM, Steve Burrus <steveburru...@gmail.com
>>>>>> > wrote:
>>>>>>
>>>>>>> well I was able to create a new project earlier however I am now
>>>>>>> having trouble with starting the django ser ver. when I ran this 
>>>>>>> cpommand
>>>>>>> "python .\Scripts\django-admin.py runserver" I always get this error
>>>>>>> message : "python: can't open file '.\Scripts\django-admin.py': [Errno 
>>>>>>> 2]
>>>>>>> No such file or directory". What's going on for me to get this error?
>>>>>>>
>>>>>>> On Wednesday, July 1, 2015 at 10:27:14 AM UTC-5, Steve Burrus wrote:
>>>>>>>>
>>>>>>>> I need some help please with  tryiong to start a new Django
>>>>>>>> project. Here is the error message I always get when I try to do this. 
>>>>>>>> can
>>>>>>>> someone help me with this?
>>>>>>>>
>>>>>>>> "C:\Users\SteveB\Desktop\steve>.\Scripts\activate
>>>>>>>> (steve) C:\Users\SteveB\Desktop\steve>python
>>>>>>>> .\Scripts\django-admin.py startproject proj
>>>>>>>> python: can't open file '.\Scripts\django-admin.py': [Errno 2] No
>>>>>>>> such file or directory"
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>  --
>>>>>>> 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 t

Re: Can't Start Project.

2015-07-01 Thread Bill Freeman
Yes.  syncdb should work, assuming that sqlite is available (I think that
it's built in in all the python 3.x versions), and assuming that you have a
correctly configured settings.py (startproject makes one, but you will
still have things to enter, such as data base configuration info (like the
file to use to back sqlite), or to edit, such as your timezone.

On Wed, Jul 1, 2015 at 5:35 PM, Steve Burrus <steveburru...@gmail.com>
wrote:

> no django was not installed so I did a quick "pip install django" and
> installed django 1.8.2 into my ins tance of virualenv and was [finally]
> able to connect to the django server. I assume trhat I can easily do the
> "python manage.py syncdb" to connect to the sqllite3 server?
>
>
> On Wed, Jul 1, 2015 at 3:58 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>> It sounds like django isn't on your path.  If you are running in a
>> virtualenv, was django pip installed while running in that same environment?
>>
>> On Wed, Jul 1, 2015 at 4:26 PM, Steve Burrus <steveburru...@gmail.com>
>> wrote:
>>
>>> cd to the directory containing manage.py (the project directory), then:
>>> "python manage.py runserver" Yeah I just now did exact;ly that but STILL
>>> got the error message : "(steve) C:\Users\SteveB\Desktop\steve\src>python
>>> manage.py runserver Traceback (most recent call last):  File
>>> "manage.py", line 8, in  from django.core.management import
>>> execute_from_command_line ImportError: No module named
>>> django.core.management" I r enamed my newly created project to "src".
>>>
>>>
>>> On Wed, Jul 1, 2015 at 3:14 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>>>
>>>> cd to the directory containing manage.py (the project directory), then:
>>>>
>>>>   python manage.py runserver
>>>>
>>>> On Wed, Jul 1, 2015 at 2:04 PM, Steve Burrus <steveburru...@gmail.com>
>>>> wrote:
>>>>
>>>>> well I was able to create a new project earlier however I am now
>>>>> having trouble with starting the django ser ver. when I ran this cpommand
>>>>> "python .\Scripts\django-admin.py runserver" I always get this error
>>>>> message : "python: can't open file '.\Scripts\django-admin.py': [Errno 2]
>>>>> No such file or directory". What's going on for me to get this error?
>>>>>
>>>>> On Wednesday, July 1, 2015 at 10:27:14 AM UTC-5, Steve Burrus wrote:
>>>>>>
>>>>>> I need some help please with  tryiong to start a new Django project.
>>>>>> Here is the error message I always get when I try to do this. can someone
>>>>>> help me with this?
>>>>>>
>>>>>> "C:\Users\SteveB\Desktop\steve>.\Scripts\activate
>>>>>> (steve) C:\Users\SteveB\Desktop\steve>python
>>>>>> .\Scripts\django-admin.py startproject proj
>>>>>> python: can't open file '.\Scripts\django-admin.py': [Errno 2] No
>>>>>> such file or directory"
>>>>>>
>>>>>>
>>>>>>
>>>>>>  --
>>>>> 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/db741397-9c7c-4368-805c-07d60d6042bf%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/db741397-9c7c-4368-805c-07d60d6042bf%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 a topic in the
>>>> Google Groups "Django users" group.
>>>> To unsubscribe from this topic, visit
>>>> https://groups.google.com/d/topic/django-users/1wWP0wRstsU/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> django-users+unsubscr...@googlegroups.com.
>&

Re: Can't Start Project.

2015-07-01 Thread Bill Freeman
It sounds like django isn't on your path.  If you are running in a
virtualenv, was django pip installed while running in that same environment?

On Wed, Jul 1, 2015 at 4:26 PM, Steve Burrus <steveburru...@gmail.com>
wrote:

> cd to the directory containing manage.py (the project directory), then:
> "python manage.py runserver" Yeah I just now did exact;ly that but STILL
> got the error message : "(steve) C:\Users\SteveB\Desktop\steve\src>python
> manage.py runserver Traceback (most recent call last):  File "manage.py",
> line 8, in  from django.core.management import
> execute_from_command_line ImportError: No module named
> django.core.management" I r enamed my newly created project to "src".
>
>
> On Wed, Jul 1, 2015 at 3:14 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>> cd to the directory containing manage.py (the project directory), then:
>>
>>   python manage.py runserver
>>
>> On Wed, Jul 1, 2015 at 2:04 PM, Steve Burrus <steveburru...@gmail.com>
>> wrote:
>>
>>> well I was able to create a new project earlier however I am now having
>>> trouble with starting the django ser ver. when I ran this cpommand "python
>>> .\Scripts\django-admin.py runserver" I always get this error message :
>>> "python: can't open file '.\Scripts\django-admin.py': [Errno 2] No such
>>> file or directory". What's going on for me to get this error?
>>>
>>> On Wednesday, July 1, 2015 at 10:27:14 AM UTC-5, Steve Burrus wrote:
>>>>
>>>> I need some help please with  tryiong to start a new Django project.
>>>> Here is the error message I always get when I try to do this. can someone
>>>> help me with this?
>>>>
>>>> "C:\Users\SteveB\Desktop\steve>.\Scripts\activate
>>>> (steve) C:\Users\SteveB\Desktop\steve>python .\Scripts\django-admin.py
>>>> startproject proj
>>>> python: can't open file '.\Scripts\django-admin.py': [Errno 2] No such
>>>> file or directory"
>>>>
>>>>
>>>>
>>>>  --
>>> 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/db741397-9c7c-4368-805c-07d60d6042bf%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/db741397-9c7c-4368-805c-07d60d6042bf%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 a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/1wWP0wRstsU/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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAB%2BAj0uiQO5Ksjd-xkQ_kVr2SDvNEGM654x0mmEs1gCRW2jmCg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAB%2BAj0uiQO5Ksjd-xkQ_kVr2SDvNEGM654x0mmEs1gCRW2jmCg%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABcoaSAOXFYq8HQYsCw48rvGjBSEv29XgoFcARKATfx_My_eWQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CABcoaSAOXFYq8HQYsCw48rvGjBSEv29XgoFcARKATfx_My_eWQ%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0t0uoOfsbBdZ-5x0vbi4nzoQrCF6RPcUvTha3-61R6mMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't Start Project.

2015-07-01 Thread Bill Freeman
cd to the directory containing manage.py (the project directory), then:

  python manage.py runserver

On Wed, Jul 1, 2015 at 2:04 PM, Steve Burrus 
wrote:

> well I was able to create a new project earlier however I am now having
> trouble with starting the django ser ver. when I ran this cpommand "python
> .\Scripts\django-admin.py runserver" I always get this error message :
> "python: can't open file '.\Scripts\django-admin.py': [Errno 2] No such
> file or directory". What's going on for me to get this error?
>
> On Wednesday, July 1, 2015 at 10:27:14 AM UTC-5, Steve Burrus wrote:
>>
>> I need some help please with  tryiong to start a new Django project. Here
>> is the error message I always get when I try to do this. can someone help
>> me with this?
>>
>> "C:\Users\SteveB\Desktop\steve>.\Scripts\activate
>> (steve) C:\Users\SteveB\Desktop\steve>python .\Scripts\django-admin.py
>> startproject proj
>> python: can't open file '.\Scripts\django-admin.py': [Errno 2] No such
>> file or directory"
>>
>>
>>
>>  --
> 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/db741397-9c7c-4368-805c-07d60d6042bf%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: ValueError: No JSON object could be decoded

2015-06-22 Thread Bill Freeman
You probably don't want request.body.  You are probably POSTing the JSON
using a form, which means that it shows up as something like
request.POST['data'], where you should replace 'data' with the name of the
form element (textarea?) where you are putting the JSON.  Posting with a
form wraps things up in a multipart form (allowing you to have, among other
things, more than one field in a post), and that extra stuff doesn't look
line JSON, but the whole is what you get when you use request.body.

On Sun, Jun 21, 2015 at 11:13 AM, Vijay Khemlani  wrote:

> What is the actual content of request.body? (as in, "print request.body")
>
> On Sun, Jun 21, 2015 at 9:26 AM, Dhaval M  wrote:
>
>> Thank you in advance for any help (this is my first post to this
>> community)
>>
>> I am using Django as my application server for my project. I am new to
>> web development so please pardon and feel free to correct me for any
>> mistake.
>>
>> I am running simple, client server combination where from client I am
>> trying to send JSON data and on the server I am trying to parse it.
>>
>> SERVER CODE:
>>
>> def addPatient(request):
>>
>>  if request.method == 'POST':
>>
>> # Convert JSON to python objects and
>>
>> # store into the DB
>>
>> recJSON = json.loads(request.body)
>>
>> #logger.debug("%s",recJSON['SenderID'])
>>
>> logger.debug("%s",request.body)
>>
>>
>> #print 'Raw Json "%s"' % request.body
>>
>> return HttpResponse(json.dumps(request.body),content_type=
>> "application/json")
>>
>>
>>
>>
>> But getting an error at json.loads. ValueError: No JSON object could be
>> decoded
>>
>>
>> Also I would appreciate if any one can direct me to good tutorial on
>> Django (I already read http://www.djangobook.com/)
>>
>>
>> I dont know where and what I am doing wrong. I checked the client side
>> message and it is JSON used http://jsonlint.com/ to validate it is JSON
>> data.
>>
>>
>> Thank you once again.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5bc51870-6b56-456f-bc6d-18cf20487265%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei1Sdb_QGG3hxixj2RNqiqaafjQMkwqGkpokXqcCOGgejA%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0sUoKrU%2BGYBij8hnbMNkggdJFUBsYm9GNvZ%3D3nUc89B0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: comment and uncomments in django html template

2015-06-19 Thread Bill Freeman
If your JavaScript comes from a django template, yes, the comment tag will
work.  If, instead, you want the lines delivered to the browser, but
commented out as far as JavaScript is concerned, use /* to start the
comment and */ to end it -- multiple lines are allowed.

On Fri, Jun 19, 2015 at 12:48 PM, Sindhujit Ganguly 
wrote:

> This does not work for javascript defined inside html templates.. This is
> for html structures.. I needed for multiple line comments in js scripts.
>
> On Friday, June 19, 2015 at 10:46:40 AM UTC-6, Karen Tracey wrote:
>>
>> On Fri, Jun 19, 2015 at 12:42 PM, Sindhujit Ganguly > > wrote:
>>
>>>
>>>   Does anyone know how to do multiple line comments in django html
>>> templates?
>>>
>>>
>> Yes, block comment template tag:
>>
>> https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#comment
>>
>  --
> 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/3d5ed791-e3c1-4ee9-936d-e649f905839c%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Ready to throw the keyboard using Django 1.7 on Windows 7

2015-06-19 Thread Bill Freeman
Is this under manage.py or behind a wsgi front end like Apache/mod_wsgi or
ngnx?

If under manage.py, you need to cd to the directory containing manage.py
first.  (There are ways around this if absolutely necessary.)  If behind a
wsgi front end, there are other means for insuring that this directory is
on sys.path.

The directory holding manage.py must also hold a sub-directory named
myapp.  The myapp directory must, in torn, contain both a settings.py file
and a __init__.py file (the latter can be an empty file).

Let us know if this doesn't get you going.

On Fri, Jun 19, 2015 at 12:16 PM, Todd Kovalsky 
wrote:

> Having a miserable time trying to get a django site running on a wintel
> box.
>
> The issue comes after I add models to models.py.
>
> I keep getting the error Could not import settings 'myapp.settings'...No
> module named myapp.settings.
>
> Very irritating trying to get a site up and working on a windows machine
> vs osx
>
>
>
> any help is greatly 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/876bd435-9e37-4471-9840-86ac040e6434%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Reuse jquery

2015-06-02 Thread Bill Freeman
Are you saying that you can't access it as django.jQuery ?

On Tue, Jun 2, 2015 at 4:22 AM, guettli  wrote:

> I guess I am missing something.
>
> Is there no way to load jquery only once per page?
>
> Use case: I have two widgets which need jquery. I want to use
> these widgets inside the admin interface and on custom pages.
>
> The admin interface has its own jquery and in jquery.init.js this gets
> done:
>
> var django = django || {};
> django.jQuery = jQuery.noConflict(true);
>
> Since jQuery gets removed from the namespace. This means I can't use
> it in the js-files of my widgets.
>
> I really would like to load jquery only once per page.
>
> Regards,
>   Thomas Güttler
>
>
>
>
>
>  --
> 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/4183890d-7279-4c75-bfe1-de30084b15ca%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Testing a new app

2015-05-28 Thread Bill Freeman
If the "new" app doesn't need services from the larger app in order t work,
but rather the other way around, why not leave it separate, and later, just
make it an install requirement for the larger app?

On Thu, May 28, 2015 at 5:54 AM, Klaas Feenstra  wrote:

> Using GIT would be the way of working..
>
> On Thu, May 28, 2015 at 4:24 AM, DZ  wrote:
>
>> Greetings,
>>
>>  I want to start a new app that if it works out I will tie into a larger
>> django app. I do not really want the worlds to mix at the start just in
>> case I need scrap and start it over a few times. I was thinking the best
>> approach would be to create this first as a stand alone app and then when I
>> have the details worked out bring it under the larger app. When I bring it
>> under the larger app I know I would start the data over and use south to
>> bring the worlds together. I am developing under windows, django, python,
>> mysql, and I use south as my db migration tool. Does anyone forsee any
>> problems with this approach? Sorry if the question seems obvious or simple
>> just would like to travel the path of lower resistance as Im working out
>> the features/models of this new app.
>>
>> Thanks for any advice.
>>
>> DZ
>>
>> --
>> 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/81557fc6-48c7-4cea-ae9a-c5b49be06f82%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJcivaembcZ%3DNtNxiWP%3Dr8e%3DHTfZfFLn4jYDCedcKiqS_vsb0A%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0s2PnCaDnbR1_JU1r4mJh6reoeAOucL1-K6UR%3DTKO80sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Embeding HSQLDB in a standalone App

2015-05-20 Thread Bill Freeman
Can you access the js files via their static urls?
Does your html load the js (e.g. in script tags)?
Can you make it work with html accessed via file:/// type urls (keeping
django out of the mix)?

On Tue, May 19, 2015 at 10:06 PM, Robert librado 
wrote:

> Anybody understand how to connect Django and Jquery UI together I
> downloaded the Files and added to the site and added html and inserted the
> code yet it does not do the jquery motions like drag just comes out plain
> Ive done python manage.py collectstatic
>
> On Tue, May 19, 2015 at 7:57 PM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>
>>
>> On Tue, May 19, 2015 at 7:49 PM, Kapil Solanki 
>> wrote:
>>
>>> Hi All,
>>>
>>> I need to embed hsqldb in my project. I have been looking for solution
>>> online but couldnt find a proper one.
>>> BDW am new to django and python so its bit difficult also for me to
>>> search the right solution.
>>> Please suggest if there is any hsqldb llibraries or any module for
>>> django app which i can include and start performing db operation in my app.
>>>
>>
>> My guess - you'll need to use the JDBC interface. There are several JDBC
>> libraries for python; I have no idea how robust they are, but if there
>> isn't a well known Python API for HSQLDB, using JDBC will be your best
>> option.
>>
>> Yours,
>> Russ Magee %-)
>>
>> --
>> 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/CAJxq84--Q%3D5zh5rfuQUFB6bbq4Qi8SAXMv8_Nmca036VQc1bYw%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAmfpZ1qi7qdrsS9CCSS_VV3u3JB-%3DKG1TbYgzJ6iFeQqZVEHA%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0vmUzV5RX_CS_43TpgLfEXvjNc9KbFQNRt5c%3D7cGzhUpw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: clear database (drop all tables)

2015-04-29 Thread Bill Freeman
With suitable privileges, you can drop the database and recreate it.  In at
least some databases the user privilege grants are not lost with the
database and don't have to be recreated when the database is.

And, if you're using SQLite, just remove the file.

On Wed, Apr 29, 2015 at 6:10 AM, lars van Gemerden 
wrote:

> Hi all,
>
> Is there a simple programmatic way to drop all tables in the database
> (e.g. for testing purposes), also without input prompts?
>
> Cheers, Lars
>
> --
> 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/0ebbbdb5-f9ad-437b-baaa-9a39358704cd%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Serving / out of static directory, /api for Django DRF services (development/runserver/DEBUG mode)

2015-04-22 Thread Bill Freeman
And I probably would have gone with:

from django.conf import settings
if settings.DEBUG:
urlpatterns += patterns(
'django.contrib.staticfiles.views',
url(r'^$', 'serve', kwargs={'path': 'index.html'}),
url(r'^(?P.*)$', 'serve'),

The second url patter above must be the last one overall.  Any of your
other patters, for you Django views, for example, have already not matched
by the time this one gets tried.


On Wed, Apr 22, 2015 at 11:17 AM, Bill Freeman <ke1g...@gmail.com> wrote:

> By the way, you can test whether the regular expression matches without
> getting Django involved, allowing for much quicker theories and tests.
>
> $ python
> Python 2.7.3 (default, Jun  9 2014, 04:37:23)
> [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import re
> >>> re.match(r'^(?P(?:js|css|img)/.*)$', 'css/style.css')
> <_sre.SRE_Match object at 0x7fb34977ddc8>
> >>> _.groups()
> ('css/style.css',)
> >>> re.match(r'^(?P(?:js|css|img)/.*)$', 'apps/css/style.css')   #
> Does not match
> >>> re.match(r'^(?P(?:js|css|img)/.*)$', 'apps/another.html')#
> Does not match
> >>> re.match(r'^(?P(?:apps|js|css|img)/.*)$', 'apps/another.html')
> <_sre.SRE_Match object at 0x7fb34977ddc8>
> >>> _.groups()
> ('apps/another.html',)
> >>>
>
> On Wed, Apr 22, 2015 at 11:06 AM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>> Are css and js subdirectries of apps as implied by the (as received)
>> indentation of your message?  Note that your "other" url pattern has js,
>> css, and img, but no apps.
>>
>> On Wed, Apr 22, 2015 at 9:28 AM, LiteWait <t...@toogopos.com> wrote:
>>
>>> Well, this doesn't work completely.
>>>
>>> Consider the (static) tree:
>>>
>>> /client
>>>   index.html
>>>   /apps
>>>   another.html
>>>   /css
>>>   style.css
>>>   /js
>>>   my.js
>>>
>>> I need to serve this whole static tree out of /.
>>>
>>>
>>> On Tuesday, April 21, 2015 at 10:08:26 PM UTC-4, LiteWait wrote:
>>>>
>>>> I have no clue why this works, but I added the /client directory (full
>>>> path) to STATICFILE_DIRS and...
>>>>
>>>> from django.conf import settings
>>>> if settings.DEBUG:
>>>> urlpatterns += patterns(
>>>> 'django.contrib.staticfiles.views',
>>>> url(r'^(?:index.html)?$', 'serve', kwargs={'path': 'index.html'}),
>>>> url(r'^(?P(?:js|css|img)/.*)$', 'serve'),
>>>>
>>>>
>>>> Now /client/index.html is served up fine, as well as Django normal routes 
>>>> like /admin, /api, etc. I really wish I understood this better.
>>>>
>>>>
>>>>
>>>> On Tuesday, April 21, 2015 at 4:02:24 PM UTC-4, ke1g wrote:
>>>>>
>>>>> That may work for most static things.  The question is whether the
>>>>> static server is happy with an empty path, assuming that you're trying to
>>>>> serve "/" this way.  If not, you might add a separate (earlier) pattern of
>>>>> r'^$' that specifies a path in the extra parameters dictionary (where you
>>>>> have 'document_root', and you may want it's document_root to be different
>>>>> to avoid serving the home page at two urls).
>>>>>
>>>>> On Tue, Apr 21, 2015 at 1:56 PM, LiteWait <t...@toogopos.com> wrote:
>>>>>
>>>>>> Planning to host the client side of our application in production
>>>>>> from a proxy to an S3 site from Nginx.
>>>>>>
>>>>>> The problem is we'd like to mimic this behavior by serving / in
>>>>>> Django runserver using a static directory url() entry.
>>>>>>
>>>>>> I've read over
>>>>>> https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-other-directories
>>>>>>  but
>>>>>> I can't seem to make Django route / to my client directory.
>>>>>>
>>>>>> Idea is I have a project directory* /client *which contains
>>>>>> index.html along with all the other files for site, and when I hit
>>>>>> http://127.0.0.1:8000/ I want to serve up
>>>>>> */client/index.html.*
>>

Re: Serving / out of static directory, /api for Django DRF services (development/runserver/DEBUG mode)

2015-04-22 Thread Bill Freeman
By the way, you can test whether the regular expression matches without
getting Django involved, allowing for much quicker theories and tests.

$ python
Python 2.7.3 (default, Jun  9 2014, 04:37:23)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match(r'^(?P(?:js|css|img)/.*)$', 'css/style.css')
<_sre.SRE_Match object at 0x7fb34977ddc8>
>>> _.groups()
('css/style.css',)
>>> re.match(r'^(?P(?:js|css|img)/.*)$', 'apps/css/style.css')   #
Does not match
>>> re.match(r'^(?P(?:js|css|img)/.*)$', 'apps/another.html')#
Does not match
>>> re.match(r'^(?P(?:apps|js|css|img)/.*)$', 'apps/another.html')
<_sre.SRE_Match object at 0x7fb34977ddc8>
>>> _.groups()
('apps/another.html',)
>>>

On Wed, Apr 22, 2015 at 11:06 AM, Bill Freeman <ke1g...@gmail.com> wrote:

> Are css and js subdirectries of apps as implied by the (as received)
> indentation of your message?  Note that your "other" url pattern has js,
> css, and img, but no apps.
>
> On Wed, Apr 22, 2015 at 9:28 AM, LiteWait <t...@toogopos.com> wrote:
>
>> Well, this doesn't work completely.
>>
>> Consider the (static) tree:
>>
>> /client
>>   index.html
>>   /apps
>>   another.html
>>   /css
>>   style.css
>>   /js
>>   my.js
>>
>> I need to serve this whole static tree out of /.
>>
>>
>> On Tuesday, April 21, 2015 at 10:08:26 PM UTC-4, LiteWait wrote:
>>>
>>> I have no clue why this works, but I added the /client directory (full
>>> path) to STATICFILE_DIRS and...
>>>
>>> from django.conf import settings
>>> if settings.DEBUG:
>>> urlpatterns += patterns(
>>> 'django.contrib.staticfiles.views',
>>> url(r'^(?:index.html)?$', 'serve', kwargs={'path': 'index.html'}),
>>> url(r'^(?P(?:js|css|img)/.*)$', 'serve'),
>>>
>>>
>>> Now /client/index.html is served up fine, as well as Django normal routes 
>>> like /admin, /api, etc. I really wish I understood this better.
>>>
>>>
>>>
>>> On Tuesday, April 21, 2015 at 4:02:24 PM UTC-4, ke1g wrote:
>>>>
>>>> That may work for most static things.  The question is whether the
>>>> static server is happy with an empty path, assuming that you're trying to
>>>> serve "/" this way.  If not, you might add a separate (earlier) pattern of
>>>> r'^$' that specifies a path in the extra parameters dictionary (where you
>>>> have 'document_root', and you may want it's document_root to be different
>>>> to avoid serving the home page at two urls).
>>>>
>>>> On Tue, Apr 21, 2015 at 1:56 PM, LiteWait <t...@toogopos.com> wrote:
>>>>
>>>>> Planning to host the client side of our application in production from
>>>>> a proxy to an S3 site from Nginx.
>>>>>
>>>>> The problem is we'd like to mimic this behavior by serving / in Django
>>>>> runserver using a static directory url() entry.
>>>>>
>>>>> I've read over
>>>>> https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-other-directories
>>>>>  but
>>>>> I can't seem to make Django route / to my client directory.
>>>>>
>>>>> Idea is I have a project directory* /client *which contains
>>>>> index.html along with all the other files for site, and when I hit
>>>>> http://127.0.0.1:8000/ I want to serve up
>>>>> */client/index.html.*
>>>>>
>>>>> Not sure the following will work because I don't think you can't have
>>>>> a STATIC_URL = '/', right?
>>>>>
>>>>> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
>>>>> urlpatterns += staticfiles_urlpatterns()
>>>>>
>>>>>
>>>>> This one seems to make more sense, but I am not clear on what URL
>>>>> pattern could pull this off..
>>>>>
>>>>> if settings.DEBUG:
>>>>>  urlpatterns += patterns('',
>>>>>  url(r'^(?P.*)$', 'django.views.static.serve', {'document_root':
>>>>> '/client',}),
>>>>>  )
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>

Re: Serving / out of static directory, /api for Django DRF services (development/runserver/DEBUG mode)

2015-04-22 Thread Bill Freeman
Are css and js subdirectries of apps as implied by the (as received)
indentation of your message?  Note that your "other" url pattern has js,
css, and img, but no apps.

On Wed, Apr 22, 2015 at 9:28 AM, LiteWait  wrote:

> Well, this doesn't work completely.
>
> Consider the (static) tree:
>
> /client
>   index.html
>   /apps
>   another.html
>   /css
>   style.css
>   /js
>   my.js
>
> I need to serve this whole static tree out of /.
>
>
> On Tuesday, April 21, 2015 at 10:08:26 PM UTC-4, LiteWait wrote:
>>
>> I have no clue why this works, but I added the /client directory (full
>> path) to STATICFILE_DIRS and...
>>
>> from django.conf import settings
>> if settings.DEBUG:
>> urlpatterns += patterns(
>> 'django.contrib.staticfiles.views',
>> url(r'^(?:index.html)?$', 'serve', kwargs={'path': 'index.html'}),
>> url(r'^(?P(?:js|css|img)/.*)$', 'serve'),
>>
>>
>> Now /client/index.html is served up fine, as well as Django normal routes 
>> like /admin, /api, etc. I really wish I understood this better.
>>
>>
>>
>> On Tuesday, April 21, 2015 at 4:02:24 PM UTC-4, ke1g wrote:
>>>
>>> That may work for most static things.  The question is whether the
>>> static server is happy with an empty path, assuming that you're trying to
>>> serve "/" this way.  If not, you might add a separate (earlier) pattern of
>>> r'^$' that specifies a path in the extra parameters dictionary (where you
>>> have 'document_root', and you may want it's document_root to be different
>>> to avoid serving the home page at two urls).
>>>
>>> On Tue, Apr 21, 2015 at 1:56 PM, LiteWait  wrote:
>>>
 Planning to host the client side of our application in production from
 a proxy to an S3 site from Nginx.

 The problem is we'd like to mimic this behavior by serving / in Django
 runserver using a static directory url() entry.

 I've read over
 https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-other-directories
  but
 I can't seem to make Django route / to my client directory.

 Idea is I have a project directory* /client *which contains index.html
 along with all the other files for site, and when I hit
 http://127.0.0.1:8000/ I want to serve up
 */client/index.html.*

 Not sure the following will work because I don't think you can't have a
 STATIC_URL = '/', right?

 from django.contrib.staticfiles.urls import staticfiles_urlpatterns
 urlpatterns += staticfiles_urlpatterns()


 This one seems to make more sense, but I am not clear on what URL
 pattern could pull this off..

 if settings.DEBUG:
  urlpatterns += patterns('',
  url(r'^(?P.*)$', 'django.views.static.serve', {'document_root':
 '/client',}),
  )

  --
 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 http://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/ffdc58f3-e10c-46df-b14f-ec4bc02c0c70%40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5ba4b639-48df-4c3b-8fb8-00a1a166f58e%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Difficulty in passing positional arguments in url !!!

2015-04-21 Thread Bill Freeman
The @ in the email address and the . in the domain name will cause \w+ to
not match.  You could either go looser with
   .+
or better
   [^/]+
or you could be explicit with
   [a-zA-Z0-9_@.]+( . inside brackets doesn't need to be
backslashed)
though that last won't be affected by local, so you could perhaps do
   (?:\w|[@.])+
While you might have a limited set of email addresses, note that . can
occur in the username part, as can +, and we often see - in either part.

Probably best to try r'^acceptfriend/([^/]+)/$' next, then decide if you
need to be more restrictive.

On Tue, Apr 21, 2015 at 4:41 PM, HIMANSHU RANJAN <
livelikehimansh...@gmail.com> wrote:

> Thanks for replying Bill :D
> Ooops !!
>  i removed the question  mark but it is till not working !!
> The problem is that i dont have a form and i think form maynot be suitable
> to for application !!
>
> MY requirements :-
> i have some list of items and clicking on any of it should go to the view
> and tell me which item was clicked
> i.e.  These are the items which are to be clicked
>   * h...@hp.com
>   *a...@gmail.com
>   *x...@gmail.com
>
> Now if user clicks a...@gmail.com
>   My view should know that a...@gmail.com was clicked
>  i.e. item selected (a...@gmail.com) should be passed to my view and i
> should be able to perform some calculation with this email  !!!
>
>
> Any clue as to how to achieve this goal !!
> I thought using url regex extraction ,i will be able to pass paramters to
> my views
>   like
>  acceptfriend/a...@gmail.com/  or
> acceptfriend/h...@hp.com/   or
> acceptfriend/x...@gmail.com/
>
>  will match  r'^acceptfriend/(\w+)/$'and this captured parameter (
> (\w+)/)  will be passed to my appropriate view !!
>
> On Wed, Apr 22, 2015 at 1:15 AM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>> I think that it is the question mark in your url pattern that is causing
>> the problem.  In a real url, question mark separates the path from the
>> query parameters.  Parentheses in url patterns are for capturing parts of
>> the path, and are not associated with query parameters.  Just leave out
>> the ? and it may just work.
>>
>> (Of course, if you also want this parameter filled in by the submission
>> of a form, you would be better to put the email address in a query
>> paramater, as a form submission would.)
>>
>> On Tue, Apr 21, 2015 at 3:25 PM, livelikehimanshu12 <
>> livelikehimansh...@gmail.com> wrote:
>>
>>> Hello friends ,
>>> I am trying to send a simple parameter to view from my template .
>>> But i am getting the error 'Reverse for acceptfriend with arguments ('
>>> hpe...@hp.com',) and keyword arguments {} not found.
>>> Plzz help me !! I am not much comfortable with url concepts !!
>>> > i need to pass hpe...@hp.com to my view !!
>>>
>>> ## url.py
>>> ##
>>> from django.conf.urls import patterns, include, url
>>> from django.contrib import admin
>>> from django.conf import settings
>>> from django.conf.urls.static import static
>>>
>>> admin.autodiscover()
>>>
>>>
>>> urlpatterns = patterns('',
>>> url(r'^admin/', include(admin.site.urls)),
>>>
>>> url(r'^$', 'app.views.home',name='homeurl'),
>>> url(r'^signup/$','app.views.signup',name='signupurl'),
>>> url(r'^verifylogin/$','app.views.loginverify',name='verifyloginurl'),
>>>
>>> url(r'^verifysignup/$','app.views.signupverify',name='verifysignupurl'),
>>> url(r'^login/$','app.views.login',name='loginurl'),
>>># url(r'^imgurl/$','app.views.imageviewer',name='imgurl'),
>>> url(r'^uploadpic/$','app.views.uploadpic',name='uploadpic'),
>>> url(r'^refreshpage/$','app.views.refreshpage',name='refreshpage'),
>>> url(r'^acceptfriend/?(\w+)/$',
>>> 'app.views.acceptfriend','acceptfriend'),
>>> )+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
>>>
>>> ## profile.html (my
>>> template )##
>>> ..
>>> ..
>>> ..{% for g in list_reqfromemail %}
>>> 
>>> {{ g }} 
>>>
>>>   

Re: Serving / out of static directory, /api for Django DRF services (development/runserver/DEBUG mode)

2015-04-21 Thread Bill Freeman
That may work for most static things.  The question is whether the static
server is happy with an empty path, assuming that you're trying to serve
"/" this way.  If not, you might add a separate (earlier) pattern of r'^$'
that specifies a path in the extra parameters dictionary (where you have
'document_root', and you may want it's document_root to be different to
avoid serving the home page at two urls).

On Tue, Apr 21, 2015 at 1:56 PM, LiteWait  wrote:

> Planning to host the client side of our application in production from a
> proxy to an S3 site from Nginx.
>
> The problem is we'd like to mimic this behavior by serving / in Django
> runserver using a static directory url() entry.
>
> I've read over
> https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-other-directories
>  but
> I can't seem to make Django route / to my client directory.
>
> Idea is I have a project directory* /client *which contains index.html
> along with all the other files for site, and when I hit
> http://127.0.0.1:8000/ I want to serve up
> */client/index.html.*
>
> Not sure the following will work because I don't think you can't have a
> STATIC_URL = '/', right?
>
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
> urlpatterns += staticfiles_urlpatterns()
>
>
> This one seems to make more sense, but I am not clear on what URL pattern
> could pull this off..
>
> if settings.DEBUG:
>  urlpatterns += patterns('',
>  url(r'^(?P.*)$', 'django.views.static.serve', {'document_root':
> '/client',}),
>  )
>
>  --
> 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/ffdc58f3-e10c-46df-b14f-ec4bc02c0c70%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Runserver/DEBUG only, serve / from static directory

2015-04-21 Thread Bill Freeman
If I understand your needs, try r'^$', which will catch only the top of the
site.  (You might want r'^(?:index.html)?$' in case some old browser you
deal with has that fiddle, but the browser really should try what you typed
first.)

On Tue, Apr 21, 2015 at 3:02 PM, LiteWait  wrote:

> I have the need in runserver/debug mode to map http://127.0.0.1:8000/ out
> of a static /client directory.  Django will only serve up pages from /api
> which a DRF REST services.
>
> I can't seem to find a way to create the URL mapping for this.  It seems
> https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-during-development
> describes how to do this but the URL pattern escapes me.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1d9cb2c6-7419-42a9-ad53-74fde9285c5d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Difficulty in passing positional arguments in url !!!

2015-04-21 Thread Bill Freeman
I think that it is the question mark in your url pattern that is causing
the problem.  In a real url, question mark separates the path from the
query parameters.  Parentheses in url patterns are for capturing parts of
the path, and are not associated with query parameters.  Just leave out the
? and it may just work.

(Of course, if you also want this parameter filled in by the submission of
a form, you would be better to put the email address in a query paramater,
as a form submission would.)

On Tue, Apr 21, 2015 at 3:25 PM, livelikehimanshu12 <
livelikehimansh...@gmail.com> wrote:

> Hello friends ,
> I am trying to send a simple parameter to view from my template .
> But i am getting the error 'Reverse for acceptfriend with arguments ('
> hpe...@hp.com',) and keyword arguments {} not found.
> Plzz help me !! I am not much comfortable with url concepts !!
> > i need to pass hpe...@hp.com to my view !!
>
> ## url.py
> ##
> from django.conf.urls import patterns, include, url
> from django.contrib import admin
> from django.conf import settings
> from django.conf.urls.static import static
>
> admin.autodiscover()
>
>
> urlpatterns = patterns('',
> url(r'^admin/', include(admin.site.urls)),
>
> url(r'^$', 'app.views.home',name='homeurl'),
> url(r'^signup/$','app.views.signup',name='signupurl'),
> url(r'^verifylogin/$','app.views.loginverify',name='verifyloginurl'),
>
> url(r'^verifysignup/$','app.views.signupverify',name='verifysignupurl'),
> url(r'^login/$','app.views.login',name='loginurl'),
># url(r'^imgurl/$','app.views.imageviewer',name='imgurl'),
> url(r'^uploadpic/$','app.views.uploadpic',name='uploadpic'),
> url(r'^refreshpage/$','app.views.refreshpage',name='refreshpage'),
> url(r'^acceptfriend/?(\w+)/$',
> 'app.views.acceptfriend','acceptfriend'),
> )+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
>
> ## profile.html (my
> template )##
> ..
> ..
> ..{% for g in list_reqfromemail %}
> 
> {{ g }} 
>
> 
> {% endfor %}
>  views.py
> 
> def acceptfriend(request,reqfromemail):
> try:
> myemail=request.session['email']
> print("\n\n",request,"\n\n",myemail,"\n\n",reqfromemail)
> return
> render(request,'success.html',{"message":"congrats","name":myemail})
> except:
> return render(request,'error.html',{"error":"It is not working
> !!!"})
>
>
> ###
> If i remove the  href line from my template ,profile.html then my app runs
> normally !!
> So obviously there is some mistake that i am doing while using href ,or
> sending url parameters or  in extracting it. Also what is the use of
> reverse() in django i read the documentation but i am unable to understand
> it !!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f300d565-d747-46a4-b685-2c1df8bb2d19%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How can I work with pyserial and django form?

2015-04-07 Thread Bill Freeman
It sounds as though you have a set of sensors (scales, license readers,
barcode readers) which provide their readings over asynchronous serial
(that's what pyserial can connect with).  You have some computer or set of
computers that collectively provide a sufficient number of serial ports to
interface to your set of sensors.

And I believe you are wondering how to use a browser (Firefox, Chrome,
Safari, IE) to read from the serial ports and post the data to Django.  You
might be able to write a Firefox extension that does this, but it would be
a lot of work, and sensitive to updates to the browser.

If I had the task of reading the sensors and sending the data to Django, I
would write a small python program using pyserial and requests (or if you
are a glutton for punishment, use urllib2 directly) to POST to your Django
instance, using rest or an ad hoc protocol.  You can POST to a form page,
but the fact that forms are designed to appear to humans will just make
things a bit harder.

If you need a GUI to control the program you could add one with wxPython
(or other alternatives) or you could run a simple web server (python comes
with on) in a separate thread.

If the serial ports are run on the same box as Django or on a box that can
access the same database as Django is using, you could do the process as a
custom Django management command that uses pyserial to talk to the ports
and stores the results in the database directly.  GUI based control could
be via an extra table in the database controlled by an extra Django page.

There are other possibilities.  But trying to get a browser involved sounds
like a recipe for frustration.

Or maybe I misunderstand your needs?

On Mon, Apr 6, 2015 at 8:36 PM, Vijay Khemlani  wrote:

> I'm still not sure whether you are trying to load the value in the form
> input from the server or from the browser of the client.
>
> On Mon, Apr 6, 2015 at 5:42 PM, José Jesús Palacios 
> wrote:
>
>> I'm trying read serial to put in a field on a form and submit to database
>> . Data can be a weight of weighbridge, number of  car plate or reading a
>> barcode.
>> Outside the browser, It's not problem, but I want to use it as user
>> interface.
>>
>> El domingo, 5 de abril de 2015, 19:55:02 (UTC+2), Vijay Khemlani escribió:
>>>
>>> What are you trying to do exactly?
>>>
>>> On Sun, Apr 5, 2015 at 10:27 AM, José Jesús Palacios 
>>> wrote:
>>>
 How can I work with pyserial and django form to read from serial to
  field?
 Is it possible?

 Thanks to everyone.

 --
 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 http://groups.google.com/group/django-users.
 To view this discussion on the web visit https://groups.google.com/d/
 msgid/django-users/aa063945-c98d-488f-ba0f-16d66809395e%
 40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/8bc3e63e-599c-4fa0-a276-70cbbb24706b%40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei22C7ipPoVnEtQMb1a%3DS9qnzJWppvUpnpiBCe8jShoZCg%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 

Re: Django TCP socket communication

2015-03-27 Thread Bill Freeman
There is a sense in which what you are describing, for the Django side, is
what a webserver, including one involving Django, ordinarily does.

The only requirement the web server makes (and some can get around it with
work) is that the data sent over the socket, at least from the client
(microcontroller) to the server be formatted as HTTP.  That's not a big
deal to do.  It could consist of a canned (or nearly so, if the length of
your data varies) header in front of what you actually want to send.

The format of the data in the reply is potentially even more flexible.

Particularly if the connection is closed after each round trip, that's very
vanilla web serving.

And if you can see your way to doing it as an HTTP request/response pair,
that will significantly reduce your need to code at a low level on the
server side.

As to what libraries you use on the microcontroller side, that depends on
what microcontroller, and what software it is running.  (With Linux on a
Raspberry Pi, this is a trivial Python program.  It is probably tougher on
a Teensy.)

On Fri, Mar 27, 2015 at 3:03 PM, Bobby  wrote:

> I am new to TCP socket programming. I have a django based server
> communicating with a microcontroller. Now, I want to implement TCP based
> socket on the server side in order to communicate with the TCP socket on
> the microcontroller. Can anyone give me an idea on how to do this ? What
> libraries should I use on my django server The microprocessor basically
> opens the socket every 5 seconds and sends a notification to the server. I
> on the server side should be able to read this and pump data back to the
> microprocessor using this socket which was opened by the microprocessor.
>
> --
> 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/5ea5bf85-0163-40cf-a4da-ec9edb27f3ac%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Load Template without rendering/parsing

2015-03-16 Thread Bill Freeman
But that's what the template loader does.  It loads *DJANGO* templates.  If
it does the loading, the template will receive Django processing.

I see two choices:

1. Quote everything in the template that looks like a Django template
special syntax so that the rendering process instead just renders it as
what you wanted orriginally.

2. Load the file yourself.  Yes, you have to know the path or search
suitable sub-directories of installed apps yourself.  But those directories
probably shouldn't be called "templates", because those are for Django
templates.  Perhaps "angular_templates"?

On Mon, Mar 16, 2015 at 10:24 AM, Guilherme Leal 
wrote:

> Just to clarify the things a little bit more to Avraham.. i DO want the
> request to pass through django
>
> what i dont want is that django treat this particular html as a template.
>
> Em seg, 16 de mar de 2015 às 11:15, Guilherme Leal 
> escreveu:
>
>> Can you give me an exemple?
>>
>> Em seg, 16 de mar de 2015 às 11:05, Avraham Serour 
>> escreveu:
>>
>> if you don't want django to render your angularjs template file then
>>> don't.
>>>
>>> You could treat it as a static file, same way as a .png, the request
>>> woudn't even get to django
>>>
>>> you can not use render to return on the view, instead return the file
>>> without loading it in the template renderer
>>>
>>> On Mon, Mar 16, 2015 at 3:55 PM, Guilherme Leal 
>>> wrote:
>>>
 and the {% ssi %} was the winner :)

 the only thing that i didnt liked is that i have to strictly type the
 file path. But that would happend either way, working with the file
 directly or not.

 anyway, worked with the {% ssi %}.

 Thanks A LOT!

 Em seg, 16 de mar de 2015 às 10:32, François Schiettecatte <
 fschietteca...@gmail.com> escreveu:

 I am not sure what you mean.
>
> I have this is urls.py
>
> # Root view, goes to 'app.home.views.page'
> (r'^$', 'app.home.views.page'),
>
> and the code below in page() in views.py, django routes ‘/‘ to that
> view and it renders the home page.
>
> Or you could use {% ssi %} to include the angular stuff.
>
> François
>
>
> > On Mar 16, 2015, at 9:01 AM, Guilherme Leal 
> wrote:
> >
> > This solution crossed my mind, and the only down side that i see on
> it, is that i cant use the "template.loader" logic for finding the right
> template.
> >
> > Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte <
> fschietteca...@gmail.com> escreveu:
> > You can just read the file content and return it with an
> HttpResponse(), like this:
> >
> >
> > # File handle
> > fileHandle = None
> >
> > # Open the file, return a 404 if failed
> > try:
> > fileHandle = open(filePath, 'r')
> > except IOError:
> > raise Http404()
> >
> ># Return the file
> > return HttpResponse(content=fileHandle.read(),
> content_type=’text/html')
> >
> > François
> >
> >
> > > On Mar 16, 2015, at 8:49 AM, Guilherme Leal 
> wrote:
> > >
> > > Hello!
> > >
> > > Anyone knows a way to load a template file WITHOUT
> parsing/rendering it?
> > >
> > > To ilustrate a bit more:
> > >
> > > I have a django app serving a restfull api, and everithing is just
> fine with it. The front end that consumes this api, is an Angular.js 
> single
> page app. To centralize the routing logic, what i want to do is to let
> django to serve the "index.html" of this app. The only problem is, when i
> load the html of the front end (through 
> "django.template.loader.get_template"),
> the template engine tries to parse it, and throws an exception because 
> this
> "template" has the angularjs template tags on it.
> > >
> > > What i need is:
> > > - Load the template without parsing/rendering it
> > > OR
> > > - Serve this html document as static in production (the static
> serving view only works when debug is activated)
> > >
> > > Thanx in advance!
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Django users" group.
> > > To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users+unsubscr...@googlegroups.com.
> > > To post to this group, send email to django-users@googlegroups.com
> .
> > > Visit this group at http://groups.google.com/group/django-users.
> > > To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAOs3Lp43aDqX
> DSfNNcH10gUvAZB-3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com.
> > > For more options, visit https://groups.google.com/d/optout.
> >
> 

Re: Django 1.6's lifespan for security updates?

2015-03-11 Thread Bill Freeman
You should really decouple yourself from the distro's choices, saving
headaches in the future.  Let me expand on Avraham's suggestion.

There is little difficulty in having more than one version of python on a
box.  The main caution here is that the distrio's use of python might
depend on that python being a 2.6.  That means that (ignoring PATH
modifications and use of virtualenvs) that typing "python" should get you a
2.6..  If your distro offers a 2.7 package, it is probably built so that
"python" gets you a 2.6, and "python2.7" gets you a 2.7, and the distor's
python based tools will continue to work (as) fine (as they ever did).

But I don't recommend using a distro 2.7 package, even if available.  You
become subject to them doing something bizarre in an update.  You have much
better control if you build it yourself.  Avoiding replacing what you get
when you type "python" is easy enough:  instead of "make install" use "make
altinstall", which does everything except "ln python2.7 python".  Another
approach, used where I work, is to set the install path to a directory not
included in the default PATH setting, but then you can't simply type
"python2.7" (at least as root) to get a 2.7, or, more to the point, you
have to give a full path to virtualenv's -p flag.  It takes some fiddling
(last time I did this) to be certain that you have all the necessary
development libraries (-devel on RPM based systems), since, for some,
python will still build, but some features won't be available.  You may not
care about some of them now (readline support is a case in point) but they
don't hurt anything, and it's better than rebuilding later.  Document what
you had to add for future reference.

Another requirement, if you are using mod_wsgi, is to re-link it against
your python.  A given httpd - mod_wsgi install can only use one version.of
python.  This, in practice, means building your own mod_wsgi, rather than
using a distro version.  And if you're going this far, you may as well take
full control by building Apache httpd as well, though, so long as a
suitable development package is available, you may not need to..  It's not
as big a deal as it may sound.

If you're not using httpd/mod_wsgi, I can't offer any advice on what may be
required, since I haven't done my own installs of ngnx, etc.

Bill

On Wed, Mar 11, 2015 at 8:53 AM, Andreas Kuhne 
wrote:

>
> 2015-03-11 13:28 GMT+01:00 Stephen Gallagher :
>
>>
>> On Tuesday, March 10, 2015 at 6:01:28 PM UTC-4, Carl Meyer wrote:
>>>
>>> I sympathize with your situation, but Python 2.6 reached end-of-life on
>>> October 29, 2013 (a year and a half ago now), and since then has been
>>> unsupported and not receiving security updates. I don't think the Django
>>> core team should set a precedent of extended support for Python versions
>>> which are themselves unsupported by the core Python developers.
>>>
>>> If some Linux distributions are backporting Python security patches to
>>> 2.6 themselves in order to extend its lifetime in their distribution,
>>> perhaps it would make sense to ask them whether they will also backport
>>> Django security patches to Django 1.6. (I would guess that some of them
>>> may already be planning to do so, and may even have already done so for
>>> previous Django releases in the past.)
>>>
>>
>>
>> So, here's the basic problem. The distributions that are packaging python
>> 2.6 are, basically Red Hat Enterprise Linux 6 and its clones (CentOS,
>> Scientific Linux, Oracle, etc.) and SUSE Linux Enterprise Server 11. These
>> two distributions make up a significant percentage of the enterprise
>> deployment space. Neither of these distributions ships Django itself. For
>> RHEL, the Fedora Project provides the EPEL add-on repository which is
>> unsupported and *may* carry Django (though it has proven to be difficult,
>> more on that in a minute). For SLES, there is OpenSUSE which acts
>> similarly. These are community-sponsored and generally limited to only
>> packaging what upstream provides, since with no corporate backing and
>> engineering support, backporting patches from newer releases is unlikely to
>> happen.
>>
>> The reason that neither of these distributions carries Django is
>> specifically because of the short lifecycle of Django. The LTM releases
>> (1.4 and the upcoming 1.8) are somewhat better aligned with the goals of
>> enterprise distributions, but even those approximately three-year lifespans
>> are significantly shorter than the ten years that the enterprise
>> distributions want to maintain. So the chances of Django ever being shipped
>> by a company capable of supporting it for that length of time is basically
>> zero. (Not unless Django someday becomes a critical part of the standard
>> Linux platform).
>>
>> In the Enterprise software space, there's an average of a two-year period
>> between a new version of software becoming available and companies actually
>> deploying 

Re: Using the eval() command

2015-03-10 Thread Bill Freeman
eval() operates on an expression, not a statement.  Assignment makes it a
statement.

Why wouldn't you just say:

  innerDict['+newinnrkey+'] = newinnrval


On Tue, Mar 10, 2015 at 5:25 PM, Henry Versemann 
wrote:

> I have a new dictionary that I want to build, using data from another
> dictionary. I have a view which is receiving a single key/value pair
> from the original dictionary. Then in the view I've defined the new
> dictionary like this:
>
> innerDict = {}
>
> Now I want to make this as dynamic as possible so I'm trying to use the
> "eval()" statement below to add the new key/value pair to the new
> dictionary, which is declared above. Will the following code work to
> actually add the new key/value pair to the new dictionary?
>
> innrDictCmnd = "innerDict['"+newinnrkey+"'] = newinnrval"
> eval(innrDictCmnd)
>
> If not why not, and in lieu of the statements above not working, then how
> would I do it?
>
> Thanks for the help.
>
> Henry
>
>
>  --
> 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/e6c61ca1-efba-4965-a5ec-f10b55927b15%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to modify and then recombine json response data without breaking json formatting

2015-03-10 Thread Bill Freeman
OK.  but I need more code context.  The if statement that does the
modification is clearly python, so at that point rspnsdata must be a python
dictionary, not a JSON string.  Yet, if I understand you correctly, it is
JSON to begin with (and you are using json.loads() to turn it into python
data so that you can manipulate it, but then you must later turn it back
into a JSON string (json.dumps()) to send as a response.  So there's lots
of code you haven't shown.  If the problem were where you're concentrating,
you would have found it.  Please expand the scope of what you're showing.

On Mon, Mar 9, 2015 at 3:35 PM, Henry Versemann 
wrote:

> OK here goes. The logic in the routine which I actually doing the
> modification to each individual JSON response looks like this:
>
> if str(objctTyp) == 'user':
> rspnsdata['name'] = lstobjct['name']
> rspnsdata['id'] = lstobjct['id']
>
>
> The routine which is doing this is receiving parameter data that looks
> like this when printed in string format in the windows command prompt
> window:
>
> The following piece of parameter data is actually what came back as my
> JSON response from the current secondary request that the application sent.
> rspnsdata=
>
> {
> u'participations': [],
> u'page_views':
> {
> u'2015-02-05T00:00:00-06:00': 1,
> u'2015-03-02T23:00:00-06:00': 1,
> u'2015-01-24T19:00:00-06:00': 1,
> u'2015-02-08T13:00:00-06:00': 1,
> u'2015-01-28T19:00:00-06:00': 1,
> u'2015-01-20T19:00:00-06:00': 1,
> u'2015-02-19T10:00:00-06:00': 2,
> u'2015-02-21T17:00:00-06:00': 1,
> u'2015-02-02T13:00:00-06:00': 1,
> u'2015-02-16T13:00:00-06:00': 1,
> u'2015-02-01T23:00:00-06:00': 2,
> u'2015-02-03T12:00:00-06:00': 2
> }
>
> }
>
> The following bit of parameter data was actually passed in as the data for
> the current student which the latest secondary request was sent for and
> whose associated data JSON data is shown above.
>
> lstobjct=
>
> {
> 'name': 'Brennan Kennedy',
> 'id':'8202'
> }
>
> The following parameter data type "user" indicates that 'name' and 'id'
> key data is passed in in the 'lstobjct' parameter and those key value pairs
> will be added to the received JSON data.
>
> objctTyp=
>
> user
>
> Hope this helps.
> Thanks.
>
> Henry
>
> On Monday, March 9, 2015 at 1:04:12 PM UTC-5, ke1g wrote:
>
>> If it's not the basics, then you haven't provided enough information to
>> allow someone to spot the problem.  If you post the code that is performing
>> the modification, someone may be able to spot the issue.
>>
>> On Mon, Mar 9, 2015 at 1:50 PM, Henry Versemann 
>> wrote:
>>
>>> Yes Id did do that. The problems I seem to be having only seem to happen
>>> whenever I modify the data before sending it. For many other requests that
>>> I'm sending and not modifying the data, before I send them back to the
>>> client I have no problems and everything is apparently parsed out ok by the
>>> javascript on the client side.
>>> Thanks.
>>>
>>> Henry
>>>
>>> On Monday, March 9, 2015 at 12:42:23 PM UTC-5, ke1g wrote:
>>>
 Did you remember to set the content type of your response to
 application/json?

 On Mon, Mar 9, 2015 at 1:18 PM, Henry Versemann 
 wrote:

> First to be clear up front let me say that I'm using Django1.7, Python
> 2.7.8, and the requests (Requests: HTTP for Humans
> ) 
> library
> version2.4.3 to build the application mentioned below.
>
> I have an application which needs to be able to process a single AJAX
> request as a series of related sub-requests sent to a remote API. Each
> sub-request response comes back in JSON format. The first of these
> sub-requests returns a list of students in a particular course, and the
> returned response data is a list containing student objects all in JSON
> format. A Django view code then strips outs the 'name' and 'id' of each
> student object in the list and builds it as an entry in another python 
> list
> to be used later(I'm using "json.loads()" to get to successfully the
> original JSON data returned in each reasponse). Then once this list is
> built it is passed to another view which then submits a different request,
> for each student "id", in the newly built list, to the same API, to return
> all student information (related to a particular course-id which is also
> passed in this second request), for the current student. Then the returned
> course-student information, for this second request, is also returned in
> JSON format.
>
> Everything up to this point works perfectly, but it is at this point
> that I believe my process is going wrong, when I try to modify the JSON
> data returned, form the 

Re: How to modify and then recombine json response data without breaking json formatting

2015-03-09 Thread Bill Freeman
If it's not the basics, then you haven't provided enough information to
allow someone to spot the problem.  If you post the code that is performing
the modification, someone may be able to spot the issue.

On Mon, Mar 9, 2015 at 1:50 PM, Henry Versemann 
wrote:

> Yes Id did do that. The problems I seem to be having only seem to happen
> whenever I modify the data before sending it. For many other requests that
> I'm sending and not modifying the data, before I send them back to the
> client I have no problems and everything is apparently parsed out ok by the
> javascript on the client side.
> Thanks.
>
> Henry
>
> On Monday, March 9, 2015 at 12:42:23 PM UTC-5, ke1g wrote:
>
>> Did you remember to set the content type of your response to
>> application/json?
>>
>> On Mon, Mar 9, 2015 at 1:18 PM, Henry Versemann 
>> wrote:
>>
>>> First to be clear up front let me say that I'm using Django1.7, Python
>>> 2.7.8, and the requests (Requests: HTTP for Humans
>>> ) 
>>> library
>>> version2.4.3 to build the application mentioned below.
>>>
>>> I have an application which needs to be able to process a single AJAX
>>> request as a series of related sub-requests sent to a remote API. Each
>>> sub-request response comes back in JSON format. The first of these
>>> sub-requests returns a list of students in a particular course, and the
>>> returned response data is a list containing student objects all in JSON
>>> format. A Django view code then strips outs the 'name' and 'id' of each
>>> student object in the list and builds it as an entry in another python list
>>> to be used later(I'm using "json.loads()" to get to successfully the
>>> original JSON data returned in each reasponse). Then once this list is
>>> built it is passed to another view which then submits a different request,
>>> for each student "id", in the newly built list, to the same API, to return
>>> all student information (related to a particular course-id which is also
>>> passed in this second request), for the current student. Then the returned
>>> course-student information, for this second request, is also returned in
>>> JSON format.
>>>
>>> Everything up to this point works perfectly, but it is at this point
>>> that I believe my process is going wrong, when I try to modify the JSON
>>> data returned, form the second series of requests.
>>>
>>> My modifications seem to work, on the server side(and I'm using
>>> json.dumps() to serialize my data into JSON format), and all of my data
>>> seems to be present when I print it in my command prompt window right
>>> before sending it back to the client, as part of an HttpResponse. Then when
>>> I try to access some of the data using javascript/jQuery once its
>>> been sent back to the client then some of the  "jQuery.parseJSON()"
>>> statements fail when I try to access the data I've formatted in the view,
>>> for my response.
>>>
>>> So my next question is how do I correctly modify the JSON response data
>>> (for each course student) returned from each request? Then once modified
>>> how do I correctly add it to a list, without breaking the JSON formatting,
>>> and causing it to not be well-formed, when I send it back to the client?
>>>
>>> This is the first time that I've attempted to do anything like this
>>> (modify and/or recombine) with JSON data, so I'm looking for an answer that
>>> my current level of Django/Python experience can't seem to provide, though
>>> I am continuing to search for answers.
>>>
>>> Any suggestions will be greatly appreciated.
>>>
>>> Thanks for the help.
>>>
>>> Henry
>>>
>>>  --
>>> 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 http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/790b2c45-edc8-4528-9faa-4cecfc072626%
>>> 40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ec7f326d-1e10-40be-9e75-8363d2ffde6f%40googlegroups.com
> 

Re: How to modify and then recombine json response data without breaking json formatting

2015-03-09 Thread Bill Freeman
Did you remember to set the content type of your response to
application/json?

On Mon, Mar 9, 2015 at 1:18 PM, Henry Versemann 
wrote:

> First to be clear up front let me say that I'm using Django1.7, Python
> 2.7.8, and the requests (Requests: HTTP for Humans
> ) library
> version2.4.3 to build the application mentioned below.
>
> I have an application which needs to be able to process a single AJAX
> request as a series of related sub-requests sent to a remote API. Each
> sub-request response comes back in JSON format. The first of these
> sub-requests returns a list of students in a particular course, and the
> returned response data is a list containing student objects all in JSON
> format. A Django view code then strips outs the 'name' and 'id' of each
> student object in the list and builds it as an entry in another python list
> to be used later(I'm using "json.loads()" to get to successfully the
> original JSON data returned in each reasponse). Then once this list is
> built it is passed to another view which then submits a different request,
> for each student "id", in the newly built list, to the same API, to return
> all student information (related to a particular course-id which is also
> passed in this second request), for the current student. Then the returned
> course-student information, for this second request, is also returned in
> JSON format.
>
> Everything up to this point works perfectly, but it is at this point that
> I believe my process is going wrong, when I try to modify the JSON data
> returned, form the second series of requests.
>
> My modifications seem to work, on the server side(and I'm using
> json.dumps() to serialize my data into JSON format), and all of my data
> seems to be present when I print it in my command prompt window right
> before sending it back to the client, as part of an HttpResponse. Then when
> I try to access some of the data using javascript/jQuery once its
> been sent back to the client then some of the  "jQuery.parseJSON()"
> statements fail when I try to access the data I've formatted in the view,
> for my response.
>
> So my next question is how do I correctly modify the JSON response data
> (for each course student) returned from each request? Then once modified
> how do I correctly add it to a list, without breaking the JSON formatting,
> and causing it to not be well-formed, when I send it back to the client?
>
> This is the first time that I've attempted to do anything like this
> (modify and/or recombine) with JSON data, so I'm looking for an answer that
> my current level of Django/Python experience can't seem to provide, though
> I am continuing to search for answers.
>
> Any suggestions will be greatly appreciated.
>
> Thanks for the help.
>
> Henry
>
>  --
> 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/790b2c45-edc8-4528-9faa-4cecfc072626%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: django doesnt wait for my time.sleep

2015-03-04 Thread Bill Freeman
Sleeping in a web server, which potentially has many users, is considered
bad form, even if it works.  A better place for such time outs is in
JavaScript in the browser.  Some designs use a view that the JavaScript (or
user) can poll to determine when the resource is available.

On Wed, Mar 4, 2015 at 12:03 PM, dk  wrote:

> i am using matplotlib to generate a plot/graph,  even do that python is
> generating the file and saving it so I can use it later on in my web page,
> django show the page before the process finish,
> so I decided to put a time.sleep(3)  so it wait 3 sec while all this
> happen, but doesn't respect that =(
>
> any ideas why that might happen or a workaround?
>
> I usually get in my web page an old plot so I have to click refresh on the
> page to get the new actual one =(.
> thank.s
>
> --
> 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/536faca6-2abb-4df6-b97d-414cc199e8d4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Issue in Django count string in a template

2015-02-12 Thread Bill Freeman
Show me your view.

On Thu, Feb 12, 2015 at 2:49 PM, Ronaldo Bahia  wrote:

> Thanks for answering.
>
> Can you provide some example?
>
> Cheers
>
> Em quinta-feira, 12 de fevereiro de 2015 17:00:28 UTC-2, ke1g escreveu:
>>
>> I presume that your messages are model instances.  If so, create a
>> queryset for the unread messages in your view, and pass that, or the result
>> of applying .count() to it, as a template context variable, say
>> "unread_message_count".
>>
>> On Thu, Feb 12, 2015 at 1:06 PM, Ronaldo Bahia 
>> wrote:
>>
>>> I am facing issues trying to get a count. Hope you can help me.
>>>
>>> In the template, if I insert {{ message.count }} not happens 'coz
>>> message is a string. If I insert {% load inbox %} {% inbox_count as message
>>> %} it returns all unread messages, but I need to get the unread messages
>>> sent by a given user, in my case, a candidate to a job position.
>>>
>>> How can I do it?
>>> Here is the thread:
>>> http://stackoverflow.com/questions/28484620/issue-in-
>>> django-count-string-in-a-template
>>>
>>> Thanx,
>>> Ronaldo
>>>
>>> --
>>> 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 http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/c9a6fd12-9c3a-4ac0-a2ed-550c1bb56e21%
>>> 40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1322fcec-9c69-4d34-9e24-cd719061a469%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Issue in Django count string in a template

2015-02-12 Thread Bill Freeman
I presume that your messages are model instances.  If so, create a queryset
for the unread messages in your view, and pass that, or the result of
applying .count() to it, as a template context variable, say
"unread_message_count".

On Thu, Feb 12, 2015 at 1:06 PM, Ronaldo Bahia  wrote:

> I am facing issues trying to get a count. Hope you can help me.
>
> In the template, if I insert {{ message.count }} not happens 'coz message
> is a string. If I insert {% load inbox %} {% inbox_count as message %} it
> returns all unread messages, but I need to get the unread messages sent by
> a given user, in my case, a candidate to a job position.
>
> How can I do it?
> Here is the thread:
>
> http://stackoverflow.com/questions/28484620/issue-in-django-count-string-in-a-template
>
> Thanx,
> Ronaldo
>
> --
> 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/c9a6fd12-9c3a-4ac0-a2ed-550c1bb56e21%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: export DJANGO_SETTINGS_MODULE

2015-01-21 Thread Bill Freeman
It looks like you are typing "*django-admin.py startproject WebSite*" at
the python prompt, which is incorrect.  You type it at the shell.  If you
get command not found, then instead type "python
full/path/to/django-admin.py startproject WebSite".  And in any case, the
current directory must be the one under which you want WebSite created.

On Wed, Jan 21, 2015 at 5:03 PM,  wrote:

>
> Hello
>
> i have sesinstalled django and re installed withdebian package
> when i lauch command django-admin.py startproject website here is what i
> get:
>
>
>
>
>
>
>
>
>
>
>
>
>
> *python3.4Python 3.4.2 (default, Dec 27 2014, 13:16:08) [GCC 4.9.2] on
> linuxType "help", "copyright", "credits" or "license" for more
> information.>>> django-admin.py startproject WebSite  File "", line
> 1django-admin.py startproject WebSite
> ^SyntaxError: invalid syntax*i moved dist-packages from python3 directory
> to python3.4 directory but without any result
> What can i do???
> Please help
>
> Thanks
>
> Le mercredi 21 janvier 2015 13:19:49 UTC+1, th.gr...@free.fr a écrit :
>>
>> Hello
>>
>> i have just installed django 1.7 on Debian jessie via synaptic
>>
>> when i start a console,
>>
>> import django is OK
>>
>> print(django.get_version()) ---> version 1.7.2
>>
>> Now i try to launch the command "django-admin.py startproject WebSite"
>> i get the error:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *Traceback (most recent call last):  File
>> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 94,
>> in __init__mod = importlib.import_module(self.SETTINGS_MODULE)  File
>> "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
>> return _bootstrap._gcd_import(name[level:], package, level)  File "> importlib._bootstrap>", line 2254, in _gcd_import  File "> importlib._bootstrap>", line 2237, in _find_and_load  File "> importlib._bootstrap>", line 2212, in _find_and_load_unlocked  File
>> "", line 321, in _call_with_frames_removed
>> File "", line 2254, in _gcd_import  File
>> "", line 2237, in _find_and_load  File
>> "", line 2224, in
>> _find_and_load_unlockedImportError: No module named 'WebSite'During
>> handling of the above exception, another exception occurred:Traceback (most
>> recent call last):  File "/usr/local/bin/django-admin.py", line 5, in
>> management.execute_from_command_line()  File
>> "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py",
>> line 385, in execute_from_command_lineutility.execute()  File
>> "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py",
>> line 345, in executesettings.INSTALLED_APPS  File
>> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 46,
>> in __getattr__self._setup(name)  File
>> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 42,
>> in _setupself._wrapped = Settings(settings_module)  File
>> "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 98,
>> in __init__% (self.SETTINGS_MODULE, e)ImportError: Could not import
>> settings 'WebSite.settings' (Is it on sys.path? Is there an import error in
>> the settings file?): No module named 'WebSite'*it seems that the
>> variable *SETTINGS_MODULE *is not properly initialized.
>> I don't know what to 
>>
>> Thanks for your help
>>
>> PS: the directory WebSite is empty but created
>>
>>  --
> 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/006aca02-67f1-4447-9faa-65fc01039f05%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Database field for Image Upload

2014-10-29 Thread Bill Freeman
Note that if these images will be displayed on the site it is best done by
your front end (Apache, ngnx, etc.) since the HTML to show them treats them
as a separate request, and serving static files is your front end's forte.
The front end knows how to do this with files, but probably not with
database blobs.  Thus the design followed by Django (and many other
frameworks) is to store the image as a file, and store something that
allows easy generation of the src attribute of the image tag, such as a
relative or absolute file name.

On Wed, Oct 29, 2014 at 9:14 AM, pjotr  wrote:

> https://docs.djangoproject.com/en/1.7/ref/models/fields/#imagefield
>
> The image file will not be stored in the database, but in MEDIAROOT by
> default. So maybe this is not the answer to your question.
>
> On Wednesday, October 29, 2014 10:18:30 AM UTC+1, Shubham Gupta wrote:
>>
>> Is there  any way from which i can add image  as a field so that images
>> are added into my database?
>> what data type i must use for this problem..?
>> thank you in advance
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b8612d81-a510-43d7-bc7f-57d81b76d686%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How can I make the field layout of a model form dynamic?

2014-10-22 Thread Bill Freeman
Perhaps the most djangoish way would be to create two model forms, with
different fields excluded, and choose which to render in the template.

Or you could render CSS style information to hide one or the other.

Or you could use JavaScript to hide one or the other based on something
else that you render.

Or write the template code to render the fields instead of using .as_p, etc.

On Wed, Oct 22, 2014 at 7:48 AM, DJ-Tom  wrote:

> Hi,
>
> I have a model that contains either a text or a numerical information,
> based on the type of the entry:
>
> equipment = models.ForeignKey(equipment)
> number = models.DecimalField('Amount/number', max_digits=6,
> decimal_places=2, blank=True, null=False, default=0)
> text = models.TextField("Text", blank=True, null=True, default='')
>
> Based on that model I created a model form:
>
> class RoomsetupEquipmentForm(ModelForm):
> equipment =
> forms.ModelChoiceField(queryset=equipment.activeobjects.order_by('category__name',
> 'name'))
>
> def __init__(self, *args, **kwargs):
> super(RoomsetupEquipmentForm, self).__init__(*args, **kwargs)
> self.fields['equipment'].choices = equipment_as_choices()
>
> class Meta:
> model = roomsetup_equipments
> fields = ('equipment', 'number', 'text')
>
> I'm looking for a way to selectively show either the number or the text
> field when the form is created.
>
> Thomas
>
>
>  --
> 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/138b45bd-ad73-4d5b-ac7f-27530b8e4e0c%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: What is *the* django 1.7 IDE which is opensource & multiplattform

2014-09-24 Thread Bill Freeman
I just use emacs.  One of the original open source tools.  Template syntax
support requires a plugin, and I might try one some day, but html mode has
been satisfying so far.  Also, since I know how to type, running my own
management commands in an emacs shell window works for me.  This sort of
magically includes source code view of the current line when you hit a
set_trace() or breakpoint or single step in pdb,  If you want a good
overview of available django relevant extensions for emacs, see
https://code.djangoproject.com/wiki/Emacs

On Wed, Sep 24, 2014 at 7:40 AM, Adam Stein  wrote:

>  Not sure what you are looking for in terms of Django template support.
> The only difference between pycharm community (free) and commercial in
> terms of Django support that I've noticed is that Django's development web
> server won't restart automatically when code changes in the
> community edition.  Haven't used community edition since last year, but I
> seem to recall, I was still able to have a task to start Django's dev
> web server (in debug mode so I can trace through my code as you'd expect),
> so as long as I restarted that after making changes, things
> were fine.
>
>
> On Wed, 2014-09-24 at 11:36 +0200, anton wrote:
>
> Hi,
>
> actually I use Aptana Studio 3.4.1 (http://www.aptana.com/)
> to develop Django apps (on Windows and Linux).
>
> What I (personally) need from an ide:
>  1. ability to debug (python code)
>  2. support for django templates
>  3. support for django (start a new project, adding a django app)
>  4. support for refactoring (like rename and so on)
>  5. support for mercurial
>  6. multi plattform (at least windows/linux)
>
> Starting with *django 1.7*, aptana marks some line
> as errors which are not errors (undefined variables from import ..)
>
> Now I have the following problem:
>
>  - I tried the actual aptana 3.6.0, but it is buggy and does not work
>(no idea if and when it will be fixed, the development
>speed is actually slow)
>
>  - if I use eclipse + actual pydev 3.7.1 I have
>no support for *django templates*
>
>  - all other ides like PyCharm are commercial (the free pycharm does
>not support django and django templates, only python)
>
> Now the question: does somebody know a solution?
>
> Thanks
>
>  Anton
>
>
>
>
>   --
> Adam (a...@csh.rit.edu)
>
>
>--
> 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/1411558851.20736.10.camel%40localhost.localdomain
> 
> .
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0uKNUv-ALbdxJVCfN8WTtzmF53H27fwGmrAqdaLqSFYTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I have configured SysLogHandler for my django app but nothing is going into the log file

2014-09-23 Thread Bill Freeman
This is from my logging config file from a non-django project, but the
principals should be similar.

Before you look too hard here, are you sure that rsyslog.d (or
equivalent) is running on the box (at which you have targeted the
logger?
Is the facility on which you are logging configured (In my case,
local5, see args below, is not configured by default and requires
stuff in /etc/rsyslog.d, including configuring the socket
'/dev/octopus', see args below.
[handler_logfile]
class=handlers.SysLogHandler
level=WARN
formatter=f_logfile
args=('/dev/octopus',handlers.SysLogHandler.LOG_LOCAL5)


On Tue, Sep 23, 2014 at 8:51 AM, Collin Anderson 
wrote:

> What does your SysLogHandler look like?
>
> --
> 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/def7f54c-48b8-4bcb-acc7-fe65751b8b43%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: websockets in django

2014-08-25 Thread Bill Freeman
+1 on tornado.  I may be behind the times, but I don't think that the
Django architecture lends itself to persistent connections.  Also, Django
is intended  to run behind another server, such as Apachi, nginx, etc., and
that server, too, would need to be amenable to persistent connections.

This doesn't mean that you can't use Django as part of your solution, if
other areas of the overall web site would benefit from it.  But you would
want to direct your websockets connections to something that handles that
well, such as tornado.


On Sun, Aug 24, 2014 at 10:44 AM, İsrafil KARA 
wrote:

> Hi, i think you use tornado. It's a simple way.
> On Aug 24, 2014 4:56 PM, "Rituparna Matkar"  wrote:
>
>> Hi
>>
>> I am trying to finish a phonegap app with django as a backend. I want to
>> implement web sockets in this app. To give a use case, there are an array
>> of buttons that all the users can see, if one user makes any changes to the
>> button (enable/disables) the change should be visible to other users as
>> well. The way I am coin it right now is after every 3 seconds I am sending
>> a call to the server weather the status of the button has changed and if
>> yes I refresh the page. I believe there could be a better solution to this.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/fbbe58cd-8986-4197-8516-77c37ac8dd87%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAe_hYb9sjcb1vEr8Qtj_g5D3Lxuw6-EryMUrd2-5p-jcMb0eQ%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0uqm-25HQMeSMhp6Ayk2G2kso17-uYe8Ue%2BKu0Xu%2BJqYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: nginx and django without virtualenv

2014-08-06 Thread Bill Freeman
Right.  I thought of that later.

But virtualenv or not is still just a different sys.path, and you still
have to have your stuff installed in the correct python.


On Wed, Aug 6, 2014 at 1:53 PM, Bill Freeman <ke1g...@gmail.com> wrote:

> Though if he's moving to nginx, thus not mod_wsgi, I guess it doesn't
> matter what mod_wsgi is linked against.
>
>
> On Wed, Aug 6, 2014 at 1:49 PM, Collin Anderson <cmawebs...@gmail.com>
> wrote:
>
>> Actually, that's a good point. I always use the same python version
>> that's linked with mod_wsgi. I don't use a virtualenv to use a different
>> python version.
>>
>> --
>> 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/CAFO84S6UhP0OKPSNDCFaLfqf_u_Lgc9ANpEq9cqGuhdpY%2BvEzQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAFO84S6UhP0OKPSNDCFaLfqf_u_Lgc9ANpEq9cqGuhdpY%2BvEzQ%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0vHqKopXN5nRGPgf-_5Ysi7JiGs0DYXyAsoKgbsxBPh7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: nginx and django without virtualenv

2014-08-06 Thread Bill Freeman
Though if he's moving to nginx, thus not mod_wsgi, I guess it doesn't
matter what mod_wsgi is linked against.


On Wed, Aug 6, 2014 at 1:49 PM, Collin Anderson 
wrote:

> Actually, that's a good point. I always use the same python version that's
> linked with mod_wsgi. I don't use a virtualenv to use a different python
> version.
>
> --
> 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/CAFO84S6UhP0OKPSNDCFaLfqf_u_Lgc9ANpEq9cqGuhdpY%2BvEzQ%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0t2G2PKuufbrCi0kjm2yvTUfyKQQW0XvJf62PLjzgd2DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: nginx and django without virtualenv

2014-08-06 Thread Bill Freeman
Performance *should* be identical.

All that virtualenv does (from the point of view of the executing python
program) is to change how sys.prefix and sys.exec_prefix are set, and thus,
how sys.path is calculated.

But with a vanilla sys.path, you need to be sure that django, your other
dependencies, and your project are all still found.  (Installing django in
a virtualenv does *NOT* also install it in the main python (actually, it's
the python that mod_wsgi is linked against that counts).


On Wed, Aug 6, 2014 at 1:22 PM, Paul Greenberg  wrote:

>  All,
>
>
>  I was running django with Apache and mod_wsgi for a while. Now, I am
> planning to run django without virtualenv. Although, it
> seems virtualenv might help.
>
> http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
>
>
>  Any pointers? Performance issues?
>
>
>   Best Regards,
> Paul Greenberg, Esq.
>
> Law Office of Paul Greenberg
> 530 Main Street, Suite 102
> Fort Lee, NJ 07024
> E-mail: p...@greenberg.pro
> Tel:  201-402-6777
> Fax:  201-301-8876
> Web: http://www.greenberg.pro/
> Twitter: @nymetrolaw
>
>--
> 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/1407345736984.18318%40greenberg.pro
> 
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0vZJLX4f-5e9-hNXkHGkdLDDXU7UWZy7%3D-E_feF2yoBcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to call a function when a project starts.

2014-07-31 Thread Bill Freeman
It runs twice because runserver uses two processes: the real server, and;
the monitoring process that restarts the other when you change a source
file. You could fool around with undocumented internals to figure out which
a given import is running in.  Or you could use a modifies runserver
command. Or you could modify manage.py. Or you could, if your O/S supports
it, open a file for exclusive use and the one that can't knows that it is
the server process.
On Jul 30, 2014 7:30 PM, "Mike Dewhirst"  wrote:

> On 31/07/2014 5:57 AM, Chen Xu wrote:
>
>> Hi Everyone:
>> I would like to call a function when my project starts, basically I want
>> to call a do_something() when I run python manage.py runserver. However,
>> when I put it into settings.py, it gets called twice, but I only want it
>> to execute once.
>>
>> Is there a good way to do it.
>>
>
> Maybe you could turn do_something() a singleton so it only executes once?
>
> http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python
>
>
>
>
>
>> Thanks
>>
>>
>> --
>> âš¡ Chen Xu âš¡
>>
>> --
>> 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/CACac-
>> qbTXbMGmYU%3D5R618rbt7pT%3DgTL%3DWAxhCR-prmuLbz-VKw%40mail.gmail.com
>> > qbTXbMGmYU%3D5R618rbt7pT%3DgTL%3DWAxhCR-prmuLbz-VKw%
>> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/53D97FE6.3000301%40dewhirst.com.au.
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0v1qGWYCXtJxBGqCRwSmYGfF%3DM54JXomAp-k-Hdd4OZAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Find link in a "dynamic" page

2014-07-19 Thread Bill Freeman
Are you keeping the cookies and returning them is subsequent requests?
(Particularly the session cookie, but all will work as well - if this is
the problem.)


On Thu, Jul 17, 2014 at 1:50 PM, Carlos Perche  wrote:

> Hello guys, could someone help me with this ...
>
> I am needing to find the link Ext #
> http://docs.sencha.com/ext/5.0.0/apidocs/source/Focusable.html-util-Focusable
>
> starting the url http://docs.sencha.com/ext/5.0.0/apidocs/
>
> The problem is that when having to recover the contents of the page with
> urllib2 or selenium it always returns the contents of the page 'default',
> because from what I understand, it is dynamically loaded from the iteration
> of the User.
>
> Not even the treeview page with links are returned with the get
>
> So I can never get up the link ...
>
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/19e44728-0e92-4f9d-8526-b3ccc28779cf%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Did Ubuntu 14.04 or Linux Mint 17 break your Django project files?

2014-07-16 Thread Bill Freeman
I make it a point to never use a python build that comes from a .deb for
any real development.

The OS vender may require certain python features for its management
scripts, but I don't like my development tools changing out from under me.

Build yourself a python from source, putting it some where in, say, /opt
then modify your PATH in .bashrc to find yours first (or only).

Then always develop in in virtualenv (based on your python) and no
dist-packages directories about it.

If you need to install something in python, use pip, never apt-get (though
you may need apt to install C library dependencies.


On Wed, Jul 16, 2014 at 4:53 PM, Pepsodent Cola 
wrote:

> Hi,
> I have been learning and developing my first Django project in Linux Mint
> 14 for about 2 years.  This month I moved my Django project files to Linux
> Mint 17.
> When I run my unit tests then I get this error, which I don't remember
> having when I was testing code in Linux Mint 14.
>
> *IntegrityError: NOT NULL constraint failed:*
> userprofile_userprofile.likes_cheese
>
>
> NOT NULL constraint failed
> I try to change the old code from this.
>
> class UserProfile(models.Model):
> user = models.OneToOneField(User)
> likes_cheese = models.*BooleanField()*
> favourite_hamster_name = models.CharField(max_length=50)
>
> To this.
>
> class UserProfile(models.Model):
> user = models.OneToOneField(User)
> likes_cheese = models.*NullBooleanField()*
> favourite_hamster_name = models.CharField(max_length=50)
>
> But then all kinds of different stuff in the project breaks.  Which makes
> me suspect that nothing was wrong with my code to begin with, that perhaps
> the change of operating system has caused this error.
>
> Did Ubuntu 14.04 or Linux Mint 17 break your Django project files also?
>
>
>
> admin.TabularInline
> Also I think Linux Mint 17 broke admin.py's TabularInline function because
> now the fields looks stacked instead.  I'm not sure if this has anything to
> do with my operating system switch.  Or if it's because of my recent
> experimentations with overriding certain parts of the admin template.
>
> class UserProfileInline(admin.*TabularInline*):
> model = UserProfile
> extra = 1
>
> Did Ubuntu 14.04 or Linux Mint 17 break your Django admin?
>
>
>
>  --
> 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/f0b3c781-e088-4ba1-a251-8e78795fd0f1%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: settings.configure() does not allow me to access custom variables in settings.py

2014-07-07 Thread Bill Freeman
I don't know how fussy about not using stuff from django you are, but the
following works for me:

  $ DJANGO_SETTINGS_MODULE=foo.ct python
  >>> from django.conf import settings
  >>> settings.INSTALLED_APPS

Obviously, you replace "foo" with the name of your project.  This prints my
installed apps.  For settings with defaults, middlewares, for example, you
will the default if you haven't set it in your settings file.

You must have DJANGO_SETTINGS_MODULE in the environment, though you could,
instead of using the shell, add it to os.environ (I don't think that it has
to be there for the import from django.conf, but it must be there for the
first reference to an attribute of settings, which is a lazy object).

This doesn't import much, unless you have a things implied in your project
path or settings module.  I have the currect celery boiler plate in my
project's __init__.py file, so I get a lot of stuff.  Just check
sys.modules and see if the import load is too much for you before you go
re-implementing the django.conf mechanisms.


On Fri, Jul 4, 2014 at 5:12 PM, Chen Xu  wrote:

> Hi Everyone,
> I want to access some variables in my settings.py without starting my
> server, I know I will have to run settings.configure(); however, running
> settings.configure() does not allow me to access my custom variables.
>
> What should I do with that.
>
>
> Thanks
>
> --
> ⚡ Chen Xu ⚡
>
> --
> 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/CACac-qbCUJ3WCDVN022%3DU6nnh40X4tYPiW8oJ6q%3DY_LTGN9Bhw%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0s4def1YrqcQ2V%2B2f%3DVcxfQkngxHmU2GMs-NtNH5eLwxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to install psycopg2 using Pip?

2014-06-16 Thread Bill Freeman
One possibility is that you have it, but it is in a directory that is not
on you path. Try:

   find / -name pg_config 2> /dev/null

If this finds the executable, you can add the directory your current
invocation of the shell (It will be gone when you log out and back in) to
do the pip install.

But you may not find it, in which case you need to install the PostgreSQL
"development" package (xxx-dev on deb based systems, xxx-devel on .rpm
based systems, for other systems you will need to do your own research).
Having installed it, you will still probably have to do the steps above.
All this can be found using google.


On Thu, Jun 12, 2014 at 6:26 AM, Sugatang Itlog 
wrote:

> Hi - When installing psycopg2 and errors like ...
>
> Error: pg_config executable not found
>
> do the following 
>
> [root@localhost ~]# which -a pg_config
> /usr/bin/which: no pg_config in
> (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
>
> [root@localhost ~]# find / -iname 'pg_config' 2>/dev/null
> /usr/pgsql-9.3/bin/pg_config
>
> [root@localhost ~]# ln -s /usr/pgsql-9.3/bin/pg_config /usr/bin/pg_config
>
> Then install psycopg2 via pip. If still got errors install the postgresql
> devel then do the above steps again.
>
> Thanks.
> SGTItlog
>
>
> On Thursday, March 24, 2011 10:01:43 AM UTC-5, Andre Lopes wrote:
>>
>> Hi,
>>
>> This question is not directly related with Django, but with Python.
>>
>> I have installed "virtualenv" to have a virtual environment. Now I
>> need to instal "psycopg2" in my virtual environment, but I have not
>> successfully installed.
>>
>> My steps:
>>
>> [quote]
>> pip install
>> http://pypi.python.org/packages/source/p/psycopg2/
>> psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
>> [/quote]
>>
>> And I got this message with an error:
>>
>> [quote]
>> Downloading/unpacking
>> http://pypi.python.org/packages/source/p/psycopg2/psycopg2
>> -2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
>>   Downloading psycopg2-2.4.tar.gz (607Kb): 607Kb downloaded
>>   Running setup.py egg_info for package from
>> http://pypi.python.org/packages/sou
>> rce/p/psycopg2/psycopg2-2.4.tar.gz#md5=
>> 24f4368e2cfdc1a2b03282ddda814160
>> Error: pg_config executable not found.
>>
>> Please add the directory containing pg_config to the PATH
>> or specify the full executable path with the option:
>>
>> python setup.py build_ext --pg-config
>> /path/to/pg_config build ...
>>
>> or with the pg_config option in 'setup.cfg'.
>> Complete output from command python setup.py egg_info:
>> running egg_info
>>
>> creating pip-egg-info\psycopg2.egg-info
>>
>> writing pip-egg-info\psycopg2.egg-info\PKG-INFO
>>
>> writing top-level names to pip-egg-info\psycopg2.egg-
>> info\top_level.txt
>>
>> writing dependency_links to pip-egg-info\psycopg2.egg-
>> info\dependency_links.txt
>>
>> writing manifest file 'pip-egg-info\psycopg2.egg-
>> info\SOURCES.txt'
>>
>> warning: manifest_maker: standard file '-c' not found
>>
>> Error: pg_config executable not found.
>>
>> Please add the directory containing pg_config to the PATH
>>
>> or specify the full executable path with the option:
>>
>> python setup.py build_ext --pg-config /path/to/pg_config
>> build ...
>>
>> or with the pg_config option in 'setup.cfg'.
>>
>> 
>> Command python setup.py egg_info failed with error code 1
>> Storing complete log in C:\Documents and
>> Settings\anlopes\Application
>> Data\pip\p
>> ip.log
>> [/quote]
>>
>> My question:
>>
>> How can I tell to "pip" where is my pg_config?
>>
>> Best 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7eb7c3a5-8d1b-4b2e-9ed4-277538b0623a%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this 

Is anyone using MariaDB for Django on CentOS

2014-06-12 Thread Bill Freeman
I'm having trouble installing mysql-python because the MariaDB installed
libmysqlclient_r.a is "incompatible" (missing dependencies according
to 
http://data-matters.blogspot.com/2013/08/install-mysql-python-with-mariadb.html).
There is rumored to be a fixed package for deb based systems, but neither
yum nor googling finds an RPM for CentOS 6.


Has anyone gotten past this?  (My google-fu is apparently inadequate.)

Bill

-- 
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/CAB%2BAj0vMw8ta2bXqXQnsruscwen2Oy%2BP73P1%2BRJ%2BeXi%2BPaLtYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django installation

2014-06-11 Thread Bill Freeman
Still, the OP's command should have worked.  The most likely problem is
that Django was installed to a different python than the one  he gets when
he types "python" at the shell.  He does not say how he installed Django,
so it is hard to advise.


On Wed, Jun 11, 2014 at 6:23 AM, Daniel Roseman 
wrote:

> On Wednesday, 11 June 2014 11:00:38 UTC+1, Srinivas Reddy T wrote:
>>
>> There is no need to install virtualenv to install Django.
>>
> While this is technically correct, it is not good advice to give to a
> newbie. Experienced developers should be encouraging best practice among
> newcomers, and to be honest there really isn't a good reason *not* to use
> virtualenv.
> --
> DR.
>
> --
> 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/da3adcf3-de91-4727-8b3e-7c8613112574%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: PyDev 3.4.1 & Django 1.7: undefined variable from Import

2014-05-12 Thread Bill Freeman
Also, I don't think that it's the += that he's worried about.  What he's
saying is that you shouldn't expect every sub-directory of BASE to always
be an app, and/or that the order of INSTALLED_APPS can be important, and/or
that your settings.py file should document what you are using.


On Mon, May 12, 2014 at 9:04 AM, Bill Freeman <ke1g...@gmail.com> wrote:

> But the code works, right?
>
> This is a PyDev issue, not a Django issue.
>
> (If you can only use code that your IDE understands, that leaves out a lot
> of interesting programs.)
>
>
> On Mon, May 12, 2014 at 4:04 AM, Florian Auer <f.c.a...@gmail.com> wrote:
>
>> Hi folks
>>
>> I'am new to django and try to follow the tutorial to digg into the code.
>>
>> I am using eclipse 4.3.SR2 with PyDev 3.4.1 and Django 1.7.b2 (because of
>> the new features)
>> In Tutorial Part 3 (
>> https://docs.djangoproject.com/en/1.7/intro/tutorial03/) the database
>> API is used to get the latest 5 objects
>>
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>>
>>
>> But my eclipse/PyDev does not resolve the objects correctly. "Question.
>> objects" will e resolved bot not further on. This leads to the problem
>> that PyDev is claiming about a "undefined variable from import: order_by"
>> I know that I can turn off this in the settings, but I would like to know
>> if there is a way to bring this auto-completion feature to work.
>>
>> The application is running correctly an on the python shell the
>> auto-completion is also working.
>> So therefor I would think it is a PyDev problem or did I just missed to
>> add something to the config?
>>
>>  --
>> 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/13b3436a-402e-47ef-acfd-23fdbaf5166a%40googlegroups.com<https://groups.google.com/d/msgid/django-users/13b3436a-402e-47ef-acfd-23fdbaf5166a%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0tM79-6TcEtnCnbfgoBpwXSvsSAty5CMKw0_xeG7EKTtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What does "+=" mean, or do?

2014-05-12 Thread Bill Freeman
a += b

is nominally the same as

a = a + b

To make class instances support this behavior the class can implement the
__iadd__ special method.  See docs.python.org and read about special
methods.

This notation originated, so far as I know, in the C language.  It at least
goes back that far.


On Mon, May 12, 2014 at 9:22 AM, Malik Rumi  wrote:

> I saw it here
> http://www.slideshare.net/jacobian/the-best-and-worst-of-django on slide
> 41. That's a lot to go through, I know, sorry about that. But I googled it
> and of course got nothing because Google ignores things like + and = now.
> And I know in this particular example he says 'don't do this", I just want
> to know what += means or does? Thx.
>
> --
> 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/f364291f-ae62-4b0b-a2d9-23e3f81a64e4%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


  1   2   3   4   5   6   7   8   9   >