Unable to load application to production environment

2011-11-30 Thread Ganesh Kumar
Hi guys,

I am trying to load to my application to production environment,
It will work on test server, How to do this please guide me.

my settings file:-
'registration',
'fileupload',
'password_required',

those application cant load at production time.

error says:-
No module named registration

-Ganesh
Did I learn something today? If not, I wasted it.

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



Django admin URL redirect problem in admin page

2011-11-30 Thread Asif
Dear All,

In one of my django app, I extended the django User model and created
a new ‘UserProfile ‘ model. But when I’m trying to add new user
through this model in admin page, the URL is not redirecting to
successful page, instead its stopped on ‘admin/auth/user/add/?
_popup=1’ this URL. (user is created but not redirecting to success
page)

Here is the code

class UserProfile(User):

age = models.CharField(max_length=20, blank=True, null=True)
education = models.CharField(max_length=50, blank=True,
 null=True,
 choices=EDUCATION_CHOICES)

class TestPopulation(models.Model):

user = models.ManyToManyField(UserProfile, blank=True, null=True)
questionnaire = models.ManyToManyField(Questionnaire, blank=True,
null=True)

def __unicode__(self):
return "%s" % (self.user)

This creating creating the user object in admin page but not
redirecting to successpage, instead its stopped at  ‘admin/auth/user/
add/?_popup=1’

Any suggestions?

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



Re: Using request.POST.copy() to get hidden field in html template

2011-11-30 Thread DrBloodmoney
On Wed, Nov 30, 2011 at 7:43 PM, jim  wrote:
> I'm trying to use request.POST.copy() to get a hidden field in an html
> template.  The hidden field looks like:
>
> 
>
> I also tried:
>
> 
>
> In my view.py I have:
>
>      postdata = request.POST.copy()
>       url = str(postdata.get('url'))
>
> The value of url is None.  Is there an additional trick to this?

1. Make sure that the hidden field is inside of the  tags.

2. You shouldn't need to copy the QueryDict to get the value:

url = request.POST.get('url', 'default') # or request.POST['url']

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



Using request.POST.copy() to get hidden field in html template

2011-11-30 Thread jim
I'm trying to use request.POST.copy() to get a hidden field in an html
template.  The hidden field looks like:



I also tried:



In my view.py I have:

  postdata = request.POST.copy()
   url = str(postdata.get('url'))

The value of url is None.  Is there an additional trick to this?

Thanks
Jim

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



Re: converting a large site to Django

2011-11-30 Thread marjenni
Hi,ne
   Thank you for your quick reply :)

Actually, I am a little concerned that I may have a lot of work ahead
of me!

I have an existing php based website that is used to advertise holiday
accommodation, and the pages that contain advert listings are
dynamically recreated every 24 hours.

I needed to implement a search feature, and this seemed much easier to
write in python than php, so on a new server I created a django
project, and basically all this contains is the modified home page of
the existing website with the search that generates a list of results.

Now I need to move across the rest of the website to the new server,
and I need to do this with minimal effort. I also need to preserve the
existing page URLs.

It maybe the case that there are no real shortcuts, but I just didn't
want to make unnecessary work for myself!

If anyone has some tips, please let me know.

Thanks again for the support

Mark


On Nov 30, 5:21 pm, creecode  wrote:
> Hello Mark,
>
> On Wednesday, November 30, 2011 8:46:28 AM UTC-8, marjenni wrote:
>
> All seems good, but what I need to know is what is the easiest/> quickest way 
> of moving across the rest of the website onto this new
> > server? Will I need an entry for each page in the urls file?
>
> It will be hard for us to answer that question unless we know more about
> how/where the old webpages are stored and how you would like to store them
> in your Django based website.
>
> You have several options:
>
>     Use an app like Flatpages 
> , which
> comes with Django.  Webpages are stored in the database.  It might be
> pretty easy to populate your Django website with some python code you would
> write that would grab your old webpages, massage them, and store them into
> your new website database.
>
>     If the old webpages are static, you could put them into the static area
> of your website.
>
> Give us more detail and we can probably be of more help.
>
> Toodle-lo..
> creecode

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



LocalWiki, a crazy-easy-to-use django-based geographic wiki, released!

2011-11-30 Thread philipn
Folks-

We just made the first general public release of LocalWiki, a really
easy to use wiki that focuses on geographic communities.  It's all
Django-based.  Check it out:

http://localwiki.org

Django devs will probably want to check out http://dev.localwiki.org
and follow our 'manual' installation instructions :)

But check out how we've packaged the whole project as a single easy-to-
install Ubuntu package.  We modeled the management system after Trac,
which seems to be the most widely installed Python-based web app
("localwiki-manage" is an alias to a 'python manage.py' inside a well-
contained virtualenv)  Making it this easy to install (for non-
Djangonauts) was a big challenge, but I'm there's some stuff others
can learn.

-Philip

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



Two Servers plus one Load Balancer Vip Advice for DB?

2011-11-30 Thread Colin
Hi Django users,

So I have two servers behind a vip. I currently have it setup so if
one server goes down it uses the other http server which works great.
However I tried to set up mysql master - master and I keep getting
duplicate key errors and grind the process to a hault and causes a
real headache.

My only requirment is that if one server goes down the system will
still work, either physical or software server. So what would your
advice be? This isnt a high volumn system but it needs high
availability due ot the fact I use this as a tools mainsite and
configuration system.

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



RE: MS Access integration with DJango through conversion to (Postgres or MySQL) xor direct interaction

2011-11-30 Thread Sells, Fred
There's a free access to mysql converter; try google; I forgot the name
and have it on a different computer than this one.  Contact list again
if you cannot find it and I'll look harder.

-Original Message-
From: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] On Behalf Of Alec Taylor
Sent: Wednesday, November 30, 2011 12:58 AM
To: django-users@googlegroups.com
Subject: MS Access integration with DJango through conversion to
(Postgres or MySQL) xor direct interaction

Good afternoon,

Is there an ORM library for python/django which integrates with MS
Access? - I know SQLalchemy dropped support after 0.4, but maybe
there's another to use?

Alternatively how would I convert one to PostgreSQL or MySQL then
interpret it into ORM syntax for use in i.e. SQLalchemy?

Thanks for all suggestions,

Alec Taylor

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


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



Feature Flipping with Gargoyle and Waffle

2011-11-30 Thread Adam Nelson
We just put out a post about feature flipping using Gargoyle or Waffle:

http://tech.yipit.com/2011/11/30/getting-to-continuous-deployment-in-django-feature-flipping/
---
Adam Nelson
CTO, Yipit
Join the Yipit Team and work with Python, Django, MongoDB, jQuery,
Backbone.js and Sass @ http://yipit.com/jobs/ 

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



django south

2011-11-30 Thread william ratcliff
Is there anyone available late next week to give a webinar on django
south?  No need for a detailed presentation, but more to be around to
answer questions  (I think that 9am EST would cover most time zones)?
If so, please contact me off list about dates/times/compensation.

The goal would be to offer another django chat.

