Re: RichTextField widget for django

2009-03-23 Thread Scot Hacker


On Mar 20, 2009, at 7:27 AM, Greg Fuller wrote:

> http://code.google.com/p/django-fckconnector/
> http://code.google.com/p/django-tinymce/

See also:

http://www.wymeditor.org/
https://trac.wymeditor.org/trac/wiki/Contrib/IntegrateInDjango

./s



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django book mostly done?

2009-03-23 Thread Scot Hacker


On Mar 17, 2009, at 10:51 AM, Alex Gaynor wrote:

> Adrian just put the last batch of chapters online, so I believe all  
> the content is now up.  Having skimmed most of it I can say it looks  
> really good and I'm sure it basically all works, that said it isn't  
> a final addition so there may be tiny errors, typos, or other  
> mistakes.  I wouldn't have a problem reading through that(I  
> originally learned from the original book before it was published).   
> If you haven't already I would take a look at the official django  
> docs/tutorial, they really are quite good :).


Considering what an important learning resource the Django Book is,  
you'd think it would get some linkage from djangoproject.com  -- the  
string "book" doesn't appear on the homepage or any of the six top- 
level pages, or even in the Django FAQ index!

./s



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Arguments to django_inlines

2009-07-09 Thread Scot Hacker

Having great success with django_inlnes 
http://github.com/mintchaos/django_inlines/
and am able to pass in and process custom arguments just fine. But
can't solve an issue I've hit: If an argument includes any kind of
punctuation marks, the inline template fails to render. For example,
in:

{{ jwp /path/to/video.m4v poster=/path/to/image.png width=720
height=550 }}

The first path arg is handled fine, automatically. The second poster=
arg is a path and so includes slashes and a dot by necessity. But as
soon as a custom arg includes slashes or a dot, django_inlines bails.
Surrounding the arg in quotes also causes it to break. I'm processing
the arg like this:

def get_context(self):
video_path = self.value
poster = self.kwargs['poster']

Has anyone had success passing an arg to django_inlines that includes
punctuation marks? Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



cPanel Python/Django support

2012-04-30 Thread Scot Hacker
For the past couple of years, cPanel (the most widely deployed hosting control 
panel system) has been taking pulse on user demand for native Django support 
(similar to their Rails installer). Just saw this note from cPanel devs  and 
thought some folks here might be interested. This is a great opportunity to 
help shape the future of what could become one of the most widely available 
routes to Django deployment on commodity hosting.

./s

Begin forwarded message:
> 
> Dear shacker23,
> 
> cPanelDavidG has just replied to a thread you have subscribed to entitled - 
> After EA3 Django support [Case 33011] - in the Feature Requests for 
> cPanel/WHM forum of cPanel Forums.
> 
> This thread is located at:
> http://forums.cpanel.net/f145/django-support-case-33011-a-146541-new-post.html
> 
> Here is the message that has just been posted:
> ***
> For those who are not aware, we are soliciting feedback regarding a preferred 
> Python implementation via a new mailing list devoted specifically for this 
> subject.  If you want to participate, you can visit: cPanel 
> (http://go.cpanel.net/python)
> ***
> 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django search query

2013-06-30 Thread Scot Hacker

On Saturday, June 29, 2013 9:32:19 PM UTC-7, Harjot Mann wrote:
>
> Is there any search query in django which can ignore vowels like I want to 
> make a query which displays all the clients name who writes their name as 
> 'amanjit' or 'amanjeet'. 
> It should take take ee=i or anything like this. Please help me I have to 
> finish my task asap. 
>

This is really a question about regular expressions, not about Django. 
Whether you implement simple or complex search in Django, whether you use 
Django or some other platform, this is going to come down to using a fairly 
complex regular expression. So I would search for "regex ignore vowels" and 
similar. I would also expect performing a search like that to be extremely 
expensive, computationally, since it will need to tear apart every single 
word in the pool. That, in turn, means you'll want to use a search system 
with very robust indexes. In fact, you might do best with a system that 
pre-indexes all of your content without vowels. 

./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.
For more options, visit https://groups.google.com/groups/opt_out.




Strange 404s

2010-10-06 Thread Scot Hacker
We have enabled the option to have 404 requests automatically emailed  
to admins. It works well, but sometimes we get strange reports like  
this:



Referrer: http://ourdomain.edu/forums/software/
Requested URL: /forums/software/
User agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
IP address: 94.29.103.134


What's strange about it is that the referring URL http://ourdomain.edu/forums/software/ 
  *does not exist* - we removed it more than a year ago. So I can see  
why the requested URL is 404, but don't understand how a non-existent  
URL can be considered to be the referrer. Is this evidence of some  
kind of bot activity that fakes the referrer?


Anyone seeing anything similar?

Scot

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



wsgi conf ignored after apache restart

2010-10-26 Thread Scot Hacker
We have a consistent mystery on one of our .edu sites I'm hoping  
someone can help solve.


If we restart apache on this shared host, the site reverts to a very  
old, non-Django version of itself. That is, an antique PHP-based  
version of  the site is served up, and the design changes to one that  
we haven't used for 1.5 years. IOTW, the wsgi configuration works  
perfectly  on a fresh server boot, but if apache is restarted, the  
wsgi configuration is ignored and apache tries to pull in an old PHP- 
based site instead.


The problem is NOT triggered by apachectl graceful, but it IS  
triggered by apachectl restart.


Once this happens, the ONLY fix we've been able to find is to  
physically restart the entire server (taking all the other sites down  
for a few minutes as we do). No amount of restarting apache or mysql  
will fix it.


WHM/cPanel server with mod_wsgi
Django 1.2.3, MySQL 5
Source in svn
There is NO Django caching enabled whatsoever
No *.pyc files
We don't use memcached (beefy server, moderate loads, we really don't  
need caching).
In WHM, there are no parked domains, add-on domains, or subdomains  
configured.


Has anyone ever experienced this or anything like it? I run a number  
of Django sites on a number of servers, and have never experienced  
anything like it. Thanks for a clue.



Thanks,

Scot

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: OT: getting strange attempted gets

2010-11-15 Thread Scot Hacker
On Nov 14, 11:25 am, Federico Capoano 
wrote:
> No one is attacking your server, that's just the django server telling
> you what's going on in your app (when you perform any action the
> server logs it).

Right, but he said he's seeing requests that *can't* be explained by
his own requests.

I see this too when running runserver on the static IP of my dev box
rather than on localhost. In my case, it's almost always requests from
the university network security probes. It's actually satisfying to
sit there watching requests for all kinds of known XSS attempts,
security issues specific to common CMSs, etc., and see them all fail
against Django.

If you don't have security scanning happening on your network, it
could be requests from crackers running port scanners or similar.
Again, the solution is run runserver on 127.0.0.1, not on a public IP.

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django tagging app choices

2010-11-16 Thread Scot Hacker
On Nov 15, 8:55 pm, Thomas Schreiber  wrote:
> check the grids on django packages:http://djangopackages.com/grids/g/tagging/

django-taggit seems to be the new hotness. Unfortunately we've been
waiting for months for a conversion script to help us migrate from
django-tagging to django-taggit.

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: OT: getting strange attempted gets

2010-11-16 Thread Scot Hacker
On Nov 15, 8:45 pm, Steve Holden  wrote:
>
> Perhaps he did, but that's no reason to believe him until we know that
> his assessment of the situation  is likely to be realistic. Don't forget
> that a lot of people who post here aren't particularly experienced and
> so may not appreciate exactly what's going on.

I dunno. When you sit there watching runserver registering hits on
bizarre URLs and you know you're not the one clicking through the test
site, it's pretty obvious that something else is going on.

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User model optional

2010-11-21 Thread Scot Hacker
On Nov 20, 2:55 pm, VB  wrote:

> If I intend to write my own authentication, can I use my define my own
> User model? Or, am I better off naming the model something else?
>

Why write your own authentication? That wheel's been invented so
excellently by  django-registration (and its equally indispensable
cousin django-profiles). I'd recommend sticking with the Django User
object, and doing your auth with django-registration - they're
fundamentals of most Django projects.

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django-grappelli issue

2010-05-02 Thread Scot Hacker
On May 1, 10:12 pm, Tran Cao Thai  wrote:
> I discovered the grappelli app today and just set up it. However, the admin
> site doesn't look as good as the screenshot from the site. Here is the
> screenshot of my admin page
>
> http://i979.photobucket.com/albums/ae280/jasonvoorheeszzz/Capture.png
>

This is what happens to Grappelli when you set your media directory
correctly (the CSS is being found) but you haven't yet added the
Grappelli templates directory to your TEMPLATES tuple in settings.

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: surveys

2010-05-12 Thread Scot Hacker

On May 11, 3:16 pm, HARRY POTTRER  wrote:
> I have a project that I'm working on that works like this:
>
> the user enters some points on a map which are then stored in a
> database as a LineString object (via geodjango). Along with the
> geographic data, the user is given a survey to fill out consisting of
> simple questions like "how fun was this", "how old are you", and "was
> the parking sufficient", etc. There will be a pool of roughly 100
> questions, and the survey will be constructed based on the locale of
> the user. Different locales results in different sets of questions.
> There are 40-50 locales for this project.
>
> My question is how should I set up the surveys. I don't really want to
> hard code each survey per locale. I'd prefer to have the questions and
> choices defined in the database.
>
> There is a reusable app called "django-survey" but as far as I can
> tell the project is completely undocumented. I have it installed, but
> I can't figure out how to use it. Is this app the kind of thing that I
> can use, or is it meant for something else completely?

django-survey is probably your best starting point, but it will
probably take some customizing given your need to ask different
questions depending on answers to previous questions. No, it's not
well-documented, but it's also not too hard to get working. I found
the author pretty responsive to feedback when working with it last
year. But the Django world really needs a full-featured alternative to
Lime Survey, with all the bells and whistles people expect from survey
tools these days.

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: RSS Aggregator

2010-05-13 Thread Scot Hacker
On May 12, 11:06 am, beetlecube  wrote:
> Hello,
>  Just wondering if there are alternatives to the feedjack RSS
> aggregator that anyone has used. It doesn't have to be "Django-ized"
> like feedjack is.
>
> Just any Python library that you've had good luck with, parsing a lot
> of different RSS feeds.  I know there are examples of using Mark
> Pilgrim's feedparser with an aggregator tool, on his site. Was
> thinking of just using that.

I spent some time with feedjack and django-planet last year and came
to the same conclusion - writing your own system with feedparser is
the way to go, in combination with the source that drives the
Community section of the djangoproject web site.

http://birdhouse.org/blog/2009/10/20/generating-rss-mashups-from-django/

"The surprising solution came from the Community section of the
official Django project web site. The Django developers keep the code
that drives djangoproject.com in subversion along with the source code
to Django itself. And the code that drives that section of the site is
really lightweight. So I did a subversion checkout of the Aggregator
app, and found that all I really needed from it was its
update_feeds.py script, which itself is a wrapper around Universal
Feed Parser, tweaked to talk to my own models."

That became the system behind http://baynewsnetwork.org/ , which is an
RSS aggregator / mashup generator.

Scot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



ellipsis is not safe, use ellipsis.__new__()

2010-03-01 Thread Scot Hacker
I've been tracking trunk on 1.2 and recently started getting this
error when get_profile() is invoked:

TypeError at /item/9/

object.__new__(ellipsis) is not safe, use ellipsis.__new__()

Request Method: GET
Request URL:http://127.0.0.1:8000/item/9/
Django Version: 1.2 beta 1 SVN-12642

File "/Users/shacker/Sites/virtualenvs/domain.org/project/app/
views.py" in item_view
  268. mylist =
get_object_or_404(List,profile=request.user.get_profile())


