Re: Recommendations for hosting service?

2015-01-06 Thread Kristofer Pettijohn
Also +1 for AWS. You can start out small for free for your first year, and grow 
to the size of Pinterest over time. All of the other tools they provide are 
helpful as well: RDS so you don't have to manage your own database, Caching 
Service, Queuing Service, etc. 


From: "Fred Stluka"  
To: django-users@googlegroups.com 
Sent: Tuesday, January 6, 2015 8:01:25 PM 
Subject: Re: Recommendations for hosting service? 

+1 for AWS. 

Been using it for years. Keeps getting cheaper and better. 

--Fred 
Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ 
Bristle Software, Inc -- http://bristle.com -- Glad to be of service! 
Open Source: Without walls and fences, we need no Windows or Gates. 
On 1/6/15 10:46 AM, Mark Phillips wrote: 



+1 for Linode and Digital Ocean. 

Also, you can get 2 Virtual Private Servers on AWS EC2 for free for the first 
year. 

http://aws. amazon .com/free/ 

Mark 

On Tue, Jan 6, 2015 at 7:21 AM, claudiomet < claudio...@gmail.com > wrote: 

BQ_BEGIN

I have digitalocean and no problems 

2015-01-06 11:05 GMT-03:00 Vijay Khemlani < vkhem...@gmail.com > : 


BQ_BEGIN

I like Linode, and DigitalOcean is also a great choice. 

Both require low-level configuration of the server but I prefer that over the 
pre-packaged solutions. 

On Tue, Jan 6, 2015 at 10:44 AM, Brad Rice < bradri...@gmail.com > wrote: 

BQ_BEGIN

I like webfaction, too. I think they would have all the stuff you list as well 
as more. 

On Tuesday, January 6, 2015 6:30:18 AM UTC-5, Bobby Mozumder wrote: 
BQ_BEGIN
Anyone have recommendations for hosting services that can do Django, Node.js, 
Postgreqsl, python3, as well as PHP/MySQL for legacy stuff? I’m also looking to 
have IMAP email. This would be for several domains, with maybe 100GB of data. 

-bobby 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group. 
To unsubscribe from this group and stop receiving emails from it, send 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/1c61b6c7-ae41-48fa-a2f1-2eb1b8a7ea68%40googlegroups.com
 . 

For more options, visit https://groups.google.com/d/optout . 

BQ_END


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group. 
To unsubscribe from this group and stop receiving emails from it, send 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/CALn3ei2Vh-OmGWYd25-fL829cokjKLvcF59EV0nvpk7E%2BQEd5g%40mail.gmail.com
 . 

For more options, visit https://groups.google.com/d/optout . 

BQ_END




-- 
Claudio Cortes N. 
Project Engineer 
Environmental Area 
MICOMO S.A. 
Tel: +56 (2) 22400516 
Cel: +56 (9) 65871064 
ccor...@micomo.cl 
www.micomo.cl 
Antonio Rabat Sur 6165, Vitacura 
Región Metropolitana, Chile 
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group. 
To unsubscribe from this group and stop receiving emails from it, send 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/CABWjCh3rsr23aw2LwhJPcO3SkR_FG3_Ct4VPAAUdi9iz97WBfQ%40mail.gmail.com
 . 

For more options, visit https://groups.google.com/d/optout . 

BQ_END


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

BQ_END



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

-- 
You received this message bec

Re: Default UserCreationForm and UserChangeForm hard-coded to User; is this required?

2015-01-06 Thread Joel Burton
James –

Thanks for the reply.

I'd agree that the docs suggest you have things to do if you replace the 
User with a custom user mode—but the docs also say to use get_user_model() 
versus hardcoding User ;)

It's true that the built-in user form makes assumptions about the length of 
the username and that the only immediately-requried thing are the username 
and password.

I'd say, though, that for most of the custom-user-models I've used and 
seen, the standard user form in the admin would work fine -- the UserChange 
form, after all, shows all fields on the model, so it adapts to custom user 
model with more fields. 

It seems like an unnecessary hoop for someone to have to jump through to 
subclass those two forms just to change the model when we already have a 
get_user_model() feature for avoid that sort of thing.

(And, thanks; I was changing the codebase directly to ensure that it worked 
when changed as such. I originally had subclassed the forms but was curious 
about whether it would have worked for Django to simply use 
get_user_model() in the contrib.auth directly. For now, I've moved back to 
subclassing--I'd agree it would be crazy to try to maintain a private for 
this. My question was about whether there was a compelling reason for 
Django not to use get_user_model() itself)

Thanks again for thoughtful reply!



On Monday, January 5, 2015 9:48:13 PM UTC-8, James Schneider wrote:
>
> The docs are pretty specific that the forms are only designed to work with 
> the included User model. 
>
> IMO the rationale behind this is if you plan to substitute your own model, 
> it is likely that you'll break the behavior of the included form, or more 
> likely, it will produce unintended behavior.
>
> For instance, if you wanted to expand the number of characters allowed for 
> a user name from the default of 30 to 100, the included form will still 
> limit the username field to 30 characters or it will fail validation, even 
> if your custom user model allows it.
>
> I believe it is expected that if you have a custom user model, you are 
> also planning to override all of the related functionality to match, 
> including the forms related to creating a user, since you have different 
> requirements than what Django provides by default. Otherwise there is no 
> reason to override the User model.
>
> If you are fine with the default parameters enforced by the Django User 
> model, but want to add additional information to the user (such as info you 
> would find on a user profile page like address, phone number, etc.), then 
> you should consider creating a separate model with a foreign key back to 
> User so that it can be retrieved when the profile information is needed. 
> See the second paragraph here:
>
>
> https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#extending-the-existing-user-model
>
> I would only override the existing User model for the following reasons:
>
> 1. You have specific requirements about the information a user can use to 
> authenticate themselves, such as a longer user name, or only accepting an 
> email address as a user name, two-factor authentication, etc.
>
> 2. If the current included model is fine, but there is ANY chance that 
> your requirements for logging in will change in the future, create a custom 
> user model now (along with all of the related forms, etc.), even if it 
> exactly mirrors the existing model functionality. You can even inherit 
> directly from User to keep the existing Django batteries intact. While I 
> haven't tried this myself, my understanding is that converting to a custom 
> user model with existing production data can be quite an unpleasant 
> adventure. Having a custom user model in place from the beginning generally 
> means that your existing data stays put in the same table, and changes to 
> your custom user model are handled much more gracefully through standard 
> migrations, rather than potentially invasive and direct schema alterations.
>
> If you do use a custom user model, keep the fields to the minimum needed 
> to authenticate and uniquely identify a user, and for information that will 
> be needed on a majority of pages (such as first/surname if you display it 
> on a toolbar or something). If you keep the default context processors, 
> your user model will be loaded on every request, so having a small amount 
> of data to load will be helpful. Other ancillary information can be loaded 
> on demand via a user profile model via the link above.
>
> Also, I hope by 'changing the Django codebase' you weren't actually 
> modifying the internal Django code. There shouldn't be any need for that, 
> since pretty much all behavior can be overridden externally. If that is the 
> case, a question about user creation forms will be the least of your 
> concerns given the bugs you'll likely run into. The only reason I would 
> recommend doing so would be for learning the internals in a sandbox or 
> supplying a patch to commit f

Re: Serving static files and media in Django 1.7.1

2015-01-06 Thread Sithembewena Lloyd Dube
Thanks @Vijay! Can't believe that caught me out like that.

Regards,
Sithu

On Wed, Jan 7, 2015 at 1:34 AM, Vijay Khemlani  wrote:

> the static tag should be
>
> {% static 'mainsite/bootstrap.css' %}
>
> according to the layout you said
>
> On Tue, Jan 6, 2015 at 8:30 PM, Sithembewena Lloyd Dube  > wrote:
>
>> Hi everyone,
>>
>> I have a Django 1.7.1 project structured as per documentation. In it, I
>> have an app called "mainsite". In mainsite, I have
>> templates/mainsite/index.html and static/mainsite/bootstrap.css. In the
>> index template, I use {% load staticfiles %} and then for css I have the
>> following link: > rel="stylesheet"> However, when I load the page in the browser, the css
>> does not load and when in "view source" mode, I click the link href
>> ("/static/css/bootstrap.css"). This generates a 404 error.
>>
>> What am I missing? Any suggestions welcome.
>>
>> P.S: I have the STATIC_URL = '/static/' setting defined in the settings
>> file.
>>
>> --
>> Regards,
>> Sithu Lloyd Dube
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send 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/CAH-SnCBJamc9ZKzmy3y63fAo5n7p7xT6G8oAiu%3DFUbjM-KF%2Bbw%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei1gt%2BKmk9zU%3DGRuR8DFxmYiwyQ_cF%2Ba9fMTgMk3Vg0nmA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Regards,
Sithu Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/CAH-SnCBeXSMWjKkr5WojN8%3DDSq3hn5%2B27jwqgEZvD65N_jeeOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Recommendations for hosting service?

2015-01-06 Thread Fred Stluka

+1 for AWS.

Been using it for years.  Keeps getting cheaper and better.

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

On 1/6/15 10:46 AM, Mark Phillips wrote:

+1 for Linode and Digital Ocean.

Also, you can get 2 Virtual Private Servers on AWS EC2  for free for 
the first year.


http://aws.amazon.com/free/ 

Mark

On Tue, Jan 6, 2015 at 7:21 AM, claudiomet > wrote:


I have digitalocean and no problems

2015-01-06 11:05 GMT-03:00 Vijay Khemlani mailto:vkhem...@gmail.com>>:

I like Linode, and DigitalOcean is also a great choice.