Best,
William

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



Re: Website Statistics - What should I use to have Google Analytics in Django?

2011-11-30 Thread Sime Ramov
* Andre Lopes  [2011-11-30 20:25+]:
> I need to track visitors with Google Analytics. What should I use to
> get Google Analytics working on Django?

Are you serious?

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



Re: Website Statistics - What should I use to have Google Analytics in Django?

2011-11-30 Thread william ratcliff
Google gives you a small piece of javascript that you need to insert
into your pages to track them.  So, all you need to do is to insert
that code into your templates...

On 11/30/11, Carlos Daniel Ruvalcaba Valenzuela  wrote:
> A quick Google revealed that there is already a
> django-google-analytics package, why not try to check it out?
> otherwise you could as last resort just put their tracking code on
> your master template and be done with it.
>
> http://code.google.com/p/django-google-analytics/
>
> Regards,
> Carlos Ruvalcaba
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Website Statistics - What should I use to have Google Analytics in Django?

2011-11-30 Thread Carlos Daniel Ruvalcaba Valenzuela
A quick Google revealed that there is already a
django-google-analytics package, why not try to check it out?
otherwise you could as last resort just put their tracking code on
your master template and be done with it.

http://code.google.com/p/django-google-analytics/

Regards,
Carlos Ruvalcaba

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



Website Statistics - What should I use to have Google Analytics in Django?

2011-11-30 Thread Andre Lopes
Hi,

I need to track visitors with Google Analytics. What should I use to
get Google Analytics working on Django?

What is my best choice?

Best Regards,

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



Re: unit tests and 'system' tests with history

2011-11-30 Thread Ian Clelland
On Wed, Nov 30, 2011 at 2:48 AM, Gelonida N  wrote:

> 2.) Stress / System tests
> --
>

These are often called 'integration tests', and are used to test whether
all of the (properly unit-tested) components of the system actually
function properly when assembled together.


>
> I'd also like to do some other tests, where I work on a system and where
> I am able to suffer from my history.
>
> Example (the example is perhaps too simple to see what I'm aiming it)
> - I create an entry
> - I rename an entry
> - I remove an entry
>
> If I had three independent tests I would never find out if I had a weird
> bug, which would make the system fail if I tried to remove an entry
> which has been renamed before.
>

As an aside, I'm not sure that I would use this sort of test framework for
these kinds of bugs -- there are just too many ways for the system to fail
if you start thinking this way:

   - What if it only fails when the entry has been renamed?
   - What if it only fails when the entry has been renamed to something
   longer?
   - What if it only fails when the entry has been renamed while someone
   else was editing it?
   - What if it only fails when the entry has a name with no vowels in it,
   which was also used as another user's password, but not in the last six
   weeks? :)

You can only simulate so many conditions, and lots of bugs can lurk
undetected even with a whole suite of such tests. Even worse, if the code
changes, then the exact bug that you were testing for might appear to be
fixed, but actually changes very slightly, and doesn't get picked up any
more.

In a case like this, I would normally wait to find out that there was a
problem in the first place, and then institute a 'regression test' --
figure out the cause of the original bug (say, renaming the entry put the
record into an inconsistent state) and then set up a test which:

   1. instantiates a correct record directly
   2. performs the rename operation that was failing
   3. checks that the record is still consistent under every constraint.

And I would do all of these at the lowest level that makes sense --
certainly not by starting at the HTTP level.


> What would be a recommended way to run such system tests?
>
> 'just create a unit test, which is just calling sunb tests explicitely
> in the required order?)
>

For integration testing, that's exactly what I do -- set up a unit test
(not really a unit test in this case, but it's a subclass of
unittest.TestCase) that uses the django test client to perform a small
sequence of operations; usually a GET, checking the returned context, and
then a POST, checking the return status (200 for form errors; 30x for
successful redirects). I will set up any required objects in the database
first (in fixtures, setUp or the test method itself), and test them
afterwards.

Usually there aren't too many of these tests, though -- just enough that I
know that the GET and POST methods are not failing spectacularly. The
actual logic is tested with a bunch of much faster unit tests.


> As part of these system tests I would like to add some of my unit tests,
> but such, that the data base is NOT reset after each test run.
>

As a rule, I find it makes much more sense to declare the state of the
database before each test, and then just test a few operations. As long as
you properly test the consistency of the data after each operation, then
you shouldn't run into the "cascading failures" that you can get if each
test is dependent on the ones before it (or worse, cascading successes, if
one bug cancels out the effects of the another)

If you're actually looking for stress-testing, then there are a number of
other frameworks for that (ab, Bees with Machine Guns, etc) that will tell
you how your site performs under load. Host-based testing should be there
to tell you that your site behaves predictably and correctly under normal
operation.

Ian


>
>
> As you can see from my previous questions I'm used to 'non-atomic'
> testing (This was for systems which needed a very huge startup time
> and where taking snapshots was virtually impossible)
>
> Thus I often combined unit tests / system tests.
>
> These stress tests shall be able to run for several hours / days,
> whereas unit tests would run in a few minutes.
>
>
> Thanks for any suggestions
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Ian Clelland


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegr

Re: Django or python question about classes

2011-11-30 Thread youpsla
Thanks for the link Tom.

I'll read that in details later (it's a little bit complicated) an for
my POC I'll just use a not DRY method !!! :-)

Regards

Youpsla

On 28 nov, 17:16, Tom Evans  wrote:
> On Mon, Nov 28, 2011 at 4:07 PM, youpsla  wrote:
> > Hello,
> > in my code, I like to overrride the form_valid() method in both
> > CreateView and UpdateView generic class views.
>
> > I've put my code in views.py.
>
> > class MyCreateView(UpdateView):
> >    .
> >    def form_valid(self, form, **kwargs):
> >        some code
>
> > class MyUpdateView(CreateView):
> >    .
> >    def form_valid(self, form, **kwargs):
> >        some code
>
> > The both form_valid() methods are exactly the same (Only the
> > dispatch() method differ from both classes).
>
> > My question is : is there a way of doing this more in a DRY way ?
>
> > Thanks in advance.
>
> > Best regards
>
> > Alain
>
> http://stackoverflow.com/questions/533631/what-is-a-mixin-and-why-are...
>
> Cheers
>
> Tom

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



Re: A view associated with a lot of urls

2011-11-30 Thread Nolhian
> > Well I agree that if the category doesn't exist he will get a 404. But
> > if the Category exists and there are no items in the 'table', it will
> > not be empty, it will also raise a 404 too.  That's why I wrote :
>
> >> However with that, there is no way for example to make a difference
> >> between "there is no items in this category" and "this category
> >> doesn't exist” !
>
> No. with the line below items will be empty ant not 404.
>
> items= get_object_or_404(Category,name=category).items().filter(name=item)
>
> or  items without the brackets. (not sure about the syntax at the moment)
>
> The above is the same as:
>
> # This could produce 404
> category = get_object_or_404(Category,name=category)
>
> # This will result in an empty queryset and not 404
> items = category.items().filter(name=item)
>
> It is also obvious that the last line does not produce 404 since 404 is HTML 
> related and the line above is a DB query which at most should result in 
> something empty.