Commenting out the get_profile() call makes the problem go away. It
was working fine in previous builds. Anyone else seeing this? Should I
file a ticket or is this a red herring (maybe I have another problem
I'm not seeing somewhere)?

Thanks,
Scot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Overriding admin Media class

2010-03-23 Thread Scot Hacker
Given an admin media class that sets up a rich text editor, like:

class TutorialAdmin(admin.ModelAdmin):

fields...

class Media:
js = ['/paths/...',]

I would like the ability to selectively override js. I've added a
"use_editor" boolean to the Tutorial model. The question is, how can I
detect whether the current instance has that bool set? I'd like to end
up with something like:

class Media:
if self.use_editor:
js = ['/paths',]
else:
js = ''

But can't find a way to make this work. Anyone have a working sample?
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Overriding admin Media class

2010-03-24 Thread Scot Hacker

On Mar 23, 5:32 pm, Paulo Almeida  wrote:
> I don't have a working sample (never did this), but you may be looking for
> something like this:
>
> class Media:
>        js = get_path()


>
> And in the class where you keep use_editor:
>
> def get_path(self)
> if self.use_editor:
> return path1
> else:
> return path2
>
>

This is a cool idea, but unfortunately throws me back to the original
problem - the class in Admin.py doesn't know how to get to attributes
on the model it references. So if I do:

 class Media:
js = get_path()

I get: "name 'get_path' is not defined".

If I do:

js = Tutorial.get_path()

I get: "unbound method get_editor_path() must be called with Tutorial
instance as first argument (got nothing instead)"

If I do:

js = Tutorial.get_path(self)

I get: "name 'self' is not defined"

Which is exactly the same problem as when I tried to access the field
directly. Seems like the core of the problem is that for some reason
"self" is not recognized from within admin.py classes.

Thanks for any tips on this.

Scot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Overriding admin Media class

2010-03-24 Thread Scot Hacker


On Mar 24, 12:05 pm, Firat Can Basarir 
wrote:
> Scot you need to learm Python.

Do you mean learn *more* Python? Great, I'm always game to learn more!
I've taken a Python class and read books and run several Django sites.
It's not like I don't know enough Python to be functional. But we're
all here to learn. Just saying, there's no need to be snarky.

>The problem is you are defining get_class as
> an instance method and trying to call it is a class method (or static
> method).

Sorry, I have no idea what you're referring to here, and Googling for
static vs. class methods is not turning up anything I can understand.
Can you show what you mean by example? (i.e. how it pertains to this
problem)?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Overriding admin Media class

2010-03-24 Thread Scot Hacker

On Mar 24, 2:08 pm, Shawn Milochik  wrote:

>
> http://docs.python.org/library/functions.html#staticmethod
>
> It means that the method is function that, when you run it, doesn't 
> specifically belong to any particular instance, but to the class itself.
>
> Shawn

Thanks Shawn. That URL's not working but I think I understand the
gist. To attach it to this problem: Usually when I define a method on
my model classes, they're accessible from views just attributes,
almost as if they were fields. In this case though I'm accessing the
model field or method not from a view but from admin.py and it's not
working. It sounds like you're saying that the model method is not
attaching to an instance like it usually does (which is why "self"
doesn't work). But I'm no closer to figuring out how why it's
different from model methods accessed from within views, or how I can
fix it.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Overriding admin Media class

2010-04-02 Thread Scot Hacker
Sorry for long delay on this thread. Back at the problem now.

On Mar 25, 1:22 am, Sam Lai <samuel@gmail.com> wrote:
> On 25 March 2010 09:25, Scot Hacker <shac...@berkeley.edu> wrote:
>
>
>
> > 
> > It sounds like you're saying that the model method is not
> > attaching to an instance like it usually does (which is why "self"
> > doesn't work). But I'm no closer to figuring out how why it's
> > different from model methods accessed from within views, or how I can
> > fix it.
>
> It's different because the Media class is a class itself, even though
> its definition is nested within the model/form class. It only has
> access to the methods/properties/variables it contains (unless it is
> given something else when constructed).

Ah! Now I understand this distinction, thanks for that.


> The solution to your problem is here 
> -http://docs.djangoproject.com/en/dev/topics/forms/media/#media-as-a-d...
>
> Admin media is based on Forms media, so the same principles apply.
>
> Sidenote - what's you've implemented is documented at the top of that
> link, and as stated, it is designed for static media. follow the
> 'media as a dynamic property' section and you should be able to
> achieve what you want.

That gets me part of the way there,  but not quite.

>
> Here's an example from my CkWidget class (no if blocks at the moment,
> but you can easily add them there as it is just a normal instance
> method inside your class):
>
> def _media(self):
> # add CKEditor JS to page. It is assumed that it is located at
> # MEDIA_URL + 'js/ckeditor/ckeditor.js' unless base path is overridden
> # in settings
> js = [settings.CKEDITOR_BASEPATH + 'ckeditor.js']
>
> return widgets.Media(js=js)
>
> media = property(_media)

OK I've got something similar now, using _media rather than "class
Media:" Now all that remains is to do a conditional on the js= line.
That would be easy IF I could access fields on the model it references
to see what the boolean is currently set to. I've been reading
everything I can find, including
http://docs.djangoproject.com/en/dev/topics/forms/media/#media-as-a-dynamic-property
but still can't see how to access a field value on a model from the
admin.

To boil it down, is it possible to get something similar to the print
statement below to work (once I can print it out I can use it in the
conditional).

# models.py
class Tutorial(models.Model):
 use_visual_editor = models.BooleanField()

# admin.py
class TutorialAdmin(admin.ModelAdmin):
def _media(self):
print [current value of use_visual_editor for the
instance]
js = ['/paths/to/media',]
return forms.Media(js=js)

media = property(_media)

admin.site.register(Tutorial, TutorialAdmin)

I appreciate your help - this has turned out to be one of those
problems that looks trivial but turns out hair-pulling. Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Overriding admin Media class

2010-04-02 Thread Scot Hacker
On Apr 2, 3:48 pm, Sam Lai  wrote:

>
> And that should work. You need to make sure you have the right imports
> for the various classes. I tend to define my forms in a separate
> forms.py but that's up to you.

Sam, you're a genius - that worked perfectly. Thanks SO much. I really
appreciate it.

Scot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Styling help_text

2011-01-31 Thread Scot Hacker
This ticket

http://code.djangoproject.com/ticket/8426

says that, as of six months ago, model field help_text rendered in
forms by {{form.as_p}} gets wrapped in a style-able span. But in
Django 1.2.4, {{form.as_p}} still generates unspanned help_text. It
also doesn't show up spanned in the docs:

http://docs.djangoproject.com/en/dev/ref/forms/fields/#help-text

I'm not sure what I'm missing here. I'd really like to stop manually
creating every field in form templates just to get style-able help
text.

Any pointers? Thanks.

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django email client (reusable app) kickstarter

2014-10-13 Thread Scot Hacker


On Monday, October 13, 2014 4:18:52 AM UTC-7, biuro wrote:
>
>  
>
> perhaps I run out too far in the future and this should be put on a 
> different database. 
> what do you think guys?
>

I think that database independence is a core feature of Django and of 
virtually every reusable app. Your project is designed (I assume) to be 
integrated into existing Django projects. By tying yourself to one 
database, your app is not being a good Django community citizen, and will 
be unusable by hundreds of thousands of existing Django projects that don't 
use postgres. 

If you find down the line that your app absolutely must have some 
pg-specific features, I recommend making those into *optional* features 
that can be enabled for qualifying users.

./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/1f8d0f7f-9e61-4fb4-ad7b-c5684cfab833%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New app - architecture

2014-10-19 Thread Scot Hacker

All good advice from Avraham Serour - just a couple of additional comments:

On Sunday, October 19, 2014 1:06:55 AM UTC-7, Avraham Serour wrote:
>
>
>
> > BE API for web services integrations: TastyPie? (API will have to be 
> versioned, I would like to have the auto documentation, too)
> I like tastypie, but use it only if you actually need it
>

Django REST Framework eclipses the functionality and ease of use of 
Tastypie, IMO, and has become the de facto standard for Django API 
generation. Its documentation is stellar and it is quite actively 
developed. I'm hoping that, now that migrations are in core, a discussion 
about integrating API generation into core is a next big topic for Django 
core (this is an area where Django lags behind Rails).

 

> > Deployment: Fabric?
> yes, but on the other hand this doesn't have much meaning, fabric just 
> makes easier automating ssh commands, it doesn't provide recipes for 
> deployment, you still have to plan this
>

Fabric is awesome, but as you move past the "automating ssh commands" into 
"we need a real build system," check out Ansible.

./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/e484397c-b665-4fa0-84a9-e21d40a39d82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: entering data directly into a postgreSQL database

2014-10-19 Thread Scot Hacker


On Saturday, October 18, 2014 10:05:11 PM UTC-7, Jon Joseph wrote:
>
>
> def __str__(self):
> return self.problem_number + '\n' + self.problem_statement
>

I don't like this idea of sticking a new line into a string representation. 
Do you really want a new line crammed into every possible situation where a 
string repr might appear? Feels like "code smell" to me. Does the problem 
go away if you replace the \n with a hyphen or something? 
 

>
> I would like to populate the database by using the PostgreSQL specific 
> command:
>
> COPY solutions_problemlist from 'filename'  
>

Rather than using pg's COPY command, I recommend writing an actual Django 
import script to parse your tab-delim file and import via the ORM. It'll be 
more automatable, part of your code repo, and more Django-like. You could 
also do it as a migration if you just need it to happen once.

./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/d350010b-20a9-4821-9a0a-0f8f6ca7b6a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: AUTH_USER_MODEL does not accept sub application

2014-10-27 Thread Scot Hacker


On Monday, October 27, 2014 8:58:36 AM UTC-7, Scot Hacker wrote:
>
>
> add2virtualenv /path/to/custom/apps/directory
>
>
>
And when its time to deploy, you'll need to do similar on the server, using 
an equivalent method in the wsgi definition, e.g.:

import os, sys, site

sys.path.append('/path/to/custom/apps/directory') 


./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/a3bb2bcd-d642-4c58-b59c-661e5e164953%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: AUTH_USER_MODEL does not accept sub application

2014-10-27 Thread Scot Hacker


On Monday, October 27, 2014 5:44:55 AM UTC-7, Collin Anderson wrote:
>
> Hi Frankline,
>
> Like you said, you need to use 'app_label.model_name' for AUTH_USER_MODEL, 
> instead of 'apps.app_label.model_name'. Django looks at INSTALLED_APPS and 
> knows to add the "apps" prefix when importing.
>
> What's wrong with setting AUTH_USER_MODEL to 'app_label.model_name'?
>


Since the  apps are in an "apps" folder, that folder location will need to 
be added to the python path. Then Frankline will be able to refer to them 
throughout the codebase via app_label.model_name rather than 
apps.app_label.model_name. 
If you're using virtualenv/virtualenvwrapper, this is easy to do:

add2virtualenv /path/to/custom/apps/directory

./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/ac31d04b-46ed-4e05-a36f-e3f7034946d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple site package directories for Python and question about apache configuration

2014-11-05 Thread Scot Hacker
 

You want to establish the path directories in your .wsgi file. Use 
`addsitedir` to set the path to site-packages and set additional paths with 
path.append, e.g.:

import os, sys, site

site.addsitedir('/path/to/site-packages')

sys.path.append('/extra/path/1')

sys.path.append('/extra/path/2')



On Tuesday, November 4, 2014 4:26:12 AM UTC-8, robert brook wrote:
>
> I see that there are 2 paths in my application for site packages.
>
> How do I configure Apache to use the 2 packages.
>
> A typical entry in Apache is
>
> WSGIPythonPath 
> /path/to/mysite.com:/path/to/your/venv/lib/python3.X/site-packages
>
> Can I specify 2 paths to represent the 2 locations of site packages.
> And what would the syntax be?
>
> On Monday, November 3, 2014 4:15:59 PM UTC-5, Aliane Abdelouahab wrote:
>>
>> On linux, python installs libs in diffferents places: for example in open 
>> suse, when you install it the first time, and you choose python and some 
>> third party libraries, and then when you will do setup.py for a library you 
>> download, they will be in different locations!
>> http://stackoverflow.com/a/12950101/861487
>>
>> Le lundi 3 novembre 2014 21:24:17 UTC+1, robert brook a écrit :
>>>
>>> I overlooked mentioning that the path command returned 2 different 
>>> locations for the 3 modules.
>>> Not sure why one package got installed in the lib64 path.  They were all 
>>> installed with the setup.py install command.
>>>
>>> On Monday, November 3, 2014 3:18:06 PM UTC-5, robert brook wrote:

 I am building the web application on a linux red hat machine.

 I was trying to pull the path for the site packages for the 3 modules 
 that I have installed so that I can specify the path in the apache config 
 file

 Can I specify 2 paths in Apache?

 Thanks



 >>> import django

 >>> print (django.__path__)

 ['*/opt/rh/python33/root/usr/lib/python3.3/site-packages/*
 Django-1.7-py3.3.egg/django']

  >>> import sql_server.pyodbc

 >>> print (sql_server.pyodbc.__path__)

 ['/opt/rh/python33/root/usr/*lib*
 /python3.3/site-packages/django_pyodbc_azure-1.2.0-py3.3.egg/sql_server/pyodbc']

   

 >>> import sqlalchemy

 >>> print (sqlalchemy.__path__)

 ['/opt/rh/python33/root/usr/*lib64*
 /python3.3/site-packages/SQLAlchemy-0.9.7-py3.3-linux-x86_64.egg/sqlalchemy']

 >>> 

>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/5f62bd18-f5ed-418f-8e78-181433c353c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ModelMultipleChoiceField forcing required

2014-11-05 Thread Scot Hacker
I'm having a strange issue with a pair of ManyToManyFields, where they're 
acting like they're required fields in the admin even though they're not.


# In models.py
instructors = models.ManyToManyField(Instructor, blank=True)
students = models.ManyToManyField(Profile, blank=True)



I can update an instance of this model with no instructors or students from 
the CLI just fine. The fields are not required. But I'm using 
ModelMultipleChoiceField in the admin:


# In admin.py
class OfferingAdminForm(forms.ModelForm):

instructors = forms.ModelMultipleChoiceField(
widget = widgets.FilteredSelectMultiple('Instructors',is_stacked=
False),
queryset = Instructor.objects.all())


students = forms.ModelMultipleChoiceField(
widget = widgets.FilteredSelectMultiple('Students',is_stacked=False
),
queryset = User.objects.filter(is_active=True))

and when I try to save via the admin, it tells me these fields are 
required. If I tweak it to not use this ModelForm, I can save without 
instructors or students just fine. 

Theories? 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/b99c64ec-d6af-4716-8d86-5f93bd00af0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModelMultipleChoiceField forcing required

2014-11-05 Thread Scot Hacker


On Wednesday, November 5, 2014 11:15:47 AM UTC-8, Carl Meyer wrote:


>
> So because you are manually creating your `instructors` and `students` 
> fields on the form, the `blank=True` in the model has no effect; you 
> need to pass `required=False` to your two form fields. 
>

Got it, right you are - that works fine. 
 

>
> (Because of this, I frequently choose to update/tweak form fields in an 
> overridden `__init__` method of a ModelForm, rather than overriding the 
> fields entirely.) 
>
>
Makes sense! 

Thanks,
./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/ff79b372-a8d0-4c39-ab62-277fd4869a1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django strange behaviour

2014-11-09 Thread Scot Hacker


On Saturday, November 8, 2014 9:07:04 AM UTC-8, monoBOT monoBOT wrote:
>
> Lists are inmutable 
>
Lists are absolutely mutable in Python - hence the availability of 
`result.append()`. 

Perhaps you're thinking of tuples, which are not mutable and have no 
methods for alteration. 

./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/3a17280a-ca43-448c-af2a-973e48db9207%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is django framework feasible for developing online LMS?

2014-11-12 Thread Scot Hacker


On Wednesday, November 12, 2014 7:54:18 AM UTC-8, Tom Evans wrote:
>
>
> There is basically no difference between any web framework in terms of 
> features, so pick whichever one you want that is in the language you 
> know or wish to learn. 
>
>
Frameworks may all have roughly the same features, but that doesn't mean 
they're equally effective to work in. Some frameworks are just better 
designed than others, or feel more intuitive, or have a better ecosystem, 
etc. In my opinion, the choice of a framework and its ecosystem is far more 
important than the particular language it's in. I love Python, but I love 
Django even more (IOTW I'd choose Django for what it is even if it wasn't 
written in Python). Django makes complex feature development easy, compared 
to other systems I've worked with. 
 

> As to whether you can build  in , it would 
> be a pretty bad  if you cannot build whatever  type> you want in it. 
>

Agreed.

./s
 

>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/5ea7726d-3551-417f-859b-f7b24ed189ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is django framework feasible for developing online LMS?

2014-11-12 Thread Scot Hacker


On Wednesday, November 12, 2014 8:11:16 AM UTC-8, Ari Davidow wrote:
>
> I am curious as to why you would write an LMS from scratch, rather than 
> use an existing framework--edX uses Django and that code is open-sourced 
> and available. Other open source possibilities, not relying on Django, 
> include Moodle and Sakai.
>

The nine months I spent working on a Sakai project were among the very 
worst of my professional development career. And it's virtually a dead 
project now. Now I'm working part-time on a large Moodle installation and 
finding it incredibly frustrating. You know how they say PHP has a tendency 
toward sprawling spaghetti code? Moodle feels like the poster child for 
that tendency. It's badly written, badly documented, the community is full 
of people taking wild guesses, plugins are half-baked, and lots of people 
are hacking core to make it do what they need it to do.

A lot of the complexity and mess in these products comes from their need to 
be all things to all people. Everything is overly abstracted, and 90% of 
the features you'll never use. Meanwhile you bear the brunt of all that 
baggage and complexity. I am currently lobbying the .edu I work for to 
replace a Moodle installation with a custom Django system that will do 
exactly the things we need it to do and nothing more. To discard the 
complexity and baggage and replace it with clean data modeling and known 
workflows that aren't "black box." Case in point: I spent around a month 
getting the Moodle course enrollment system to behave with a PHP script. 
Then I wrote a similar one for a separate Django system on the side. The 
Django version worked the first time and was literally 1/0 the size, in 
lines of code.

./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/6584d076-0aea-47a3-86d7-4ef0a3cb5f57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.contrib.comments depreciated, any good alternatives?

2014-11-21 Thread Scot Hacker


On Thursday, November 20, 2014 10:35:18 PM UTC-8, Code wrote:
>
> Hi,
>
> I have been facing a nightmare with django comments app.
>
> see: https://groups.google.com/forum/#!topic/django-users/7B2umISG-9I
>
> I found out it has been depreciated and so wanted to know suitable 
> alternatives. Disqus is one but is this suitable for local environment, I 
> am a beginner so need a little help with this. Also, Are there any other 
> good alternatives?  
>

Just because it's deprecated as part of core doesn't mean the software is 
unavailable. It's been moved over to its own repo as "extcontrib":

https://github.com/django/django-contrib-comments

 It's still a perfectly fine reusable django app; just no longer part of 
core. Remove references to the old official one in your project and install 
excontrib via:

http://django-contrib-comments.readthedocs.org/en/latest/quickstart.html

./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/c71b56d5-8590-415c-a349-ed483a9268d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple levels of user in django application

2014-11-28 Thread Scot Hacker

On Friday, November 28, 2014 3:16:41 AM UTC-8, Anju SB wrote:
>
> Dear Friends,
>
> I want to develop a django based GIS web application.  In my application 
> there are different levels of users namely station level user, circle level 
> user etc.  Each user details are provided in different table,  How can I 
> map/ relate the user with these tables.  Pleas help me to solve this issue. 
>  
>

I think of situations like this as having two prongs:

1) Various groups have various permission levels in portions of the project
2) Group members may have additional data/fields associated with their 
profiles.

For #1, use Django's Groups system to assign group memberships and 
 permissions as needed. You can start using those permissions throughout 
your project immediately.

For #2, you can create additional profile sub-types, keyed to a base 
profile. e.g. maybe everyone gets a UserProfile, while instructors also get 
an InstructorProfile that's FK'd to UserProfile. You can use post-save 
signals or other mechanisms to make sure that everyone has the right 
additional profile fields. Now let's say a user is looking at their profile 
editor - you could say "If user in group Instructors, also let them edit 
their associated InstructorProfile."

There are many ways to skin this cat...

./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/d4ee0831-d6c9-4c9e-8c90-61ef7b140292%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple levels of user in django application

2014-11-29 Thread Scot Hacker
On Saturday, November 29, 2014 8:49:25 AM UTC-8, Anju SB wrote:
>
>
> Thank your for your reply.  Actually I created another model that 
> aggregates all the values from each group table.  but after analyzing I 
> feel its a worst method and performance is also very low.So model re-design 
> is the only way to sort out this issue and need  help for redesigning the 
> models.  Because I want to add users and map these users to group details 
> from the admin page.  I am very confused state and I don't know how to 
> re-design and optimize the queries.   
>
>>
>>  
Django makes it easy to have multiple profile types with different sets of 
custom fields, and various permissions levels (roles). The admin does a 
good job of letting you add users to groups. I think you're going to have 
to spell out your problem/goals with more detail - we're not clear on 
exactly what's not working for you.  It might help (you and us) if you 
sketched out your desired model relationships with a charting tool or 
graphics program, or even as ascii art. 

./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/2559036e-17fd-4664-9011-a2efd6a7d2ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple levels of user in django application

2014-12-01 Thread Scot Hacker


On Monday, December 1, 2014 9:00:51 PM UTC-8, Anju SB wrote:
>
> Actually I can't change the models of the different user details 
> (state_data,district_data,dub-division_data,circle_data,station_data) 
> because these tables are used for other GIS activities.  
> I need to map user with these tables.
>
>
Looks like you deleted the message that contained the schema for the other 
tables, but I would probably give each of them a ForeignKey connection to 
your UserProfile model. Then you can do something like 

profile = UserProfile.objects.get(user__username='joe')

if profile.StateData:


It's hard to say more without being closer to the code or having a better 
sense of your goals.

./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/68a8a3b9-eb4b-4c73-96c9-809b81356e5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple levels of user in django application

2014-12-02 Thread Scot Hacker


On Tuesday, December 2, 2014 1:53:36 AM UTC-8, Anju SB wrote:
>
>
> We can't modify the 5 user details tables, because the other applications 
> are associated with that table. It is required to map these table with user 
> table.  But using the foreign key relationship we can only relate to one 
> table. How can I design models without affecting the 5 tables mentioned.  
>

 FK the UserProfile to those tables, not the other way around. That will 
leave them untouched/unmodified.

./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/89a54217-2270-4a04-9464-445fc3ca8792%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Devils advocate question

2014-12-17 Thread Scot Hacker


On Tuesday, December 16, 2014 1:15:57 PM UTC-8, Sayth Renshaw wrote:
>
> With django what benefit do I get for the extra build time over Drupal or 
> Rails. 


I'd strongly contest that statement. Development time might be roughly 
equivalent to Rails (given equally experienced developers), but compared to 
Drupal? I see Drupalistas struggling to convince the platform to do the 
simplest things, on a regular basis. With Django or Rails you build what 
you need and nothing gets in your way. I just blew the minds of people in a 
predominantly Drupal-centric establishment with a Django intranet/portal 
demo I built in three weeks - they couldn't believe it. Especially for 
development of more advanced features, I'd go head-to-head with a Drupal 
dev any day of the week.

This is five years old now, and a bit long-winded, but I still stand behind 
most of it:

http://birdhouse.org/blog/2009/11/11/drupal-or-django/

./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/ff329c68-151c-41a5-a203-d66b6c8c6616%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Any actual open project to create a company "social" network using Django?

2014-12-27 Thread Scot Hacker


On Friday, December 26, 2014 8:31:16 AM UTC-8, Fellipe Henrique wrote:
>
> Hi,
>
> There's any actual open project to create a company "social" network using 
> Django? I search on google, and I don't find any project using django (or 
> even other python framework)  only PHP or Ruby...
>


The Pinax Project includes quite a few social features:
http://pinaxproject.com/

See also the "Social" section of djangopackages.com:
https://www.djangopackages.com/grids/g/social/ 

but  at the end  of the day, Django is more about helping you to build the 
features you need. You might start by creating a project that uses one of 
the social login modules (like django-allauth) and then integrate a simple 
Follow model with manytomany connections between users.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/e1491222-31db-4b51-9ec6-c4ea4d763217%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Write Multiple Text Files into a Single CSV File

2014-12-31 Thread Scot Hacker


On Tuesday, December 30, 2014 9:54:10 PM UTC-8, Martin Mirero wrote:
>
> Hi folks,
>
> I'm just cutting my teeth on Python/Django and need some assistance on 
> something I've been grappling with for a few days:
>
>- I have a bunch of text files on disk that all have the same basic 
>format: first line is the *title* and the rest is the *body*
>- I want to create one CSV file with the first column being populated 
>from the first line of each text file (title) and the second column being 
>populated from the rest of the text file contents (body)
>- Once I have the CSV file, I'm good to import that into my django 
>model
>
>
Depending on your use case, there may be an easier (or more efficient way) 
to skin this cat. Both mysql and postgres have syntax that will let you 
load an entire csv into a db table as a one-liner. To do that from within 
Django, you need to be able to run an external shell command, and the best 
way to do that is (often) with Fabric. And since this is a function you'll 
likely want to do on a regular basis, it makes sense to wrap it all up in a 
Django management command.

Here's an excerpt of some code I use to do something similar:

http://pastebin.com/crpnNVrx

This is located in someapp/management/commands/import_courses.py . With 
this in place I can run

./manage.py import_courses

at any time. On each run, it:

- Drops a temporary table 
- Re-creates that temporary table according to a predefined postgres schema 
(contained in importer_courses.sql)
- Imports the CSV into that temporary table

In my case, I needed to be able to perform queries across the CSV data 
*before* importing some of it into my real models, but this turned out to 
be a wonderfully efficient way of handling CSV data in general. You don't 
have to drop and recreate the temp table each time - I chose to do it that 
way for my use case but season to taste.

To use this technique you'll need to `pip install fabric`, set a directory 
location where your CSVs are located (as IMPORTER_DATA_DIR in your 
settings), and read up a bit on Fabric and Django management commands. Then 
you'll need to modify it to handle multiple CSVs rather than just one.

./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/178e2096-a9b7-4f92-8d7a-f375371a527e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: passing variables

2015-01-13 Thread Scot Hacker


On Monday, January 12, 2015 at 5:29:08 PM UTC-8, suabiut wrote:
>
> How to you pass variable from one template to another template?
>

You haven't provided any information about your problem, but it sounds like 
you might want to read the docs on template inheritance:

https://docs.djangoproject.com/en/1.7/topics/templates/#template-inheritance

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/019d7274-0d52-4f7e-be9a-46f8335220af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Map Django Model to Legacy multi-join query

2015-01-21 Thread Scot Hacker
On Tuesday, January 20, 2015 at 8:02:57 AM UTC-8, Fred wrote:
>
> I've got a complex 1000+ table vendor read-only MS SqlServer database and 
> only have SELECT privileges.  I can connect with pymssql no problem.
>
> Of all these tables, I probably care about 50 or less.
>
> I cannot create views unless I introduce another physical server and use 
> the "Linked Server" option.  
>

I am working in a similar environment - 800+ tables in an external 
read-only  mysql db, plus whatever internal tables I need. To set it up, I 
used inspectdb to generate starter models for all 800 tables and piped the 
results to a text file. Then I manually copy out just the model definitions 
for the tables I actually interact with, and remove the many rows I don't 
need access to, and paste those into standard Django models. Massaged those 
as necessary. Then used Django's routers system for getting those 
definitions to appear in the admin (read only of course). And am able to 
create custom views via the .using() syntax. It's working so far, but I 
haven't gotten much farther than initial setup yet. Not sure what you mean 
by "linked server" - I don't see that mentioned in the docs. 

./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/c8b11988-efe0-4197-86ec-2d81dfd04228%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to check appname via Django commands?

2015-01-23 Thread Scot Hacker


On Saturday, January 17, 2015 at 1:38:32 AM UTC-8, Sugita Shinsuke wrote:
>
> Hi there.
>
> I use Django 1.6 version.
>
> The database of Django store the information of application.
> So, I know that if I  change the hierarchy of the Django project folders, 
> some trouble occurs.
>

The project name is contained in the manage.py file that's generated when 
you use `django-admin startproject` . If you change the project name you'll 
need to change it in manage.py as well.

./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/eae5d9b5-4256-44a3-8f28-6d7c7501858d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django for backend and frontend

2015-01-26 Thread Scot Hacker
On Sunday, January 25, 2015 at 4:29:00 AM UTC-8, Xiangyu Wu wrote:
>
> Hello,
>
> Shall I use Django for backend and frontend or is it a good idea to use 
> Angular JS for frontend and Django for backend. What are the advantages and 
> disadvantages?
>

Doing this means using Django as basically a JSON generator. And that 
generally means integrating something like Django REST Framework or 
Tastypie.

Advantages:

- If you want to build both a standard site and a smartphone native app 
that talk to the same back-end, you're ahead of the game
- If you have plans for rich client-side interactions, Angular is a great 
choice

Disadvantages:

- Your developers now have to learn and maintain two frameworks rather than 
one. Angular has a fairly steep learning curve once you get past the basics.
- You are discarding a ton of productivity tools and abilities that come 
with Django. For example the ability to follow relations between models via 
dot notation.

Basically, you are adding complexity and slowing down development time by 
adopting the SPA approach. You should have a very good reason for doing 
that.

./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/e4da656e-dd62-47af-97ea-413c2db97d41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Context processors, am I doing them right?

2015-02-04 Thread Scot Hacker


On Tuesday, February 3, 2015 at 4:56:09 PM UTC-8, Dean De Leo wrote:
>
>  Hi, 
> I am new to Django and I am still going through the tutorial. I've tried 
> to set up a context processor for the following scenario, and I would like 
> to obtain some confirmation if this is a proper solution or I am doing some 
> mess..
> In my base template with a header there is a navigation bar. A single 
> button should be highlighted among the others depending in the current 
> section / page in the website:
>

To me, this feels overly complex. Here's how I do current element selection 
in navigation, without context processors, by passing variables during the 
navigation's include statement. It does make templates a bit more verbose, 
but seems very clear and simple. 

In each page template:

{% block app_nav %}
{% include "dirapp/include/nav.html" with active_tab='something' %}
{% endblock app_nav %}

In the navigation:

Foo






-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/1c039e95-c4e2-41dd-94ec-dc720a122cba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to access json data value(s) returned back to django view from 'GET' request to an api

2015-02-06 Thread Scot Hacker
On Thursday, February 5, 2015 at 11:10:32 AM UTC-8, Henry Versemann wrote:
>
> I have a django view (django v. 1.7 ; python v. 2.7.8) which currently and 
> successfully sends a request to an api, and receives a good response back. 
> I'm sending and receiving using the 'requests' library (v. 2.4.3). Now in 
> addition to sending the raw response data back in an HttpResponse I would 
> also like to strip out some of the data and create a summary report of it, 
> to also send back in my HttpResponse.
>
What Larry said - you need to convert the javascript data format into a 
python data format. json.loads() will do that for you. Here's a working 
example: 


import json

def get_nyt_news():
# NYT API data
response = requests.get(

'http://api.nytimes.com/svc/mostpopular/v2/mostshared/all-sections/7.json?api-key={apikey}'.format(apikey=settings.NYT_API_KEY)
)

json_data = json.loads(response.text)
data = json_data['results'][0:4]

# Rewrite data to conform internal links
for d in data:
d['get_absolute_url'] = d['url']

return {'object_list': data}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/b7300a03-2200-485f-9d4e-227f08cef92d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to access json data value(s) returned back to django view from 'GET' request to an api

2015-02-06 Thread Scot Hacker
On Friday, February 6, 2015 at 9:39:00 AM UTC-8, Henry Versemann wrote:
>
> Scot, Thanks for the reply. OK I've gotten down to the point to where I 
> have my version of your json_data in your code below, but I'm not sure I 
> understand exactly what your code is doing, after you have the json_data 
> variable contents. In my case the first object of response data that I'm 
> trying to use is a list of two items, with each item containing multiple 
> keys and internal or sub objects within them.
>

Once your data comes back from the API and has been converted to python 
data structures, it's up to you to parse and extract from it what you need 
- every situation is different. All you need to know is that you access 
list items by their index, and dictionary items by quoted key name. So if I 
assign the response object you show here to a variable "data", I can do the 
following:

print(data[0]['parameters'])
print(data[0]['parameters']['extra_text'])
print(data[1]['attachment']['display_name'])

and the result is:

{u'enrollment_term_id': u'', u'extra_text': u'Term: All Terms;'}
Term: All Terms;
grade_export_csv_22_Oct_2013_2_27551-0.csv

Hope this helps!

./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/428cc652-220e-44d8-8818-33725c0b141f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Login in all pages

2015-02-07 Thread Scot Hacker


On Thursday, February 5, 2015 at 5:35:09 AM UTC-8, Juan Diego Gonzalez 
wrote:
>
> Hi, I need to put the django login feature in all pages, I mean, the user 
> will be able to login in the reserved area of the web from any public page.
>
>
Install django-stronghold or similar.
https://github.com/mgrouchy/django-stronghold

That'll lock down the entire site to registered users only. You can exempt 
any URLs that need to  be publicly accessible.

./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/efe9a984-e413-46e3-ab8b-20bf90c8f592%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Tests and read-only database

2015-02-09 Thread Scot Hacker
My project access two databases, one of which is remote and read-only. When 
running tests, Django wants to create a test_ copy of that db on the remote 
host, but of course it lacks permission (I lack write access to the entire 
db host). So I'm blocked from running *any* tests, even ones that don't 
involve models for the remote data.

I've come up with four possible solutions:

1) Tell Django's test runner to create the test version of that db locally, 
not on the remote host. However, the documentation 
 
doesn't indicate a way to use the TEST: {} dictionary to specify an 
alternate host. This would be my preferred approach, but it doesn't seem 
possible.

2) Use this 
 module, 
