Re: 2 projects based on the same codebase

2011-06-14 Thread Benedict Verheyen
On 14/06/2011 17:24, Stuart MacKay wrote:
> Benedict,
> 
> One solution I tried was project franchising,
> http://www.huyng.com/archives/franchising-running-multiple-sites-from-one-django-codebase-2/394/
>  The idea was to have a core site that was
> customized for different deployments. The idea had a lot of appeal but I 
> quickly ran into issues with the limited ability for customization
> and the codebases began to diverge quickly.
> 
> Until you can get to the stage where you can factor out the common parts (not 
> always easy) into reusable apps  I would second the suggestion
> for separate projects. It seems like needless duplication (which it is to 
> some extent) but you easily avoid compatibility issues and then
> both projects are free to take whatever path works best.
> 
> Regards,
> 
> Stuart MacKay
> Lisbon, Portugal
> 

Hi Stuart,

thanks for link and the advise.
I've since split the code into 2 projects and so far, so good :)

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: Get MAC from diferent fields

2011-06-14 Thread rat attack
Hi Jirka,
I say weird format because:
external_serial (contains 1 mac address)
mac_address (contains 2 mac adress)
computer_id (isn't a mac adress)

I will look up info to resolve this in pure Python like you said.
Thanks guys

On Jun 14, 4:15 pm, Jirka Vejrazka  wrote:
> Hi there,
>
> Django is just a Python package. Forget for a moment that you use
> Django for database connection and solve your "how do I recognize a
> MAC address?" problem just as you'd solve it in pure Python.
>
> There is nothing wrong with the MAC addresses in your example - why do
> you say these are in "weird format" ?
>
>   Cheers
>
>     Jirka

-- 
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: Unsafe to continue Django session unencrypted? (i.e. login with HTTPS then drop to HTTP after that?)

2011-06-14 Thread Mike Dewhirst
They should be worried. But the session id is not the  credentials. So it is 
probably argued that it is secure enough. 

However, you should google firesheep. That is a browser add-on which can hijack 
non-SSL sessions over unsecured wireless. 

Mike

On 15/06/2011, at 2:40 PM, Chris Seberino  wrote:

> 
> On Jun 14, 10:47 am, Tom Evans  wrote:
>> Yes, of course it is - HTTP is stateless, so how else would sessions
>> work if the session id is not transmitted back to the server by the
>> browser?
> 
> I agree.  Yet, eBay, Google Groups & Godaddy drop down to HTTP after
> login.
> Why aren't they worred?
> 
> cs
> 
> -- 
> 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: Unsafe to continue Django session unencrypted? (i.e. login with HTTPS then drop to HTTP after that?)

2011-06-14 Thread Chris Seberino

On Jun 14, 10:47 am, Tom Evans  wrote:
> Yes, of course it is - HTTP is stateless, so how else would sessions
> work if the session id is not transmitted back to the server by the
> browser?

I agree.  Yet, eBay, Google Groups & Godaddy drop down to HTTP after
login.
Why aren't they worred?

cs

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



Moving Away from if/else Template Logic

2011-06-14 Thread Greg Corradini
Hello All,

I'm try to get away from doing if/else in a template:

{% if x.message|regtest == "True" %}
do something cool
{% else %}
do something less cool
{% endif %}

given this template filter:

@register.filter(name='regtest')
def regtest(value):
regex = re.compile(r'^\*\*(?P.*)\*\*')
m = regex.match(value)
if m != None:
return "True"
return "False"

I would like to move to something like this in the template:

{{ x.message|regtest }}

given this template filter:

def regtest(value):
regex = re.compile(r'^\*\*(?P.*)\*\*')
m = regex.match(value)
if m != None: return "%s"%value
else: return value


However, the html tags returned from the filter becomes part of the
element's text value instead of tags. So that's not working.

I'm sure there's way better ways to side-step ugly if/else logic in
the templates. What types of things can people recommend for a Django
new guy.


-- 
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: How to catch and log exceptions?

2011-06-14 Thread Roy Smith
Exactly what I was looking for.  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.



import with django-batchimport and only insert if record doesn't exist else update based on foreignkey reference.

2011-06-14 Thread mongoose
I'm trying to run an import and in my identity fields I'm referencing
a foreignkey field. The excel file holds the name of the brand and
this field seems to be ignored when the import happens. My theory was
that perhaps it's because it's not mapped and in fact it's probably
matching the brand_name against the brand_id. Wondering if you've run
into this?

class Ingredient(models.Model):
'identity_fields':['name', 'brand_name'],
...
name = models.CharField(max_length=60)
brand_name = models.ForeignKey(Brand)
...


The end goal is to see if the name and the brand match then to and not
insert.
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.



Re: storing django object into javascript array

2011-06-14 Thread jay K.
Hello,

I was given the following solution for storing a django object in a
javascript variable

//SOLUTION BEGINS HERE
1. Use a loop in the template:

var map_schools = [{% for school in city.school_set.all %}"{{
school|escapejs }}"{% if not forloop.last %},{% endif %}{% endfor %}];

You'll notice a couple of things there:
  - there is a "for" loop there, to iterate over all of the schools in the
result set
  - the quotes are present in the template, to make sure that the school