Yes, sorry I misread what you said. I read it correctly shortly after
posting and that's why I deleted my post like 1 min after posting it,
didn't think you would still get it though !

> I just saw your answer about using NoSQL. Sorry, forgot about that.
> In that case I cannot help you.

Okay ! Anyway thank you for your help, your infos about the urls and
configuring the site to send 404 errors are also really appreciated ;)

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



Re: Retrieve object model admin userid & password?

2011-11-30 Thread Ian Clelland
On Wed, Nov 30, 2011 at 10:22 AM, Tim Sawyer wrote:

> You can't retrieve the password, as that would be a security flaw.  The
> security works by hashing the password entered into the login form, and
> comparing the hashed version with the one stored on the database.  Hash
> functions are quick to run one way, but difficult to reverse, hence it's
> difficult to get back the password used.
>
> You can reset a users password in the admin site - login to admin, open
> the user up, then use the change password link next to the user's password
> field.
>
> This, of course, supposes that the password you've forgotten isn't the
> only admin password.  If it is, then you could delete the row from the
> auth_user database table and do a syncdb - that should prompt you to create
> a superuser, if I recall correctly.
>

Yes, yes and yes.

If you have console access, you can also do this:

manage.py changepassword username_goes_here

That will allow you to reset anybody's password; superuser or otherwise.

-- 
Regards,
Ian Clelland


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



Re: Retrieve object model admin userid & password?

2011-11-30 Thread Tim Sawyer
You can't retrieve the password, as that would be a security flaw.  The 
security works by hashing the password entered into the login form, and 
comparing the hashed version with the one stored on the database.  Hash 
functions are quick to run one way, but difficult to reverse, hence it's 
difficult to get back the password used.


You can reset a users password in the admin site - login to admin, open 
the user up, then use the change password link next to the user's 
password field.


This, of course, supposes that the password you've forgotten isn't the 
only admin password.  If it is, then you could delete the row from the 
auth_user database table and do a syncdb - that should prompt you to 
create a superuser, if I recall correctly.


HTH,

Tim.

On 30/11/11 18:10, Marc Edwards wrote:

I am working through some authentication examples.

When I created my first database, I "recall" entering a username and
password, but entering what I recall was the correct input is not
authenticating.

Is there an easy way to reset or retrieve the username and password
that was used to create the object model?



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



Retrieve object model admin userid & password?

2011-11-30 Thread Marc Edwards
I am working through some authentication examples.

When I created my first database, I "recall" entering a username and
password, but entering what I recall was the correct input is not
authenticating.

Is there an easy way to reset or retrieve the username and password
that was used to create the object model?

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



Re: What server configuration should I use for a Django site like this?

2011-11-30 Thread bryan hunt
Build it on 512 Linode, upgrade to 1024 if necessary. Linode are so
far ahead of the competition Price/Performance ratio, I wouldn't
bother with anyone else (VPS).

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



Re: Cache timeout

2011-11-30 Thread Tom Evans
On Sat, Nov 26, 2011 at 4:07 PM, Addy Yeow  wrote:
> If I use cache_page() decorator for my view function, will the TIMEOUT be
> able to take precedence over CACHE_MIDDLEWARE_SECONDS?
>
> In my settings.py,
>
> CACHES = {
>     'default': {
>         'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
>         'LOCATION': os.path.join(WEB_ROOT, "django_cache"),
>         'TIMEOUT': 5184000,
>     }
> }
> CACHE_MIDDLEWARE_SECONDS = 86400
>

TIMEOUT (from CACHES) is never used with the cache_page decorator.
TIMEOUT is only used when no timeout is specified when
adding/setting/updating an item in the cache, and cache_page always
does specify a timeout.

The cache_page decorator is a special invocation of the
CacheMiddleware, which is a mixin of both UpdateCacheMiddleware and
FetchFromCacheMiddleware, the former of which is documented as
follows:

* The number of seconds each page is stored for is set by the "max-age" section
  of the response's "Cache-Control" header, falling back to the
  CACHE_MIDDLEWARE_SECONDS setting if the section was not found.

The cache_page decorator adjusts this slightly, so that if a timeout
is specified within the tag, this is used instead of using
settings.CACHE_MIDDLEWARE_SECONDS as a default, but it will always use
'max-age' from the 'Cache-Control' header in preference to either of
these.

eg:

@cache_page
def foo():
# This will be cached for CACHE_MIDDLEWARE_SECONDS if no max-age

@cache_page(15 * 60)
def bar():
# This will be cached for 15 minutes if no max-age

Cheers

Tom

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



Fixture migrations using South?

2011-11-30 Thread Jeremy Dunck
I have some test fixtures with scenarios under test.  Later, I need to
migrate (with South) the DB schema around, which of cours necessitates
changing domain and test code.

A common problem I run into, though, is that I also need to migrate
the data in my fixtures.  It is possible to create a new DB, sync it
to a given migration point, load the fixture, run the remaining
migrations, and dump a new fixture, then drop the extra db.  But it
seems like a very awkward dance given how often I have the problem.

Is there already a solution to this?   It seems to me that South could
manage some book keeping to maintain what fixtures are at which
migration level, and a new south command could manage the migration of
fixtures.

./manage migrate --fixtures [all other options staying the same]

I imagine this would read/write some bookmark files to each affected
app's ./fixtures/ directory.  If the bookmark file didn't exist, the
0001 schema would be assumed.  Otherwise it'd be something along the
lines of:
fixture_file.name.south, and contents would roughly mirror
south_migrationhistory, perhaps in JSON format.

Thoughts?

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



Re: converting a large site to Django

2011-11-30 Thread creecode
Hello Mark,

On Wednesday, November 30, 2011 8:46:28 AM UTC-8, marjenni wrote:

All seems good, but what I need to know is what is the easiest/
> quickest way of moving across the rest of the website onto this new
> server? Will I need an entry for each page in the urls file?
>
It will be hard for us to answer that question unless we know more about 
how/where the old webpages are stored and how you would like to store them 
in your Django based website.

You have several options:

Use an app like Flatpages < 
https://docs.djangoproject.com/en/1.3//ref/contrib/flatpages/ >, which 
comes with Django.  Webpages are stored in the database.  It might be 
pretty easy to populate your Django website with some python code you would 
write that would grab your old webpages, massage them, and store them into 
your new website database.

If the old webpages are static, you could put them into the static area 
of your website.

Give us more detail and we can probably be of more help.

Toodle-lo..
creecode

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



Re: converting a large site to Django

2011-11-30 Thread Tim Sawyer
Do the pages that you're moving across to the new site need to be 
change-able through the admin system, or are they static HTML that won't 
change?


Only use flatpages if you want them to be editable through the web.

Tim.

On 30/11/11 17:09, Juan de Dios Manjon Perez wrote:

Try flatpages https://docs.djangoproject.com/en/dev/ref/contrib/flatpages/