which tells the test runner to treat the read-only db "as-is" rather than 
creating a copy of it. I don't like this because of the risk that the db 
might one day NOT be read-only (it's been discussed in our org). And  the 
module is 3 years old without updates.

3) Use this  technique, where the 
read-only db is pop()'d off the settings, making Django effectively forget 
it exists during testing (but then of course I can't test any code that 
involves those models). I'm currently doing this just to get tests back on 
the rails, but it's obviously very limiting. 

4) Use this 

 
technique, which alters the routers configuration during testing.

Is there a preferred or recommended approach to this problem? 

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/2d599e4b-d208-472f-9a62-fc9c187da1d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tests and read-only database

2015-02-10 Thread Scot Hacker

On Tuesday, February 10, 2015 at 12:55:57 AM UTC-8, Avraham Serour wrote:
>
> you can tell django to use sqlite for tests, it will create an in memory 
> sqlite
>

Thanks Avraham. Having a bit of trouble finding specifics on this in the 
documentation, but this works neatly:

if 'test' in sys.argv or 'test_coverage' in sys.argv:  # Covers regular 
testing and django-coverage
DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
DATABASES['tmi']['ENGINE'] = 'django.db.backends.sqlite3' 

Nice speed improvement with those in-memory dbs, too! 

./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/71da6c8c-69ce-4a76-96b5-624be72771cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Rewrite (port) project from PHP (Code Igniter) to Django