Both require low-level configuration of the server but I
prefer that over the pre-packaged solutions.

On Tue, Jan 6, 2015 at 10:44 AM, Brad Rice
mailto:bradri...@gmail.com>> wrote:

I like webfaction, too. I think they would have all the
stuff you list as well as more.

On Tuesday, January 6, 2015 6:30:18 AM UTC-5, Bobby
Mozumder wrote:

Anyone have recommendations for hosting services that
can do Django, Node.js, Postgreqsl, python3, as well
as PHP/MySQL for legacy stuff?  I’m also looking to
have IMAP email. This would be for several domains,
with maybe 100GB of data.

-bobby

-- 
You received this message because you are subscribed to

the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails
from it, send 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/1c61b6c7-ae41-48fa-a2f1-2eb1b8a7ea68%40googlegroups.com

.


For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the

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

https://groups.google.com/d/msgid/django-users/CALn3ei2Vh-OmGWYd25-fL829cokjKLvcF59EV0nvpk7E%2BQEd5g%40mail.gmail.com

.


For more options, visit https://groups.google.com/d/optout.




-- 
Claudio Cortes N.

Project Engineer
Environmental Area
MICOMO S.A.
Tel: +56 (2) 22400516 
Cel: +56 (9) 65871064 
ccor...@micomo.cl 
www.micomo.cl 
Antonio Rabat Sur 6165, Vitacura
Región Metropolitana, Chile
-- 
You received this message because you are subscribed to the Google

Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send 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/CABWjCh3rsr23aw2LwhJPcO3SkR_FG3_Ct4VPAAUdi9iz97WBfQ%40mail.gmail.com

.


For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to dja

Re: Serving static files and media in Django 1.7.1

2015-01-06 Thread Vijay Khemlani
the static tag should be

{% static 'mainsite/bootstrap.css' %}

according to the layout you said

On Tue, Jan 6, 2015 at 8:30 PM, Sithembewena Lloyd Dube 
wrote:

> Hi everyone,
>
> I have a Django 1.7.1 project structured as per documentation. In it, I
> have an app called "mainsite". In mainsite, I have
> templates/mainsite/index.html and static/mainsite/bootstrap.css. In the
> index template, I use {% load staticfiles %} and then for css I have the
> following link:  rel="stylesheet"> However, when I load the page in the browser, the css
> does not load and when in "view source" mode, I click the link href
> ("/static/css/bootstrap.css"). This generates a 404 error.
>
> What am I missing? Any suggestions welcome.
>
> P.S: I have the STATIC_URL = '/static/' setting defined in the settings
> file.
>
> --
> Regards,
> Sithu Lloyd Dube
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/CAH-SnCBJamc9ZKzmy3y63fAo5n7p7xT6G8oAiu%3DFUbjM-KF%2Bbw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Serving static files and media in Django 1.7.1

2015-01-06 Thread Sithembewena Lloyd Dube
Hi everyone,

I have a Django 1.7.1 project structured as per documentation. In it, I
have an app called "mainsite". In mainsite, I have
templates/mainsite/index.html and static/mainsite/bootstrap.css. In the
index template, I use {% load staticfiles %} and then for css I have the
following link:  However, when I load the page in the browser, the css
does not load and when in "view source" mode, I click the link href
("/static/css/bootstrap.css"). This generates a 404 error.

What am I missing? Any suggestions welcome.

P.S: I have the STATIC_URL = '/static/' setting defined in the settings
file.

-- 
Regards,
Sithu Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/CAH-SnCBJamc9ZKzmy3y63fAo5n7p7xT6G8oAiu%3DFUbjM-KF%2Bbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re: prob. with non-related objects deleted

2015-01-06 Thread James Schneider
No problem. If you are happy with the functionality, then keep it simple
and go with what you know.

However, I would highly, highly recommend that you do not rely on system
level packages for application development (such as those installed as .deb
packages). I would move your entire project into a Python virtual
environment and manage all package versions via pip. It is definitely worth
a Google...

If you have any plans to make it a long-standing project, future developers
who look at your code will thank you.

-James

On Tue, Jan 6, 2015 at 1:08 PM,  wrote:

>  thank you for your answer, james.
>
> i had a quick look, but unfortunatly, both are not readily available as
> .deb packages for python3, so i just just had some tries and came away with
> the following solution. in the previously mentioned "removeEntry" method, i
> changed the "with" block to the following:
>
>  with transaction.atomic():
> if self.prev_entry == self.next_entry:
> self.prev_entry.next_entry = self.prev_entry
> self.prev_entry.prev_entry = self.prev_entry
> self.prev_entry.save()
> else:
> self.prev_entry.next_entry = self.next_entry
> self.prev_entry.save()
> self.next_entry.prev_entry = self.prev_entry
> self.next_entry.save()
> self.next_entry = None
> self.prev_entry = None
> self.save()
> self.delete()
>
>  now it works as it should. i have a feeling that in the previous
> version, when there where only 2 entries left, self.prev_entry.next_entry
> and self.next_entry.prev_entry were different objects in django, although
> they are the same database objects.
>
> best regards
>
>
> tom
>
>
> *Gesendet:* Dienstag, 06. Januar 2015 um 12:56 Uhr
> *Von:* "James Schneider" 
> *An:* django-users@googlegroups.com
> *Betreff:* Re: prob. with non-related objects deleted
>
> This looks a lot like a basic MPTT tree. Have you looked at django-mptt or
> django-treebeard? Either of those packages could probably save you a ton of
> headache here, assuming that your lists contain all of the same type of
> model, which it appears they do.
>
>
> http://django-mptt.github.io/django-mptt/overview.html#what-is-modified-preorder-tree-traversal
>
> https://tabo.pe/projects/django-treebeard/docs/tip/
>
> -James
> On Jan 6, 2015 3:30 AM,  wrote:
>>
>> hello all,
>>
>> my problem is the following (the models.py is attached):
>> i want to implement a double-linked list (type BasicEntry) with the first
>> entry having an empty name. each entry has two attributes prev_entry and
>> next_entry to its neigbours. the first entry is created automaticaly and
>> should never be removed. upon removing the second to last entry (using the
>> function removeEntry), the last entry is also removed, although i do not
>> know why. i tracked it down to the "collect" function in "deletion.py" on
>> line 190:
>>
>> for related in model._meta.get_all_related_objects(
>> include_hidden=True, include_proxy_eq=True):
>>
>> do i misunderstand django or is this a known problem or "feature"?
>> although i think i removed all references from the to be removed entry to
>> the other entries...
>>
>>
>> class BasicEntry(models.Model):
>> name = models.CharField(max_length=10)
>> entry_col = models.ForeignKey(EntryCollection)
>> next_entry = models.ForeignKey('BasicEntry', related_name='next',
>> null=True, default=None)
>> prev_entry = models.ForeignKey('BasicEntry', related_name='prev',
>> null=True, default=None)
>>
>> def addEntry(self, name):
>> try_nr = 1
>> new_entry = None
>> while True:
>> try:
>> with transaction.atomic():
>> new_entry = BasicEntry(name=name,
>>entry_col=self.entry_col,
>>next_entry=self.next_entry,
>>prev_entry=self)
>> new_entry.save()
>> self.next_entry.prev_entry = new_entry
>> self.next_entry.save()
>> self.next_entry = new_entry
>> if self.prev_entry == self:
>> self.prev_entry = new_entry
>> self.save()
>> except IntegrityError as e:
>> print('addEntry: try %d' %(try_nr))
>> try_nr += 1
>> if try_nr >= DB_Transaction_Tries:
>> raise(e)
>> time.sleep(DB_Transaction_sleep)
>> else:
>> break
>> return(new_entry)
>>
>> def removeEntry(self):
>> if self.name == '':
>> print('** The "virtual" first track can not be remo

Aw: Re: prob. with non-related objects deleted

2015-01-06 Thread sneaky56


thank you for your answer, james.

 

i had a quick look, but unfortunatly, both are not readily available as .deb packages for python3, so i just just had some tries and came away with the following solution. in the previously mentioned "removeEntry" method, i changed the "with" block to the following:

 


    with transaction.atomic():
    if self.prev_entry == self.next_entry:
    self.prev_entry.next_entry = self.prev_entry
    self.prev_entry.prev_entry = self.prev_entry
    self.prev_entry.save()
    else:
    self.prev_entry.next_entry = self.next_entry
    self.prev_entry.save()
    self.next_entry.prev_entry = self.prev_entry
    self.next_entry.save()
    self.next_entry = None
    self.prev_entry = None
    self.save()
    self.delete()

 


now it works as it should. i have a feeling that in the previous version, when there where only 2 entries left, self.prev_entry.next_entry and self.next_entry.prev_entry were different objects in django, although they are the same database objects.

 

best regards

 

 

tom

 

 

Gesendet: Dienstag, 06. Januar 2015 um 12:56 Uhr
Von: "James Schneider" 
An: django-users@googlegroups.com
Betreff: Re: prob. with non-related objects deleted


This looks a lot like a basic MPTT tree. Have you looked at django-mptt or django-treebeard? Either of those packages could probably save you a ton of headache here, assuming that your lists contain all of the same type of model, which it appears they do.

http://django-mptt.github.io/django-mptt/overview.html#what-is-modified-preorder-tree-traversal

https://tabo.pe/projects/django-treebeard/docs/tip/

-James

On Jan 6, 2015 3:30 AM,  wrote:

hello all,

my problem is the following (the models.py is attached):
i want to implement a double-linked list (type BasicEntry) with the first entry having an empty name. each entry has two attributes prev_entry and next_entry to its neigbours. the first entry is created automaticaly and should never be removed. upon removing the second to last entry (using the function removeEntry), the last entry is also removed, although i do not know why. i tracked it down to the "collect" function in "deletion.py" on line 190:

    for related in model._meta.get_all_related_objects(
                    include_hidden=True, include_proxy_eq=True):

do i misunderstand django or is this a known problem or "feature"? although i think i removed all references from the to be removed entry to the other entries...


class BasicEntry(models.Model):
    name = models.CharField(max_length=10)
    entry_col = models.ForeignKey(EntryCollection)
    next_entry = models.ForeignKey('BasicEntry', related_name='next', null=True, default=None)
    prev_entry = models.ForeignKey('BasicEntry', related_name='prev', null=True, default=None)

    def addEntry(self, name):
        try_nr = 1
        new_entry = None
        while True:
            try:
                with transaction.atomic():
                    new_entry = BasicEntry(name=name,
                                           entry_col=self.entry_col,
                                           next_entry=self.next_entry,
                                           prev_entry=self)
                    new_entry.save()
                    self.next_entry.prev_entry = new_entry
                    self.next_entry.save()
                    self.next_entry = new_entry
                    if self.prev_entry == self:
                        self.prev_entry = new_entry
                    self.save()
            except IntegrityError as e:
                print('addEntry: try %d' %(try_nr))
                try_nr += 1
                if try_nr >= DB_Transaction_Tries:
                    raise(e)
                time.sleep(DB_Transaction_sleep)
            else:
                break
        return(new_entry)

    def removeEntry(self):
        if self.name == '':
            print('** The "virtual" first track can not be removed!')
            return
        try_nr = 1
        while True:
            try:
                with transaction.atomic():
                    self.prev_entry.next_entry = self.next_entry
                    self.prev_entry.save()
                    self.next_entry.prev_entry = self.prev_entry
                    self.next_entry.save()
                    self.next_entry = None
                    self.prev_entry = None
                    self.save()
                    self.delete()
            except IntegrityError as e:
                print('removeEntry: try %d' %(try_nr))
                try_nr += 1
                if try_nr >= DB_Transaction_Tries:
                    raise(e)
                time.sleep(DB_Transaction_sleep)
            else:
                break




Re: Django - trying to access User model column field from a view

2015-01-06 Thread Henry Versemann
Thanks James. You were right and its all there.
Thanks again.

Henry

On Tuesday, January 6, 2015 2:54:42 PM UTC-6, James Schneider wrote:

> Not sure what you mean. The User model will act just like any other model.
>
> $ python manage.py shell
> >>> from django.contrib.auth.models import User
> >>> 
> >>> userobj = User.objects.get(username='jrschneider')
> >>> 
> >>> userobj
> 
> >>> 
> >>> type(userobj)
> 
> >>> 
> >>> userobj.username
> u'jrschneider'
> >>> 
> >>> userobj.is_staff
> True
> >>> 
> >>> userobj.is_superuser
> True
> >>> 
> >>> dir(userobj)
> ['DoesNotExist', 'Meta', 'MultipleObjectsReturned', 'REQUIRED_FIELDS', 
> 'USERNAME_FIELD', '__class__', '__delattr__', '__dict__', '__doc__', 
> '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', 
> u'__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', 
> '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 
> '__unicode__', '__weakref__', '_base_manager', '_default_manager', 
> '_deferred', '_do_insert', '_do_update', '_get_FIELD_display', 
> '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', 
> '_get_pk_val', '_get_unique_checks', '_meta', '_perform_date_checks', 
> '_perform_unique_checks', '_save_parents', '_save_table', '_set_pk_val', 
> '_state', 'check_password', 'clean', 'clean_fields', 'date_error_message', 
> 'date_joined', 'delete', 'email', 'email_user', 'first_name', 'full_clean', 
> 'get_absolute_url', 'get_all_permissions', 'get_full_name', 
> 'get_group_permissions', 'get_next_by_date_joined', 
> 'get_next_by_last_login', 'get_previous_by_date_joined', 
> 'get_previous_by_last_login', 'get_profile', 'get_short_name', 
> 'get_username', 'groups', 'has_module_perms', 'has_perm', 'has_perms', 
> 'has_usable_password', 'id', 'is_active', 'is_anonymous', 
> 'is_authenticated', 'is_staff', 'is_superuser', 'last_login', 'last_name', 
> 'natural_key', 'objects', 'password', 'pk', 'prepare_database_save', 
> 'save', 'save_base', 'serializable_value', 'set_password', 
> 'set_unusable_password', 'unique_error_message', 'user_permissions', 
> 'username', 'validate_unique']
> >>> 
> >>> repr(userobj)
> ''
> >>> print userobj
> jrschneider
> >>> 
> >>> for i in dir(userobj):
> ... if not i.startswith('_'):
> ... print i
> ... 
> DoesNotExist
> Meta
> MultipleObjectsReturned
> REQUIRED_FIELDS
> USERNAME_FIELD
> check_password
> clean
> clean_fields
> date_error_message
> date_joined
> delete
> email
> email_user
> first_name
> full_clean
> get_absolute_url
> get_all_permissions
> get_full_name
> get_group_permissions
> get_next_by_date_joined
> get_next_by_last_login
> get_previous_by_date_joined
> get_previous_by_last_login
> get_profile
> get_short_name
> get_username
> groups
> has_module_perms
> has_perm
> has_perms
> has_usable_password
> id
> is_active
> is_anonymous
> is_authenticated
> is_staff
> is_superuser
> last_login
> last_name
> natural_key
> objects
> password
> pk
> prepare_database_save
> save
> save_base
> serializable_value
> set_password
> set_unusable_password
> unique_error_message
> user_permissions
> username
> validate_unique
> >>> 
> >>> vars(userobj)
> {'username': u'jrschneider', 'first_name': u'', 'last_name': u'', 
> 'is_active': True, '_state':  0x3b6c410>, 'email': u'', 'is_superuser': True, 'is_staff': True, 
> 'last_login': datetime.datetime(2014, 11, 14, 15, 57, 27, 58040, 
> tzinfo=), 'password': 
> u'pbkdf2_sha256$12000$5zwVBOTE9oft$C25SqN0TztFt6qbonqS0NVNu1WIsVUi+yuNxywMbTZA=',
>  
> 'id': 1, 'date_joined': datetime.datetime(2014, 8, 8, 0, 18, 58, 7156, 
> tzinfo=)}
> >>> 
> >>> import pprint
> >>> pprint.pprint(vars(userobj))
> {'_state': ,
>  'date_joined': datetime.datetime(2014, 8, 8, 0, 18, 58, 7156, 
> tzinfo=),
>  'email': u'',
>  'first_name': u'',
>  'id': 1,
>  'is_active': True,
>  'is_staff': True,
>  'is_superuser': True,
>  'last_login': datetime.datetime(2014, 11, 14, 15, 57, 27, 58040, 
> tzinfo=),
>  'last_name': u'',
>  'password': 
> u'pbkdf2_sha256$12000$5zwVBOTE9oft$C25SqN0TztFt6qbonqS0NVNu1WIsVUi+yuNxywMbTZA=',
>  'username': u'jrschneider'}
> >>> 
>
>
>
> The output of 'print userobj' is controlled by the __str__() method of the 
> User model (inherited from AbstractBaseUser), and only returns the 
> username. I showed a couple of different ways to enumerate the attributes 
> and methods available on a User object via a for loop using the dir() 
> function, and the vars() function, the latter of which is likely what you 
> want, and will produce a consistent output rather than relying on repr() or 
> print() (assuming the magic enumeration methods are available, which should 
> be true for all Django models). 
>
> For those concerned, the password field is a hash of a throwaway password 
> on a non-Internet available development system.
>
> HTH,
>
> -James
>
>
> On Tue, Jan 6, 2015 at 12:09 PM, Henry Versemann  > wrote:
>
>> I tried what you suggested and printed from the view what the type 
>> command returned

Re: Django - trying to access User model column field from a view

2015-01-06 Thread Babatunde Akinyanmi
James said it all.
I'll just add that you really need to brush up on your python. Django is
pure python. I've all been there before.
On 6 Jan 2015 21:10, "Henry Versemann"  wrote:

> I tried what you suggested and printed from the view what the type command
> returned and it looks like this:
>
> type(userobj)=()
>
> so that part of it does seem to be working. So why can't I see the other
> values within the object then displayed in normal object notation instead
> of just seeing this:
>
> userobj=(hvadmin)
>
> when I print out a string representation of the User object? I had
> expected to see a lot of different fields like "id",
> "username",  "first_name", "last_name", "email", "password", "groups",
>  "user_permissions", "is_staff", "is_active", "is_superuser", "last_login",
> and "date_joined"
>
> which are just about all of the columns defined for the User model
> according to the documentation.
> So how do I get to that data then if I can't see it this way?
> Thanks for the help.
>
> On Tuesday, January 6, 2015 1:18:57 PM UTC-6, Tundebabzy wrote:
>
>> userobj = User.objects.get(username=myuser)
>>
>> Will get you a User object or throw an error if it can't find anything.
>> The string representation of the User object is the string contained its
>> username field.
>>
>> Try this to confirm:
>> type(userobj)
>> On 6 Jan 2015 18:48, "Henry Versemann"  wrote:
>>
>>> I currently using Python 2.7.7 and Django 1.7 as I build a new
>>> application.
>>> I need to retrieve an entire User object from the authentication User
>>> Model, but when I do the following:
>>>
>>> userobj = User.objects.get(username=myuser)
>>>
>>> all I'm getting returned is just the same username value (contained in
>>> myuser) that I'm trying to use, to get the complete associated User object.
>>> So my question is what am I doing wrong?
>>> Can't I use a regular query on the User model (that I get from this
>>> import: "from django.contrib.auth.models import User" ) the same way that I
>>> would be able to use on one of my application's models?
>>> This is very frustrating and while I'm comfortable with using Django
>>> apparently I still have a lot to learn about it.
>>> Thanks for the help.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/b9f1b941-d01b-402a-94e9-33b2dbd13dbe%
>>> 40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/18705df9-e1da-4c85-9b21-9e13949b6d20%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Class Based Views tutorials