-Juande

On Wed, 30 Nov 2011 08:46:28 -0800 (PST), marjenni wrote:

Hi,
I am working on a website with many pages (in the hundreds).

I have recreated the website front page on a new server with the
desired new functionality implemented in Python and Django.

All seems good, but what I need to know is what is the easiest/
quickest way of moving across the rest of the website onto this new
server? Will I need an entry for each page in the urls file?

Many thanks for all your help

Mark




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



Re: converting a large site to Django

2011-11-30 Thread Juan de Dios Manjon Perez
Try flatpages 
https://docs.djangoproject.com/en/dev/ref/contrib/flatpages/


-Juande

On Wed, 30 Nov 2011 08:46:28 -0800 (PST), marjenni wrote:

Hi,
   I am working on a website with many pages (in the hundreds).

I have recreated the website front page on a new server with the
desired new functionality implemented in Python and Django.

All seems good, but what I need to know is what is the easiest/
quickest way of moving across the rest of the website onto this new
server? Will I need an entry for each page in the urls file?

Many thanks for all your help

Mark


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



Re: Cache timeout

2011-11-30 Thread Jian Chang
u can test by yourself.
yes, i don't know the answer, neather
在 2011-11-27 上午12:08,"Addy Yeow" 写道:

> If I use cache_page() decorator for my view function, will the TIMEOUT be
> able to take precedence over CACHE_MIDDLEWARE_SECONDS?
>
> In my settings.py,
>
> CACHES = {
> 'default': {
> 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
> 'LOCATION': os.path.join(WEB_ROOT, "django_cache"),
> 'TIMEOUT': 5184000,
> }
> }
> CACHE_MIDDLEWARE_SECONDS = 86400
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



converting a large site to Django

2011-11-30 Thread marjenni
Hi,
   I am working on a website with many pages (in the hundreds).

I have recreated the website front page on a new server with the
desired new functionality implemented in Python and Django.

All seems good, but what I need to know is what is the easiest/
quickest way of moving across the rest of the website onto this new
server? Will I need an entry for each page in the urls file?

Many thanks for all your help

Mark

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



Re: A view associated with a lot of urls

2011-11-30 Thread Ivo Brodien

> Well I agree that if the category doesn't exist he will get a 404. But
> if the Category exists and there are no items in the 'table', it will
> not be empty, it will also raise a 404 too.  That's why I wrote :
> 
>> However with that, there is no way for example to make a difference
>> between "there is no items in this category" and "this category
>> doesn't exist” !

No. with the line below items will be empty ant not 404.

items= get_object_or_404(Category,name=category).items().filter(name=item)

or  items without the brackets. (not sure about the syntax at the moment)

The above is the same as:

# This could produce 404
category = get_object_or_404(Category,name=category)

# This will result in an empty queryset and not 404 
items = category.items().filter(name=item)

It is also obvious that the last line does not produce 404 since 404 is HTML 
related and the line above is a DB query which at most should result in 
something empty.

I just saw your answer about using NoSQL. Sorry, forgot about that.

In that case I cannot help you.

Good Luck

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



Re: A view associated with a lot of urls

2011-11-30 Thread Nolhian
Well that should work pretty well with an SQL database. But as I said
my database is  a NoSQL one, here I need to have one "table" per
category. So creating another Categorylist table just for fun and put
all the category names into, then hit it in order to check if the
category exists just seems wrong to me.
I thought of retrieving a list of the table names from the database
and check if the category the user want is in that list but for that I
must import another module.

On Nov 30, 1:41 pm, Ivo Brodien  wrote:
> > I don't quite understand what you mean here. You want me to create a
> > CategoryModel of which all my Category models should be derived ? If
> > that's it, how can it help me to determine if URL is valid or not, I
> > can't see how that works.
>
> Sorry, it was DrBloodmoney, who wrote this:
>
> > class Category(models.Model):
> >    name = models.CharField # should be unique
>
> > class Item(models.Model):
> >  name = models.CharField()
> >   category = models.ForeignKey(Category, related_name='items’)
>
> in your view you do so:
>
> def view(request, category, item):
>      items= 
> get_object_or_404(Category,name=category).items().filter(name=item)
>      
>
> That’s it.
>
> Now if someone enters a category by hand which does not exist, he gets a 404. 
> If the category exists, but there is no item with such a name items will be 
> empty.
>
> Bye
> Ivo

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



Re: Process management with Supervisord

2011-11-30 Thread Andre Lopes
Thank you for the reply.

Best Regards,


On Wed, Nov 30, 2011 at 2:51 PM, DrBloodmoney  wrote:
> On Wed, Nov 30, 2011 at 9:35 AM, Andre Lopes  wrote:
>> Hi,
>>
>> I'm serving to production a Django website with Nginx + Gunicorn with
>> virtualenv.
>>
>> My dumb question is: I must to install supervisord in my virtualenv or
>> outside my virtualenv?
>
> You should just install supervisord to your system python install
> (easy_install). I run it as root manage it with upstart on Ubuntu so
> it'll restart/start properly (run nginx workers and gunicorn as
> non-root (servers) - this example is for uwsgi but it'll be very
> similar for gunicorn):
>
> # supervisord.conf
> # put this directive at the bottom of your /etc/supervisord.conf
>
> [program:uwsgi_example]
> command=/usr/local/sbin/uwsgi
>  --pythonpath "/home/servers/www/example.com/app/example"
>  --virtualenv "/home/servers/virtualenvs/example"
>  --socket 127.0.0.1:9000
>  --module example.django_wsgi
> user=servers
> autostart=true
> autorestart=true
> stdout_logfile=/home/servers/www/example.com/logs/uwsgi.log
> redirect_stderr=true
>
> 
>
> # Upstart init
> # copy or symlink to /etc/init/supervisord.conf
> # /etc/init/supervisord.conf
>
> # supervisord script for upstart
>
> description    "Supervisor"
>
> start on runlevel [2345]
> stop on runlevel [!2345]
>
> # --nodaemon: Run supervisord in the foreground
> exec /usr/local/bin/supervisord --nodaemon
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Creating an app for recurring features

2011-11-30 Thread Benedict Verheyen
Hi,


I have made several projects now for internal use and some of the functionality 
keeps coming back.
For instance, language selection, user authentication, ad syncronization of 
users.

I want to put these in seperate apps that I can easily install in a project. 
All projects use virtualenv.
My first try is with the language stuff as this is only some settings and a 
view.
I've put the urls.py, views and so on in a seperate dir and then copied this 
dir in my current project.
Made a setup.py file to install the app with "python setup.py develop".

This works, and I can access the view from the project. So far so good.
I'm however not sure this is the right way to put some recurring functionality 
in a reusable app.
Some questions that arise:

- For the language selection view, I use small flags to make the language 
selection nicer.
These images are installed in the static directory of the application.
I then "installed" them in my project by including the correct dir in 
STATICFILES_DIRS
in the projec settings and then collected them with "python manage.py 
collectstatic --link"
I know I could have linked to the files but this seemed more Django like, yet, 
I'm not
sure this is the right way.