names are strings in the JavaScript
  - there is a test after every string to see if a "," is needed as a
separator (some javascript implementations are not very forgiving if you put
a comma after the last element)
  - Every school name is passed through the "escapejs" filter, to avoid
breaking out of the string.

//SOLUTION ENDS

Now, I was wondering how I can store the {{ school|escapejs }} into a
javascript array, and use the data inside school as if it were an array
element, like map_schools[1], map_schools[3] etc

Thanks

regards,

JK


On Fri, Jun 10, 2011 at 12:21 PM, Ian Clelland  wrote:

>
>
> On Fri, Jun 10, 2011 at 7:48 AM, jay K. wrote:
>
>>
>> Hello,
>>
>> I am not a django developer, but I have a background on html, css,
>> javascript, jquery and php.
>>
>> I was wondering if you can help me with a question regarding django,
>> since I'm working on a website built on django (which was not started
>> by me)
>>
>> I want to store a django object into a javascript array. So far I have
>> this code:
>>
>> In my template file:
>>
>> 
>>
>> var map_schools = {{ city.school_set.all }};
>>
>> 
>>
>> Unfortunately the django object is not stored as desired, but instead
>> it gets stored like the following:
>>
>> var map_schools = []
>>
>>
> [] is the printable representation of your query
> set (what you get when you call city.school_set.all()) -- what you need to
> do is build up a JavaScript literal that you can insert into the code. There
> are two fairly simple ways of doing this:
>
> 1. Use a loop in the template:
>
> var map_schools = [{% for school in city.school_set.all %}"{{
> school|escapejs }}"{% if not forloop.last %},{% endif %}{% endfor %}];
>
> You'll notice a couple of things there:
>   - there is a "for" loop there, to iterate over all of the schools in the
> result set
>   - the quotes are present in the template, to make sure that the school
> names are strings in the JavaScript
>   - there is a test after every string to see if a "," is needed as a
> separator (some javascript implementations are not very forgiving if you put
> a comma after the last element)
>   - Every school name is passed through the "escapejs" filter, to avoid
> breaking out of the string.
>
> 2. Construct a JSON string in python:
>
> In your view, do something like this:
>
> from django.utils.simplejson import dumps
> ...
> school_list = dumps([school.name for school in city.school_set.all()])
>
> and then add school_list to the context variables that are passed to the
> template. Then in the template, you can just use {{ school_list }}, and it
> will be a properly formatted JavaScript array.
>
>
>
> --
> 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.
>

-- 
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: Authentication in API (REST)

2011-06-14 Thread Malcolm Box
I think oauth solves this problem well. What do you see wrong with it?

Malcolm

Sent from my iPhone, please excuse any typos

On 14 Jun 2011, at 16:35, Stuart MacKay  wrote:

> Neznez,
> 
> The authentication problem is one that has never really been solved to any 
> general level of satisfaction for REST APIs, since the connection should be 
> stateless. For HTTP authentication there is either HTTPS + Basic or Digest.  
> HTTPS + Basic considered to be the easiest to implement and the most secure 
> but running a server with SSL is not the most trivial of tasks and there are 
> issues for clients and the problems of managing certificates, etc. etc.
> 
> For a Java based REST API I used the scheme used by Amazon web services where 
> the request is signed using a secret key and then authenticated on the server 
> which worked rather well and was resistant against lots of different types of 
> attack. You can find out more at 
> http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html.
>  However I am not sure what level of support you can find in django.
> 
> Stuart
> 
>> Hi all, I'm newbie in Django, and I started to build my own API. I
>> know that there is Piston or Django REST framework, but I want to
>> learn API from scratch. What I want to know is, how to make my HTTP
>> Response (View) is perform authentication before can be accessed, or
>> we can make it have to throw username and password to access the HTTP
>> Response?
>> 
>> My code is very simple, like this one:
>> def test_api_view(request, whatever):
>>   #
>>   # do things
>>   #
>>   return HttpResponse(serializers.serialize("json", mydictionary),
>> mimetype='application/json')
>> 
>> Thank you.
>> 
> 
> -- 
> 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: __unicode__() addition not working in basic poll application.

2011-06-14 Thread Micky Hulse
On Tue, Jun 14, 2011 at 11:01 AM, Kyle Latham  wrote:
 Poll.objects.all()
> []

What do you get when you try:

>>> p = Poll.objects.all()[0]
>>> p
>>> type(p)
>>> dir(p)

Try this too:

>>> p = Poll.objects.all()
>>> for x in p:
. . .print x (indent this line four spaces, hit return key once)
. . . (hit return key again)

Does any of that help?

Good luck!

Cheers,
Micky

-- 
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: __unicode__() addition not working in basic poll application.

2011-06-14 Thread Kyle Latham
Hello,

I am having the same problem while working through the tutorial. have
searched these forums and tried everything that was recommended. My
spacing is good also - I checked that.  I am still getting the same
output:

>>> Poll.objects.all()
[]

Any ideas on how to fix my issue?