2015-01-06 Thread Lachlan Musicman
To answer the unanswered q's:

Meta is where you define things about the class, but are not in the
class. If you can imagine a space created that *all* classes would
need, mine as well as yours, this is in Meta. It's "Meta". IE. How
does this class sort? Should a couple of fields be "unique together",
do you want it's table to have a particular name in the database -
things that have sensible defaults, are common across all classes, but
can be changed.

"pk" is also known as "id" and stands for "primary key". This is a
fundamental of relational databases - every tuple has an identifying
element, usually table name and pk/id.

In days gone by we used to have things UUID (universally unique id) or
GUID (Globally Unique Identifier) - and they tended to look like this
a603732f-2314-4a34-b06e-3f016dd7a54c

Django largely hides the pk away, so that you don't need to worry
about it, although it can be useful in day to day use if you don't
have a particular identifying need - the biggest problem with a long
string of hex is that it's hard to look at it and say "oh, that's
John's tuple".

the slug_field is an URL shortener that makes identifying an object
via URL easier.

eg: John's tuple:

(without slug, with ugly uuid)
http://myapp.com/a603732f-2314-4a34-b06e-3f016dd7a54c

or

(with slug = name)
http://myapp.com/john-smith

Originating from newspaper urls, it's why you now get the easier to recall:

http://boingboing.net/2014/11/16/band-releases-unplayable-glass.html

It's not only got a slug, but also the date - so should there ever be
the need for another article about unplayable glass master discs, it
can still be unique (via Meta)

I hope that helps.

On 7 January 2015 at 00:49, Brad Rice  wrote:
> Does anyone have a recommendation for intermediate reading to understand
> Class Based Views? It seems most of the Django books were written when
> function based views were prevalent. I'm still having trouble understanding
> what the differences are between CreateView and UpdateView and what Meta is
> as well as slug_field and pk. Perhaps my issue is understanding Object
> oriented python? I wish there were some tutorials or cookbooks that offer
> better understanding.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
--
"We are at once both obnoxious and indispensable." - John Ngumi on the Kikuyu
in It's Our Turn To Eat, by Michela Wrong.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/CAGBeqiNTDSq3qenDad1oh9PqO9BuL8wGSNomc%3DvM%2BusJPAvL4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - trying to access User model column field from a view

2015-01-06 Thread James Schneider
Not sure what you mean. The User model will act just like any other model.

$ python manage.py shell
>>> from django.contrib.auth.models import User
>>>
>>> userobj = User.objects.get(username='jrschneider')
>>>
>>> userobj

>>>
>>> type(userobj)

>>>
>>> userobj.username
u'jrschneider'
>>>
>>> userobj.is_staff
True
>>>
>>> userobj.is_superuser
True
>>>
>>> dir(userobj)
['DoesNotExist', 'Meta', 'MultipleObjectsReturned', 'REQUIRED_FIELDS',
'USERNAME_FIELD', '__class__', '__delattr__', '__dict__', '__doc__',
'__eq__', '__format__', '__getattribute__', '__hash__', '__init__',
u'__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'__unicode__', '__weakref__', '_base_manager', '_default_manager',
'_deferred', '_do_insert', '_do_update', '_get_FIELD_display',
'_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order',
'_get_pk_val', '_get_unique_checks', '_meta', '_perform_date_checks',
'_perform_unique_checks', '_save_parents', '_save_table', '_set_pk_val',
'_state', 'check_password', 'clean', 'clean_fields', 'date_error_message',
'date_joined', 'delete', 'email', 'email_user', 'first_name', 'full_clean',
'get_absolute_url', 'get_all_permissions', 'get_full_name',
'get_group_permissions', 'get_next_by_date_joined',
'get_next_by_last_login', 'get_previous_by_date_joined',
'get_previous_by_last_login', 'get_profile', 'get_short_name',
'get_username', 'groups', 'has_module_perms', 'has_perm', 'has_perms',
'has_usable_password', 'id', 'is_active', 'is_anonymous',
'is_authenticated', 'is_staff', 'is_superuser', 'last_login', 'last_name',
'natural_key', 'objects', 'password', 'pk', 'prepare_database_save',
'save', 'save_base', 'serializable_value', 'set_password',
'set_unusable_password', 'unique_error_message', 'user_permissions',
'username', 'validate_unique']
>>>
>>> repr(userobj)
''
>>> print userobj
jrschneider
>>>
>>> for i in dir(userobj):
... if not i.startswith('_'):
... print i
...
DoesNotExist
Meta
MultipleObjectsReturned
REQUIRED_FIELDS
USERNAME_FIELD
check_password
clean
clean_fields
date_error_message
date_joined
delete
email
email_user
first_name
full_clean
get_absolute_url
get_all_permissions
get_full_name
get_group_permissions
get_next_by_date_joined
get_next_by_last_login
get_previous_by_date_joined
get_previous_by_last_login
get_profile
get_short_name
get_username
groups
has_module_perms
has_perm
has_perms
has_usable_password
id
is_active
is_anonymous
is_authenticated
is_staff
is_superuser
last_login
last_name
natural_key
objects
password
pk
prepare_database_save
save
save_base
serializable_value
set_password
set_unusable_password
unique_error_message
user_permissions
username
validate_unique
>>>
>>> vars(userobj)
{'username': u'jrschneider', 'first_name': u'', 'last_name': u'',
'is_active': True, '_state': , 'email': u'', 'is_superuser': True, 'is_staff': True,
'last_login': datetime.datetime(2014, 11, 14, 15, 57, 27, 58040,
tzinfo=), 'password':
u'pbkdf2_sha256$12000$5zwVBOTE9oft$C25SqN0TztFt6qbonqS0NVNu1WIsVUi+yuNxywMbTZA=',
'id': 1, 'date_joined': datetime.datetime(2014, 8, 8, 0, 18, 58, 7156,
tzinfo=)}
>>>
>>> import pprint
>>> pprint.pprint(vars(userobj))
{'_state': ,
 'date_joined': datetime.datetime(2014, 8, 8, 0, 18, 58, 7156,
tzinfo=),
 'email': u'',
 'first_name': u'',
 'id': 1,
 'is_active': True,
 'is_staff': True,
 'is_superuser': True,
 'last_login': datetime.datetime(2014, 11, 14, 15, 57, 27, 58040,
tzinfo=),
 'last_name': u'',
 'password':
u'pbkdf2_sha256$12000$5zwVBOTE9oft$C25SqN0TztFt6qbonqS0NVNu1WIsVUi+yuNxywMbTZA=',
 'username': u'jrschneider'}
>>>



The output of 'print userobj' is controlled by the __str__() method of the
User model (inherited from AbstractBaseUser), and only returns the
username. I showed a couple of different ways to enumerate the attributes
and methods available on a User object via a for loop using the dir()
function, and the vars() function, the latter of which is likely what you
want, and will produce a consistent output rather than relying on repr() or
print() (assuming the magic enumeration methods are available, which should
be true for all Django models).

For those concerned, the password field is a hash of a throwaway password
on a non-Internet available development system.

HTH,

-James


On Tue, Jan 6, 2015 at 12:09 PM, Henry Versemann 
wrote:

> I tried what you suggested and printed from the view what the type command
> returned and it looks like this:
>
> type(userobj)=()
>
> so that part of it does seem to be working. So why can't I see the other
> values within the object then displayed in normal object notation instead
> of just seeing this:
>
> userobj=(hvadmin)
>
> when I print out a string representation of the User object? I had
> expected to see a lot of different fields like "id",
> "username",  "first_name", "last_name", "email", "password", "groups",
>  "user_permissions", "is_staff", "is_active", "is_superuser", "last_login",

Re: Class Based Views tutorials

2015-01-06 Thread Sergiy Khohlov
Add function get() and post() to the view class.  Code is near to same not
class view

6 січ. 2015 18:45, користувач "Brad Rice"  написав:
>
> When I was working with formsets, it seemed to me best to just use a
single UpdateView with post and get functions defined rather than having a
separate CreateView class. Seemed to handle both create and update ok.
>
> On Tuesday, January 6, 2015 9:39:49 AM UTC-5, Sergiy Khohlov wrote:
>>
>> Diff is simple : UpdateView is using for changing already created
object. CreateView is using  for creating new object.
>> I have few simpleast class for your request. But I have not  commented
yet.
>>
>> Many thanks,
>>
>> Serge
>>
>>
>> +380 636150445
>> skype: skhohlov
>>
>> On Tue, Jan 6, 2015 at 3:49 PM, Brad Rice  wrote:
>>>
>>> Does anyone have a recommendation for intermediate reading to
understand Class Based Views? It seems most of the Django books were
written when function based views were prevalent. I'm still having trouble
understanding what the differences are between CreateView and UpdateView
and what Meta is as well as slug_field and pk. Perhaps my issue is
understanding Object oriented python? I wish there were some tutorials or
cookbooks that offer better understanding.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com
.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/703f0448-2152-418a-9466-4e87e1226b62%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.

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


Re: Django - trying to access User model column field from a view

2015-01-06 Thread Henry Versemann
I tried what you suggested and printed from the view what the type command 
returned and it looks like this:

type(userobj)=() 