- I would like to be able to test the application. I thought that I could get 
away with a
minimal system (virtualenv + django) but it seems I need a rather complete 
settings.py
file and a typical project/app structure setup. I don't have that, so testing 
doesn't work.
How can I test the application code? Is there another way besides creating a 
full django project?

The settings file of the application (comments etc. left out)
===
ugettext = lambda s: s
LANGUAGES = (
('nl', ugettext('Dutch')),
('fr', ugettext('French')),
('en', ugettext('English')),
)
DEFAULT_LANGUAGE = 1
LANGUAGE_CODE = 'nl'


USE_I18N = True
USE_L10N = True
===

In my testproject, I made these changes to load the app succesfully.

1. I enabled- the LocaleMiddleware
2. I add the app to the INSTALLED_APPS
3. I load the language app settings file at the end of the projecs settings.py
This feels kind of hackish.
4. I add the path with the app static files to STATICFILES_DIRS
5. Add the app urls to the test project urls.

As I said, this is for local projects only, not meant to be distributed to the 
outside world.

Regards,
Benedict

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



Re: A view associated with a lot of urls

2011-11-30 Thread Nolhian
> Sorry, it was DrBloodmoney, who wrote this:
>
> > class Category(models.Model):
> >    name = models.CharField # should be unique
>
> > class Item(models.Model):
> >  name = models.CharField()
> >   category = models.ForeignKey(Category, related_name='items’)
>

Oh that, yes I intended to do so.

>Now if someone enters a category by hand which does not exist, he gets a >404. 
>If the category exists, but there is no item with such a name items will >be 
>empty.

Well I agree that if the category doesn't exist he will get a 404. But
if the Category exists and there are no items in the 'table', it will
not be empty, it will also raise a 404 too.  That's why I wrote :

>However with that, there is no way for example to make a difference
>between "there is no items in this category" and "this category
>doesn't exist" !

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



Re: Process management with Supervisord

2011-11-30 Thread DrBloodmoney
On Wed, Nov 30, 2011 at 9:35 AM, Andre Lopes  wrote:
> Hi,
>
> I'm serving to production a Django website with Nginx + Gunicorn with
> virtualenv.
>
> My dumb question is: I must to install supervisord in my virtualenv or
> outside my virtualenv?

You should just install supervisord to your system python install
(easy_install). I run it as root manage it with upstart on Ubuntu so
it'll restart/start properly (run nginx workers and gunicorn as
non-root (servers) - this example is for uwsgi but it'll be very
similar for gunicorn):

# supervisord.conf
# put this directive at the bottom of your /etc/supervisord.conf

[program:uwsgi_example]
command=/usr/local/sbin/uwsgi
  --pythonpath "/home/servers/www/example.com/app/example"
  --virtualenv "/home/servers/virtualenvs/example"
  --socket 127.0.0.1:9000
  --module example.django_wsgi
user=servers
autostart=true
autorestart=true
stdout_logfile=/home/servers/www/example.com/logs/uwsgi.log
redirect_stderr=true



# Upstart init
# copy or symlink to /etc/init/supervisord.conf
# /etc/init/supervisord.conf

# supervisord script for upstart

description"Supervisor"

start on runlevel [2345]
stop on runlevel [!2345]

# --nodaemon: Run supervisord in the foreground
exec /usr/local/bin/supervisord --nodaemon

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



Try to follow the Tutorial "Wiki in 20 minutes" on ShowMeDo

2011-11-30 Thread moRytox
Hi Guys,

at first: please excuse my bad english. I hope you can understand what
i mean.
i just started working with Django and used the tutorial @
djangoproject.com.
After i completed it i tried to rebuild the djangotutorial for
wikicamp shown on ShowMeDo ( 
http://showmedo.com/videotutorials/video?name=110&fromSeriesID=110
). I recognized that it's an old version of django he used, so i
successfully solved all issues until I tried to rebuild the first half
of the third video. Its about manytomany relations.
Now I got the problem, when i send the form with the Pagedata and one
or More Tags (there is the ManyToMany relation, On or More pages can
have one or more Tags) it tells me that the needed model doesn't
exists. And it calls the model wiki_page_tags , but i got a model Page
and a model Tags.
The error message shows following code phrase:

for tag in tag_list:
page.tags.add(tag)

As attachment there are the Views.py and the Models.py. If You need
more Information to solve my problem, please let me know.

I use a SQLite  DB and thats my views.py:

from djangotutorial.wiki.models import Page, Tag
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.template import RequestContext
from django import forms

class SearchForm(forms.Form):
text = forms.CharField(label="Enter search term")
search_content = forms.BooleanField(label="Search content",
required=False)

def search_page(request):
if request.method == "POST":
f = SearchForm(request.POST)
if not f.is_valid():
return render_to_response("wiki/search.html", {"form":f},
context_instance=RequestContext(request))
else:
pages = Page.objects.filter(name__contains =
f.cleaned_data["text"])
contents = []
if f.cleaned_data["search_content"]:
contents = Page.objects.filter(content__contains =
f.cleaned_data["text"])

return render_to_response("wiki/search.html", {"form":f,
"pages":pages, "contents":contents},
context_instance=RequestContext(request))
f = SearchForm()
return render_to_response("wiki/search.html", {"form":f},
context_instance=RequestContext(request))

specialPages = {"SearchPage": search_page}

def view_page(request, page_name):
if page_name in specialPages:
return specialPagespage name(request)
try:
page = Page.objects.get(pk=page_name)
except Page.DoesNotExist:
return render_to_response('wiki/create.html',
{'page_name':page_name})
content = page.content
return render_to_response("wiki/view.html",
{"page_name":page_name, "content":content})

def edit_page(request, page_name):
try:
page = Page.objects.get(pk=page_name)
content = page.content
except Page.DoesNotExist:
content = ""
return render_to_response("wiki/edit.html",
{"page_name":page_name, "content":content},
context_instance=RequestContext(request))

def save_page(request, page_name):
content = request.POST["content"]
tag_list = []
if "tags" in request.POST:
tags = request.POST["tags"]
tag_list = [Tag.objects.get_or_create(name=tag) for tag in
tags.split()]
try:
page = Page.objects.get(pk=page_name)
page.content = content
for tag in tag_list:
page.tags.add(tag)
except Page.DoesNotExist:
page = Page(name=page_name, content=content)
page.save()
return HttpResponseRedirect("/wiki/page/" + page_name + "/")





and the models.py:
from django.db import models

# Create your models here.

class Tag(models.Model):
name = models.CharField(max_length=20, primary_key=True)

class Page(models.Model):
name = models.CharField(max_length=20, primary_key=True)
content = models.TextField(blank=True)
tags = models.ManyToManyField(Tag)

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



Process management with Supervisord

2011-11-30 Thread Andre Lopes
Hi,

I'm serving to production a Django website with Nginx + Gunicorn with
virtualenv.

My dumb question is: I must to install supervisord in my virtualenv or
outside my virtualenv?