On Jun 5, 11:20 am, EPS  wrote:
> Hi, i found this post when try to solve same problem: my trouble was a
> "spaces" in models.py.
> in your first message it seems to be ok, but you must really check
> spaces in your class 
> describe.http://mail.python.org/pipermail/tutor/2007-January/051903.html
>
> On May 17, 4:59 pm, maaz muqri  wrote:
>
>
>
> > im just getting "Pollobject" as output
>
> > On May 17, 1:14 pm, Roman Klesel  wrote:> 
> > 2011/5/16 maaz muqri :
>
> > > > I am getting this
>
> > > Poll.objects.all()
> > > > []
>
> > > What do you get when you do:
>
> > > print unicode(Poll.objects.all()[0])
>
> > > ?
>
> > > Regards
> > >  Roman- Hide quoted text -
>
> - Show quoted text -

-- 
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: Problem in accepting values from a form in a template . How to debug this ?

2011-06-14 Thread vikalp sahni
Page Not Found or 404, basically doesn't have any relation with template of
form.

Just check if you have the URL that you are trying to hit in urls.py, as 404
happens when the URL you are trying to access is not configured or not
available on your webapp.

Regards
//Vikalp

On Tue, Jun 14, 2011 at 3:43 PM, Satyajit Sarangi  wrote:

> My forms.py is this
>
>
> from django import forms
> from django.forms.widgets import RadioSelect
> import floppyforms as forms
> class PermForm(forms.Form):
>user = forms.CharField(max_length=100)
>RADIO_CHOICES1 = [['1','Radio 1'],['2','Radio 2']]
>RADIO_CHOICES2 = [['3','Radio 2'],['4','Radio 2']]
>radio = forms.ChoiceField( widget=RadioSelect(),
> choices=RADIO_CHOICES1)
>radio = forms.ChoiceField( widget=RadioSelect(),
> choices=RADIO_CHOICES2)
>
>
> My views.py is this
>
> from django.conf import settings
> from django.shortcuts import render_to_response
> from django.template import RequestContext, loader
> from django import forms
> from django.core import validators
> from django.contrib.auth.models import User
> from django.utils import simplejson
>
> def PermLayer(request):
>users = User.objects.all()
>if request.method == 'POST':
>form = PermForm(request.POST)
>if form.is_valid():
>data = form.cleaned_data
>rad1=form.cleaned_data['RADIO_CHOICES1']
>rad2=form.cleaned_data['RADIO_CHOICES2']
>User.objects.get(username = data['username'])
>print rad1
>perm = Permission()
>perm.user = User.objects.get('pk')
>perm.table =
> ContentType.objects.get_for_model(TableToAddPermissionFor)
>perm.permi = rad1 + rad2
>perm.save()
>return
> render_to_response('permission.html',{'user':users})
>else:
>form = PermForm()
>
>
>
>return render_to_response('permission.html', {'user':users})
>
>
> My template is this
>
>
>
>
>
>
>
> 
> 
> Permissions
>
> 
>
> These are the present users {{user}} 
>
>
>
>
> 
> 
> 
>
> User: >
>
> 
> 
> Who can view the data 
> 
> Any registered users label>
>  Only users that
> can edit
> 
> Who can edit the data 
> 
> Any registered
> user
>  Only the
> following users
> 
> 
> 
> 
> 
> 
> 
>
>
> When I click on the submit button . it shows an error showing that
> page not found PermForm 404 .
>
> How to debug ?
>
> --
> 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.



How to make databrowseadmin of django show all the objects of shape file and not one by one ?

2011-06-14 Thread Satyajit Sarangi
After I upload a shapefile , the databrowse admin allows to view the
files in databrowse admin , but does not all the objects to be shown
on one file , i.e it allows only one row of a table mapped onto a
openlayers file . How to make all the data , (all the rows ) be
displayed on one openlayers file using the databrowse admin ?

-- 
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: Test runner fails with Django 1.2.1 and psycopg2 2.4.2

2011-06-14 Thread Andrew Brookins
Looks like there's already a ticket (my search-fu failed me):

https://code.djangoproject.com/ticket/16250

Andrew

-- 
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/-/7D7CrjiJaXMJ.
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.



Test runner fails with Django 1.2.1 and psycopg2 2.4.2

2011-06-14 Thread Andrew Brookins
Hey, 

Yesterday I started seeing test runner failures with Django 1.2.1 and 
psycog2 2.4.2. 

Here's the traceback (where [project_dir] is the path to my virtualenv):

Traceback (most recent call last):
  File "./manage.py", line 11, in 
execute_manager(settings)
  File 
"[project_dir]/lib/python2.6/site-packages/django/core/management/__init__.py", 
line 438, in execute_manager
utility.execute()
  File 
"[project_dir]/lib/python2.6/site-packages/django/core/management/__init__.py", 
line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"[project_dir]/lib/python2.6/site-packages/django/core/management/base.py", 
line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"[project_dir]/lib/python2.6/site-packages/django/core/management/base.py", 
line 218, in execute
output = self.handle(*args, **options)
  File 
"[project_dir]/lib/python2.6/site-packages/django/core/management/commands/test.py",
 
line 37, in handle
failures = test_runner.run_tests(test_labels)
  File "[project_dir]/lib/python2.6/site-packages/django/test/simple.py", 