2015-03-05 Thread Scot Hacker
On Thursday, March 5, 2015 at 4:28:13 AM UTC-8, Alexey Milogradov wrote:
>
> Hello everyone!
>
> I would like to collect thoughts, articles, posts, code bases, actually 
> any shared experience on how to port existing project from PHP to 
> Python/Django.
>

The specifics of the process are really different for each project, there's 
not much that can be said as a generality, but my advice:

1) Conceptualize  the major pieces of functionality of the site into what 
will become separate Django apps. Create a blank Django project with those 
apps stubbed out.

2) Starting with inspectdb,  break up its output into the various models.py 
files of the various apps.

3) Before working on any other part of the site, spend a good long time 
massaging those data models to perfection, using a combination of the 
Django Admin and ./manage.py shell. Work with the ORM to make sure every 
aspect of the data modeling is working exactly as you expect. All data 
relationships should be wired up properly before proceeding. 

4) Take a generated HTML page from the old site and save it base.html in 
your new project. Bring in all the CSS, JS and static media. Once that's 
working, break it up into the template fragments you'll need and get the 
basic interaction workflow of the site working.

The rest is standard Django development and has nothing to do with porting 
per se'.

I personally wouldn't worry about bridge plugins or anything. 

./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/960eec33-d0eb-4540-a9a7-df986739b166%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Binding hand written HTML(form) or forms that are not created through djnago forms to django forms validation errors

2015-03-10 Thread Scot Hacker


On Tuesday, March 10, 2015 at 4:10:48 AM UTC-7, Mahesh Thipparthi wrote:
>
> Hi All,
> Kindly help me with following questions.
>  
> Use case is this:
> 1. i have created a form manually ( not generated through django forms)
> 2. I am calling a Django view function upon submission.
> 3. validating the field through django form as i ensured that form names 
> are same.
>

>From your example code, I'm guessing the reason why you don't want to use a 
Django form is because you need to have  Bootstrap classes  on the form 
elements. A much better way to skin this cat is to use a standard Django 
form and then render it out with 
django-bootstrap-forms: https://django-bootstrap-form.readthedocs.org/en/latest/

./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/58f66a37-a512-44c6-ac22-1e5958a70a6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is bcc implemented?

2015-04-02 Thread Scot Hacker

>
> See 
> https://docs.djangoproject.com/en/1.7/topics/email/#emailmessage-objects
>

./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/3fba2b64-2423-4592-9bc3-e39cb0fbb8ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Admin should really support Twitter Bootsrap

2015-04-16 Thread Scot Hacker


On Monday, April 13, 2015 at 3:16:40 PM UTC-7, Patrick Lemiuex wrote:
>
> It's about time, the django admin tool should support twitter bootstrap 
> markups and styling. This is the third django project where I've had to 
> deal with custom form widgets because the admin tool supports kind of an 
> outdated layout scheme in the admin template.
>
> This also affects a lot of third party apps as well. It would be something 
> worth contributing to the community by me.
>