Best Regards,

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



Re: MS Access integration with DJango through conversion to (Postgres or MySQL) xor direct interaction

2011-11-30 Thread Michael Manfre
An access database should not be used for a production site. There are
various ways/tools for migrating from access to other databases.
Search for how to export from ms access and it should turn up a lot of
different methods for migrating to mysql or postresql.

Access to MySQL example -  http://www.kitebird.com/articles/access-migrate.html

Regards,
Michael

On Nov 30, 12:58 am, Alec Taylor  wrote:
> Good afternoon,
>
> Is there an ORM library for python/django which integrates with MS
> Access? - I know SQLalchemy dropped support after 0.4, but maybe
> there's another to use?
>
> Alternatively how would I convert one to PostgreSQL or MySQL then
> interpret it into ORM syntax for use in i.e. SQLalchemy?
>
> Thanks for all suggestions,
>
> Alec Taylor

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



Re: A view associated with a lot of urls

2011-11-30 Thread Ivo Brodien

> I don't quite understand what you mean here. You want me to create a
> CategoryModel of which all my Category models should be derived ? If
> that's it, how can it help me to determine if URL is valid or not, I
> can't see how that works.

Sorry, it was DrBloodmoney, who wrote this:

> class Category(models.Model):
>name = models.CharField # should be unique
> 
> class Item(models.Model):
>  name = models.CharField()
>   category = models.ForeignKey(Category, related_name='items’)


in your view you do so:

def view(request, category, item):
 items= get_object_or_404(Category,name=category).items().filter(name=item)
 

That’s it.

Now if someone enters a category by hand which does not exist, he gets a 404. 
If the category exists, but there is no item with such a name items will be 
empty.

Bye
Ivo

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



Re: Delete a many to many field who is in another table

2011-11-30 Thread jose osuna perez
I try to make this using delete, remove.. Also I using too
 if request.POST.get('experimentosDelete','')!='':
 for i in
request.POST.getlist('experimentosDelete'):
 
exp=Experimentos.objects.get(proyecto=datos,id=i)
 
exp.experimentos=[]

...
I don't know how to make this..
Anyone who say me ??? Thanks a lot

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



Re: A view associated with a lot of urls

2011-11-30 Thread Nolhian
Hello,


>As Reinout suggested you should have a CategoryModel which you can check >if a 
>Category exists and the get the items of show that the category does not 
>>exist or 404 if somebody entered a wrong URL/Category. Checking against the 
>>DB is probably the same thing you want to do, but it uses the DB and not a 
>>List/Dict which you have to maintain manually somehow.

I don't quite understand what you mean here. You want me to create a
CategoryModel of which all my Category models should be derived ? If
that's it, how can it help me to determine if URL is valid or not, I
can't see how that works.


>I think you care too much about people entering wrong URLs. People are 
>>clicking links on your webpage, right? Or do you give him instructions to 
>>write urls in the adress field?

Yes they click links on the webpages :)

1) use the url tag or get_absolute_url of your models to produce the
urls in your template
2) configure your site to send you 404 errors which have a referer
(read below and [1])

>404 errors
>Django can also be configured to e-mail errors about broken links (404 “page 
>>not found” errors). Django sends e-mails about 404 errors when:
>DEBUG is False
>SEND_BROKEN_LINK_EMAILS is True
>Your MIDDLEWARE_CLASSES setting includes CommonMiddleware (which it >does by 
>default).
>If those conditions are met, Django will e-mail the users listed in the 
>>MANAGERS setting whenever your code raises a 404 and the request has a 
>>referer. (It doesn’t bother to e-mail for 404s that don’t have a referer – 
>those >are usually just people typing in broken URLs or broken Web ‘bots).

Wow that's nice to know, thanks for all these infos !


On Nov 30, 11:15 am, Ivo Brodien  wrote:
> Hi,
>
> > That's why I'm
> > considering checking at the beginning of the view with a list/dict
> > filled with category names and one filled with item names to make sure
> > that the category is in the list/dict and same for the item before
> > hitting the database, and if not respond with a 404.
>
> As Reinout suggested you should have a CategoryModel which you can check if a 
> Category exists and the get the items of show that the category does not 
> exist or 404 if somebody entered a wrong URL/Category. Checking against the 
> DB is probably the same thing you want to do, but it uses the DB and not a 
> List/Dict which you have to maintain manually somehow.
>
> I think you care too much about people entering wrong URLs. People are 
> clicking links on your webpage, right? Or do you give him instructions to 
> write urls in the adress field?
>
> As long as you produce correct urls the code works and only should show 404 
> if someone messed with the URL.
>
> Consider doing this:
>
> 1) use the url tag or get_absolute_url of your models to produce the urls in 
> your template
> 2) configure your site to send you 404 errors which have a referer (read 
> below and [1])
>
> 404 errors
> Django can also be configured to e-mail errors about broken links (404 “page 
> not found” errors). Django sends e-mails about 404 errors when:
> DEBUG is False
> SEND_BROKEN_LINK_EMAILS is True
> Your MIDDLEWARE_CLASSES setting includes CommonMiddleware (which it does by 
> default).
> If those conditions are met, Django will e-mail the users listed in the 
> MANAGERS setting whenever your code raises a 404 and the request has a 
> referer. (It doesn’t bother to e-mail for 404s that don’t have a referer – 
> those are usually just people typing in broken URLs or broken Web ‘bots).
>
> bye
>
> [1]https://docs.djangoproject.com/en/1.3/howto/error-reporting/

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



Re: Delete a many to many field who is in another table

2011-11-30 Thread Tom Evans
On Wed, Nov 30, 2011 at 11:42 AM, jose osuna perez
 wrote:
> Hi, I am finally going to finish the project started and where I end
> up liking this xD Django that the problem I have is the clearing of a
> field.
> ...
> I try like this:
>
> if request.POST.get('experimentosDelete','')!='':
>                                                 for i in 
> request.POST.getlist('experimentosDelete'):
>                                                        
> exp=Experimentos.objects.get(proyecto=datos,id=i)
>                                                        
> exp.experimentos.remove(request.POST.get('experimentosDelete'))
>

The remove() method takes objects, not ids.

https://docs.djangoproject.com/en/1.3/ref/models/relations/#django.db.models.fields.related.RelatedManager.remove

Cheers

Tom

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



Re: What server configuration should I use for a Django site like this?

2011-11-30 Thread Salvatore Iovene
Hi, I recently launched a Django project on a Linode 1024.

I serve django with nginx, run mysql, and a bunch of other stuff. I 
routinely have about 500MB of free RAM. I wouldn't recommend a Linode 512, 
you will swap a lot.

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



Re: Delete a many to many field who is in another table

2011-11-30 Thread Salvatore Iovene
Hi,
after:

exp.experimentos.remove(request.POST.get('experimentosDelete'))

You should do:

exp.save()

I hope this helps.
Salvatore.

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



Delete a many to many field who is in another table