line 313, in run_tests
old_config = self.setup_databases()
  File "[project_dir]/lib/python2.6/site-packages/django/test/simple.py", 
line 270, in setup_databases
connection.creation.create_test_db(self.verbosity, autoclobber=not 
self.interactive)
  File 
"[project_dir]/lib/python2.6/site-packages/django/db/backends/creation.py", 
line 346, in create_test_db
test_database_name = self._create_test_db(verbosity, autoclobber)
  File 
"[project_dir]/lib/python2.6/site-packages/django/db/backends/creation.py", 
line 381, in _create_test_db
self.set_autocommit()
  File 
"[project_dir]/lib/python2.6/site-packages/django/db/backends/creation.py", 
line 448, in set_autocommit
self.connection.connection.autocommit = True
psycopg2.ProgrammingError: autocommit cannot be used inside a transaction

Reverting to psycopg2 2.4.1 fixes the problem. Anyone seen this?

Best,
Andrew

-- 
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/-/bYngn9hESksJ.
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: Integrity Error with generic relation using ContentType

2011-06-14 Thread Amit Sethi
On Tue, Jun 14, 2011 at 8:00 PM, christian.posta
 wrote:
> Yes, it is. Any reason why you want the content-types to be part of
> your fixtures? Why not let django build that up by itself?
>
Well essentially it was just a dumpdata from earlier that is being
used. But why should I not have it as part of fixtures ?


-- 
A-M-I-T S|S

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



Re: How to create a single data view from multiple data sources

2011-06-14 Thread Shawn Milochik

On 06/14/2011 12:20 PM, rohan wrote:

Can you please be a bit more specific? The link you provided is for
Django tutorials. It would be great if you could guide me to the
specific page.



Try searching Google. You'll probably get the answer faster.

If you can ask a more specific question about how some part of Django 
works I might be able to send you to a more specific page, but your 
question is too general.


--
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 admin report

2011-06-14 Thread Andre Terra
If all you need translating is README.rst, here goes:

Django Admin Report

Django Admin Report is a small django application that allows for easy
exporting of PDF reports through the admin interface.

Dependencies

