Re: How should I use manage.py dumpdata, and loaddata?

2009-11-19 Thread f4nt
I typically dump all of my apps individually, and load them
individually. Unfortunately finding out where/why imports break with
loaddata is problematic without inserting some debugging code in your
django stack. Hence, I dump all my stuff individually, and I can at
least somewhat narrow down what's breaking the importer.

On Nov 18, 7:59 pm, Sachi  wrote:
> Hi, all,
>
> I have been developing a website, where I use the same postgresql
> database server for both development and production. Now that I have
> had many users and a significant amount of data, I am trying to use
> sqlite3 engine when I do development locally instead of connecting to
> the production server. In my settings.py, I have something that looks
> like:
>
> if ON_PRODUCTION_SERVER: DATABASE_ENGINE  = "postgresql_psycopg2" ...
> else: DATABASE_ENGINE = "sqlite3" ...
>
> My task right now is to dump data (I wish to dump all of them) from
> the production server, and install them in the local sqlite database.
> This is what I did:
>
> python manage.py dumpdata > data.json
>
> Then, I switched to sqlite3 database, and did
>
> python manage.py syncdb
> python manage.py loaddata data.json
>
> However, I met the following errors:
>
> Installing json fixture 'data' from absolute path.
> Problem installing fixture 'data.json': Traceback (most recent call
> last):
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/core/management/commands/loaddata.py",
> line 153, in handle
>     obj.save()
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/core/serializers/base.py", line 163, in
> save
>     models.Model.save_base(self.object, raw=True)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/base.py", line 474, in
> save_base
>     rows = manager.filter(pk=pk_val)._update(values)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/query.py", line 444, in
> _update
>     return query.execute_sql(None)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/sql/subqueries.py", line 120,
> in execute_sql
>     cursor = super(UpdateQuery, self).execute_sql(result_type)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/sql/query.py", line 2369, in
> execute_sql
>     cursor.execute(sql, params)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/backends/util.py", line 19, in
> execute
>     return self.cursor.execute(sql, params)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/backends/sqlite3/base.py", line 193,
> in execute
>     return Database.Cursor.execute(self, query, params)
> IntegrityError: columns app_label, model are not unique
>
> Could anybody let me know why this error happened, and how I get
> correctly dump/load data?
>
> Thanks a lot!
>
> Sachi

--

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




Serving Password Protected Files

2009-11-16 Thread f4nt
Hello,

Is there a good way to handle serving files behind django
authentication? I'm working on a project right now where people can
upload files, and based on certain permissions can download them as
well. However, there doesn't seem to be a good way to handle checking
authentication, and then serving the files. I'd prefer a web server
agnostic approach since I'd like this application to stay as pluggable
as possible. Any thoughts?

Thanks,
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: Prevent brute-force password attacks?

2009-11-09 Thread f4nt

Yes, teaching users to not choose stupid username/password
combinations. That's the only correct/true fix. Are you worried about
the traffic that it consumes? If so, you continue to play in dicey
territory, since you're trying to deduce harmful bots from potentially
stupid users that just can't remember their account information. Yes,
it's easy to see in the aftermath with human eyes the difference,
seeing it as it happens with code, and being right 100% (which is the
only acceptable percentage in the case of usability) is difficult.

I don't personally know if anything exists to do what you want to do,
but it shouldn't be incredibly hard to write. You could log all the
IPs to the database, compare the frequency, and then what you do with
them from there is up to you. You could redirect the user elsewhere,
or serve them 404s to make them think the content's gone (could have
ill effects on SEO in rare cases). Then you could cron up a purge
scenario, after so many days, or if you definitely don't like the IP
you could write the IPs out to your firewall's blacklist (at least,
easy to do in shorewall). Ironically, doing all that will create
potentially more database calls and traffic than just weathering the
storm. Your call.

Btw, don't mean to be blunt/rude, as that's not my intention. Just
dealt with a lot of these scenarios as a sys admin in a former life,
and the answer is always to beat users over the head until they stop
choosing "god/god" as their username/password combination.

On Nov 9, 3:57 pm, Adam Seering  wrote:
> Hi,
>         Does there exist any code for Django to help defeat brute-force login
> attempts?  Something like blocking IP addresses from logging in if they
> try and fail too many times, etc.
>
> Adam
--~--~-~--~~~---~--~~
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: Comments & redirection

2009-11-05 Thread f4nt

I used a cheap hack. The comment object has an ID of the item that the
comment was attached to. You can then give users a link to that to
click, or auto-redirect them to that. If you use slugs, you can create
a view that catches that ID, grabs the slug, and thus redirects them
again to the original post. Like I said, cheap hacks.

On Nov 5, 1:39 pm, Ethan Jucovy  wrote:
> On Thu, Nov 5, 2009 at 2:30 PM, David  wrote:
> > Is it possible to redirect upon successful comment submission to the
> > previous page when using Djangos built in render_comment_form ?
>
> I'm not sure if there's a more direct way, but you can override the
> "comment_done" named URLconf with a custom view that redirects to
> request.META.get('HTTP_REFERER', '/')
>
> hth,
> egj
--~--~-~--~~~---~--~~
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: Where are forms usually defined?

2009-11-03 Thread f4nt

I've seen that before as well, and I don't particularly like it. Some
people also customize the admin in the models.py file, which is also
annoying :).

On Nov 3, 1:28 pm, Nick Arnett <nick.arn...@gmail.com> wrote:
> On Tue, Nov 3, 2009 at 11:26 AM, f4nt <xxf4n...@gmail.com> wrote:
>
> > forms.py is pretty standard. You'd end up importing them in your
> > views.py.
>
> Thanks... that's what I was guessing.  But it appears to me that I sometimes
> see ModelForms in models.py... wondering if that's typical.
>
> Nick
--~--~-~--~~~---~--~~
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: Where are forms usually defined?

2009-11-03 Thread f4nt

forms.py is pretty standard. You'd end up importing them in your
views.py.

On Nov 3, 1:20 pm, Nick Arnett  wrote:
> I find myself frequently frustrated by examples and tutorials that include
> code snippets that don't identify where they live.  In particular, I haven't
> quite figured out where forms usually are defined and then where they need
> to be imported.
>
> I see that forms sometimes are in a file called forms.py... but somewhere
> I'd expect to then see an import statement along the lines of "from
> mysite.forms import *".  If I use forms.py for my forms, where does that
> file need to be imported?
>
> Thanks,
>
> Nick
--~--~-~--~~~---~--~~
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: displaying posted data

2009-10-22 Thread f4nt

You're initting your variables from request.GET instead of
request.POST.

On Oct 22, 12:20 pm, Dhruv Adhia  wrote:
> Hello,
>
> Quite a basic question.. I am posting data from Unity, its like name
> and score. I want to read the posted data and display it.
>
> Here is the code that I currently have inside views.py
>
> def add_score(request):
>    response_dict ={}
>    if request.POST:
>        name = request.GET['name']
>        score = request.GET['score']
>        hash = request.GET['hash']
>        response_dict = {'name': name, 'score': score, 'hash': hash}
>    return render_to_response('add_score.html', response_dict)
>
> and template part
>
> Carbon Chaos leader board
>
> 
> {% for carbon_chaos in response_dict %}
> {{carbon_chaos.name}} >>> {{carbon_chaos.score}} >>>
> {{carbon_chaos.hash}}
> {% endfor %}
>
> Can somebody point out what is the mistake?
>
> Thanks,
> Dhruv

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---