Have a look at this thread on the django-developers mailing list - a lot of 
work is going into the appearance of the admin right now:

https://groups.google.com/forum/#!topic/django-developers/HJAikaEBqJ4 

./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/fc5c8a93-8fb2-4296-a9ed-2c0fdf2310c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django data to Javascript

2013-10-15 Thread Scot Hacker


On Tuesday, October 15, 2013 8:45:09 AM UTC-7, larry@gmail.com wrote:
>
>
>>
> You can embed js anywhere in your template, e.g.:
>
> {% for shbf in should_have_found_list %}
> 
> my_js_function(shbf);
> 
> {% endfor %} 
>

I think you meant to write:

my_js_function({{shbf}});

Another take on this, should you need it, is to send JSON directly over 
from the django view or model method into the template. Here's how I solved 
that recently:

importance_options = json.dumps(dict(BundleNode.importance_options))

That will convert a Django queryset into a JSON object. Then, in your JS 
template, something like:

var $options_obj = {{importance_options|safe}};

Season to taste.

./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/5e97192a-e293-4856-9c78-65e9133e30a4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANNOUNCE] Django 1.6 release candidate available

2013-10-23 Thread Scot Hacker
On Tuesday, October 22, 2013 8:08:33 PM UTC-7, James Bennett wrote:

> It's almost here!
>
> Tonight we've issued a release candidate for Django 1.6. Information, 
> including links to downloads and release notes, is available on the Django 
> project blog:
>
> https://www.djangoproject.com/weblog/2013/oct/22/16c1/
>

 The removal of django.contrib.markup is noted in the deprecation plans but 
the release notes should probably mention that it's now been completely 
removed. 

Best,
Scot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/d4fe8e4e-5f9a-4cb9-aee5-d076a157747d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Can i Use history.js in Django?

2013-12-01 Thread Scot Hacker
On Sunday, December 1, 2013 4:21:33 AM UTC-8, Robert Jonathan Šimon wrote:
>
> Hello everyone,
> I want to use history.js on one page in my website, where there will be a 
> photo gallery, and I want to know before I will write the code, if it can 
> be done, and if so is there any problem  with it?
>

 Django is a back-end framework and thus completely agnostic about your 
front-end toolchain - go for it.

./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/2d86671a-6b83-4e54-b82a-0e84ba98b7d7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: need some explanation

2013-12-05 Thread Scot Hacker
On Wednesday, December 4, 2013 5:27:39 AM UTC-8, Tom Evans wrote:
>
> On Wed, Dec 4, 2013 at 7:20 AM, Hussain Nagri 
>  
> wrote: 
> > Hello, 
> > I am new to Django and trying to learn myself. 
> > My question is that when we create models in model.py then after each 
> class 
> > we define a '__unicode__'. Is it necessary that we define this method ? 
> It 
> > gets called every time I try to fetch any data from that model. what if 
> I 
> > don’t want it to run every time I try to fetch data ? 
>
>
 As Tom says, your model instances have to be represented on-screen 
*somehow*, so Python is going to run *something* to calculate what that 
representation should be. You should define it so you get the 
representation you want rather than going with the defaults - you're not 
going to save measurably on performance by skipping the _unicode_ 
definition.

./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/abc53592-8444-4762-a223-e522b623e1eb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django 1.6 + django-allauth facebook authentication error

2013-12-24 Thread Scot Hacker

On Monday, December 23, 2013 11:05:26 PM UTC-8, Nobin Mathew wrote:
>
> Hi,
>
> I am writing a django website using django-allauth for facebook 
> authentication.
>
> When I sign into facebook(after giving username and passwd) from my local 
> development server( 
> `<`http://127.0.0.1:8001/gallery/`>` 
> ) I get following error:
>

 When developing against Facebook, I find it easiest to create a localhost 
DNS entry emulating the domain registered in the FB app itself. So, if 
you're on Mac:

sudo vi /etc/hosts

and enter:

127.0.0.1  somedomain.com

And then:

./manage.py runserver somedomain.com:8080

Then just pull up somedomain.com:8080 in your browser and you'll be running 
a local dev site that FB sees as the production site, so your apps will 
work.

No such hassle with Twitter or Google.

./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/a83bd998-f2db-40ae-a088-9bcfc4e6c7a6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Need some suggestions on picking up the best combination

2015-06-01 Thread Scot Hacker

On Monday, June 1, 2015 at 4:03:46 AM UTC-7, William Dai wrote:
>
>
>
> Any comments on above options appreciated.  This would help me decide the 
> right way to go since once we commit, we would need to stick to the 
> decision for long time.  The project is a longterm project and could grow 
> to become a large website.
>
>
The philosophy of almost the entire Django ecosystem is one of modularity 
and re-usability - everything is designed for integration (but you'll have 
to do the integration yourself). Choices between Wagtail or Django-CMS, 
stripe or other, oscar or cartridge are really non-questions. Pick the 
tools you like best and go for it. 

I do really love Wagtail - that would be my pick for the CMS component for 
sure. 

./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/ff79558e-90d0-4f92-a30b-e39e11389fc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Grouping lists in a template

2015-07-13 Thread Scot Hacker


On Sunday, July 12, 2015 at 5:50:11 PM UTC-7, Andrea wrote:
>
> Hello. I'm new to both django and python. Been trying to figure out how to 
> group items from  a model for hours now. 
>

Check out the `regroup` template tag:

https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#regroup

It can probably save you from writing custom code for this.

./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/40de5ec2-c4d1-4cf2-8e4e-766dea21460b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I install Python 3 in a virtualenv on a MAC ?

2015-07-17 Thread Scot Hacker


On Thursday, July 16, 2015 at 2:24:10 PM UTC-7, plan9d...@gmail.com wrote:
>
> I'm new to Django and would like to install Python 3.x  in a virtualenv so 
> I can follow the tutorial given on the Django website.
> How do I install Python 3.x (latest version) within a virtualenv on a Mac? 
>

Assuming you have virtualenvwrapper as well:

which python3
[reports path to python3]
mkvirtualenv -p [path] venvname

./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/b95664b8-6b6b-4f1e-8fce-c71d767df39a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name error ,not defined problem

2015-07-19 Thread Scot Hacker
Your URL definition is calling a module that hasn't been imported. At the 
top of your urls.py, add:

from newsletter import views


In the URL definition, do:

url(r'^$', views.home, name='home'),


./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/87e47cfe-7495-467c-ac9a-07f1be84007a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why should we use Django Rest Framework?

2015-10-03 Thread Scot Hacker
Just  a quick tip: Sometimes you need a little JSON endpoint for some 
feature of your site or project, and a full REST framework like DRF is 
completely overkill. Django makes this incredibly easy, out of the box:


from django.http import JsonResponse

def some_view(request):
my_dict = {'foo': "bar"}  # Arbitrarily complex dictionary
return JsonResponse(my_dict) 


And that's it - the URL for that view now emits JSON, ready for JS to 
consume. It's ridiculous how little code you need to make it happen.

./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/eec3ec6d-921e-46b7-9099-d3dcc08bc08c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create a global management command?

2015-10-28 Thread Scot Hacker
Right - even though a management command must live inside of an app, all of 
them work "globally" across the project.  I often include an app called 
"base" in my projects for just this purpose - it includes management 
commands and utility functions that don't  belong logically to any other 
app.

./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/1b9194ba-34b7-4d03-8f3f-f08a5507729f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: git exclude files

2015-12-12 Thread Scot Hacker
On Saturday, December 12, 2015 at 7:38:21 AM UTC-8, Gary Roach wrote:
>
> Unfortunately, venv doesn't give me a choice as to where the files are 
> stored. They are all under the top directory of the same name as the 
> project but are actually in the same directory as the top level project 
> folder. ie /root/archive/ venv files, and archive/ project. From what you 
> say, they should not be included in the git source control. 
>

I think the misunderstanding here is that you're thinking you should put 
your project code into the venv/virtualenv directory. That's not really how 
it's intended to be used. A typical setup might be:

~/virtualenvs/myproject
~/dev/myproject

When you activate myproject, the corresponding virtualenv is placed on your 
python path, so the libs it contains are available to you, and your pip 
installs end up there. But you do *your own* work in ~/dev/myproject. 
Complete separation of installed libs from your own project code. The 
question you're asking should never come up.

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/71e3a0b0-9ac4-4728-aca6-c1abd86f884a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: git exclude files

2015-12-13 Thread Scot Hacker
On Sunday, December 13, 2015 at 8:17:15 AM UTC-8, Gary Roach wrote:
>
> As I mentioned earlier, venv and virtualenv do not work the same. There 
> may be a way to force venv to  put the files in a different place but the 
> default is to put them in the directory just above the start of the project 
> not in a separate .virtualenv file. So a different directory is not an 
> option. 
>

The venv docs  say that the 
process of creating a new virtual environment is just:

pyvenv /path/to/new/virtual/environment


It's not a matter of "forcing" the creation of the environment dir 
somewhere. If you are intentionally putting your project code in the same 
dir tree with the environment, you have a recipe for chaos. Again, there 
should be no need to .git exclude anything. 


./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/117573f1-d6fd-431e-ac6f-b821ae2463ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Structuring an API in a large project

2014-05-02 Thread Scot Hacker
On Thursday, May 1, 2014 8:59:25 AM UTC-7, Cezar Jenkins wrote:
>
>
> As you can guess, the views.py file is pretty big and I want to refactor 
> this out. Currently I have a few options in front of me, the one I'm 
> leaning towards is to put an 'api/v1' package into each app and use the api 
> app to tie all the urls together and hold views that don't fall into an app.
>
>
>
Hmm, I think the convention is to keep api code with each of your apps, so 
there shouldn't be a danger of anything getting too big / unwieldy:

apps
-- app1
models.py
views.py
apiviews.py
serializers.py
-- app2
models.py
views.py
apiviews.py
serializers.py

etc. import statements throughout the project are nice and readable. Works 
well for our (very large) project anyway.

./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/eeeb2695-db81-42f6-9594-1d83d86641df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Angular and Django

2014-06-22 Thread Scot Hacker
Angular is really wonderful, and I use it with several Django projects. But 
the two are agnostic about each other. All Angular needs from the back-end 
is a solid JSON API to work with and a few core back-end features like 
handling authentication. Modern JS frameworks like Angular, sadly, make the 
back-end almost (but not quite) irrelevant. The reason I use Django as the 
back-end is because Django REST Framework is so freaking fantastic as an 
API generator. I'm really hoping that once Django 1.7 lands and migrations 
are in, the dev team will turn its attention to native RESTfulness.

You do lose a lot of Django goodness when adopting a client-side framework 
though. For example, you can't traverse model relationships however and 
whenever you want - any data you need in the view needs to be added to the 
API first. 

This isn't *quite* ready for public consumption yet, but here's something 
I've been working on - a kit for building hybrid Django + Angular sites:

https://github.com/shacker/tristano


On Saturday, June 21, 2014 4:03:17 PM UTC-7, zweb wrote:
>
>
> I was looking at Angular and looks like it does many of the thing Django 
> Templates does but on the client side. 
>
> Are you using Angular with Django? How is the experience? What are the 
> /pros/cons? What are using django for and what are you using angular for?
> Is django pretty much a rest framework  with business logic and DB access? 
> (when used with Angular)
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/a1c94581-afe2-4a39-844e-72abc7973fa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to django-registration (unmaintaned since September 2013)

2014-07-24 Thread Scot Hacker
On Friday, July 18, 2014 5:31:14 AM UTC-7, Santiago L wrote:
>
> Hi,
>
> Some weeks ago I noticed that django-registration is not longer maintained 
> by
> its creator:
>

I've switched to django-allauth for my Django projects, which does an 
equally superb job of supporting both social and traditional logins, is 
very well documented, actively supported, and easy to implement. 

https://github.com/pennersr/django-allauth

YMMV. 

./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/23766955-9002-40bf-a064-c28e5ada382a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: school website

2014-08-13 Thread Scot Hacker
On Tuesday, August 12, 2014 6:46:40 AM UTC-7, ngangsia akumbo wrote:
>
> PLease i have a small question. I just need some guidance
>

Django is a great choice for school portals/intranets, and can accomplish 
everything you describe (I've built several of them, but can't make the 
source available, sorry). However, you have not asked any specific 
questions. You just need to start with the tutorials, read Django books, 
use StackOverflow and this list, etc... basically you need to learn how 
Django works, and the rest will fall into place naturally.  Maybe build a 
small sample/starter project first, then tackle this very large project. 
When you do, start with careful data modeling on paper, figuring out all of 
the intricate data relationships you'll need to describe the school's inner 
workings from an information architecture perspective. If your models are 
solidly defined, the rest will flow sanely from that. You have a big job in 
front of you.