-Pisa (http://www.xhtml2pdf.com/)
Installation

   1. Download the application
   2. Add the package "report" to your path.

Usage

- In your application's admin.py, import the following 'action' like so:

from report.actions import report_generic

- Also in admin.py, in your model's ModelAdmin specify a variable called
"list_report" that should contain an iterable with the model attributes that
should appear on the report, e.g.

 list_report = ('some_attribute', 'other_attribute', )

- Finally, make sure you also add the aforementioned 'action' to your
ModelAdmin's list of actions, like so:

actions = [report_generic, ]


---

I should add that some screenshots would go a long way!


Cheers,

André Terra


On Mon, Jun 13, 2011 at 5:59 AM, Derek  wrote:

> On Jun 9, 9:13 pm, Leonardo da Costa Santos
>  wrote:
> > Good morning guys!
> >
> > I came to share with you the Django Admin Report ... she is a little
> Django
> > app that makes it easy to export reports in PDF using the administration
> > interface of django.
> >
> > The idea is to just tell the class of directors which is the list of
> template
> > fields to be exported (list_report) and add a generic action
> (report_generic
> > ), which he does the rest alone. With this you use the filters bassta
> > administration and research and select the lines that go to the report by
> > clicking on the action (Generating report net) PDF will appear in your
> > browser to be downloaded!
> >
> > You can encortrar the sources here:
> https://github.com/leonardocsantoss/django-admin-report
> >
> > Today in list_report attributes can be passed either as methods ... Yet
> he can
> > not print an attribute of a foreign key ... This will be the next step
> > would the
> > project!
>
> Leonardo
>
> This looks to be useful; can you please translate the Git page into
> English?
>
> 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.
>
>

-- 
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: How to create a single data view from multiple data sources

2011-06-14 Thread rohan
Can you please be a bit more specific? The link you provided is for
Django tutorials. It would be great if you could guide me to the
specific page.

On Jun 14, 10:16 am, Shawn Milochik  wrote:
> On 06/14/2011 10:42 AM, rohan wrote:
>
> > I have two tables in my database with one common field. Is it possible
> > to write a web app to create views using django?
>
> > Any help would be greatly appreciated.
>
> > Thank you
>
> Yes, it is.
>
> Do the tutorial and then re-do it using your own data.
>
> https://docs.djangoproject.com/en/1.3/

-- 
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: Unsafe to continue Django session unencrypted? (i.e. login with HTTPS then drop to HTTP after that?)

2011-06-14 Thread Tom Evans
On Tue, Jun 14, 2011 at 4:39 PM, Chris Seberino  wrote:
> I have Apache in front of my Django app.  It forces login pages to use
> HTTPS but then forces rest of pages to only use HTTP.
>
> Is client browser sending sensitive login or session info in the clear
> when I am not using HTTPS?
>

Yes, of course it is - HTTP is stateless, so how else would sessions
work if the session id is not transmitted back to the server by the
browser?

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.



Unsafe to continue Django session unencrypted? (i.e. login with HTTPS then drop to HTTP after that?)

2011-06-14 Thread Chris Seberino
I have Apache in front of my Django app.  It forces login pages to use
HTTPS but then forces rest of pages to only use HTTP.

Is client browser sending sensitive login or session info in the clear
when I am not using HTTPS?

My nonencrypted pages don't present or ask for sensitive info.  The
only danger would be if sensitive info is being sent behind the scenes
I didn't program myself.

cs

-- 
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: Authentication in API (REST)

2011-06-14 Thread Stuart MacKay

Neznez,

The authentication problem is one that has never really been solved to 
any general level of satisfaction for REST APIs, since the connection 
should be stateless. For HTTP authentication there is either HTTPS + 
Basic or Digest.  HTTPS + Basic considered to be the easiest to 
implement and the most secure but running a server with SSL is not the 
most trivial of tasks and there are issues for clients and the problems 
of managing certificates, etc. etc.


For a Java based REST API I used the scheme used by Amazon web services 
where the request is signed using a secret key and then authenticated on 
the server which worked rather well and was resistant against lots of 
different types of attack. You can find out more at 
http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html. 
However I am not sure what level of support you can find in django.


Stuart


Hi all, I'm newbie in Django, and I started to build my own API. I
know that there is Piston or Django REST framework, but I want to
learn API from scratch. What I want to know is, how to make my HTTP
Response (View) is perform authentication before can be accessed, or
we can make it have to throw username and password to access the HTTP
Response?

My code is very simple, like this one:
def test_api_view(request, whatever):
   #
   # do things
   #
   return HttpResponse(serializers.serialize("json", mydictionary),
mimetype='application/json')

Thank you.



--
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: How to catch and log exceptions?

2011-06-14 Thread Shawn Milochik

Yes, you can access the traceback from the middleware.

Just call logger.exception() instead of something like logger.debug() 
and you'll get the output in your log.


Here's my middleware:


import logging
logger = logging.getLogger(__name__)

class RequestExceptionMiddleware(object):

"""
Log any exceptions that happen in a view.
"""

def process_exception(self, request, exception):

logger.exception('view broke')

return None


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



How to catch and log exceptions?

2011-06-14 Thread Roy Smith
I want to catch any exceptions thrown in my views (or anywhere else, I
suppose) and log a full stack trace.  I know I can write middleware
which implements process_exception(), but that just gets me the naked
exception object, not a full stack dump.  I'm assuming that by the
time my process_exception() method gets called, it's too late to call
sys.exc_info().  Or is it?

I can't use the default DEBUG mechanism which displays the stack trace
in the browser.  For one thing, I want the information in the log.
For another, most of my routes are AJAX calls, so there's nowhere to
display 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.



Re: 2 projects based on the same codebase

2011-06-14 Thread Stuart MacKay

Benedict,

One solution I tried was project franchising, 
http://www.huyng.com/archives/franchising-running-multiple-sites-from-one-django-codebase-2/394/ 
The idea was to have a core site that was customized for different 
deployments. The idea had a lot of appeal but I quickly ran into issues 
with the limited ability for customization and the codebases began to 
diverge quickly.


Until you can get to the stage where you can factor out the common parts 
(not always easy) into reusable apps  I would second the suggestion for 
separate projects. It seems like needless duplication (which it is to 
some extent) but you easily avoid compatibility issues and then both 
projects are free to take whatever path works best.


Regards,

Stuart MacKay
Lisbon, Portugal


Hi,


I developed a calltracking for our team and now, another team is interested to 
have their own calltracking.
The best way to seem to deal with a project that is the same from the start, is 
to makea new virtualenv
and "git clone" the codebase. The new project might slightly differ in the 
futur.

I have a development machine where I maintain the code, then "git push" the 
code to a server.
On the production machine, i "git pull" the code.
This all works but what if the 2nd team wants slight changes, changes that my 
team may not want?
2 virtualenv's based on the same code might not be the best option in this case.

Do I create a new repository for the code of the other project ?
I feels like the best way to go ahead.
However, this would mean that I need to maintain 2 projects that are and 
probably will remain very similar.
How would i transfer code changes from 1 repository to the other? Patches?

Thanks for any insight, or links to documentation that deal with this kind of 
setup and
sorry in advance for going OT.

Regards,
Benedict


Hi,

thanks for the info.
I will use a seperate repository for the 2nd project.

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: How to create a single data view from multiple data sources

2011-06-14 Thread Shawn Milochik

On 06/14/2011 10:42 AM, rohan wrote:

I have two tables in my database with one common field. Is it possible
to write a web app to create views using django?

Any help would be greatly appreciated.

Thank you



Yes, it is.

Do the tutorial and then re-do it using your own data.

https://docs.djangoproject.com/en/1.3/



--
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: Userprofile, signal and admin inline edit.

2011-06-14 Thread Jon Biddle
The issue seems to come from the fact that the order of operations
when you create the user looks like this:

1) Django admin saves the new User
2) post_save on User is triggered, and User's profile is created
3) Django admin saves the UserProfile... but it already exists, and an
integrity error is raised


I'm currently looking into a solution to this as well, and will let
you know what I find.