2011-11-30 Thread jose osuna perez
Hi, I am finally going to finish the project started and where I end
up liking this xD Django that the problem I have is the clearing of a
field.
I have the following tables.

class Proyectos(models.Model):
titulo=models.CharField(max_length=100)
creacion=models.DateField(default=datetime.datetime.now)
estado=models.CharField(max_length=30)
objetivo=models.TextField(null=True)
conclusion=models.TextField(null=True)
porcentaje=models.IntegerField()
modificado=models.DateTimeField(default=datetime.datetime.now)
autor=models.IntegerField()
usuarios=models.ManyToManyField(User)
proyectos_rel=models.ManyToManyField("self")
documentos=models.ManyToManyField(Documentos)
class Meta:
db_table='Proyectos'
def __unicode__(self):
return self.titulo

class Experimentos(models.Model):
titulo=models.CharField(max_length=100)
creacion=models.DateField(default=datetime.datetime.now)
estado=models.CharField(max_length=30)
objetivo=models.TextField(null=True)
conclusion=models.TextField(null=True)
porcentaje=models.IntegerField()
modificado=models.DateTimeField(default=datetime.datetime.now)
autor=models.IntegerField()
proyecto=models.ForeignKey(Proyectos)
usuarios=models.ManyToManyField(User)
experimentos=models.ManyToManyField("self")
documentos=models.ManyToManyField(Documentos)
class Meta:
db_table='Experimentos'
.
I want to eliminate only one of the experiments which may contain a
Project
I try like this:

if request.POST.get('experimentosDelete','')!='':
 for i in 
request.POST.getlist('experimentosDelete'):

exp=Experimentos.objects.get(proyecto=datos,id=i)

exp.experimentos.remove(request.POST.get('experimentosDelete'))

The result is that it does nothing ... and otherwise remove whole
objects, not the relationship.I don't  know .
I greatly appreciate your help in all questions.

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



save_model on django.contrib.auth.admin.UserAdmin not called by password change form

2011-11-30 Thread Marc
Hello,

I would like to get control on the password change form of the admin
site.

I put the following code in the admin.py:

class MyUserAdmin(UserAdmin):
def save_model(self, request, obj, form, change):
...
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)

The problem is that when user calls the password change build form the
save_model method is not called.

is there a way to intercept the password change action ?

Thanks

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



unit tests and 'system' tests with history

2011-11-30 Thread Gelonida N
I started implementing tests for my django application.


I anticipate two kind of tests:


1.) Unit tests
---

The unit tests should be as the uni tests are implemented in django.

They should be 'atomic' independent, could be executed in any order and
should always yield the same results


2.) Stress / System tests
--

I'd also like to do some other tests, where I work on a system and where
I am able to suffer from my history.

Example (the example is perhaps too simple to see what I'm aiming it)
- I create an entry
- I rename an entry
- I remove an entry

If I had three independent tests I would never find out if I had a weird
bug, which would make the system fail if I tried to remove an entry
which has been renamed before.


What would be a recommended way to run such system tests?

'just create a unit test, which is just calling sunb tests explicitely
in the required order?)

As part of these system tests I would like to add some of my unit tests,
but such, that the data base is NOT reset after each test run.


As you can see from my previous questions I'm used to 'non-atomic'
testing (This was for systems which needed a very huge startup time
and where taking snapshots was virtually impossible)

Thus I often combined unit tests / system tests.

These stress tests shall be able to run for several hours / days,
whereas unit tests would run in a few minutes.


Thanks for any suggestions


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



Re: django tests. where to create users

2011-11-30 Thread Gelonida N
On 11/29/2011 12:34 PM, Piotr Zalewa wrote:
> I use all solutions, depending on the needs.
> 
> When I'm testing a usage of many objects I use fixtures (also with users
> as I'm "pretending" that users created them)
> 
> When there is a test involving a user I create this object, either in
> test or the setUp.
> 
> On 11/28/11 01:58, Gelonida N wrote:
>> Hi,
>>
>> I'd like to run some django tests, which use the test client and which
>> should check, that certain users can only access certain contents.
>>
>> Where would you create this users / passwords.
>> - With a fixture
>> - as part of a test class in the SetUp section and tear
>>   it down afterwards?
> 
> There is no need to remove them
> Just create a user in setUp if you need it for all tests, if for a part
> of the tests only - create 2 test classes and create a user in one of
> them only

Thanks. Yes I noticed meanhwile as well that the the database is reset
implicitely.

> 
>> - create a custom test runner with a setup phase ?
> 
> I've got it as well - I don't create users there, but I've got a few
> other methods which are useful for more than one app.
> 
I mightl look at something like this.
If you midofied the database there, then would this become the initial
state for each test?
Reading the doc I assume yes.

>> Is there any other recommended code section, which could do the setup
>> prior to running tests.
>>
>> Ideally I'd like to avoid fixtures.
> 
> Is there a reason?
> 
Two reasons:

Migrations:

Fixtures are rather sensitive to migrations
(so as part of the migration steps I had to regenerate them)

Lack pseudo randomness:
--
It's a question of taste, but I like a certain amount of controlled
randomness in my tests and data sets. (The idea is to log the random
seed in order to be able to reproduce failures)
So a test covers all the anticipated boundary cases (if the amount is
small enough) , but explores some  others as well.
 As soon a s a new killer data set is found it can be
added as a separate test (or fixture).












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



Re: django tests. where to create users

2011-11-30 Thread Gelonida N
On 11/29/2011 11:45 AM, Tom Christie wrote:
> What's wrong with just creating them in the .setUp()?
> 
> Don't sweat the small amount of time it'll take to re-create the users
> on each test run, it's almost certainly not worth worrying about.
> 

Well this is what I'm doing at the moment.
And I think you're right for this case:
Creating users will not be where a considerable amnount of time is
spent.

I'm just learning to use Django-testing / unit tests and as I could
imagine other setup activities which would consume more time
for setup I wanted to see whether there are ways to do some
programatical setup of 'fixtures' before the first test is run.

Basically I'd like to be sure I know my tools.

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



Re: A view associated with a lot of urls

2011-11-30 Thread Ivo Brodien
Hi,

> That's why I'm
> considering checking at the beginning of the view with a list/dict
> filled with category names and one filled with item names to make sure
> that the category is in the list/dict and same for the item before
> hitting the database, and if not respond with a 404.

As Reinout suggested you should have a CategoryModel which you can check if a 
Category exists and the get the items of show that the category does not exist 
or 404 if somebody entered a wrong URL/Category. Checking against the DB is 
probably the same thing you want to do, but it uses the DB and not a List/Dict 
which you have to maintain manually somehow.

I think you care too much about people entering wrong URLs. People are clicking 
links on your webpage, right? Or do you give him instructions to write urls in 
the adress field?

As long as you produce correct urls the code works and only should show 404 if 
someone messed with the URL.

Consider doing this:

1) use the url tag or get_absolute_url of your models to produce the urls in 
your template
2) configure your site to send you 404 errors which have a referer (read below 
and [1])