so that part of it does seem to be working. So why can't I see the other 
values within the object then displayed in normal object notation instead 
of just seeing this:

userobj=(hvadmin)

when I print out a string representation of the User object? I had expected 
to see a lot of different fields like "id", "username",  "first_name", 
"last_name", "email", "password", "groups", 
 "user_permissions", "is_staff", "is_active", "is_superuser", "last_login", 
and "date_joined"

which are just about all of the columns defined for the User model 
according to the documentation. 
So how do I get to that data then if I can't see it this way?
Thanks for the help.

On Tuesday, January 6, 2015 1:18:57 PM UTC-6, Tundebabzy wrote:

> userobj = User.objects.get(username=myuser)
>
> Will get you a User object or throw an error if it can't find anything. 
> The string representation of the User object is the string contained its 
> username field. 
>
> Try this to confirm:
> type(userobj)
> On 6 Jan 2015 18:48, "Henry Versemann" > 
> wrote:
>
>> I currently using Python 2.7.7 and Django 1.7 as I build a new 
>> application.
>> I need to retrieve an entire User object from the authentication User 
>> Model, but when I do the following:
>>
>> userobj = User.objects.get(username=myuser)
>>
>> all I'm getting returned is just the same username value (contained in 
>> myuser) that I'm trying to use, to get the complete associated User object.
>> So my question is what am I doing wrong?
>> Can't I use a regular query on the User model (that I get from this 
>> import: "from django.contrib.auth.models import User" ) the same way that I 
>> would be able to use on one of my application's models?
>> This is very frustrating and while I'm comfortable with using Django 
>> apparently I still have a lot to learn about it.
>> Thanks for the help.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/b9f1b941-d01b-402a-94e9-33b2dbd13dbe%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: Django - trying to access User model column field from a view

2015-01-06 Thread Babatunde Akinyanmi
userobj = User.objects.get(username=myuser)

Will get you a User object or throw an error if it can't find anything. The
string representation of the User object is the string contained its
username field.

Try this to confirm:
type(userobj)
On 6 Jan 2015 18:48, "Henry Versemann"  wrote:

> I currently using Python 2.7.7 and Django 1.7 as I build a new application.
> I need to retrieve an entire User object from the authentication User
> Model, but when I do the following:
>
> userobj = User.objects.get(username=myuser)
>
> all I'm getting returned is just the same username value (contained in
> myuser) that I'm trying to use, to get the complete associated User object.
> So my question is what am I doing wrong?
> Can't I use a regular query on the User model (that I get from this
> import: "from django.contrib.auth.models import User" ) the same way that I
> would be able to use on one of my application's models?
> This is very frustrating and while I'm comfortable with using Django
> apparently I still have a lot to learn about it.
> Thanks for the help.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b9f1b941-d01b-402a-94e9-33b2dbd13dbe%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Matching logic is case sensitive when I want it case insensitive

2015-01-06 Thread joboppsgpp
This worked beautifully. Thanks Vijay! 

(ps thanks for the suggestions regarding a long-term solution).

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


Re: Matching logic is case sensitive when I want it case insensitive

2015-01-06 Thread Vijay Khemlani
on line 12 you would need a more complex logic

try:
obj = SocialAccount.objects.get(social_profile=profile,
service=service, value__iexact=value)
except SocialAccount.DoesNotExist:
obj = SocialAccount.objects.create(social_profile=profile,
service=service, value=value)

(assuming "value" is the case insensitive field)

A little more permanent solution would be to always store the value in
lowercase and make all the queries using lowercase values, as the solution
above only prevents the bug in this method.

On Tue, Jan 6, 2015 at 2:20 PM,  wrote:

> Hi,
>
> I have a bug where when I upload data from a csv into my database into a
> model that houses social accounts (eg a twitter value, a facebook value
> etc) it is adding new social account objects if there's a discrepency
> between the casing of the value in the csv and the value that is already in
> the db.  I don't want to add a new object if a case insensitive version of
> the value is already represented in the db.  So if "JoeSchmoe" is in the
> csv, and an object with a value of "joeschmore" is in the db already, I
> don't want to create a new social account object, I want it to behave the
> same way it currently behaves for case sensitive matches.
>
> I think I have found where in the code the problem is:
>
> https://snipt.net/joboppsgpp/code-with-bug-d8fa565f
>
> However, I don't program myself, and since this seems like a trivial
> change, I was hoping someone here could suggest a fix for my issue.
>
> Thanks in advance.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b8fa1696-4a29-4dcf-b9af-08b704790ae8%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Django - trying to access User model column field from a view

2015-01-06 Thread Henry Versemann
I currently using Python 2.7.7 and Django 1.7 as I build a new application.
I need to retrieve an entire User object from the authentication User 
Model, but when I do the following:

userobj = User.objects.get(username=myuser)

all I'm getting returned is just the same username value (contained in 
myuser) that I'm trying to use, to get the complete associated User object.
So my question is what am I doing wrong?
Can't I use a regular query on the User model (that I get from this import: 
"from django.contrib.auth.models import User" ) the same way that I would 
be able to use on one of my application's models?
This is very frustrating and while I'm comfortable with using Django 
apparently I still have a lot to learn about it.
Thanks for the help.

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


Matching logic is case sensitive when I want it case insensitive

2015-01-06 Thread joboppsgpp
Hi,

I have a bug where when I upload data from a csv into my database into a 
model that houses social accounts (eg a twitter value, a facebook value 
etc) it is adding new social account objects if there's a discrepency 
between the casing of the value in the csv and the value that is already in 
the db.  I don't want to add a new object if a case insensitive version of 
the value is already represented in the db.  So if "JoeSchmoe" is in the 
csv, and an object with a value of "joeschmore" is in the db already, I 
don't want to create a new social account object, I want it to behave the 
same way it currently behaves for case sensitive matches.  

I think I have found where in the code the problem is:

https://snipt.net/joboppsgpp/code-with-bug-d8fa565f

However, I don't program myself, and since this seems like a trivial 
change, I was hoping someone here could suggest a fix for my issue.

Thanks in advance.

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


Class Based Views tutorials

2015-01-06 Thread Jim Wombles
Two Scoops of Django is definitely the book you are looking for. I don't know 
if it's out for 1.7 yet, but I purchased the book for Django 1.6 and it covers 
l of the best practices that you won't read about just from the Django docs. 

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


Re: Class Based Views tutorials

2015-01-06 Thread Brad Rice
When I was working with formsets, it seemed to me best to just use a single 
UpdateView with post and get functions defined rather than having a 
separate CreateView class. Seemed to handle both create and update ok.

On Tuesday, January 6, 2015 9:39:49 AM UTC-5, Sergiy Khohlov wrote:
>
> Diff is simple : UpdateView is using for changing already created object. 
> CreateView is using  for creating new object.
> I have few simpleast class for your request. But I have not  commented 
> yet.  
>
> Many thanks,
>
> Serge
>
>
> +380 636150445
> skype: skhohlov
>
> On Tue, Jan 6, 2015 at 3:49 PM, Brad Rice 
> > wrote:
>
>> Does anyone have a recommendation for intermediate reading to understand 
>> Class Based Views? It seems most of the Django books were written when 
>> function based views were prevalent. I'm still having trouble understanding 
>> what the differences are between CreateView and UpdateView and what Meta is 
>> as well as slug_field and pk. Perhaps my issue is understanding Object 
>> oriented python? I wish there were some tutorials or cookbooks that offer 
>> better understanding.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: Recommendations for hosting service?

2015-01-06 Thread Jeff Kerr
I'm a total noob, but I was able to get a basic Django app (Postgresql as 
DB) running on DigitalOcean without much trouble. It wasn't *easy--*in 
fact, I was ready to throw my computer out the window a few times--but I'm 
happy that I now have that skill.

DigitalOcean also has a great interface and very reasonable pricing. 

On Tuesday, January 6, 2015 6:30:18 AM UTC-5, Bobby Mozumder wrote:
>
> Anyone have recommendations for hosting services that can do Django, 
> Node.js, Postgreqsl, python3, as well as PHP/MySQL for legacy stuff?  I’m 
> also looking to have IMAP email.  This would be for several domains, with 
> maybe 100GB of data. 
>
> -bobby

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


Re: Recommendations for hosting service?

2015-01-06 Thread Richard Brockie
I'm using webfaction also - though still shared, they (and others) are 
much, much better than commodity shared hosting.

Apart from the above, the reasons I chose webfaction:

   1. Django support, plus:
   2. php/MySQL for my existing codebase 

R.

On Tuesday, January 6, 2015 5:44:40 AM UTC-8, Brad Rice wrote:
>
> I like webfaction, too. I think they would have all the stuff you list as 
> well as more.
>
> On Tuesday, January 6, 2015 6:30:18 AM UTC-5, Bobby Mozumder wrote:
>>
>> Anyone have recommendations for hosting services that can do Django, 
>> Node.js, Postgreqsl, python3, as well as PHP/MySQL for legacy stuff?  I’m 
>> also looking to have IMAP email.  This would be for several domains, with 
>> maybe 100GB of data. 
>>
>> -bobby
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/77e4ec40-81c7-45d6-bfa4-fc221d340e5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Recommendations for hosting service?

2015-01-06 Thread Mark Phillips
+1 for Linode and Digital Ocean.

Also, you can get 2 Virtual Private Servers on AWS EC2  for free for the
first year.

http://aws.amazon.com/free/

Mark

On Tue, Jan 6, 2015 at 7:21 AM, claudiomet  wrote:

> I have digitalocean and no problems
>
> 2015-01-06 11:05 GMT-03:00 Vijay Khemlani :
>
> I like Linode, and DigitalOcean is also a great choice.
>>
>> Both require low-level configuration of the server but I prefer that over
>> the pre-packaged solutions.
>>
>> On Tue, Jan 6, 2015 at 10:44 AM, Brad Rice  wrote:
>>
>>> I like webfaction, too. I think they would have all the stuff you list
>>> as well as more.
>>>
>>> On Tuesday, January 6, 2015 6:30:18 AM UTC-5, Bobby Mozumder wrote:

 Anyone have recommendations for hosting services that can do Django,
 Node.js, Postgreqsl, python3, as well as PHP/MySQL for legacy stuff?  I’m
 also looking to have IMAP email.  This would be for several domains, with
 maybe 100GB of data.

 -bobby
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> 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/1c61b6c7-ae41-48fa-a2f1-2eb1b8a7ea68%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CALn3ei2Vh-OmGWYd25-fL829cokjKLvcF59EV0nvpk7E%2BQEd5g%40mail.gmail.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Claudio Cortes N.
> Project Engineer
> Environmental Area
> MICOMO S.A.
> Tel: +56 (2) 22400516
> Cel: +56 (9) 65871064
> ccor...@micomo.cl
> www.micomo.cl
> Antonio Rabat Sur 6165, Vitacura
> Región Metropolitana, Chile
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/CABWjCh3rsr23aw2LwhJPcO3SkR_FG3_Ct4VPAAUdi9iz97WBfQ%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Question on Template placement in file system

2015-01-06 Thread Tobias Dacoir
I have been working through the official Django 1.7 tutorial and also Tango 
with Django but I'm confused as to where put my templates - I want to 
follow best practices as much as possible.
Now currently I only plan to develop a single project with a single app, 
but I might want to include 3rd party apps later on.
So I have created my project and started a new app inside. Since all pages 
should use the same html template I wanted to place the base.html into the 
project template folder. Or should I still put everything into the 
app/template folder?

Suggestion A)
project_dir/templates/base.html
project_dir/templates/app/index.html (extends base.html)

Suggestion B)
project_dir/app_dir/templates/base.html
project_dir/app_dir/templates/index.html

Suggestion C) (as in the tutorial)
project_dir/app_dir/templates/base.html
project_dir/app_dir/templates/app/index.html


Later on when somebody goes to my website I want to show him some stuff 
from my app on the index page already. So on http://mysite.com/ there 
should already be content from my app, but there will also be static html 
files like 'contact', 'impress', 'help' and so on, which I wanted to put 
somewhere in my project folder and not within the app. But everything 
should rely on the same base.html template so all pages use the same 
javascript & css files. 

Is there maybe another good tutorial for this available?

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


Re: Class Based Views tutorials

2015-01-06 Thread Sergiy Khohlov
Diff is simple : UpdateView is using for changing already created object.
CreateView is using  for creating new object.
I have few simpleast class for your request. But I have not  commented
yet.

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Tue, Jan 6, 2015 at 3:49 PM, Brad Rice  wrote:

> Does anyone have a recommendation for intermediate reading to understand
> Class Based Views? It seems most of the Django books were written when
> function based views were prevalent. I'm still having trouble understanding
> what the differences are between CreateView and UpdateView and what Meta is
> as well as slug_field and pk. Perhaps my issue is understanding Object
> oriented python? I wish there were some tutorials or cookbooks that offer
> better understanding.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Recommendations for hosting service?

2015-01-06 Thread claudiomet
I have digitalocean and no problems

2015-01-06 11:05 GMT-03:00 Vijay Khemlani :

> I like Linode, and DigitalOcean is also a great choice.
>
> Both require low-level configuration of the server but I prefer that over
> the pre-packaged solutions.
>
> On Tue, Jan 6, 2015 at 10:44 AM, Brad Rice  wrote:
>
>> I like webfaction, too. I think they would have all the stuff you list as
>> well as more.
>>
>> On Tuesday, January 6, 2015 6:30:18 AM UTC-5, Bobby Mozumder wrote:
>>>
>>> Anyone have recommendations for hosting services that can do Django,
>>> Node.js, Postgreqsl, python3, as well as PHP/MySQL for legacy stuff?  I’m
>>> also looking to have IMAP email.  This would be for several domains, with
>>> maybe 100GB of data.
>>>
>>> -bobby
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send 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/1c61b6c7-ae41-48fa-a2f1-2eb1b8a7ea68%40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei2Vh-OmGWYd25-fL829cokjKLvcF59EV0nvpk7E%2BQEd5g%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Claudio Cortes N.
Project Engineer
Environmental Area
MICOMO S.A.
Tel: +56 (2) 22400516
Cel: +56 (9) 65871064
ccor...@micomo.cl
www.micomo.cl
Antonio Rabat Sur 6165, Vitacura
Región Metropolitana, Chile

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


Re: Recommendations for hosting service?

2015-01-06 Thread Vijay Khemlani
I like Linode, and DigitalOcean is also a great choice.

Both require low-level configuration of the server but I prefer that over
the pre-packaged solutions.

On Tue, Jan 6, 2015 at 10:44 AM, Brad Rice  wrote:

> I like webfaction, too. I think they would have all the stuff you list as
> well as more.
>
> On Tuesday, January 6, 2015 6:30:18 AM UTC-5, Bobby Mozumder wrote:
>>
>> Anyone have recommendations for hosting services that can do Django,
>> Node.js, Postgreqsl, python3, as well as PHP/MySQL for legacy stuff?  I’m
>> also looking to have IMAP email.  This would be for several domains, with
>> maybe 100GB of data.
>>
>> -bobby
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/1c61b6c7-ae41-48fa-a2f1-2eb1b8a7ea68%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Error: No module named polls

2015-01-06 Thread tita
Hi,
thanks for your answer...
here is the path of my site, that i called "primerdjango":

C:\xampp\htdocs\primerdjango\

   inside of that folder i have:

 polls\
primerdjango\
   db.sqlite3
 manage.py
   Vista.py

then inside of - polls -  i have:

migrations\
admin.py
admin.pyc
models.py
models.pyc
tests.py
tests.pyc
urls.py
urls.pyc
views.py
views.pyc
__init__.py
__init__.pyc

i have my python in C:\Python27\

i notice that when i try to start my apache ( at the first time), i
have to erase the module mod_wsgi.so...
( LoadModule wsgi_module modules/mod_wsgi.so )

and comment that line in the httpd.conf, because that's the only way
that my apache run, the and i  can start my xampp and finally  run the
server with manage.py runserver...
that only happens at the first time, gradually during the day that
things doesn't happens again...

here is another problem:

when i try to follow the step of the tutorial
(https://docs.djangoproject.com/en/1.7/intro/tutorial01/) where it
said:
"from polls.models import Question, Choice"

begins other problems...

for example:

if i write  into the CMD the manage.py shell :
>>> q = Question(question_text="que hay?", pub_date=timezone())

i got this message:

Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'module' object is not callable

and there i stuck...

my http pages looks fine, i can work with polls page, create, modify
and erase...

what i do wrong??

sorry for my english, i'm extra newbie in python and django...

i hope that you could understand all that i try to explain...

THANKS A LOT AGAIN.

regards.
ibes.



2015-01-05 14:33 GMT-05:00, Vijay Khemlani :
> Also make sure that there is an __init__.py file in the polls directory
>
> On Mon, Jan 5, 2015 at 12:47 PM, Xavier Ordoquy 
> wrote:
>
>> Hi,
>>
>>
>> Le 5 janv. 2015 à 16:41, ibes ...  a écrit :
>>
>> hello,
>> I am frustrated with django and phyton tutorial it is very difficult
>> i'm having a problem with the tutorial of django and python,
>>
>> am using django 1.7.1 and python 2.7 on win xp-sp3 so far it was good, i
>> create everything without problem but in tutorial step where it says:
>>
>> https://docs.djangoproject.com/en/1.7/intro/tutorial01/
>>
>> Once you’re in the shell, explore the *database API*
>> :
>>
>> i've got the message:
>>
>> C:\xampp\htdocs\primerdjango>manage.py runserver
>> Traceback (most recent call last):
>>   File "D:\xampp\htdocs\primerdjango\manage.py", line 10, in 
>> execute_from_command_line(sys.argv)
>>   File
>> "D:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\managem
>> ent\__init__.py", line 385, in execute_from_command_line
>> utility.execute()
>>   File
>> "D:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\managem
>> ent\__init__.py", line 354, in execute
>> django.setup()
>>   File
>> "D:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\__init__.py"
>> , line 21, in setup
>> apps.populate(settings.INSTALLED_APPS)
>>   File
>> "D:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\apps\registr
>> y.py", line 85, in populate
>> app_config = AppConfig.create(entry)
>>   File
>> "D:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\apps\config.
>> py", line 123, in create
>> import_module(entry)
>>   File "D:\Python27\lib\importlib\__init__.py", line 37, in import_module
>> __import__(name)
>> ImportError: No module named polls
>>
>> i don't know what to do can anyone help, please!!!
>>
>> sorry for my bad english…
>>
>>
>> It looks like Python couldn’t find the « polls » directory.
>> Maybe you didn’t create it or it is at the wrong location. Could you
>> write
>> us where the « polls » directory is, relating to « mysite » ?
>>
>> Regards,
>> Xavier Ordoquy,
>> Linovia.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send 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/6CA9FED6-CCA2-4854-B834-8D6F3B74D316%40linovia.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/Dg6zBJ5hlYc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr.

Re: CSRF verification failed when I use smart phone

2015-01-06 Thread Vijay Khemlani
¿Did you include de {% csrf_token %} tag in the form? ¿Is it generating the
corresponding hidden input tag in the html?

On Tue, Jan 6, 2015 at 6:09 AM, Sugita Shinsuke  wrote:

> Hello.
>
> When I use Django via my smart phone Android and iOS.
> The error sometimes occurred.
>
> Forbidden (403)
> CSRF verification failed. Request aborted.
> Help
> Reason given for failure:
> CSRF token missing or incorrect.
>
> In general, this can occur when there is a genuine Cross Site Request
> Forgery, or when Django's CSRF mechanism has not been used correctly. For
> POST forms, you need to ensure:
> Your browser is accepting cookies.
> The view function uses RequestContext for the template, instead of Context.
> In the template, there is a {% csrf_token %} template tag inside each POST
> form that targets an internal URL.
> If you are not using CsrfViewMiddleware, then you must use csrf_protect on
> any views that use the csrf_token template tag, as well as those that
> accept the POST data.
> You're seeing the help section of this page because you have DEBUG = True
> in your Django settings file. Change that to False, and only the initial
> error message will be displayed.
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>
> I append django.middleware.csrf.CsrfViewMiddleware', of MIDDLEWARE_CLASSES
> in settings.py
>
> I use
> Python 2.7.5
> Django 1.6.4
>
> Anyone who know this matter, please help.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e0db1d43-8897-40fc-be1d-65c76d9da503%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Class Based Views tutorials

2015-01-06 Thread Brad Rice
Does anyone have a recommendation for intermediate reading to understand 
Class Based Views? It seems most of the Django books were written when 
function based views were prevalent. I'm still having trouble understanding 
what the differences are between CreateView and UpdateView and what Meta is 
as well as slug_field and pk. Perhaps my issue is understanding Object 
oriented python? I wish there were some tutorials or cookbooks that offer 
better understanding.

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


Re: Recommendations for hosting service?

2015-01-06 Thread Brad Rice
I like webfaction, too. I think they would have all the stuff you list as 
well as more.

On Tuesday, January 6, 2015 6:30:18 AM UTC-5, Bobby Mozumder wrote:
>
> Anyone have recommendations for hosting services that can do Django, 
> Node.js, Postgreqsl, python3, as well as PHP/MySQL for legacy stuff?  I’m 
> also looking to have IMAP email.  This would be for several domains, with 
> maybe 100GB of data. 
>
> -bobby

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/1c61b6c7-ae41-48fa-a2f1-2eb1b8a7ea68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with for and if

2015-01-06 Thread Erik Cederstrand

> Den 05/01/2015 kl. 22.45 skrev Dariusz Mysior :
> 
> I try develop this code to get a number of position this letter in word, and 
> I have it but for example if i search letter "t" I get "1, 5, b", why I get b 
> instead of 11???
> 
> def gen2():
>count=0
>count2=0
>for a in zmienna:
>count2+=1
>if a==szukana:
>count+=1
>pozycja.append(count2)
> 
>return pozycja
> print("3. Literka '",szukana,"' w słowie ",zmienna,
>  "wystąpiła " ,gen(),"razy w kolejności")
> #print(gen2())
> 
> print(", ".join(["%x" % a for a in gen2()]))

Whoa, that code is really convoluted. It won't even compile, as far as I can 
see. Try this instead:

import re
def indices(needle, haystack):
return [match.start() for match in re.finditer(re.escape(needle), 
haystack)]


If your search strings can be overlapping, you'll need another solution.

Erik

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/4551A371-1AAA-405C-BC30-2C7B3044D88B%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Recommendations for hosting service?

2015-01-06 Thread Avraham Serour
I like webfaction, https://www.webfaction.com/?aid=43671 (shameless link
with affiliate or here for affiliateless link https://www.webfaction.com/)

it is a shared hosting, you get shell access and 8 cores, you can compile
your own stuff as needed or use their click and install

for django projects you can create your own virtualenv and install or
compile on your home nginx, uwsgi or whatever you prefer

you can use the shared postgres db, you get your own database under the
shared postgres installation


or you can get your own VM on digitalocean, it start cheaper and can do
whatever you want, but you'll have to do it yourself

good luck


On Tue, Jan 6, 2015 at 1:57 PM, Daniele Procida  wrote:

> On Mon, Jan 5, 2015, Bobby Mozumder  wrote:
>
> >Anyone have recommendations for hosting services that can do Django,
> >Node.js, Postgreqsl, python3, as well as PHP/MySQL for legacy stuff?
> >I'm also looking to have IMAP email.  This would be for several domains,
> >with maybe 100GB of data.
>
> I recommend Django Europe - . You get shell
> access.I've used them for years. Very reliable, the rates seem reasonable,
> and support is superb.
>
> Daniele
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/20150106115733.526848132%40mail.wservices.ch
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Recommendations for hosting service?

2015-01-06 Thread Daniele Procida
On Mon, Jan 5, 2015, Bobby Mozumder  wrote:

>Anyone have recommendations for hosting services that can do Django,
>Node.js, Postgreqsl, python3, as well as PHP/MySQL for legacy stuff? 
>I'm also looking to have IMAP email.  This would be for several domains,
>with maybe 100GB of data.

I recommend Django Europe - . You get shell 
access.I've used them for years. Very reliable, the rates seem reasonable, and 
support is superb. 

Daniele

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


Re: prob. with non-related objects deleted

2015-01-06 Thread James Schneider
This looks a lot like a basic MPTT tree. Have you looked at django-mptt or
django-treebeard? Either of those packages could probably save you a ton of
headache here, assuming that your lists contain all of the same type of
model, which it appears they do.

http://django-mptt.github.io/django-mptt/overview.html#what-is-modified-preorder-tree-traversal

https://tabo.pe/projects/django-treebeard/docs/tip/

-James
 On Jan 6, 2015 3:30 AM,  wrote:

> hello all,
>
> my problem is the following (the models.py is attached):
> i want to implement a double-linked list (type BasicEntry) with the first
> entry having an empty name. each entry has two attributes prev_entry and
> next_entry to its neigbours. the first entry is created automaticaly and
> should never be removed. upon removing the second to last entry (using the
> function removeEntry), the last entry is also removed, although i do not
> know why. i tracked it down to the "collect" function in "deletion.py" on
> line 190:
>
> for related in model._meta.get_all_related_objects(
> include_hidden=True, include_proxy_eq=True):
>
> do i misunderstand django or is this a known problem or "feature"?
> although i think i removed all references from the to be removed entry to
> the other entries...
>
>
> class BasicEntry(models.Model):
> name = models.CharField(max_length=10)
> entry_col = models.ForeignKey(EntryCollection)
> next_entry = models.ForeignKey('BasicEntry', related_name='next',
> null=True, default=None)
> prev_entry = models.ForeignKey('BasicEntry', related_name='prev',
> null=True, default=None)
>
> def addEntry(self, name):
> try_nr = 1
> new_entry = None
> while True:
> try:
> with transaction.atomic():
> new_entry = BasicEntry(name=name,
>entry_col=self.entry_col,
>next_entry=self.next_entry,
>prev_entry=self)
> new_entry.save()
> self.next_entry.prev_entry = new_entry
> self.next_entry.save()
> self.next_entry = new_entry
> if self.prev_entry == self:
> self.prev_entry = new_entry
> self.save()
> except IntegrityError as e:
> print('addEntry: try %d' %(try_nr))
> try_nr += 1
> if try_nr >= DB_Transaction_Tries:
> raise(e)
> time.sleep(DB_Transaction_sleep)
> else:
> break
> return(new_entry)
>
> def removeEntry(self):
> if self.name == '':
> print('** The "virtual" first track can not be removed!')
> return
> try_nr = 1
> while True:
> try:
> with transaction.atomic():
> self.prev_entry.next_entry = self.next_entry
> self.prev_entry.save()
> self.next_entry.prev_entry = self.prev_entry
> self.next_entry.save()
> self.next_entry = None
> self.prev_entry = None
> self.save()
> self.delete()
> except IntegrityError as e:
> print('removeEntry: try %d' %(try_nr))
> try_nr += 1
> if try_nr >= DB_Transaction_Tries:
> raise(e)
> time.sleep(DB_Transaction_sleep)
> else:
> break
>
>
>
> a few details:
> linux (debian amd64)
> python3 (v3.4.2-2)
> django (v1.7.1-1)
>
> here's an example in postgres:
>
> django=> select * from entry_test_basicentry order by id;
> id | name | entry_col_id | next_entry_id | prev_entry_id
> +---+--+---+---
> 33 | | 14 | 34 | 35
> 34 | test1 | 14 | 35 | 33
> 35 | test2 | 14 | 33 | 34
> (3 rows)
>
>
> after removing ID 34:
>
> django=> select * from entry_test_basicentry order by id;
> id | name | entry_col_id | next_entry_id | prev_entry_id
> +---+--+---+---
> 33 | | 14 | 35 | 35
> 35 | test2 | 14 | 33 | 33
> (2 rows)
>
>
> after removing ID 35:
>
> django=> select * from entry_test_basicentry order by id;
> id | name | entry_col_id | next_entry_id | prev_entry_id
> +--+--+---+---
> (0 rows)
>
>
> thanks in advance and best regards
>
>
> 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 disc

Re: what's different between {% static %} and {{ STATIC_URL}}

2015-01-06 Thread Andreas Kuhne
Hi,

The difference is the age of the django project you are looking at. {% load
staticfiles %} the {% static %} is the current way to load and use static
files. It also has the option to do other things (like MD5 hashes for
versions) automatically and should be used.

If you create a project in the new way, you will also get all of your
static files nicely copied to a static file directory that you can serve
from your webserver automatically. It's the best way to do it.

Regards,

Andréas

2015-01-06 12:23 GMT+01:00 老张 :

> hi,guys
> i'm new to django。when I write my first app, there are 2 options to access
> static files,
> 1 using  {{ STATIC_URL}}
> 2 using  {% load staticfiles%} then {% static %}
> what 's different between the 2 options, and ,when I migrate from
> development to production env
> which one is conveniency ?
> Thanks alot
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/31d5812d.1eba0.14abefc5261.Coremail.paiis314%40163.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


prob. with non-related objects deleted

2015-01-06 Thread sneaky56
hello all,

my problem is the following (the models.py is attached):
i want to implement a double-linked list (type BasicEntry) with the first entry 
having an empty name. each entry has two attributes prev_entry and next_entry 
to its neigbours. the first entry is created automaticaly and should never be 
removed. upon removing the second to last entry (using the function 
removeEntry), the last entry is also removed, although i do not know why. i 
tracked it down to the "collect" function in "deletion.py" on line 190:

for related in model._meta.get_all_related_objects(
include_hidden=True, include_proxy_eq=True):

do i misunderstand django or is this a known problem or "feature"? although i 
think i removed all references from the to be removed entry to the other 
entries...


class BasicEntry(models.Model):
name = models.CharField(max_length=10)
entry_col = models.ForeignKey(EntryCollection)
next_entry = models.ForeignKey('BasicEntry', related_name='next', 
null=True, default=None)
prev_entry = models.ForeignKey('BasicEntry', related_name='prev', 
null=True, default=None)

def addEntry(self, name):
try_nr = 1
new_entry = None
while True:
try:
with transaction.atomic():
new_entry = BasicEntry(name=name,
   entry_col=self.entry_col,
   next_entry=self.next_entry,
   prev_entry=self)
new_entry.save()
self.next_entry.prev_entry = new_entry
self.next_entry.save()
self.next_entry = new_entry
if self.prev_entry == self:
self.prev_entry = new_entry
self.save()
except IntegrityError as e:
print('addEntry: try %d' %(try_nr))
try_nr += 1
if try_nr >= DB_Transaction_Tries:
raise(e)
time.sleep(DB_Transaction_sleep)
else:
break
return(new_entry)

def removeEntry(self):
if self.name == '':
print('** The "virtual" first track can not be removed!')
return
try_nr = 1
while True:
try:
with transaction.atomic():
self.prev_entry.next_entry = self.next_entry
self.prev_entry.save()
self.next_entry.prev_entry = self.prev_entry
self.next_entry.save()
self.next_entry = None
self.prev_entry = None
self.save()
self.delete()
except IntegrityError as e:
print('removeEntry: try %d' %(try_nr))
try_nr += 1
if try_nr >= DB_Transaction_Tries:
raise(e)
time.sleep(DB_Transaction_sleep)
else:
break



a few details:
linux (debian amd64)
python3 (v3.4.2-2)
django (v1.7.1-1)

here's an example in postgres:

django=> select * from entry_test_basicentry order by id;
id | name | entry_col_id | next_entry_id | prev_entry_id
+---+--+---+---
33 | | 14 | 34 | 35
34 | test1 | 14 | 35 | 33
35 | test2 | 14 | 33 | 34
(3 rows)


after removing ID 34:

django=> select * from entry_test_basicentry order by id;
id | name | entry_col_id | next_entry_id | prev_entry_id
+---+--+---+---
33 | | 14 | 35 | 35
35 | test2 | 14 | 33 | 33
(2 rows)


after removing ID 35:

django=> select * from entry_test_basicentry order by id;
id | name | entry_col_id | next_entry_id | prev_entry_id
+--+--+---+---
(0 rows)


thanks in advance and best regards


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/trinity-29b3450f-f209-4d1d-8406-9f7ff205766a-1420541277592%403capp-gmx-bs67.
For more options, visit https://groups.google.com/d/optout.
from django.db import models, IntegrityError, transaction
import time

# Create your models here.

DB_Transaction_Tries = 5
DB_Transaction_Sleep = 0.8  # seconds

class EntryCollection(models.Model):
name = models.CharField(max_length=10)

def save(self, *args, **kwargs):
super(EntryCollection, self).save(*args, **kwargs)
if BasicEntry.objects.filter(entry_col=self).count() == 0:
entry = BasicEntry(entry_col=self, ne

Recommendations for hosting service?

2015-01-06 Thread Bobby Mozumder
Anyone have recommendations for hosting services that can do Django, Node.js, 
Postgreqsl, python3, as well as PHP/MySQL for legacy stuff?  I’m also looking 
to have IMAP email.  This would be for several domains, with maybe 100GB of 
data.

-bobby

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/28330C48-FA41-4A84-9591-2A2DBB1872D3%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Couldn't get django-compressor/assets to work on Heroku

2015-01-06 Thread Po Chen
Hi there,

I've been trying to get some automatic assets handling setup in my tiny 
django app.
I've tried django-compressor and django-assets, no success so far.
Both of the libraries seem to fail to create files in the staticfiles 
directory on Heroku.
Both of them work locally with/without debug on.

I feel like I must be missing something really trivial..
Did anyone have the same experience and figured it out eventually?

Your help will be much appreciated!

P.S. I created a support ticket and got an answer telling me to check in 
the staticfiles directory,
which is created automatically when deploying django apps (created when 
collectstatic is run post-deploy)
I did try committing the directory with a .keep file in it, but no success 
either.

Thanks,
Po

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/32ae27eb-ee08-4006-802f-1fb2aa797793%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django-compressor/assets not working on Heroku

2015-01-06 Thread Po Chen
Hi there,

I've been trying to get some automatic assets handling setup in my tiny 
django app.
I've tried django-compressor and django-assets, no success so far.
Both of the libraries seem to fail to create files in the staticfiles 
directory on Heroku.
Both of them work locally with/without debug on.

I feel like I must be missing something really trivial..

Your help will be much appreciated!

P.S. I created a support ticket and got an answer telling me to check in 
the staticfiles directory,
which is created automatically when deploying django apps (created when 
collectstatic is run post-deploy)
I did try committing the directory with a .keep file in it, but no success 
either.

Thanks,
Po

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/19d7d081-971d-4180-ac68-37e22bdcb2e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


what's different between {% static %} and {{ STATIC_URL}}

2015-01-06 Thread 老张
hi,guys
i'm new to django。when I write my first app, there are 2 options to access 
static files,
1 using  {{ STATIC_URL}}
2 using  {% load staticfiles%} then {% static %}
what 's different between the 2 options, and ,when I migrate from development 
to production env
which one is conveniency ?
Thanks alot 
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/31d5812d.1eba0.14abefc5261.Coremail.paiis314%40163.com.
For more options, visit https://groups.google.com/d/optout.


CSRF verification failed when I use smart phone

2015-01-06 Thread Sugita Shinsuke
Hello.

When I use Django via my smart phone Android and iOS.
The error sometimes occurred.

Forbidden (403)
CSRF verification failed. Request aborted.
Help
Reason given for failure:
CSRF token missing or incorrect.

In general, this can occur when there is a genuine Cross Site Request 
Forgery, or when Django's CSRF mechanism has not been used correctly. For 
POST forms, you need to ensure:
Your browser is accepting cookies.
The view function uses RequestContext for the template, instead of Context.
In the template, there is a {% csrf_token %} template tag inside each POST 
form that targets an internal URL.
If you are not using CsrfViewMiddleware, then you must use csrf_protect on 
any views that use the csrf_token template tag, as well as those that 
accept the POST data.
You're seeing the help section of this page because you have DEBUG = True 
in your Django settings file. Change that to False, and only the initial 
error message will be displayed.
You can customize this page using the CSRF_FAILURE_VIEW setting.

I append django.middleware.csrf.CsrfViewMiddleware', of MIDDLEWARE_CLASSES 
in settings.py

I use
Python 2.7.5
Django 1.6.4

Anyone who know this matter, please help.

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


Re: how can I choose option price from checkbox option and calculate the sum.

2015-01-06 Thread rdyact
Oh, thanks a lot, I'll try it anyway. ~~

2015년 1월 6일 화요일 오후 12시 45분 49초 UTC+9, Collin Anderson 님의 말:
>
> Hi,
>
> You probably need to use javascript to make the total price auto-update 
> when you check or uncheck each box. Check out jQuery if you haven't.
>
> Once you have that, then, yes, you'll want to re-calculate the price in 
> django to be sure it's correct.
>
> You could create an Order or Cart model that stores which (or how many of 
> each) items have been select, and maybe the total price too.
>
> Collin
>
> On Sunday, January 4, 2015 12:55:02 AM UTC-5, rdyact wrote:
>>
>>
>> 
>> I want to program to calculate sum of user sleclecion of options with 
>> checkbox.
>> Pls help me how to keep away from this suffer.
>> I summarize what I want to do in my attached ppt file.
>>
>> How can I code for this in my viws.py & models.py each?
>>
>>
>> #Product&Choice Model - models.py
>>
>> class Product(models.Model):
>> title = models.CharField(max_length=120)
>> description = models.TextField(null=True, blank=True)
>> price = models.DecimalField(decimal_places=0, max_digits=100, 
>> default=1)
>>
>> class Choice(models.Model):
>> product = models.ForeignKey(Product)
>> name = models.CharField(max_length=255)
>> price = models.DecimalField(decimal_places=0, max_digits=100, default=0)
>>
>> # single.html
>>
>> Your Product Price : {{ product.price }}$
>>
>> {% for item in product.choice_set.all %}
>> {% csrf_token %}> value='{{ item.id }}' name='choice'> {{ item.name }} : {{ item.price }}$ 
>> 
>> {% endfor %}
>> 
>> 
>> ~~
>>
>

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