./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/f06a1405-59c6-4081-8fe2-fc192d274e51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Multidimensional form requirements

2016-04-08 Thread Scot Hacker
I need to build a pretty complex / non-standard form and am looking for 
advice on the overall architecture. Consider the following models:

class UserProfile(User):
  ... standard set of fields


class ProfileExtra():
  ForeignKey(UserProfile)
  extratype (e.g. skill, work experience, website, publication, etc.)
  ... another set of fields


The idea is that, when editing a profile, a user can add an unlimited 
number of these ProfileExtras to their profile. So a user might end up with:

Profile
  name
  title
  about
  photo
Skills
  skill 1
  skill 2
Publications
  pub1
  pub2
  pub3
Jobs
  job1
  job2


etc. When editing their profiles, they'll be able to add/edit/delete any of 
these *in place* without leaving the page (it'll be ajax.)

So we have one core model and "n" number of related models. Obviously, a 
standard ModelForm can't encompass all of this cleanly. There are several 
things about this that just don't mesh well with Django's forms library. It 
deals with multiple model types, it deals with unknown additional numbers 
of a related model, it needs to be all ajax.

I'm really not sure about the best way to put it all together. I'm thinking 
we probably won't use Django forms at all - just do standard JS to 
create/destroy html form inputs on the page dynamically. Consider the whole 
thing as one big form element, and it all gets submitted every time. In the 
receiving view, pull apart the POST request and process it all manually. 
Advantage: total control. Disadvantage: we lose all the magic provided by 
model and modelform validation.

Another thought is that we could make e.g. "skills" into a single field and 
use ArrayField (we're on postgres) to store all of the related skills. Need 
to experiment with that.

Have any of you solved a similar problem? Are good ways to meet the 
requirements while still being able to take advantage of Django form 
validation goodness? I'm all ears. Thanks.

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9a14486b-c7fc-4a99-a0b0-03774c04ae1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multidimensional form requirements

2016-04-09 Thread Scot Hacker


On Friday, April 8, 2016 at 11:27:01 AM UTC-7, Tundebabzy wrote:
>
> I don't know if I'm off target but. 
>
> I'm presently work on something like this where I have have to save three 
> models at a go. One model is a stand alone while the other two have a 
> foreign key to the stand alone model which is a many to one relationship. 
> So to implement the many to one where I can save many of the dependent 
> models together with the standalone models, I made use of inline formset 
> and no problems thus far.
>

It's interesting - Django provides non-model forms, model forms, and 
formsets for dealing with multiple instances of the same model, but no way 
to build a single form that deals with multiple model types simultaneously. 
At this point, it's looking pretty much like I'll solve this outside of the 
Django box, by generating JSON representing the collection of data and 
using Angular to add/edit to the set with client-side validation, then 
post-processing the results in a Django view.

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75f0a892-db07-43d3-ab0f-4f9799591721%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Comparison of django MTV and MVC architecture

2016-04-17 Thread Scot Hacker
The Django docs have an FAQ on this topic:

https://docs.djangoproject.com/en/1.9/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names

"Where does the “controller” fit in, then? In Django’s case, it’s probably 
the framework itself: the machinery that sends a request to the appropriate 
view, according to the Django URL configuration."

The rest of the FAQ is worth reading for further clarification.

./s


On Saturday, April 16, 2016 at 7:08:56 AM UTC-7, Mukul Chakravarty wrote:
>
> Can we say that views in MTV architecture is basically performing the 
> tasks of both Models and Controller in an MVC architecture like Rails ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/f3d4eb21-a827-4cc3-b3c8-fc65d98d4470%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How and where should I put a version number in my Django project?

2016-05-03 Thread Scot Hacker
Another approach is to use git commit IDs and/or git tags to track 
releases, then display that data (and commit date) in a template, only to 
superusers or some group. I did a little blog post about this recently:

http://blog.birdhouse.org/2016/04/22/django_git_template_tag/

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/33efe23d-7ed7-4358-9ff1-7b41495b93e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Redirection to SSO using Django

2017-03-09 Thread Scot Hacker


On Wednesday, March 8, 2017 at 5:26:02 AM UTC-8, Arun S wrote:
>
> Hi,
>
> My Project, i would want to redirect login page to a SSO page.
> and handle redirection in Django.
>

You didn't mention what SSO service you are using for authentication, but 
there are existing Django apps for most common  SSO services. Our campus 
uses CAS, and the django-cas-ng module was very easy to install and 
configure. Almost no custom code needed.

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2767edc8-4616-46c9-97a5-1d5985e9fcbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Simple Join with no matching primary keys

2017-03-09 Thread Scot Hacker


On Wednesday, March 8, 2017 at 8:39:43 AM UTC-8, aysh...@gmail.com wrote:
>
> Tables are coming from different sources, for each single datetime value 
> there is a different url, in order to tie up the single source data it must 
> live inside its own table.
>

So why not make them into one table? You already have a field for `source` 
to distinguish the data source of each. Two tables with an identical set of 
fields is a code smell, IMO. 

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/341855e2-9bb0-4a32-b834-762384d78ea9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM for structured Logs

2017-04-08 Thread Scot Hacker
On Tuesday, April 4, 2017 at 5:18:42 AM UTC-7, guettli wrote:
>
> In the past I was told: Don't store logs in the database.
>

For general purposes, I agree with this. Logging is a python standard, logs 
can be verbose, logrolling solutions are well established (and built in), 
etc. However, there are certain situations or activities where database 
logging makes sense, most likely *in addition to* standard logging rather 
than instead of. In one of my projects, half a dozen non-technical managers 
need the ability to track certain types of actions (related to account 
activations at a school). For this, I developed a simple ORM logging 
solution that lets those managers search and filter these special logs in 
the Django admin. 

It's not something that really deserves to be its own project, IMO - just a 
typical thing a dev might do in Django to satisfy an institutional need. 
But I've put my solution in this gist, in case its helpful:

https://gist.github.com/shacker/05bc1de527a2d7412de361ac659aecde
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/c9486b92-010d-445b-b137-1b18f7ca5efb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Totally Lost on "python manage.py runserver"

2017-04-18 Thread Scot Hacker
`pip install pysqlite2` ? 

./s

On Friday, April 14, 2017 at 5:07:06 AM UTC-7, Michael Durkin wrote:
>
> I am at a loss. My Google-Fu seems to be sub-par as I cannot find an 
> answer to what I'm looking for. 
>
> I am running Ubuntu, using Python 3.6.0 (pyenv handles different Python 
> versions for me), have installed SQLite and Apache and ran "pip install 
> django" to get Django on my machine. 
>
> I have run through the Django tutorial on installation (
> https://docs.djangoproject.com/en/1.11/topics/install/#installing-official-release)
>  
> and made it all the way to "python manage.py runserver". After running that 
> line I get the following message through the shell that I simply do not 
> understand:
>
> ~/Scripts/Django_Practice/mysite$ python manage.py runserver
> Unhandled exception in thread started by  check_errors..wrapper at 0x7f0e6c4ce730>
> Traceback (most recent call last):
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py",
>  
> line 31, in 
> from pysqlite2 import dbapi2 as Database
> ModuleNotFoundError: No module named 'pysqlite2'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py",
>  
> line 33, in 
> from sqlite3 import dbapi2 as Database
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/sqlite3/__init__.py", 
> line 23, in 
> from sqlite3.dbapi2 import *
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/sqlite3/dbapi2.py", line 
> 27, in 
> from _sqlite3 import *
> ModuleNotFoundError: No module named '_sqlite3'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 227, in wrapper
> fn(*args, **kwargs)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 117, in inner_run
> autoreload.raise_last_exception()
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 250, in raise_last_exception
> six.reraise(*_exception)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/six.py",
>  
> line 685, in reraise
> raise value.with_traceback(tb)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 227, in wrapper
> fn(*args, **kwargs)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/__init__.py",
>  
> line 27, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/apps/registry.py",
>  
> line 108, in populate
> app_config.import_models()
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/apps/config.py",
>  
> line 202, in import_models
> self.models_module = import_module(models_module_name)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/importlib/__init__.py", 
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 978, in _gcd_import
>   File "", line 961, in _find_and_load
>   File "", line 950, in 
> _find_and_load_unlocked
>   File "", line 655, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 205, in 
> _call_with_frames_removed
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/contrib/auth/models.py",
>  
> line 4, in 
> from django.contrib.auth.base_user import AbstractBaseUser, 
> BaseUserManager
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/contrib/auth/base_user.py",
>  
> line 52, in 
> class AbstractBaseUser(models.Model):
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/models/base.py",
>  
> line 124, in __new__
> new_class.add_to_class('_meta', Options(meta, app_label))
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/models/base.py",
>  
> line 330, in add_to_class
> value.contribute_to_class(cls, name)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/models/options.py",
>  
> line 214, in contribute_to_class
> self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/__init__.py",
>  
> line 33, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/utils.py",
>  
> line 211, in __getitem__
> backend = 

Re: Need help in Django User Model customization and authentication

2017-05-14 Thread Scot Hacker
This is a fairly common need in academia, where your users need a different 
set of profile fields depending on affiliation. And you always end up with 
edge cases where some people are simultaneously faculty and staff, or even 
student and faculty, etc. And those "special" people will need to have all 
of the right fields available to them.  You could take an approach 
something like this:

- Set up standard Groups for Students, Faculty, Staff (and maybe Alumni)
- Have a management command or import script that ensures everyone is in 
all the right groups
- Set up a shared UserProfile model that includes all shared fields
- For convenience, set up model methods on UserProfile that determine a 
person's status based on group membership, e.g. `is_faculty()`, 
`is_student()` etc. (taking care to not interfere with Django' built-in 
`is_staff` boolean!). This way you can do quick affiliation checks from 
anywhere (e.g. in templates)
- Set up additional FacultyProfile, StudentProfile, StaffProfile classes 
with the unique fields and with ForeignKeys to UserProfile
- Either in your import scripts or in save() method or elsewhere, 
instantiate the additional profile classes:

if user.is_faculty():
  fac_profile = FacultyProfile.objects.get_or_create(user=self)

That's very loose and there are many ways to go about it, but that's one 
possible approach.  Another would be to simply put *all* possible fields on 
UserProfile and just populate them based on affiliation. That's not very 
clean though, because if someone stops being faculty for instance, it would 
be tricky to ensure you remove all of the right field data (it's messy). So 
 season to taste.

./s

On Saturday, May 13, 2017 at 7:32:27 AM UTC-7, Ajat Prabha wrote:
>
> Hello everyone,
> I'm creating a payment gateway to make transactions on my college campus 
> go cashless. It can be used to pay library dues, stationary charges, etc. 
> The user will add money to a central account and then he/she can use that 
> money virtually. I chose Django because of its security. But as I need 3 
> groups of users viz. Faculty, Student and Staff, I'm having trouble to 
> implement this in the best possible way. I fix one thing, the other gets 
> disturbed. I'm new to Django, so I don't have much experience. I'm 
> comfortable with views, basic models, etc. But this User customization, I 
> can't get it right.
>
> I'm attaching a representational User model (any suggestions are welcome), 
> please have a look. All the 3 groups will have certain fields common and 
> certain fields specific to that group only like roll_number/employee_code 
> and permission_sets(in case the system is later used for access to labs, 
> etc.). The fields at below of the image will be common to all groups.
>
>
> 
>
> I also tried this 
>  customization 
> which 
> worked but then I had issues in Django admin view where the password was 
> stored in plain hashed value. I think it has something to do with 
> reimplementing ReadOnlyPasswordHashWidget method declared in 
> django.contrib.auth.forms but I'm not sure!
>
> I chose Django in the first place for security reasons and I'm not able to 
> get it right.
> Can someone please help me out.
>
> 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/0c767ab1-5742-4441-8e57-fdb828325f68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django dev job opportunity at California College of Arts

2017-05-17 Thread Scot Hacker
San Francisco Django developers: A great opportunity has opened up at 
California College of Arts for a full-time Python/Django developer:

https://cca.wd5.myworkdayjobs.com/en-US/CCA/job/San-Francisco/Web-Developer_R502257

Full-stack skills desirable. This is a small but excellent team at a really 
interesting college. Check it out!

- Scot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/5a149079-b504-46db-a6ca-dff3ceb3767e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Non-primary auto-incrementing field with Postgres

2017-06-20 Thread Scot Hacker
One strategy might be to:

1) Bring in the data under a different column name ('old_id' ?)
2) In a single migration, drop the default ID column,  rename old_id to id, 
and give it primary_key=True

That should preserve your old IDs and set the next auto_increment to the 
next highest value (and if it doesn't, you can set the next val manually 
immediately afterwards).

./s


On Monday, June 19, 2017 at 9:30:31 AM UTC-7, Thomas Hauk wrote:
>
> I am working on a project that uses Django 1.10.5 with Postgres 9.6 (and 
> Python 3.6.1).
>
>  
>
> I am currently migrating historical data from an old system into the new 
> system. This historical data has a table with a (non-primary key) “ID” 
> column. I would like to migrate these rows into the new database, and have 
> that column be auto-incrementing (starting from, say, 10) for new rows 
> inserted.
>
>  
>
> I think the way to do this with raw Postgres SQL would be to create a 
> serial field, and then run a SQL command like “SELECT 
> SETVAL('some_table_field_id_seq', 10)”. I think.  :)
>
>  
>
> Does Django expose functionality that lets me accomplish this?
>
>  
>
> I looked at AutoField, but it doesn’t allow usage when primary_key=False.
>
>  
>
> T
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/7dfbbaf9-88f5-44e4-b19c-7fbbdedc1fc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: setup.py for Django project?

2017-09-11 Thread Scot Hacker
Thanks for the feedback everyone. Good to get some real-world input on 
non-standard approaches like this. I'm going to try and steer the project 
away from it.

And I agree that manage.py and setup.py are not interchangeable at all - 
especially since not everything *goes* through manage.py.

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f33e3f13-4353-48b6-9e9a-b45aa8f82bd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


setup.py for Django project?

2017-09-06 Thread Scot Hacker
I am accustomed to seeing pip-installable dependencies of a Django project 
each have their own `setup.py`. I am not accustomed to seeing a Django 
project *itself* have its own `setup.py`, but I am now working with a 
project that does just that. The setup does not move the Django project 
itself to `site-packages`, but does add the whole project to the Python 
path.

This approach is not documented or recommended by Django itself, and I 
can't find many references to it on the web. The stated advantages are that 
it lets you use `manage.py` from any dir (not just the top-level) and that 
it simplifies the writing of fab commands. I am wary of it because it 
(slightly) complicates setup, is unusual, confusing to new developers, etc. 

Does anyone have experience with this approach? In 10 years of Django 
development, I've never encountered this on a project, and it feels a 
bit... strange to me. But would love to hear from anyone who has had 
positive or negative experiences doing this. 

Thanks for any feedback,
Scot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/740d00af-0e81-452b-956e-c84fd5ca2e3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and Visual Studio Code

2018-05-01 Thread Scot Hacker


On Monday, April 30, 2018 at 4:38:51 AM UTC-7, Simon Connah wrote:
>
> I've got most of Visual Studio Code configured for Django development 
> (I'm trying it out to see if I can ditch PyCharm and save some money) 
> and almost everything seems OK. 
>

After moving through BBEdit, TextMate, Sublime and Atom over the years, I'm 
feeling like VSCode is the most polished, professional editor/IDE I've ever 
used (never did the pycharm thing). Learn a dozen keyboard shortcuts, and 
it's like it's reading your mind. 
 

>
> I set the Python path to be the one in the virtual environment, and if 
> Visual Studio Code needs to install any modules, they go into the 
> virtual environment. 
>

I use pipenv, and don't like this approach, as it rewrites Pipfile, which 
is in vcs and gets shared with the team, who all use different editors. I 
assume it does similar for requirements.txt. Dependencies specific to a 
given editor should not be forced on an editor-agnostic team. 
 

>
> The major problem is that when I open a terminal in Visual Studio 
> Code, it doesn't automatically activate the virtual environment, so I 
> have to source it manually. 
>

When you open a bash terminal, does it automatically activate an 
environment? I wouldn't expect it to be different in the editor's terminal, 
and `pipenv shell` still works normally. That said, you might be able to 
pass startup arguments via `terminal.integrated.shellArgs.*`
 

>
> In addition to that, I haven't managed to get debugging working even 
> after reading a few tutorials on the subject. 
>

You haven't really told us what's working/not working or how you've gone 
about setting it up. I just use icecream and good old pdb and log 
statements (haven't tried deep vscode integration). 

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6e853d2a-5613-4a8b-99c3-04c0a84507a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Adding Junk code to your django project

2018-01-11 Thread Scot Hacker
It is possible (though not common) to distribute the compiled *.pyc files 
rather than the source *.py files. See the bottom 
of https://www.smallsurething.com/how-to-obfuscate-python-source-code/ . 
Back in early days of Django there was a (very expensive) commercially sold 
content management system that was distributed this way.

./s

On Thursday, January 11, 2018 at 4:10:44 AM UTC-8, 
ashish...@exponentiadata.com wrote:
>
> Hello,
> I have a requirement which says that the user should not be able to 
> read/modify my code.I thought to add some junk code to the project
> is it possible??
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/277486b7-efda-4bd9-a2a8-0d6cdb20467d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I make a Django model from a tab-delimited data file?

2018-01-11 Thread Scot Hacker
Another approach is to use postgres' COPY command:

https://www.postgresql.org/docs/9.6/static/sql-copy.html

which knows how to parse and import tab-delimited files (and is crazy 
fast). Then, once the table exists, use Django's `inspectdb` management 
command to generate a Model corresponding to the table. It may need a 
little manual massaging afterwards, but I've done this on several projects 
and it works very well for most purposes.

./s


On Monday, January 8, 2018 at 6:38:44 PM UTC-8, Tom Tanner wrote:
>
> I have a tab-delimited data file that looks something like this:
>
>
> NAME S1903_C02_001E state county tract State-County-Tract-ID
> Census Tract 201, Autauga County, Alabama 66000 01 001 020100 01001020100
> Census Tract 202, Autauga County, Alabama 41107 01 001 020200 01001020200
> Census Tract 203, Autauga County, Alabama 51250 01 001 020300 01001020300
>
> I want to make a Django model named `MyModel` with three columns: "name", 
> "data", and "geoid", which correspond to the file's columns "NAME", 
> "S1903_C02_001E", and "State-County-Tract-ID." Can I do this via command 
> line, or with a custom Python script? I'm running my Django project locally 
> on a computer running Debian 9.3. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/708e0f1d-1cac-4321-a68e-697a4a8cd3da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: When to use get_user_model()

2018-02-20 Thread Scot Hacker
It's good future-proofing, in case you ever change the User model in your 
project. In real life, that's highly unlikely, but where it's *really 
important* to use get_user_model() is when you are writing reusable apps 
for distribution. If your app is intended to be dropped into any existing 
Django project, you have no idea what User model is in use by other 
people's projects. This layer of abstraction makes it possible for 
re-usable apps that depend on some User model existing to work no matter 
what.

./s


On Saturday, February 17, 2018 at 2:41:12 PM UTC-8, tangoward15 wrote:
>
>
> Hi, 
>
> I am playing around with user registration. I came across a code where the 
> get_user_model() was assigned to a model in Meta class inside a form. I was 
> just wondering, what is the benefit of using the get_user_model() as Model 
> in a form instead of importing a class from models.py then use that class 
> as model of the form and when should I use it?
>
> models.py
> class RegUser(User):
>
> def __str__(self):
> return self.username
>
> forms.py
>
> class UserCreateForm(UserCreationForm):
>
> class Meta:
> fields = ('username', 'password1', 'password2')
> model = get_user_model()
>
>
> Thanks,
> Jarvis
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/b0b0b57c-e152-4340-98ba-86933156a737%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN]: django-todo 2.0

2018-04-10 Thread Scot Hacker
 

“django-todo is a *pluggable*, multi-user, multi-group, multi-list todo and 
ticketing system - a reusable app designed to be dropped into any existing 
Django project. Users can create tasks for themselves or for others, or 
create ”assigned tasks” that will be filed into a specific list (public 
tickets).”


That was the original project description, and it hasn’t changed in 10+ 
years.


When I first created django-todo, it was a simple “let’s learn Django” 
project idea. I open sourced it, it’s been relatively successful, and the 
project has received numerous contributions over the years (grateful!). 
When I heard that it wasn’t compatible with Django 2.0, I looked back on 
that dusty old code and realized it was time for a major refactor/upgrade. 


The update started small, but by the end, I had made 75 commits and written 
the first suite of working tests (finally!). Virtually every module and 
template has been refactored, I  adopted Bootstrap as the default layout 
engine, and finally got around to creating a live demo site for the project.


django-todo 2.0 requires Django 2.0 and Python 3.x  - no apologies. 
Unfortunately, this is a backwards-incompatible update (you’ll need to 
migrate old data manually, if you have any).


Hope it’s useful to a few teams or individuals out there. Contributions 
still very much welcome.


Demo site: http://django-todo.org/

Docs: http://django-todo.readthedocs.io/

Github: https://github.com/shacker/django-todo

Demo host site (which runs django-todo.org): https://github.com/shacker/gtd


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/4222bcad-bb6d-4406-936b-3d3e0cc37f06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN]: django-todo 2.0

2018-04-12 Thread Scot Hacker
On Thursday, April 12, 2018 at 1:47:14 AM UTC-7, Derek wrote:
>
> Interesting to hear of this.
>
> Unfortunately we are currently committed to Django 1.11 as it is an LTS, 
> but if you're planning on keeping this in-sync with all 2.x releases, then 
> that opens up the option to look at using this from 2.2 onwards (that's the 
> next LTS).
>

I *believe* the only Django 2-only feature in use is the URL routing. While 
untried, I suspect it would be pretty easy to get it working in a 1.11 
project site by copying the provided urls.py into your own project, 
rewriting it in the old style, and including that from your main urls 
instead. Would be interested to hear whether this works for you.

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/114a2982-0355-455e-8edf-1535037ae680%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Web app dev job at CCA - San Francisco

2018-09-21 Thread Scot Hacker
Great Django job in San Francisco - I've worked with them before and can 
vouch for the crew and the school - great people, great technology 
(including the Wagtail CMS). Passing this along:

"
I have an opening for a web application developer on my team at the 
California College of the Arts in San Francisco. It's challenging work 
using interesting technology on a small, talented team in a fun and 
stimulating work environment with lots of stuff going on all the time.

We're developing tools, sites, and applications to support communication, 
collaboration, information, and teaching and learning at a time of huge 
change at the college.

[image: ]The best part is that our customers are literally right outside 
our door. 

[image: ] Full stack: Django, React, SASS, Google Cloud, more... 

[image: ] 
https://cca.wd5.myworkdayjobs.com/en-US/CCA/job/San-Francisco/Web-Application-Developer_R504088

[image: ] Please share with your network!
"

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7c5d050-437c-4904-acab-3f417359a0db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Starting a New Project somewhat like multitenant saas appication.

2018-09-26 Thread Scot Hacker
It's a little tough to understand what your actual questions are, but:

> the role-based authentication I can do but is there any other better 
option or thing available?

The native Django permissions system is limited to specifying who can see 
or edit particular models (and even then, is limited to ALL model instances 
of a given class, rather than specific ones like "just MY posts").  In my 
experience, there is more to granting permissions for users in different 
roles than what Django provides. For more complex requirements, I've had 
great success with django-rules:

https://github.com/dfunckt/django-rules

which you can use in conjunction with Django Groups to make your 
permissions logic as fine-grained as you need, using arbitrary logic nicely 
organized into "predicates" that you can combine in and/or statements. And 
you can use it to keep all of your rules in one central place. 

Keeps permissions logic consistent throughout the project, and nicely 
testable.

./s


On Tuesday, September 25, 2018 at 4:16:32 AM UTC-7, Devender Kumar wrote:
>
> Hello,
> I am Dev just two step ahead of a beginner(recently started to code in 
> Django). I want to develop an application seeking for some thoughts(help/ 
> favors/ etc) from you guys.
> The application fundamental is like Hierarchy is like At top soft 
> engg. team (me) > partners> client> location> device> end-user. All are 
> using the same application with some changes.
> Database: wanna have a common database for all. all the tables are shared 
> among hierarchy and records are filter according to the roles.
>
> Now the few questions the role-based authentication I can do but is there 
> any other better option or thing available?
> The second question is I want some database distribution at partner level 
> there is the concept of *schemas *(can you put some light on this also). 
> I want this to make queries little fast, independent and secure.
>
> Any type of solution. suggestion, reference you have happy to see 
> Regards 
> Dev
>
> Thank you so much.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/dbee5898-01b2-4ed2-b0b7-eb47be5aaaf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I refresh admin_urls

2019-02-23 Thread Scot Hacker
Django Admin is customizable to an extent, but at a certain point those 
customizations can cost you more time than they save, and it makes more 
sense to build your business logic in a standard app/view. Without digging 
into your code, my spidey sense tells me your app is at that point - stop 
trying to do it in the admin and you'll have all the control you need or 
want.

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/43ab1f41-dedb-4302-93b9-37548d21fd8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How does WSGI work?

2019-03-09 Thread Scot Hacker
Excellent summary - should be posted for posterity on a blog or something. 
I don't know enough about wsgi internals to add to this, but would have 
been nice to have this to read the first time I set up a server, back in 
the day. 

./s

On Tuesday, February 26, 2019 at 10:26:43 AM UTC-8, Tal wrote:
>
> I've been developing web applications using Flask and Django for about a 
> year now, and although I've come across the term WSGI a bunch of times in 
> both frameworks, I never really understood what it did. I'm sure I'm not 
> the only one. The quick explanations I read never made sense to me. Even 
> PEP didn't really give me a clear picture of how WSGI fits in with 
> Nginx, and Django. There are a bunch of articles online that quickly show 
> how to setup nginx, gunicorn/uwsgi and django to work in production, and 
> once I figured that out, I never really had a reason to figure out WSGI 
> again. But it's been a year now, and I probably should understand at least 
> the basics. 
>
> I did a bit more reading recently, and I think I get it. Just looking for 
> someone to confirm that I'm on the right track.
> This is how I think it works:
>
> My example uses the most common setup I use: Nginx, Gunicorn and Django
>
>- When an HTTP request comes in, it hits Nginx first
>   - Nginx runs multiple processes, and makes sure that 
>   browsers/clients that have a slow connection don't effect other clients
>   - If it's a request for a static file, like a CSS file, JS, image, 
>   or anything like that, Nginx returns it directly
>   - If it's a request for anything else, it uses *HTTP* to send the 
>   request over a Unix socket to Gunicorn
>  - Doesn't have to be a Unix socket, but if both Nginx and 
>  Gunicorn are running on the same host, it makes sense to use Unix 
> sockets
>  - The main point is that Nginx uses HTTP to communicate with 
>  Gunicorn
>   - Gunicorn
>   - Starts up x worker processes on startup (as many as you tell it)
>   - Each worker process imports your application's code 
>   (django.core.wsgi.get_wsgi_application() in Django's case)
>  - The application's code is a callable function
>  - Gunicorn imports it so that it's ready to make a function call 
>  to it as soon as an HTTP request comes in
>   - When an HTTP request comes in from Nginx, Gunicorn will:
>  - Use its main process to assign the request to a free worker 
>  process
>  - The worker process translates the HTTP headers into a python 
>  dictionary (commonly called the 'environment' dictionary)
>  - The worker process makes a function call to your application, 
>  passing it the 'environment' dictionary, and a start_response 
> function
>   - When your application (Django) decides what to do about the 
>request, and decides to formulate a response, it will:
>   - Call start_response, giving it the HTTP response status (eg. 200 
>   OK), and the HTTP response headers as a Python object (list of tuples)
>   - Note: At this point, nothing is sent to the client's browser, or 
>  even Nginx yet
>   - *Return* the body of the response as an iterable
>- Gunicorn will then:
>   - Add any required HTTP headers the application didn't provide
>   - Turn the status, headers and body that it received from the 
>   application into an HTTP response message
>   - Send the response back to Nginx using HTTP
>- Nginx will then send the response back to the client
>
>
> So the job of the individual parts is basically this:
>
>1. Nginx
>   - Buffers slow clients
>   - Quickly serves static files
>   - Possibly handle SSL, if configured
>   - Passes HTTP requests to Gunicorn (also using HTTP)
>   2. Gunicorn
>   - Deals with TCP connections between nginx and itself
>  - Prevents your application from needing to do lower-level 
>  socket stuff with TCP
>   - Converts HTTP requests into Python objects, and responses back 
>   into HTTP
>3. Django
>   - Just worries about formulating responses to requests, not keeping 
>   track of TCP connections, or HTTP, or anything low-level
>
>
> For Apache, they have mod_wsgi, which takes the place of Gunicorn, acting 
> as a WSGI server.
>
> That sound right? Or am I way off?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/14a43f07-377d-491d-b952-487336fc257b%40googlegroups.com.
For more options, visit 

Re: Webinterface for python script

2019-02-07 Thread Scot Hacker


On Wednesday, February 6, 2019 at 1:27:18 AM UTC-8, Eric Pascual wrote:
>
> Hi Derek,
>
> but I have never seen anyone refer to it as a "lightweight" project 
> (before you, that is).
>
> I didn't meant "Django *is* lightweight" but "Django *can be* 
> lightweight", implied you configure it accordingly.
>

To be clear, I'm talking about stock Django. Out of the box, Django is 
already lightweight for all practical intents and purposes. I've *never* 
encountered a problem with startup time, memory usage, or speed due to 
Django itself. I don't need to remove the ORM or tweak the template layer 
or anything else. Out of the box, Django is already fast. Therefore, I 
cannot seem to find a use case that makes Flask worth all of the additional 
dev time that it requires worth it. 


> What really matters is : "will the job be done ?". 


Yep. And quickly. In execution time, there is no metric I care about where 
"Flask wins" but in development time, stock Django is way ahead of Flask.

>
> I agree that what could be added in Django documentation is a section 
> explaining how to strip its default application setting down to the minimal 
> stuff for equating solutions such as Flask,
>

No need. Django doesn't need to be stripped down - it's already plenty fast 
for virtually every web project. Even the smallest ones. But as small 
projects grow into large/complex ones, Django has your back while Flask 
does not. 

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8652bc68-3857-4d91-a3ba-8868ec63f636%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Webinterface for python script

2019-02-05 Thread Scot Hacker
If I were just starting out, and needed to learn how to handle uploaded 
files, google would take me to these two docs:

http://flask.pocoo.org/docs/1.0/patterns/fileuploads/
https://docs.djangoproject.com/en/2.1/topics/http/file-uploads/

Maybe I'm crazy or my perspective is skewed, but I think I would find the 
Django instructions easier to follow, and I would have my solution faster.  
In other words, I don't buy the "Flask is easier to get started with" 
argument (OK maybe for a few very primitive use cases). 

So... 

"Flask is lightweight." What does that mean? It starts up in 1 second 
rather than 2 seconds? Why would that be important to me? 

"Flask is easier to learn." Definitely not, as far as I can see. Because 
Django includes everything you need for common use cases, the path to 
success is almost always easier with Django. 

If I were teaching a class of people new to programming, I would choose 
Django over Flask for its ease of use. And as a developer, there's no web 
project so small that I would choose Flask over Django - just not worth the 
additional time investment and hassle that Flask requires. 

My .02 anyway.

./s


On Tuesday, February 5, 2019 at 5:26:34 AM UTC-8, Derek wrote:
>
> Hi Eric
>
> Of course I also think Django is great ... but I have never seen anyone 
> refer to it as a "lightweight" project (before you, that is).
>
> My use of the word "overkill" was in the context of what how the OP 
> described his need.  If he said he wanted to upload data from a spreadsheet 
> and store in a DB, then I would offered advice how to do that with Django.
>
> But its a mistake to think that "Python" + "data processing" automatically 
> equals Django.
>
> My 2c
> Derek
>
>
> On Tuesday, 5 February 2019 11:04:45 UTC+2, Eric Pascual wrote:
>>
>> Hi,
>>
>> I never know what people mean by "Django is overkill for...". Django is 
>> lightweight and starts up very quickly
>>
>> You're right WRT the Django technical part. 
>>
>> My feeling is that people implicitly refer to the learning curve, because 
>> it's the visible part. Django is a very capable framework with batteries 
>> included, but its documentation is largely ORM-centric* (which is 
>> logical because of its  motivations) *in addition to being quite 
>> voluminous *(which is a good point, since it covers every tiny bit of  
>> the beast)*. This can be intimidating when people are looking for 
>> something very basic which does not require the ORM. 
>>
>> I was among these people until my experience and skills in Django reached 
>> the level where I became aware that it can be stripped down to a very basic 
>> an lightweight framework if needed, thanks to its modular approach. But 
>> this came with time 
>>
>> Best
>>
>> Eric
>> --
>> *From:* django...@googlegroups.com  on 
>> behalf of Scot Hacker 
>> *Sent:* Tuesday, February 5, 2019 08:54
>> *To:* Django users
>> *Subject:* Re: Webinterface for python script 
>>  
>> Make a basic Django view. Place your script in a python module that lives 
>> inside your app. Call that module/ function from the Django view. See 
>> Django docs and tutorials on how to handle uploaded files. Pass the 
>> uploaded file to your module, and handle the return value(s) however you 
>> want. Hard to get more specific than that without seeing your code, but 
>> this should come together pretty quickly with some experimentation.
>>
>> I never know what people mean by "Django is overkill for...". Django is 
>> lightweight and starts up very quickly, even with large/complex projects. 
>> Django saves you mountains of time compared to Flask, which makes you go 
>> shopping for every little piece of framework you need. Every time I've 
>> experimented with Flask, I've come running back to Django after realizing 
>> my time is too valuable to waste it on creating my own framework when a 
>> perfectly great one already exists. 
>>
>> ./s 
>>
>>
>> On Sunday, February 3, 2019 at 7:53:20 AM UTC-8, Asad Hasan wrote: 
>>
>> Hi All , 
>>
>>   I have created certain python scripts to analyze log files and 
>> suggest solution based on logic which I invoke on the command line . I need 
>> some information on how to execute these through browser . I am using :
>>
>> python test.py file1 file2 
>>
>> How do I use the browser to upload the files file1 and file2 and it 
>> process the files .
>>
>> Please advice ,
>>
>> Thanks, 
>>
>> -- 
>

Re: Webinterface for python script

2019-02-04 Thread Scot Hacker
Make a basic Django view. Place your script in a python module that lives 
inside your app. Call that module/ function from the Django view. See 
Django docs and tutorials on how to handle uploaded files. Pass the 
uploaded file to your module, and handle the return value(s) however you 
want. Hard to get more specific than that without seeing your code, but 
this should come together pretty quickly with some experimentation.

I never know what people mean by "Django is overkill for...". Django is 
lightweight and starts up very quickly, even with large/complex projects. 
Django saves you mountains of time compared to Flask, which makes you go 
shopping for every little piece of framework you need. Every time I've 
experimented with Flask, I've come running back to Django after realizing 
my time is too valuable to waste it on creating my own framework when a 
perfectly great one already exists. 

./s


On Sunday, February 3, 2019 at 7:53:20 AM UTC-8, Asad Hasan wrote:
>
> Hi All ,
>
>   I have created certain python scripts to analyze log files and 
> suggest solution based on logic which I invoke on the command line . I need 
> some information on how to execute these through browser . I am using :
>
> python test.py file1 file2 
>
> How do I use the browser to upload the files file1 and file2 and it 
> process the files .
>
> Please advice ,
>
> 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/88c2337b-7e8a-4e11-968f-30299b6229d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Different types of testing

2019-07-13 Thread Scot Hacker
On Friday, July 12, 2019 at 5:33:38 AM UTC-7, Chandrashekhar Singh wrote:
>
> Hello Developers,
> I am curious to know  what are testing methods do we use in django. Does 
> any has good examples or codes except django documentation.?
> thanks
>

 I don't have numbers, but subjectively, it feels like most modern Django 
projects use pytest with pytest-django, while older projects use the native 
unittest module.

./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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/131b6ca1-d526-46c3-a2b1-343b3525ec72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm struggling with Django's view directory structure.

2020-01-08 Thread Scot Hacker
That is entirely up to you. The typical scenario is that you have one views 
module per app in your project, which would live at your 
`yourapp/views.py`. If your app has lots of views and you want to keep it 
from getting too large, another common pattern is to have one module per 
view in a directory, like: `yourapp/views/action1.py` and 
`yourapp/views/action2.py`. How are you organize it is up to you - you have 
control over your own Python imports. Really just a matter of housekeeping…

./s


On Tuesday, January 7, 2020 at 5:29:42 PM UTC-8, 片岡一平 wrote:
>
> Hi, 
>
> I'm struggling with Django's view directory structure.
> Now, I am creating an app with the following URL structure.
>
>
> domain / app / page_category1 / action1
> domain / app / page_category1 / action2
> ...
> domain / app / page_categoryN / actionM
>
>
> In this case, how should the Django view directory be constructed?
>
> Thanks for watching.
> I'm glad if you get some advice.
>
> Kataoka
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/8912eafc-8df7-4ca8-a80d-14fa94ba1e0e%40googlegroups.com.


  1   2   >