404 errors
Django can also be configured to e-mail errors about broken links (404 “page 
not found” errors). Django sends e-mails about 404 errors when:
DEBUG is False
SEND_BROKEN_LINK_EMAILS is True
Your MIDDLEWARE_CLASSES setting includes CommonMiddleware (which it does by 
default).
If those conditions are met, Django will e-mail the users listed in the 
MANAGERS setting whenever your code raises a 404 and the request has a referer. 
(It doesn’t bother to e-mail for 404s that don’t have a referer – those are 
usually just people typing in broken URLs or broken Web ‘bots).


bye

[1] https://docs.djangoproject.com/en/1.3/howto/error-reporting/

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



Re: A view associated with a lot of urls

2011-11-30 Thread Nolhian
>Probably not a problem. How are people ending up on those URLS? Not by
>guessing.

That's just the point here, to avoid crashing because some "smart"
people tried to play with urls. So with only a get or 404 there is no
way to know if the category/items does indeed exist or if the user
played with the url and gave a non existent category or category/
items. For example in one case we should display "No items in this
category" and in  the other respond a 404 error page. That's why I'm
considering checking at the beginning of the view with a list/dict
filled with category names and one filled with item names to make sure
that the category is in the list/dict and same for the item before
hitting the database, and if not respond with a 404.


On Nov 30, 8:53 am, Reinout van Rees  wrote:
> On 29-11-11 21:37, Nolhian wrote:
>
> > However with that, there is no way for example to make a difference
> > between "there is no items in this category" and "this category
> > doesn't exist" !
>
> Probably not a problem. How are people ending up on those URLS? Not by
> guessing, I think. So you probably have a start page that lists the
> categories and then a category page that lists the items.
>
> A 404 on /non/existing leads people to try /non/ which would also 404.
>
> Reinout
>
> --
> Reinout van Rees                    http://reinout.vanrees.org/
> rein...@vanrees.org            http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul Graham"

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



[ANN]: FeinCMS 1.5.0.pre1

2011-11-30 Thread Matthias Kestenholz
Hello everyone

I'm finally starting the release process for FeinCMS v1.5 (sorry for
waiting so long).

The release is available at the following places:

PyPI: http://pypi.python.org/pypi/FeinCMS
Github: https://github.com/feincms/feincms

Documentation:
http://readthedocs.org/docs/feincms-django-cms/en/next/

The release notes draft follows:



FeinCMS 1.5 release notes (upcoming)



Explicit reversing of URLs from ``ApplicationContent``-embedded apps


URLs from third party apps embedded via ``ApplicationContent`` have
been traditionally made reversable by an ugly monkey patch of
``django.core.urlresolvers.reverse``. This mechanism has been deprecated
and will be removed in future FeinCMS versions. To reverse an URL
of a blog entry, instead of this::

# deprecated
from django.core.urlresolvers import reverse
reverse('blog.urls/blog_detail', kwargs={'year': 2011, 'slug': 'some-slug'})

do this::

from feincms.content.application.models import app_reverse
app_reverse('blog_detail', 'blog.urls', kwargs={'year': 2011,
'slug': 'some-slug'})

If you do not want to use the monkey patching behavior anymore, set
``FEINCMS_REVERSE_MONKEY_PATCH = False`` in your settings file.

The new method is accessible inside a template too::

{% load applicationcontent_tags %}

{# You have to quote the view name and the URLconf as in Django's
future {% url %} tag. #}
{% app_reverse "blog_detail" "blog.urls" year=2011 slug='some-slug' %}


Inheritance 2.0
===

It's possible to use Django's template inheritance from third party
applications embedded through ``ApplicationContent`` too. To use this
facility, all you have to do is return a tuple consisting of the
template and the context. Instead of::

def my_view(request):
# ...
return render_to_response('template.html', {'object': ...})

simply use::

def my_view(request):
# ...
return 'template.html', {'object': ...}

.. note::

   ``template.html`` should extend a base template now.


Better support of ``InlineModelAdmin`` options for content types


The ``FeinCMSInline`` only differs from a stock StackedInline in
differing defaults of ``form``, ``extra`` and ``fk_name``. All inline
options should be supported now, especially ``raw_id_fields`` and
``fieldsets``.




Minor changes
=

* The main CMS view is now based on Django's class-based generic
  views. Inheritance 2.0 will not work with the old views. You don't
  have to do anything if you use ``feincms.urls`` (as is recommended).

* Request and response processors have been moved out of the
  ``Page`` class into their own module, ``feincms.module.page.processors``.
  They are still accessible for some time at the old place.

* ``django.contrib.staticfiles`` is now a mandatory dependency for
  the administration interface.

* The ``active`` and ``in_navigation`` booleans on the ``Page``
  class now default to ``True``.

* The minimum version requirements have changed. Django versions older than
  1.3 aren't supported anymore, django-mptt must be 0.4 upwards.

* The mptt tree rebuilders have been removed; django-mptt offers tree
  rebuilding functionality itself.

* ``django-queryset-transform`` has been imported under ``feincms.utils``
  and is used for speeding up various aspects of the media library. The
  prefilled attributes have been deprecated, because
  ``django-queryset-transform`` can be used to do everything they did,
  and better.

* ``PageManager.active_filters`` has been converted from a list to a
  ``SortedDict``. This means that replacing or removing individual
  filters has become much easier than before. If you only used the
  public methods for registering new filters you don't have to change
  anything.

* The same has been done with the request and response processors.

* The ``TemplateContent`` has been changed to use the ``filesystem`` and
  the ``app_directories`` template loaders directly. It can be used
  together with the cached template loader now.

* The tree editor has received a few usability fixes with (hopefully)
  more to come.

* ``Page.setup_request`` can be called repeatedly without harm now.
  The return value of the first call is cached and returned on
  subsequent calls which means that request processors are run
  at most once.

* A few bugs have been fixed.

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



Re: Nginx - How to configure the virtual.conf to serve a Django application

2011-11-30 Thread Reinout van Rees

On 29-11-11 21:05, Andre Lopes wrote:

To put things working I should replace:

[code]
 root /path/to/test/hello;
[/code]

For the path where I have my Django Project?


You won't even use that root. That's for serving regular static files 
and that's only needed for the /static_media and /media urls in Django 
(depending on how you set them).


So you need "locations" for your static stuff and a "/" location that 
proxies to gunicorn.


I've got an example below. I start gunicorn on port 11000 in this case:


server {
listen 80;
client_max_body_size 1G;
server_name wgs.lizard.net;

keepalive_timeout 5;
access_log /Users/reinout/git/nens/wgs/var/log/access.log;
error_log /Users/reinout/git/nens/wgs/var/log/error.log;

location /static_media/ {
   # django-staticfiles
   alias /Users/reinout/git/nens/wgs/var/static/;
   expires max;
   # ^^^ Now that I give this example, I see that this 'max'
   # probably only has to be on /static_media/CACHE/ ...
}

location /media/ {
   alias /Users/reinout/git/nens/wgs/var/media/;
   expires 24h;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://localhost:11000;
}
}



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

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