On May 26, 8:39 am, Malcolm Box  wrote:
> On 26 May 2011 10:23, Jani Tiainen  wrote:
>
> > If I extend auth.User with custom profile and add automatic profile
> > creation signal it works as expected.
>
> > But if I try to add admin inline editor for profile when saving I get
> > exception about integration violation.
>
> > It happens because admin tries to create second profile for user when
> > saving.
>
> Have your signal handler check whether this is a creation of a user or an
> edit. Only create the profile in the first case.
>
> You may also need to check whether the profile already exists before trying
> to create - get_or_create() is your friend here.
>
> Malcolm

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



How to create a single data view from multiple data sources

2011-06-14 Thread rohan
I have two tables in my database with one common field. Is it possible
to write a web app to create views using django?

Any help would be greatly appreciated.

Thank you

-- 
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: Integrity Error with generic relation using ContentType

2011-06-14 Thread christian.posta
Yes, it is. Any reason why you want the content-types to be part of
your fixtures? Why not let django build that up by itself?

On Jun 14, 1:21 am, Amit Sethi  wrote:
> On Tue, Jun 14, 2011 at 1:41 AM, christian.posta 
> wrote:
> > Are you using your own fixtures (like initial_data.json)?
> > Is it possible that in your initial_data.json ( or whatever fixture
> > you're using) that you're including entries into the content_types
>
> [..]
>
> Well i do have entries of the kind this :
>  {
>         "pk": 47,
>         "model": "contenttypes.contenttype",
>         "fields": {
>             "model": "user",
>             "name": "user",
>             "app_label": "auth"
>         }
>     },
>
> Are these what you are referring to ..

-- 
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: Get MAC from diferent fields

2011-06-14 Thread Jirka Vejrazka
Hi there,

Django is just a Python package. Forget for a moment that you use
Django for database connection and solve your "how do I recognize a
MAC address?" problem just as you'd solve it in pure Python.

There is nothing wrong with the MAC addresses in your example - why do
you say these are in "weird format" ?

  Cheers

Jirka

-- 
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: GET vs POST for read-only views

2011-06-14 Thread Kenneth Gonsalves
On Tue, 2011-06-14 at 15:36 +0200, Masklinn wrote:
> >> that would mean, that none of your website was ever reachable by
> >> entering the URL in a browser. Remember: all links you put on a
> >> webpage will be GET requests made by the browser, when you click on
> >> them.
> > lets put it this way - I have never typed the word 'get' in my
> editor.
> Neither dict.get nor request.GET.get? 

sorry - no
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
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: Error 'str' object has no attribute '_meta' . How to debug ?

2011-06-14 Thread Tom Evans
On Tue, Jun 14, 2011 at 1:53 PM, Satyajit Sarangi
 wrote:
> I want to create a model that brings user_id of the user_auth table as
> foreign key , layer_id from layer table(defined by me) as also a
> foreign key . Combine both to form a primary key . and have another
> integer called perm .
> My model looks like this
>                        perm.table = user_type =
> ContentType.objects.get_for_model('maps_parking')

https://docs.djangoproject.com/en/1.3/ref/contrib/contenttypes/#django.contrib.contenttypes.models.ContentTypeManager.get_for_model

get_for_model takes a model type (eg User) or a model instance. It
does not take a string.

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: GET vs POST for read-only views

2011-06-14 Thread Tom Evans
On Tue, Jun 14, 2011 at 2:03 PM, Kenneth Gonsalves
 wrote:
> On Tue, 2011-06-14 at 08:51 -0400, Steven L Smith wrote:
>> POST should only be used for things that change stuff on the server...
>> a contact form, a form that creates something in a database, etc...
>
> thanks - in 15 years of web programming I have never used get - maybe
> time to start now.

A simple example of a type of form you should always use GET for is a
search form. Browsers will warn you about resubmitting form input when
you press 'back' to a a results page that has been submitted over
POST.

Just look how google do it.

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: GET vs POST for read-only views

2011-06-14 Thread Masklinn
On 2011-06-14, at 15:26 , Kenneth Gonsalves wrote:
> On Tue, 2011-06-14 at 15:10 +0200, Ivo Brodien wrote:
>>> thanks - in 15 years of web programming I have never used get -
>> maybe
>>> time to start now.
>> 
>> ??
>> 
>> that would mean, that none of your website was ever reachable by
>> entering the URL in a browser. Remember: all links you put on a
>> webpage will be GET requests made by the browser, when you click on
>> them.
> lets put it this way - I have never typed the word 'get' in my editor.
Neither dict.get nor request.GET.get?

(also, note that GET is the default for form/@method when that value is missing)

-- 
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: GET vs POST for read-only views

2011-06-14 Thread Kenneth Gonsalves
On Tue, 2011-06-14 at 15:10 +0200, Ivo Brodien wrote:
> > thanks - in 15 years of web programming I have never used get -
> maybe
> > time to start now.
> 
> ??
> 
> that would mean, that none of your website was ever reachable by
> entering the URL in a browser. Remember: all links you put on a
> webpage will be GET requests made by the browser, when you click on
> them.
> 
> 

lets put it this way - I have never typed the word 'get' in my editor.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
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: GET vs POST for read-only views

2011-06-14 Thread Ivo Brodien


> thanks - in 15 years of web programming I have never used get - maybe
> time to start now.

??

that would mean, that none of your website was ever reachable by entering the 
URL in a browser. Remember: all links you put on a webpage will be GET requests 
made by the browser, when you click on them.



-- 
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: GET vs POST for read-only views

2011-06-14 Thread Kenneth Gonsalves
On Tue, 2011-06-14 at 08:51 -0400, Steven L Smith wrote:
> For your use case, I would definitely use GET. The user may wish to
> bookmark the report, for example, or send it to a colleague. Searches
> and such should always use GET, unless there's a truly compelling
> reason not to.
> 
> POST should only be used for things that change stuff on the server...
> a contact form, a form that creates something in a database, etc... 

thanks - in 15 years of web programming I have never used get - maybe
time to start now.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
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: Get MAC from diferent fields

2011-06-14 Thread Sil Westerveld


On Jun 14, 12:06 pm, rat attack  wrote:
> So I'm writing a new app, it fetches data from a MySQL db of other
> software, I pick up these three models:
>
>    external_serial = models.CharField("Direccion Mac
> 1",max_length=192, blank=True)
>     mac_address = models.CharField("Direccion Mac 2",max_length=765,
> blank=True)
>     computer_id = models.CharField("Direccion Mac 3",max_length=192,
> primary_key=True)
>
> This are supposed to be mac addresses but they come in weird format,
> for example:
>
> =
> external_serial =
> 00-18-FE-FF-7D-22
>
> external_serial=
> 00:80:5A:46:0A:C2 (0.0.0.0) , 00:18:FE:FF:7D:22 (147.83.76.73)
>
> computer_id=
> HP-CZC6492QRZ
> =
>
> Is it possible to extract just the real mac addrs (maybe via reg exp)
> and creating the models with them?

To extract the mac addresses you could use a regex like:
re_mac_address = re.compile(r"(([A-Fa-f\d]{2}[:-]?){5}[A-Fa-f\d]{2})")

>
> Thanks and sorry as I'm new to django and find it hard to find help.
> Cheers

-- 
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: GET vs POST for read-only views

2011-06-14 Thread Steven L Smith
Hi Shawn-

There is a consensus in the web development community at large -- the HTTP Spec 
itself touches on it, and the W3C has released a few supporting statements as 
well.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
This is the HTTP 1.1 spec, section 9, which defines the difference between the 
various verbs, including GET and POST, in terms of idempotence.

And this helps clarify:
http://www.w3.org/2001/tag/doc/whenToUseGet-20040321

For your use case, I would definitely use GET. The user may wish to bookmark 
the report, for example, or send it to a colleague. Searches and such should 
always use GET, unless there's a truly compelling reason not to.

POST should only be used for things that change stuff on the server... a 
contact form, a form that creates something in a database, etc...


Cheers!
-Steve


Steven L Smith, Web Developer
Department of Information Technology Services
Nazareth College of Rochester
585-389-2085 | ssmit...@naz.edu | KC2YTC
http://www.naz.edu/pub/~ssmith46


- Original Message -
From: "Shawn Milochik" 
To: django-users@googlegroups.com
Sent: Monday, June 13, 2011 12:45:39 PM GMT -05:00 US/Canada Eastern
Subject: GET vs POST for read-only views

Is there a consensus in the community that GET should be used for
requests that don't write to the database? As a specific example, let's
say there's a report form that allows a user to select a start and end
date, and maybe some other search fields. What would you use for this,
and why?

I use POST for almost everything, but I admit it's mainly to avoid
super-ugly URLs full of querystring content.

Thanks,
Shawn

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



Error 'str' object has no attribute '_meta' . How to debug ?

2011-06-14 Thread Satyajit Sarangi
I want to create a model that brings user_id of the user_auth table as
foreign key , layer_id from layer table(defined by me) as also a
foreign key . Combine both to form a primary key . and have another
integer called perm .
My model looks like this


from django.contrib.gis.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from maps.models import  Sdr_Layer

class PermiLayer(models.Model):
user = models.ForeignKey(User)
table =
models.ForeignKey(ContentType,related_name='custom_permission_set')
permi = models.IntegerField()



My view logic is this

if form.is_valid():
data = form.cleaned_data
rad1=form.cleaned_data['radio1']
rad2=form.cleaned_data['radio2']
user=User.objects.get(username = data['user'])

perm = PermiLayer()
perm.user = user
perm.table = user_type =
ContentType.objects.get_for_model('maps_parking')
perm.permi = rad1 + rad2
perm.save()

This gives me the error that I have mentioned above . How do I change
the model and the view to remove the error ?

-- 
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: poll problem

2011-06-14 Thread mattym
Scroll down to the second answer by Paolo.
That should lead you in the right direction.

http://stackoverflow.com/questions/625047/django-newbie-reverse-not-found


On Jun 13, 11:04 pm, jaspreet  wrote:
> Hello everyone,
> my polls application is completed. Admin part of the polls application
> is running successfully
> but I am facing the following error in the User part at the last,
> after select a choice & click on the vote button.
>
> NoReverseMatch at /polls/3/vote/
>
> Reverse for 'polls.views.results' with arguments '(3L,)' and keyword
> arguments '{}' not found.
>
> please help me to solve this problem.

-- 
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 should be a forms.py and views.py be like for a template that has radio buttons ?

2011-06-14 Thread Сергей Владимирович
Something like this:

from django import forms

class PermissionsChoiceForm(forms.Form):
group1_ch = (
(0,' Any registered users'),
(1, 'Only users that can edit ')
)
group1 = forms.ChoiceField(
   choices=group1_ch,
   widget=forms.RadioSelect,
   label='Who can view the data',
initial=0
   )
group2_ch = (
(0,' Any registered users'),
(1, 'Only the following users ')
)
group2 = forms.ChoiceField(
   choices=group2_ch,
   widget=forms.RadioSelect,
   label='Who can edit the data',
initial=0
   )

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



Get MAC from diferent fields

2011-06-14 Thread rat attack
So I'm writing a new app, it fetches data from a MySQL db of other
software, I pick up these three models:

   external_serial = models.CharField("Direccion Mac
1",max_length=192, blank=True)
mac_address = models.CharField("Direccion Mac 2",max_length=765,
blank=True)
computer_id = models.CharField("Direccion Mac 3",max_length=192,
primary_key=True)


This are supposed to be mac addresses but they come in weird format,
for example:


=
external_serial =
00-18-FE-FF-7D-22

external_serial=
00:80:5A:46:0A:C2 (0.0.0.0) , 00:18:FE:FF:7D:22 (147.83.76.73)

computer_id=
HP-CZC6492QRZ
=


Is it possible to extract just the real mac addrs (maybe via reg exp)
and creating the models with them?

Thanks and sorry as I'm new to django and find it hard to find help.
Cheers

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



multi-page, non-sequential, dynamic forms with serialization/deserialization

2011-06-14 Thread Michael Wayne Goodman
Hi all,

I looked into Django for a specific task, but before I get too deep I
want to make sure it is possible. We already have a site that does
what we need (http://depts.washington.edu/uwcl/matrix/customize/
matrix.cgi), but it is written entirely in custom, proprietary code,
and it is getting difficult to maintain.

We need the following features:
  * large, multi-page form (too many fields to fit on one page)
  * dynamic forms (ability to add more fields on demand)
  * non-sequential entry (users can jump back and forth filling it in)
  * serialization (the serialized output is sent to our existing
backend, or the user can download it)
  * deserialization (the user can upload a file that fills in field
values)

We don't currently use a database backend, as longterm storage of
entered data is not a high priority. It mostly takes the form input,
produces output, and is done.

It seems Form Wizards allow multi-page forms, but are geared towards
sequential entry (fill out page 1, submit, fill out page 2, etc). Is
it possible to jump from one subpage to another, allowing data from
each page to affect other pages? I also found some tutorials on
serialization, but I didn't see much on deserializing a file back to
form field values. Is this possible?

Thanks for any help!

-- 
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: Integrity Error with generic relation using ContentType

2011-06-14 Thread Amit Sethi
On Tue, Jun 14, 2011 at 1:41 AM, christian.posta
 wrote:
> Are you using your own fixtures (like initial_data.json)?
> Is it possible that in your initial_data.json ( or whatever fixture
> you're using) that you're including entries into the content_types
[..]

Well i do have entries of the kind this :
 {
"pk": 47,
"model": "contenttypes.contenttype",
"fields": {
"model": "user",
"name": "user",
"app_label": "auth"
}
},

Are these what you are referring to ..

-- 
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: Add text at runtime next to a field

2011-06-14 Thread Thomas Guettler
I want to add a text next to a field of the django admin interface.

The warning needs to created at runtime inside a python method. I know python 
and the django ORM well, but I don't know
how to get the text next the field.

The text should be a warning. Raising ValidationError in clean() is not a 
solution, since the user can't edit the page
any more. It should be just a warning message.

One solution would be, to create a custom admin form (easy), and subclass the 
field, to create
a custom field. That's not difficult, but I guess there is a better solution.

  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

-- 
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: views without forms

2011-06-14 Thread bruno desthuilliers

On Jun 14, 4:27 am, Kenneth Gonsalves  wrote:
> On Mon, 2011-06-13 at 15:50 +0200, Masklinn wrote:
> > You should check that it's not what's being done already, if the
> > try/except
> > blocks catch ValidationError it's possible you predecessor used that.
>
> this is the code snippet:
>
> try: booking.save()            
> except Exception, e:
>
>    return HttpResponse(simplejson.dumps({'s': 0, 'msg':'We are not able to 
> get through at this moment, please try after sometime'}), 
> mimetype="application/javascript")  


Yes, fine. Just discard the exception and traceback, so no one will
ever get a chance to know what happened.


duh :(

-- 
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: How Django render the various templates?

2011-06-14 Thread Derek
On Jun 13, 4:30 am, Nge  wrote:
> Hi Everyone!
>
> How can I create Django tablet site program?
> How can decide Django redirect the web site or mobile site or tablet
> site?
> Does there has separately browser detection?
>
You're better off following modern practice and doing feature
detection:
http://api.jquery.com/jQuery.support/

If you're looking to support mobile devices:
http://stackoverflow.com/questions/164427/change-django-templates-based-on-user-agent
http://www.chicagopython.com/blog/mobile-web-development-django/

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