Internship and job in python and Django related

2023-06-07 Thread Shubham DJ
Hello, I’m Shubhang Jori from Nerul Navi Mumbai. I have been learning web
development for a few months now and have gained familiarity with Django,
python , MySQL, HTML  and CSS. Also I have completed 3 months internship in
trivia software as a python intern. As a student , I am actively seeking
Full-time job opportunities as well as internship opportunities that will
provide me with hands on experience in Django , python and contribute to my
professional growth.  I look forward anyone who can accept me as a full
time employee as well as an intern


Also I attached resume for your reference.
[image: PDF file]
shubham cv-1-2.pdf


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


Re: Static files won't match the path given

2019-05-11 Thread Rookies DJ
Dear Anirudh Jain

Thank you for reply 

Really, apprentice it

Yes we run collectstaitc command 

And we try within setting.py files

Set path static_root/url as the same

As for web server software we using apache not nigx.

I apologize for not including this information

Really appreciate if you could help.

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


Static files won't match the path given

2019-05-10 Thread Rookies DJ
I apologise, I'm a hardware engineer, I'm not very familiar with coding; 
I'm only on Django for the past 5 months. (under my boss order)

I had managed to develop and establish a Django App, and manage to upload 
it to remote server *NameCheap*. There on the server, the issue is unable 
to locate the static files. Even when we directed the path to static files 
folder.

This static files, infrequently work and load the static, that's how we 
concluded the static error was caused by the misdirection of the path.

But reading over the Django documentary multiple time didn't help resolve 

Please help our team had been trying resolve this issue for past 2months 

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


Django, mod_wsgi and apache2.4 = 403 forbidden

2019-01-28 Thread Rookies DJ
I'm sorry if I'm asking the repetitive but i really need assistance I been 
trying to setup a server for my company system but I had no progress. 

As the tile subject mention the I'm Using Mod_wsgi 4.6.5 and Apache 2.4

for my Django is 2.1 and python 3.7

When try to run on my local machine I get 403 and I did many google search 
and the only answer I get is add in Require all granted which I had already 
add in. you could see below for particle section for my Apache http

LoadModule wsgi_module 
"C:\users\user\appdata\local\programs\python\python37\lib\site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
WSGIScriptAlias / "C:\Frontier_Website\FrounterWebApp\FrounterWeb\wsgi.py"\
WSGIPythonPath "C:\Frontier_Website\FrounterWebApp\zigview"
WSGIPythonHome "C:\Users\user\AppData\Local\Programs\Python\Python37"


Require all granted




Require all granted




for more detail you can look at at code in stackoverflow.com:
 
https://stackoverflow.com/questions/54249683/django-mod-wsgi-and-apache2-4-problems
  
I had try to run the system in virtualenv but I get no result as well and 
when I try to start the server, I get this error: *The system cannot find 
the path specified.*
The virtualenv code is below;

#python and mod_wsgi setting 

 ServerName Localhost.com 
 DocumentRoot 
C:\Frontier_Website\FATWebsite\FrontierWebApp\zigview\templates\FrounterWeb
LoadModule wsgi_module 
C:\users\user\appdata\local\programs\python\python37\lib\site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd
WSGIScriptAlias / 
C:\Frontier_Website\FATWebsite\FrontierWebApp\FrounterWeb\wsgi.py
WSGIPythonHome C:\Frontier_Website\FATWebsite\Lib
WSGIPythonPath C:\Frontier_Website\FrounterWebApp\zigview

Alias /static \Frontier_Website\FATWebsite\FrounterWebApp\zigview\static

Require all granted




   Require all granted



 
 
Please help I had been trying to solve this problem for month now

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


custom filter tag I can't get to work

2018-12-05 Thread Rookies DJ
I create my own custom filter tags to using in my project but every time i 
put in my HTML it just product this errors Invalid filter:

I don't where i do wrong, I try putting the {%load tag%} with child 
templates, it didn't work 

I try name it differently 

@register.filter("multiply", multiply) @register.filter(name="multiply") 
@register.filter() 

didn't work either 

Here my HTML code that include the filter:


   
   PH:
{{tank_system.PH|latest}}, 

   



and here my code for my custom filter


from django import template
register = template.Library()

@register.filter('latest', latest)
def custom_last(value):
last = None

try:
last = value[-1]
except AssertionError:
try:
last = value.reverse()[0]
except IndexError:
pass

return last


my views


from django.shortcuts import render
from django.views.generic import TemplateView
from zigview.models import tank_system

from django.contrib.auth.decorators import login_required
import logging
logger = logging.getLogger(__name__)


try:
@login_required(login_url='/accounts/login/')
def index(request): #gose to main dashboard page
tank = tank_system.objects.all
return render(request, 'FrounterWeb/extends/includes.html', 
{'tank': tank})
except:
logger.error('index page request failed/errors')


I intend to use two custom filter

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


Re: Why I can't pass anything to my html? Django 2.1

2018-11-17 Thread Rookies DJ
*Answer:*

Hi everyone Thanks for helping me but I found out my mistake and the cause 
of the problems; 
The problems are my URL, is not calling my def in views 


On Monday, 12 November 2018 20:13:21 UTC+8, Rookies DJ wrote:
>
> I been trying 2 weeks on trying to pass variables form Django views into 
> html, but every time I run my code, it works but it doesn't display the 
> variable I see 
>
> from django.shortcuts import render
> from zigview.models import tank_system
>
> def index(request):
> return render(request,'FrounterWeb/includes.html')
>
> def login(requset):
> return render(requset, 'FrounterWeb/login.html')
>
>
> def timedex(requset):
> tank = tank_system.object.get(id(5))
> print(tank)
> return render(requset, "FrounterWeb/body.html",tank)
>
>
> Here my models
>
> from django.db import models
>
>
> class user(models.Model):
> username = models.CharField(max_length=50)
> password = models.CharField(max_length=50)
>
>
> class tank_system(models.Model):
> Ph = models.DecimalField(max_digits=2, decimal_places=1)
> EC = models.DecimalField(max_digits=2, decimal_places=1)
> temp = models.DecimalField(max_digits=2, decimal_places=0)
> level = models.IntegerField(primary_key=True, default=0)
> data = models.DateTimeField(auto_now=True)
>
>
> Here my HTML that i try pass variable in 
>
> 
> 
>   Time
>   Tank level
>   EC
>   pH
>   room temptures
>   Water temptrure
> 
> 
>   22.30
>   900 lits
>   {{tank}}
>   7.3
>   {{tank}}
>   24
> 
>
> 
>
>
> My HTML body structures
>
> Web
>
> ├── templates
> │   ├── index.hmtl
> │   │   └── includes
> │   ├── body.hml
> │   ├── header.html
>
>   This my urls files;
>
> from django.contrib import admin
> from django.urls import include, path
> from django.views.generic.base import TemplateView
>
> urlpatterns = [
> path(r'^admin/$', admin.site.urls),
> path('account', include('django.contrib.auth.urls')),
> path('', include('zigview.urls')),
> path(r'', TemplateView.as_view(template_name='index.html'), name = 
> 'myapp'),
> ]
>
>

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


Re: Why I can't pass anything to my html? Django 2.1

2018-11-14 Thread Rookies DJ
Hi Amit pant

I'm sorry how do that (make dictionary for display variables using html)

Maybe you could give me some sample code?



On Monday, 12 November 2018 23:39:26 UTC+8, amit pant wrote:
>
> you need to make dictionary for display variables using html
>
> On Mon, Nov 12, 2018 at 6:57 PM Cuneyt Mertayak  > wrote:
>
>> vvv Typo: read "context" instead of "content" vvv
>>
>> On Monday, November 12, 2018 at 5:26:48 AM UTC-8, Cuneyt Mertayak wrote:
>>>
>>> The content for the `render` method is supposed to be a dictionary: 
>>> https://docs.djangoproject.com/en/2.1/topics/http/shortcuts/#optional-arguments
>>>
>>> So change it to this render(requset, "FrounterWeb/body.html",{'tank': 
>>> tank})
>>>
>>> Also in the template file you want to display the properties of the ORM 
>>> (tank_system) object I guess, change them to {{tank.EC}}, 
>>> {{tank. temp}}, respectively.
>>>
>>> Hope it helps!
>>>
>>> On Monday, November 12, 2018 at 4:13:21 AM UTC-8, Rookies DJ wrote:
>>>>
>>>> I been trying 2 weeks on trying to pass variables form Django views 
>>>> into html, but every time I run my code, it works but it doesn't display 
>>>> the variable I see 
>>>>
>>>> from django.shortcuts import render
>>>> from zigview.models import tank_system
>>>>
>>>> def index(request):
>>>> return render(request,'FrounterWeb/includes.html')
>>>>
>>>> def login(requset):
>>>> return render(requset, 'FrounterWeb/login.html')
>>>>
>>>>
>>>> def timedex(requset):
>>>> tank = tank_system.object.get(id(5))
>>>> print(tank)
>>>> return render(requset, "FrounterWeb/body.html",tank)
>>>>
>>>>
>>>> Here my models
>>>>
>>>> from django.db import models
>>>>
>>>>
>>>> class user(models.Model):
>>>> username = models.CharField(max_length=50)
>>>> password = models.CharField(max_length=50)
>>>>
>>>>
>>>> class tank_system(models.Model):
>>>> Ph = models.DecimalField(max_digits=2, decimal_places=1)
>>>> EC = models.DecimalField(max_digits=2, decimal_places=1)
>>>> temp = models.DecimalField(max_digits=2, decimal_places=0)
>>>> level = models.IntegerField(primary_key=True, default=0)
>>>> data = models.DateTimeField(auto_now=True)
>>>>
>>>>
>>>> Here my HTML that i try pass variable in 
>>>>
>>>> 
>>>> 
>>>>   Time
>>>>   Tank level
>>>>   EC
>>>>   pH
>>>>   room temptures
>>>>   Water temptrure
>>>> 
>>>> 
>>>>   22.30
>>>>   900 lits
>>>>   {{tank}}
>>>>   7.3
>>>>   {{tank}}
>>>>   24
>>>> 
>>>>
>>>> 
>>>>
>>>>
>>>> My HTML body structures
>>>>
>>>> Web
>>>>
>>>> ├── templates
>>>> │   ├── index.hmtl
>>>> │   │   └── includes
>>>> │   ├── body.hml
>>>> │   ├── header.html
>>>>
>>>>   This my urls files;
>>>>
>>>> from django.contrib import admin
>>>> from django.urls import include, path
>>>> from django.views.generic.base import TemplateView
>>>>
>>>> urlpatterns = [
>>>> path(r'^admin/$', admin.site.urls),
>>>> path('account', include('django.contrib.auth.urls')),
>>>> path('', include('zigview.urls')),
>>>> path(r'', TemplateView.as_view(template_name='index.html'), name = 
>>>> 'myapp'),
>>>> ]
>>>>
>>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/0ccdcf5d-1d90-41e4-be33-f3684dace2b1%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/0ccdcf5d-1d90-41e4-be33-f3684dace2b1%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: Why I can't pass anything to my html? Django 2.1

2018-11-13 Thread Rookies DJ
Hi Omar Abou Mrad thanks for helping me,
 
Please read the ones in red:

What are you seeing?
My Web page as I want but, i'm missing the key value form my database

What errors do you get?
no errors everything working fine

in summary i'm not having any errors but i can't see anything form my 
database 

My project goal is retrieve a data form the database and display on web-page

But i can't pass any value form my database into my html page

Thanks help Omar Abou Mrad


On Tuesday, 13 November 2018 17:07:47 UTC+8, Omar Abou Mrad wrote:
>
> We would require more information;
> What errors do you get?
> What are you seeing?
>
> Either way, this is not correct: tank = tank_system.object.get(id(5))
> It should be: tank = tank_system.object.get(id=5)
>
> I suggest going through the django tutorial if you haven't already.
>
> On Tue, Nov 13, 2018 at 10:29 AM Rookies DJ  > wrote:
>
>>
>>
>> On Monday, 12 November 2018 21:26:48 UTC+8, Cuneyt Mertayak wrote:
>>>
>>> The content for the `render` method is supposed to be a dictionary: 
>>> https://docs.djangoproject.com/en/2.1/topics/http/shortcuts/#optional-arguments
>>>
>>> So change it to this render(requset, "FrounterWeb/body.html",{'tank': 
>>> tank})
>>>
>>> Also in the template file you want to display the properties of the ORM 
>>> (tank_system) object I guess, change them to {{tank.EC}}, 
>>> {{tank. temp}}, respectively.
>>>
>>> Hope it helps!
>>>
>>
>> Thx for help
>> Cuneyt Mertayak
>>
>>  but it didn't work, appreciate the reply, but suspect that the whiten 
>> the request to return there nothing, is the whole code become empty, that 
>> my believes 
>>  
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/45d9f4af-4807-4692-8d6e-dcc7ab14818a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/45d9f4af-4807-4692-8d6e-dcc7ab14818a%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: Why I can't pass anything to my html? Django 2.1

2018-11-13 Thread Rookies DJ


On Monday, 12 November 2018 21:26:48 UTC+8, Cuneyt Mertayak wrote:
>
> The content for the `render` method is supposed to be a dictionary: 
> https://docs.djangoproject.com/en/2.1/topics/http/shortcuts/#optional-arguments
>
> So change it to this render(requset, "FrounterWeb/body.html",{'tank': 
> tank})
>
> Also in the template file you want to display the properties of the ORM 
> (tank_system) object I guess, change them to {{tank.EC}}, 
> {{tank. temp}}, respectively.
>
> Hope it helps!
>

Thx for help
Cuneyt Mertayak

 but it didn't work, appreciate the reply, but suspect that the whiten the 
request to return there nothing, is the whole code become empty, that my 
believes 
 

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


Why I can't pass anything to my html? Django 2.1

2018-11-12 Thread Rookies DJ
I been trying 2 weeks on trying to pass variables form Django views into 
html, but every time I run my code, it works but it doesn't display the 
variable I see 

from django.shortcuts import render
from zigview.models import tank_system

def index(request):
return render(request,'FrounterWeb/includes.html')

def login(requset):
return render(requset, 'FrounterWeb/login.html')


def timedex(requset):
tank = tank_system.object.get(id(5))
print(tank)
return render(requset, "FrounterWeb/body.html",tank)


Here my models

from django.db import models


class user(models.Model):
username = models.CharField(max_length=50)
password = models.CharField(max_length=50)


class tank_system(models.Model):
Ph = models.DecimalField(max_digits=2, decimal_places=1)
EC = models.DecimalField(max_digits=2, decimal_places=1)
temp = models.DecimalField(max_digits=2, decimal_places=0)
level = models.IntegerField(primary_key=True, default=0)
data = models.DateTimeField(auto_now=True)


Here my HTML that i try pass variable in 



  Time
  Tank level
  EC
  pH
  room temptures
  Water temptrure


  22.30
  900 lits
  {{tank}}
  7.3
  {{tank}}
  24





My HTML body structures

Web

├── templates
│   ├── index.hmtl
│   │   └── includes
│   ├── body.hml
│   ├── header.html

  This my urls files;

from django.contrib import admin
from django.urls import include, path
from django.views.generic.base import TemplateView

urlpatterns = [
path(r'^admin/$', admin.site.urls),
path('account', include('django.contrib.auth.urls')),
path('', include('zigview.urls')),
path(r'', TemplateView.as_view(template_name='index.html'), name = 'myapp'),
]

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


How to save user permissions from custom user edit form

2017-11-04 Thread DJ-Tom
Hi,

I have created the following user form for my custom user model:

class UsersForm(ModelForm):
class Meta:
model = UserAccount
fields = ('is_active', 'is_superuser', 'is_templog', 'is_crewreg', 
'is_spaceman','first_name', 'last_name',
  'company', 'address1', 'address2', 'address3', 'zipcode', 
'city', 'country', 'email', 'favourite_event',
  'user_permissions')

def __init__(self, *args, **kwargs):
super(UsersForm, self).__init__(*args, **kwargs)
self.fields['country'].required = False
self.fields['user_permissions'].widget.attrs['class'] = 'input-xxlarge'
self.fields['user_permissions'].widget.attrs['style'] = 
'min-height:150px'
self.fields['user_permissions'].help_text = 'Specific permissions for 
this user. Hold down "Control", or "Command" on a Mac, to select more than one.'



But when I save it via form.save(), any changed permissions are not saved. 
What do I have to do to change this? 

thanks 
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c11c2b2-4c2e-46d5-93cd-97924cf79bc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to clean up character database fields with leading and trailing spaces

2015-11-03 Thread DJ-Tom

It worked! Basically it was a one-liner as well :-)


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


Re: How to clean up character database fields with leading and trailing spaces

2015-11-03 Thread DJ-Tom
Thanks Vijay,

since this is a very small application, it uses sqlite 3 as the data 
backend... according to http://www.sqlite.org/lang_corefunc.html, there is 
a trim() function in sqlite... so I will check if this works.

best 
Thomas

Am Dienstag, 3. November 2015 14:02:52 UTC+1 schrieb Vijay Khemlani:
>
> As far as I know the Django ORM encapsulates SQL queries, so you can't put 
> arbitrary python code in there (".strip()")
>
> If I remember correctly SQL does not have a standard TRIM method, but 
> individual database engines do, for example for Postgres
>
> http://www.postgresql.org/docs/9.1/static/functions-string.html
>
> So you can run a raw SQL command or just iterate over all the rows in your 
> data I think.
>
> On Tue, Nov 3, 2015 at 6:57 AM, DJ-Tom <event...@gmail.com > 
> wrote:
>
>> Hi,
>>
>> I have several character fields with leading and trailing spaces and 
>> would like to know if it is possible to clean them up with a one-liner...
>>
>> I tried the following but none of this works:
>>
>>
>> rooms.objects.all().update(name=F('name').strip())  // AttributeError: 'F' 
>> object has no attribute 'strip'
>>
>> rooms.objects.all().update(name=Value(F('name')).strip())  // 
>> AttributeError: 'Value' object has no attribute 'strip'
>>
>> rooms.objects.all().update(name=name.strip())  // NameError: name 'name' is 
>> not defined
>>
>> Also searching via Google did not help.
>>
>> Of course I could do some loop, but this seems to be not very efficient to 
>> me.
>>
>> Any Idea?
>>
>> Thomas
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f018f0a5-3a8a-4c28-a1d6-2fb96807093e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f018f0a5-3a8a-4c28-a1d6-2fb96807093e%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


How to clean up character database fields with leading and trailing spaces

2015-11-03 Thread DJ-Tom
Hi,

I have several character fields with leading and trailing spaces and would 
like to know if it is possible to clean them up with a one-liner...

I tried the following but none of this works:


rooms.objects.all().update(name=F('name').strip())  // AttributeError: 'F' 
object has no attribute 'strip'

rooms.objects.all().update(name=Value(F('name')).strip())  // AttributeError: 
'Value' object has no attribute 'strip'

rooms.objects.all().update(name=name.strip())  // NameError: name 'name' is not 
defined

Also searching via Google did not help.

Of course I could do some loop, but this seems to be not very efficient to me.

Any Idea?

Thomas

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


How can I make the field layout of a model form dynamic?

2014-10-22 Thread DJ-Tom
Hi,

I have a model that contains either a text or a numerical information, 
based on the type of the entry:

equipment = models.ForeignKey(equipment)
number = models.DecimalField('Amount/number', max_digits=6, 
decimal_places=2, blank=True, null=False, default=0)
text = models.TextField("Text", blank=True, null=True, default='')

Based on that model I created a model form:

class RoomsetupEquipmentForm(ModelForm):
equipment = 
forms.ModelChoiceField(queryset=equipment.activeobjects.order_by('category__name',
 
'name'))

def __init__(self, *args, **kwargs):
super(RoomsetupEquipmentForm, self).__init__(*args, **kwargs)
self.fields['equipment'].choices = equipment_as_choices()

class Meta:
model = roomsetup_equipments
fields = ('equipment', 'number', 'text')

I'm looking for a way to selectively show either the number or the text 
field when the form is created.

Thomas


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


Re: display the elements from a database in a forms

2014-09-17 Thread DJ-Tom
Well, that is a very "high level" question... did you already work your way 
through the Django tutorials to get a grip on the basics...?

https://docs.djangoproject.com/en/1.7/intro/tutorial01/

Am Dienstag, 16. September 2014 13:32:17 UTC+2 schrieb Devin Cky:
>
>
> hi I want to know how to display the elements from a database in a django 
> forms ?  i use postgresql .  please help me 
>

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


Re: Apache on Windows & multiple Django apps

2014-09-05 Thread DJ-Tom
Well that seems much too complicated just for running variations of the 
same application twice. There all kinds of stuff running on that server and 
adding a proxy to it would be a nightmare to check if everything still 
works.

What a pity, Django is such a powerful tool, but lacks easy deployment.


> This is why I gave you two solutions. See solution 2. 
>
> Cheers 
>
> Tom 
>

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


Re: Apache on Windows & multiple Django apps

2014-09-03 Thread DJ-Tom
Hi Collin,

unfortunately, changing this makes no difference at all.

Thomas

Am Dienstag, 2. September 2014 17:45:37 UTC+2 schrieb Collin Anderson:
>
> setdefault is what's causing your trouble. Change it to an explicit:
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'app.settings'
>

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


Re: Apache on Windows & multiple Django apps

2014-09-02 Thread DJ-Tom

*facepalm*... honestly, I did not spot the difference, i believed the line 
I had was right!!!

thanks anyways, I will try that tomorrow.

Am Dienstag, 2. September 2014 17:45:37 UTC+2 schrieb Collin Anderson:
>
> setdefault is what's causing your trouble. Change it to an explicit:
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'app.settings'
>

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


Re: Apache on Windows & multiple Django apps

2014-09-02 Thread DJ-Tom


Am Dienstag, 2. September 2014 13:51:28 UTC+2 schrieb Tom Evans:
 

> The most obvious and simple solution is to not use Windows.
>

lol - ever heard of the "box of pandora"? :-)

My knowledge of Linux boxes is very close to zero - so setting up a server 
that is not based on Windows would be the most complicated solution for me.

Apart from that, the box on which all of this needs to be run also runs a 
different application server which is Windows-only.

Thomas

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


Re: Apache on Windows & multiple Django apps

2014-09-02 Thread DJ-Tom
Most likely the docs refer to this section of wsgi.py:

# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This 
> breaks
> # if running multiple sites in the same mod_wsgi process. To fix this, use
> # mod_wsgi daemon mode with each site in its own daemon process, or use
> # os.environ["DJANGO_SETTINGS_MODULE"] = "spcmanage.settings"
>

But I already have set this in wsgi.py:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")

Daemon mode is not possible as this is only available in NON-Windows 
environments.

So I'm still stuck with this. I did quite a lot of search for this but 
apparently nobody knows an answer that actually works.

Am Montag, 1. September 2014 19:11:41 UTC+2 schrieb Collin Anderson:
>
> See the docs on deploying with mod_wsgi:
>
> https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/
>
> If multiple Django sites are run in a single mod_wsgi process, all of them 
> will use the settings of whichever one happens to run first. This can be 
> solved with a minor edit to wsgi.py (see comment in the file for 
> details), or by using mod_wsgi daemon mode 
> 
>  and 
> ensuring that each site runs in its own daemon process.
>

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


Apache on Windows & multiple Django apps

2014-09-01 Thread DJ-Tom
Hi,

I'm currently trying to get the same Django app running twice under 
different URLs on the same server.

App 1 ran last year under https://www.sample.com/2013/app and should stay 
there for reference purposes.

App 2 should run under https://www.sample.com/2014/app and also should use 
a different code base and different database than last years version.

I tried the following settings in httpd.conf, but regardless if I use the 
2013 or 2014 url, I always get the 2013 version of the application... 

I also changed the database setting in the 2014 version in settings.py, but 
it seems as if this is never executed. 

what is the correct way to set this up on Windows/Apache?

#
# WSGI / Django Konfiguration

WSGIApplicationGroup %{GLOBAL}

WSGIScriptAlias /2013/app "D:/dev/app/app/wsgi.py"
WSGIScriptAlias /2014/app "D:/dev/app.2014/app/wsgi.py"

WSGIPythonPath "D:/dev/app"



Order deny,allow
Allow from all





Order deny,allow
Allow from all



Alias /static "D:/wwwroot/app/static/"
Alias /static2014 "D:/wwwroot/app.2014/static/"
Header set X-XSS-Protection 0


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


Re: Need idea how to keep data for multiple projects in one database

2014-04-11 Thread DJ-Tom

The only thing that might be a problem is that participants from all kind 
of events are mixed in one huge table. 

When there is a need to do some kind of manual maintenance there is a 
bigger potential of changing data that belongs to a different event, 
compared to the old solution where each event had its own isolated tables.

Thomas

Am Freitag, 11. April 2014 15:57:43 UTC+2 schrieb Gerald Klein:
>
> it sounds like you are on the right track, only thing is that you may want 
> to take a look at data normalization in relational databases, this will 
> give you some clues as to how best link the tables that you are describing
>
>  

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


Need idea how to keep data for multiple projects in one database

2014-04-11 Thread DJ-Tom
Hi,

I'm currently planning to port an old application that was used to register 
participants for events to Django.

The old app did not have any real database system, but was based on dBase 
files.

There was one global table where the basic information about each event was 
stored (like event name, begin and end date and lots of other details).

The actual data tables for each event where stored in a sub-folder of the 
main directory like this:

main
E001
E002
E003

This was quite convenient because creating a new event was just adding a 
record to the main database and doing a copy of a directory. It was also 
very easy to do a backup of the data.

Since there is no way to create a new database for each new event directly 
from the Django application, i'm wondering how this could be structured in 
the most efficient way.

I was thinking about creating an "events" table that holds the settings for 
each event.

All other tables, like "participants", "hotels", "packages", "payments" 
etc. would then be linked to the event table via the events primary key.

I plan to use Postgresql, so database performance should be no big issue, 
as this is a low traffic site (only a few thousand request / day).

What do you think?

thanks for any input
Thomas

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


Re: How to host multiple instances of the same app with Windows Apache & WSGI?

2014-02-27 Thread DJ-Tom


Am Dienstag, 25. Februar 2014 13:50:11 UTC+1 schrieb Tom Evans:
>
>
> Use different STATIC_ROOT for each site, eg /static2013 and /static2014. 
>
> But what you should really be doing is putting this in to a separate 
> vhost. Domain names are cheap, sub-domains are even cheaper. 
>
> Cheers 
>
> Tom 
>

The access to the application has to be made via HTTPS - so I would have to 
get proper SSL certificates for each new domain. Which isn't cheap... 

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


Re: How to host multiple instances of the same app with Windows Apache & WSGI?

2014-02-25 Thread DJ-Tom


Am Dienstag, 25. Februar 2014 13:10:00 UTC+1 schrieb Frank Bieniek:
>
>  Hi Tom,
> if I would walk in your shoes,
> duplicate the source in different folders,
> so you do not create a single point of failure.
>
>
This is exactly  what I'm after, I'm using a version control system so it 
is easy for me to create an independent branch for the new project.

So the old project will stay at D:/dev/spcmanage/spcmanage/, the new one 
should go to D:/dev/*2014*/spcmanage/spcmanage/

I just don't know how to configure that with Apache under Windows...


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


How to host multiple instances of the same app with Windows Apache & WSGI?

2014-02-25 Thread DJ-Tom
Hi,

currently I'm using the following configuration to host a Django 
appliaction:

# WSGI Configuration
> 
> WSGIScriptAlias /2013/spcmanage "D:/dev/spcmanage/spcmanage/wsgi.py"
> WSGIPythonPath "D:/dev/spcmanage"
>
> 
> 
> Order deny,allow
> Allow from all
> 
> 
>
> Alias /static "D:/wwwroot/spcmanage/static/"
> 
>

Now I need to host the same application for another project, but with a 
different database and under a different URL, e.g. 
htts://www.domain.com/2014/spcmanage

But the application from 2013 should be working as well.

Is it sufficient to just add another WSGIScriptAlias line like below?

WSGIScriptAlias /*2014*/spcmanage "D:/dev/*2014*
/spcmanage/spcmanage/wsgi.py"

But what about the alias for the /static directory?

Thomas

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


Re: How do I use mathematical calculations on my forloop Article/Publication list?

2013-11-22 Thread DJ-Tom


Am Donnerstag, 21. November 2013 18:53:00 UTC+1 schrieb Pepsodent Cola:
>
> 1.)
> I managed to make my View calculate my variables but I'm getting the same 
> result *"0.6"* for each forloop.
> What am I doing wrong with my variables calculation?
>

You are passing only a *single* value for *publicists_coverage *to the 
template - why do you expect to get a different value on each loop?

Currently there is no built-in way to do more than simple calculations via 
the "add" filter in templates, but you can easily create your own filters:

http://stackoverflow.com/questions/5848967/django-how-to-do-caculation-inside-the-template-html-page

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


Trouble running Celery as a service on Windows

2013-11-21 Thread DJ-Tom
Hi,

I followed 
http://mrtn.me/blog/2012/07/04/django-on-windows-run-celery-as-a-windows-service/
 
and managed to get redis run as a service on Windows 7.

Now I tried to get the Celery processes to run as a service but keep 
getting the following error:

Traceback (most recent call last): 
File 
"D:\python27\.virtualenvs\djellis\lib\site-packages\pywin32-218-py2.7-win32.egg\win32serviceutil.py",
 
line 835, in SvcRun self.SvcDoRun() 
File 
"D:\python27\.virtualenvs\djellis\lib\site-packages\django_windows_tools\service.py",
 
line 227, in SvcDoRun self.start() 
File 
"D:\python27\.virtualenvs\djellis\lib\site-packages\django_windows_tools\service.py",
 
line 260, in start self.processes = start_commands(self.config) 
File 
"D:\python27\.virtualenvs\djellis\lib\site-packages\django_windows_tools\service.py",
 
line 134, in start_commands services = config.get(node_name, 'run') if 
config.has_section(node_name) else config.get('services', 'run') 
File "D:\python27\Lib\ConfigParser.py", line 618, in get raise 
NoOptionError(option, section) NoOptionError: No option 'run' in section: 
'services'

the services section of service.ini (which I copied from the link above) 
looks like this, so everything should be fine:

[services]
# Services to be run on all machines
run=celeryd
clean=d:\logs\celery.log

I also checked with ProcessMonitor if the service uses the correct ini file 
and it does.

Any idea what might be wrong?

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


Re: Trouble with (unwanted) field validation

2013-11-11 Thread DJ-Tom

This is really weird - I just tried again and *can't* reproduce it at all 
... everything is suddenly working as expected.

Thanks anyways ;-)

Am Freitag, 8. November 2013 13:41:49 UTC+1 schrieb Sergiy Khohlov:
>
> answer is  simple .  Validator would like to check field which is 
> used for Key.  Look like this field is not set   before validation. 
>  I would like take a look at model  form  and part of code before 
> form.is_valid 
> Many thanks, 
>
> Serge 
>
>
> +380 636150445 
> skype: skhohlov 
>
>
> On Fri, Nov 8, 2013 at 2:29 PM, DJ-Tom <event...@gmail.com > 
> wrote: 
> > I still didn't get this to work... isn't there anybody that is able to 
> help? 
> > 
> > Am Mittwoch, 30. Oktober 2013 10:47:34 UTC+1 schrieb DJ-Tom: 
> >> 
> >> Hi, 
> >> 
> >> given the following model field: 
> >> 
> >> room_setup = models.ForeignKey("roomsetup", verbose_name='Default room 
> >> setup', blank=True, null=True, default='') 
> >> 
> >> In the modelform __init__ method I'm setting the choices for this field 
> >> like this: 
> >> 
> >> self.fields['room_setup'].choices = 
> roomsetups_as_choices(subevt) 
> >> 
> >> def roomsetups_as_choices(subevt): 
> >> rs = [['', '-']] 
> >> for setup in roomsetup.objects.filter(Q(subevent__isnull=True) | 
> >> Q(subevent=subevt)): 
> >> rs.append([setup.id, setup.name]) 
> >> 
> >> return rs 
> >> 
> >> When adding a new record I keep getting the following validation 
> message, 
> >> but only for the first try to submit of the form: 
> >> 
> >> "Select a valid choice. That choice is not one of the available 
> choices." 
> >> 
> >> It passes without error on the second try... I really don't understand 
> >> why? 
> >> 
> >> IMHO it should not complain at all... 
> >> 
> >> Any ideas? 
> >> 
> >> Thomas 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/d6ff282b-aafa-411a-a5f6-00f6b6687e7a%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21ee3080-05b9-4364-9c40-015912abb899%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with (unwanted) field validation

2013-11-08 Thread DJ-Tom
I still didn't get this to work... isn't there anybody that is able to help?

Am Mittwoch, 30. Oktober 2013 10:47:34 UTC+1 schrieb DJ-Tom:
>
> Hi,
>
> given the following model field:
>
> room_setup = models.ForeignKey("roomsetup", verbose_name='Default room 
> setup', blank=True, null=True, default='')
>
> In the modelform __init__ method I'm setting the choices for this field 
> like this:
>
> self.fields['room_setup'].choices = roomsetups_as_choices(subevt)
>
> def roomsetups_as_choices(subevt):
> rs = [['', '-']]
> for setup in roomsetup.objects.filter(Q(subevent__isnull=True) | 
> Q(subevent=subevt)):
> rs.append([setup.id, setup.name])
>
> return rs
>
> When adding a new record I keep getting the following validation message, 
> but only for the first try to submit of the form:
>
> "Select a valid choice. That choice is not one of the available choices."
>
> It passes without error on the second try... I really don't understand why?
>
> IMHO it should not complain at all...
>
> Any ideas?
>
> Thomas
>

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


Re: django debugger

2013-11-08 Thread DJ-Tom
Hi,

Pycharm ist very good, I'm using it on a daily basis with Django, debugging 
included.

Google for debugging django pycharm and you will find loads of hints how to 
set this up.

You may also want to look at this review, as it covers a lot of the 
features that Pycharm has:

http://andrewbrookins.com/tech/one-year-later-an-epic-review-of-pycharm-2-7-from-a-vim-users-perspective/

Thomas

Am Dienstag, 5. November 2013 19:29:28 UTC+1 schrieb Harjot Mann:
>
> I want to know that how can we debug django applications? 
> I got pdb but I think in this some commands are need to use and then I 
> come to know about pycharm. 
> Is it good? 
> I successfully installed it but dont' know how to use it? 
> Anyone please help me.. 
>
>

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


Re: What is the best solution to deploy Django on a Windows server?

2013-10-30 Thread DJ-Tom


Am Freitag, 11. Oktober 2013 22:54:38 UTC+2 schrieb Javier Guerra:
 

> just don't mess with IIS, Apache+mod_wsgi is a perfectly good 
> platform. (personally, I prefer nginx+uWSGI, but that would need a lot 
> more work to run on windows) 
>
>
Can only confirm that...

I'm using the following setup
  Windows 2008 Server, Apache / mod_wsgi / virtualenv 
without problems.

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


Trouble with (unwanted) field validation

2013-10-30 Thread DJ-Tom
Hi,

given the following model field:

room_setup = models.ForeignKey("roomsetup", verbose_name='Default room 
setup', blank=True, null=True, default='')

In the modelform __init__ method I'm setting the choices for this field 
like this:

self.fields['room_setup'].choices = roomsetups_as_choices(subevt)

def roomsetups_as_choices(subevt):
rs = [['', '-']]
for setup in roomsetup.objects.filter(Q(subevent__isnull=True) | 
Q(subevent=subevt)):
rs.append([setup.id, setup.name])

return rs

When adding a new record I keep getting the following validation message, 
but only for the first try to submit of the form:

"Select a valid choice. That choice is not one of the available choices."

It passes without error on the second try... I really don't understand why?

IMHO it should not complain at all...

Any ideas?

Thomas

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


Re: How do I correctly encode filenames for use in https-response "content-disposition" header?

2013-10-14 Thread DJ-Tom
Good idea - I will try if this helps - for now I'm replacing spaces with 
underscores which works as well.

Am Freitag, 11. Oktober 2013 16:29:32 UTC+2 schrieb ke1g:
>
> Not sure, but perhaps you need quotes around the file name to avoid having 
> the user agent terminate the filename on space?  E.g.;
> ..."attachement; filename=" + '"' + rep_setup..+ '.xlsx"'
>
>
>

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


Re: Looking for a way to detect changes in database records with low storage footprint

2013-10-14 Thread DJ-Tom

Thanks, this might be a way to go - since the .extra() method may create a 
dependency on the SQL dialect used I will have to be careful though ;-)

Am Donnerstag, 10. Oktober 2013 19:01:32 UTC+2 schrieb Tom Evans:
>
> This is not a full solution, but you can select out extra fields (and 
> then subsequently filter on them) using the .extra() method on 
> querysets. 
>
> Eg, if you were using mysql and wanted a field that was a hash of pk 
> (id), first_name and last_name fields, then you could do something 
> like so: 
>
>

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


How do I correctly encode filenames for use in https-response "content-disposition" header?

2013-10-11 Thread DJ-Tom
Hi,

I'm serving files via HttpResponse and currently I'm struggling with spaces 
in the filenames.

This is how I contruct the response header:

response = HttpResponse(report.reportfile.chunks(), 
mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
response['Content-Disposition'] = "attachment; filename=" + *
rep_setup.name.encode("ASCII")* + "." + 
report.date_run.strftime("%Y-%m-%d.%H%M") + ".xlsx"
report.reportfile.close()
return response

But if rep_setup.filename contains spaces, the browser (Firefox) truncates 
the filename at that position.

I tried to use django.utils.http.urlqoute(), but a filename like this looks 
just ugly: Some%20long%20Filename%20with%20Spaces.xlsx

Or should I just replace all Spaces with a underscore "_" character?

What is the technically correct way?

Thomas

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


Re: Looking for a way to detect changes in database records with low storage footprint

2013-10-10 Thread DJ-Tom

Thanks, but *how* can I create a hash from a database object in Django - is 
there a generic method to iterate over all (or only specific) fields and 
get a hash value?

Am Mittwoch, 9. Oktober 2013 19:07:54 UTC+2 schrieb Nikolas 
Stevenson-Molnar:
>
> A hash should work fine. Alternatively, you could diff the two records, 
> using something like difflib: 
> http://docs.python.org/2/library/difflib.html 
>
>
>

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


Looking for a way to detect changes in database records with low storage footprint

2013-10-09 Thread DJ-Tom
Hi,

a customer has requested a function to "compare" reports.

So let's say I create a database report on Monday, then the data is 
constantly changing the whole week and on the following Monday it should be 
possible to get a report that either contains only changed and new records 
or all records plus a column that indicates that something has changed.

It is not important to know exactly which field has changed but only that 
something has changed. 

I'm already storing a "change_date" for each record, but this is also 
updated if the user just saves the same data again without actually 
changing any content. 

Also it is important to be able to not only compare based on date/time, but 
based on a specific reports status.

So I thought about storing a hash value for every record for each report so 
I could compare this later on.

Is there any functionality that makes creating this hash, e.g. by 
serializing each record into a string and creating a hash from this 
information?

Or does someone have any other (better) idea how to implement this?

Thanks
Thomas

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


Re: Ho can I reverse urls inside urls.py?

2013-10-09 Thread DJ-Tom
Hi Tom,

works like a charm - THX!

Cheers 
Thomas

Am Dienstag, 8. Oktober 2013 17:49:18 UTC+2 schrieb Tom Evans:
>
>
> Use reverse_lazy 
>
> https://docs.djangoproject.com/en/1.5/ref/urlresolvers/#reverse-lazy 
>
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b8f5453-364e-4edb-8536-6bb6eee5de54%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Ho can I reverse urls inside urls.py?

2013-10-08 Thread DJ-Tom
Based on this 
articleI
 implemented a password reset function.

Unfortunately, currently this only works on the development server because 
the base URLs for the post_reset_redirect are different on the production 
server.

This is the relevant part of my urls.py, I marked the prolematic parts in 
red:


url(r'^password/reset/$','django.contrib.auth.views.password_reset',{'post_reset_redirect'
 
: '/accounts/password/reset/done/', 'template_name': 
'accounts/password_reset.html'}, name="password_reset"),\

(r'^password/reset/done/$','django.contrib.auth.views.password_reset_done',{'template_name':
 
'accounts/password_reset_done.html'}), \

(r'^password/reset/(?P[0-9A-Za-z]+)-(?P.+)/$','django.contrib.auth.views.password_reset_confirm',{'post_reset_redirect'
 
: '/accounts/password/done/', 'template_name': 
'accounts/password_reset_confirm.html'}),\
(r'^password/done/$', 
'django.contrib.auth.views.password_reset_complete',{'template_name': 
'accounts/password_reset_complete.html'}),
)

Normally I would use 
reverse('django.contrib.auth.views.password_reset_done') to get the correct 
URL, but using reverse() inside the urls.py leads to a configuration error, 
so how can I put the correct URLs here so it works correct both in 
development and production?

Thanks
Thomas

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


Re: Best practice for server-generated downloads?

2013-10-04 Thread DJ-Tom
Thanks - that's what I was looking for.

But how do I send the browser back to a specific page after serving the 
download?

Am Donnerstag, 3. Oktober 2013 10:54:51 UTC+2 schrieb John McNamara:
>
> Hi,
>
> Here is an example of using XlsxWriter from SimpleHTTPServer or Django. It 
> probably doesn't do 100% of what you are looking for but it may help anyway.
>
> https://xlsxwriter.readthedocs.org/en/latest/example_http_server.html
>
> John
>
>

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


Re: Best practice for server-generated downloads?

2013-10-03 Thread DJ-Tom
I have now created a test view that basically does what I want:

def reporting_new(request):

output = StringIO.StringIO()

book = Workbook(output)
sheet = book.add_worksheet('test')
sheet.write(0, 0, 'Hello, world!')
book.close()

# construct response
output.seek(0)
response = HttpResponse(output.read(), 
mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
response['Content-Disposition'] = "attachment; filename=test.xlsx"

return response

I could now use output:getvalue() to write it to disk - but how do I 
redirect the browser to the next page after the download?

Thomas


Am Mittwoch, 2. Oktober 2013 12:34:11 UTC+2 schrieb JirkaV:
>
> Hi Thomas, 
>
>  I'm doing exactly this - allowing users to download (graphically simple) 
> XLSx files from my web app, it also needs to be available for download 
> weeks later. 
>
>   As Russell pointed out, you don't need to store data on this if you have 
> a way of getting the same set of data later, you can always regenerate the 
> same Excel file. You don't even need to use StringIO for that.
>
>  I'm using the save_virtual_notebook() in openpyxl package to generate the 
> Excel file straight from database upon each (infrequent) request.
>
>   HTH
>
> Jirka
>
>
> On Wed, Oct 2, 2013 at 9:36 AM, Russell Keith-Magee <
> rus...@keith-magee.com > wrote:
>
>>
>> On Wed, Oct 2, 2013 at 2:33 PM, DJ-Tom <event...@gmail.com 
>> >wrote:
>>
>>> Hi,
>>>
>>> this is quite easy to answer - those reports need to be archived - users 
>>> must be able to download them days or weeks later.
>>>
>>> So I will create a record in a database for each report that is created 
>>> so users can access it later - maybe this can be seen as "uploading" a file 
>>> to the server that acts as a document repository, with the only difference 
>>> that the file is not uploaded, but produced by the server.
>>>
>>
>> Well, if you need archival, there are two alternatives:
>>
>> 1. Write the file to disk at the same time it is being generated. There's 
>> no reason you have to serve the file from where it was generated -- 
>> generate it, write it, and serve it.
>>
>> 2. Make sure the report will always be generated the same way. An analog 
>> here -- if you request a page from a web server, it probably isn't saved on 
>> disk like that (unless it's a genuinely static page) -- the server knows 
>> how to reproduce the same page every time you request a specific URL. Make 
>> the reports the same -- if you request /report/September-2013, you generate 
>> the same report every time. 
>>
>> The second approach depends on whether you have well time-bucketed data, 
>> but it's certainly possible to do.
>>
>>>
>>> I don't see how I could use the xlsxwriter object in the way it is 
>>> described here https://docs.djangoproject.**com/en/1.5/howto/outputting-
>>> **pdf/ <https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/> - 
>>> how could I pass the httpresponse object to xlsxWriter?
>>> (Maybe I have not yet found how this might work - but it is not what I 
>>> need anyways...)
>>>
>>
>> I haven't used xlsxwriter myself, but the key part of the PDF example is 
>> that StringIO is an object that adheres to the python File API, but doesn't 
>> actually involve a file. So, you open a StringIO object, "write" to it, 
>> then dump the contents as the HTTP response. 
>>
>> So - whatever API endpoint on xlsxwriter lets you pass in a file object 
>> -- pass in a StringIO instance instead.
>>
>> Yours,
>> Russ Magee %-)
>>
>>
>>
>> Thomas
>>>
>>> Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
>>>
>>>>
>>>> On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom <event...@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I need to create database report downloads in Excel format (via 
>>>>> xlsxwriter) and I'm wondering if there is any standard or best practice 
>>>>> as 
>>>>> to where those downloads should be located.
>>>>>
>>>>> Especially helpful would be if there was a portable way of managing 
>>>>> the file system location and web request url in a way so that I don't 
>>>>> have 
>>>>> to change settings between the development and production server.
>>>>>
>>>>> Is this ->

Re: Best practice for server-generated downloads?

2013-10-03 Thread DJ-Tom

The report can't be reporduced later on - as the data is constantly 
changing, so I need to store the result. 

Storing the data on which the report is based is very complex and would be 
too expensive regarding storage space just for this purpose.

But I also have now found how to use StringIO and xlsxWriter here:

http://stackoverflow.com/questions/16393242/xlsxwriter-object-save-as-http-response-to-create-download-in-django

So most likely I will do it like in this sample, plus saving the report for 
later retrieval and always serving through httpresponse, so I don't need to 
expose the actual storage location via the web server.

Am Mittwoch, 2. Oktober 2013 09:36:10 UTC+2 schrieb Russell Keith-Magee:
>
>
> Well, if you need archival, there are two alternatives:
>
> 1. Write the file to disk at the same time it is being generated. There's 
> no reason you have to serve the file from where it was generated -- 
> generate it, write it, and serve it.
>
> 2. Make sure the report will always be generated the same way. An analog 
> here -- if you request a page from a web server, it probably isn't saved on 
> disk like that (unless it's a genuinely static page) -- the server knows 
> how to reproduce the same page every time you request a specific URL. Make 
> the reports the same -- if you request /report/September-2013, you generate 
> the same report every time. 
>
> The second approach depends on whether you have well time-bucketed data, 
> but it's certainly possible to do.
>
>>
>> I don't see how I could use the xlsxwriter object in the way it is 
>> described here https://docs.djangoproject.**com/en/1.5/howto/outputting-*
>> *pdf/ <https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/> - 
>> how could I pass the httpresponse object to xlsxWriter?
>> (Maybe I have not yet found how this might work - but it is not what I 
>> need anyways...)
>>
>
> I haven't used xlsxwriter myself, but the key part of the PDF example is 
> that StringIO is an object that adheres to the python File API, but doesn't 
> actually involve a file. So, you open a StringIO object, "write" to it, 
> then dump the contents as the HTTP response. 
>
> So - whatever API endpoint on xlsxwriter lets you pass in a file object -- 
> pass in a StringIO instance instead.
>
> Yours,
> Russ Magee %-)
>
>
>
> Thomas
>>
>> Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
>>
>>>
>>> On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom <event...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I need to create database report downloads in Excel format (via 
>>>> xlsxwriter) and I'm wondering if there is any standard or best practice as 
>>>> to where those downloads should be located.
>>>>
>>>> Especially helpful would be if there was a portable way of managing the 
>>>> file system location and web request url in a way so that I don't have to 
>>>> change settings between the development and production server.
>>>>
>>>> Is this -> 
>>>> https://docs.djangoproject.**com/en/1.5/topics/files/<https://docs.djangoproject.com/en/1.5/topics/files/>the
>>>>  way to go?
>>>>
>>>> If they're sever generated, why do they need to hit the file system at 
>>> all? 
>>>
>>> The following example in the docs:
>>>
>>> https://docs.djangoproject.**com/en/1.5/howto/outputting-**pdf/<https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/>
>>>  
>>> shows how you can stream a report directly to the end user. The example 
>>> uses reportlab to produce a PDF, but the same approach will work for a tool 
>>> writing to a different format.
>>>
>>> Yours,
>>> Russ Magee %-)
>>>  
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/93413618-01d4-4fc0-a4d0-94fa67efe371%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


Re: Best practice for server-generated downloads?

2013-10-02 Thread DJ-Tom
Hi,

this is quite easy to answer - those reports need to be archived - users 
must be able to download them days or weeks later.

So I will create a record in a database for each report that is created so 
users can access it later - maybe this can be seen as "uploading" a file to 
the server that acts as a document repository, with the only difference 
that the file is not uploaded, but produced by the server.

I don't see how I could use the xlsxwriter object in the way it is 
described here https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/- how 
could I pass the httpresponse object to xlsxWriter?
(Maybe I have not yet found how this might work - but it is not what I need 
anyways...)

Thomas

Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
>
>
> On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom <event...@gmail.com 
> >wrote:
>
>> Hi,
>>
>> I need to create database report downloads in Excel format (via 
>> xlsxwriter) and I'm wondering if there is any standard or best practice as 
>> to where those downloads should be located.
>>
>> Especially helpful would be if there was a portable way of managing the 
>> file system location and web request url in a way so that I don't have to 
>> change settings between the development and production server.
>>
>> Is this -> https://docs.djangoproject.com/en/1.5/topics/files/ the way 
>> to go?
>>
>> If they're sever generated, why do they need to hit the file system at 
> all? 
>
> The following example in the docs:
>
> https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/
>
> shows how you can stream a report directly to the end user. The example 
> uses reportlab to produce a PDF, but the same approach will work for a tool 
> writing to a different format.
>
> Yours,
> Russ Magee %-)
>  
>

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


Best practice for server-generated downloads?

2013-10-01 Thread DJ-Tom
Hi,

I need to create database report downloads in Excel format (via xlsxwriter) 
and I'm wondering if there is any standard or best practice as to where 
those downloads should be located.

Especially helpful would be if there was a portable way of managing the 
file system location and web request url in a way so that I don't have to 
change settings between the development and production server.

Is this -> https://docs.djangoproject.com/en/1.5/topics/files/ the way to 
go?

Any ideas?

Thomas

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


Updating custom permissions not working properly

2013-10-01 Thread DJ-Tom
Hi,

I'm using Django 1.5 with South to sync my database.

According to a hint on Stackoverflow I added the following code to my 
procjects __init__.py to add permissions on every migration:

from south.signals import post_migrate


def update_permissions_after_migration(app, **kwargs):
"""
Update app permission just after every migration.
This is based on app django_extensions update_permissions management 
command.
"""
import settings
from django.db.models import get_app, get_models
from django.contrib.auth.management import create_permissions

create_permissions(get_app(app), get_models(), 2 if settings.DEBUG else 
0)

post_migrate.connect(update_permissions_after_migration)

Adding custom permissions via "class Meta:" seemed to work quite well with 
the above code.

But now I added permissions to a few models and some of them were not added 
to the permission table - without any error message, nothing.

This permission was added:

class Meta:
permissions = (
("view_equipmentcat", "Can see equipment categories"),
)


But not those (for example):

class Meta:
permissions = (
("view_equipment", "Can see equipment"),
)

class Meta:
permissions = (
("view_rooms", "Can see rooms"),
)


Is there a way to clear all custom permissions from auth_permission and 
force all custom permissions to be added again?

Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c6bbe2cd-1f77-462e-9d09-588179c909bb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a standalone python application that uses the django environment (e.g. the ORM etc...)?

2013-09-18 Thread DJ-Tom
Hi Brad,

that fixed it - plus I now have a better understanding of how python works.

I'm beginning to understand what Jeff Knupp writes here: 
http://www.jeffknupp.com/blog/2012/12/11/learning-python-via-django-considered-harmful/

:-)

Am Dienstag, 17. September 2013 17:58:42 UTC+2 schrieb Brad Pitcher:
>
> To make my code work, you could set DJANGO_SETTINGS_MODULE to 
> 'my_project.settings', and just put formdesigner.py directly under 
> my_project.
>
> If you wanted to keep formdesigner.py where it is, you would want to 
> change the sys.path.append line to this:
>
> sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), 
> '..'))
>
>
> -
> Brad Pitcher
>
>
> On Tue, Sep 17, 2013 at 12:25 AM, DJ-Tom <event...@gmail.com 
> > wrote:
>
>>
>> Hi,
>>
>> I'm also not sure if the python file is at the correct location.
>>
>> This is how the directory structure looks:
>>
>> my_project
>> \my_project\
>>  settings.py
>> \my_app\ # this is where my models are defined
>>  models.py
>>  formdesigner.py
>>
>>
>> Where should my formdesigner.py be located?
>>
>> my_project ? 
>> my_project\my_project ?
>> my_project\my_app ?
>>
>> What do I put into DJANGO_SETTINGS_MODULE?
>>
>> 'my_project.settings'?
>>
>>
>> Am Montag, 16. September 2013 18:17:21 UTC+2 schrieb Brad Pitcher:
>>
>>> You need to do something like this before import django stuff:
>>>
>>> import os
>>> import sys
>>>
>>> sys.path.append(os.path.**abspath(os.path.dirname(__**file__)))
>>> os.environ['DJANGO_SETTINGS_**MODULE'] = 'web.settings'
>>>
>>>
>>> -
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a standalone python application that uses the django environment (e.g. the ORM etc...)?

2013-09-17 Thread DJ-Tom
I need to use the ORM and more specifcally I want to use the models I 
defined inside my Django application.

I want to avoid using a different ORM like Alchemy because then I would 
have to duplicate the work I already put into my Django models - i hate 
duplicating work...

Apart from that, I don't need much else (maybe the template engine for 
sending emails...)

The formdesigner application should live inside the web application 
structure so I can manage it the same way as I'm doing it with the web 
application and have it included in the same Subversion project.

Thomas

Am Montag, 16. September 2013 18:38:35 UTC+2 schrieb אברהם סרור:
>
> the question is what for? other than the ORM what else is useful for a 
> desktop app?
> if it is only the ORM you want take a look at http://www.sqlalchemy.org/
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a standalone python application that uses the django environment (e.g. the ORM etc...)?

2013-09-17 Thread DJ-Tom

Hi,

I'm also not sure if the python file is at the correct location.

This is how the directory structure looks:

my_project
\my_project\
 settings.py
\my_app\ # this is where my models are defined
 models.py
 formdesigner.py


Where should my formdesigner.py be located?

my_project ? 
my_project\my_project ?
my_project\my_app ?

What do I put into DJANGO_SETTINGS_MODULE?

'my_project.settings'?


Am Montag, 16. September 2013 18:17:21 UTC+2 schrieb Brad Pitcher:
>
> You need to do something like this before import django stuff:
>
> import os
> import sys
>
> sys.path.append(os.path.abspath(os.path.dirname(__file__)))
> os.environ['DJANGO_SETTINGS_MODULE'] = 'web.settings'
>
>
> -
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


How do I create a standalone python application that uses the django environment (e.g. the ORM etc...)?

2013-09-16 Thread DJ-Tom
For reporting purposes I want to use List & Label from Combit. The 
web/online part is no big deal since the reporting module can be run 
without user interface (creating Excel or PDF files)

But the actual form designer part that is used to define the report layout 
is a windows GUI application, so I would like to have a python file inside 
my Django app that I can call to start the designer part on my local 
machine.

I have now read a bunch of descriptions on how to use Django in a 
standalone application but did not succeed so far in actually running my 
form designer.

This is what I currently have, i tried to start this via "python 
formdesigner.py", after activating the correct virtualenv:

from Tkinter import *
from ctypes import *
import django
from models import *

LL = windll.cmll18

### Declaration of application class omitted, this is plain python  

app = Application()
app.master.title("List & Label sample application")
app.mainloop() 


Regardless what I try, I can't get the model class import to work.

I also tried SET DJANGO_SETTINGS_MODULE=settings and project.settings and 
project.app.settings... nothing worked.

thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Paginattion: How do I pass current page number around views, forms and templates?

2013-09-16 Thread DJ-Tom

I think I could use the views name as the key to the current page - that 
way the system "remembers" the page number for each view.

Am Dienstag, 10. September 2013 18:59:19 UTC+2 schrieb ke1g:
>
> The remaining trick will be when to remove it from the session.  You don't 
> want to go into another list and start at page 5.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Paginattion: How do I pass current page number around views, forms and templates?

2013-09-10 Thread DJ-Tom
ah ok - now all makes sense :-)

Am Dienstag, 10. September 2013 18:23:12 UTC+2 schrieb ke1g:
>
> Sorry.  I meant session.
>
>
> On Tue, Sep 10, 2013 at 12:15 PM, DJ-Tom <event...@gmail.com 
> > wrote:
>
>> Hi,
>>
>> hmmm, I don't think I understand what you mean with "setting"
>>
>> Thomas
>>
>> Am Dienstag, 10. September 2013 17:47:41 UTC+2 schrieb ke1g:
>>
>>> Assuming that you can't get the edit view to cooperate, maybe store it 
>>> on the setting?
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Paginattion: How do I pass current page number around views, forms and templates?

2013-09-10 Thread DJ-Tom
Hi,

I'm currently using django's default pagination and it works as expected.

The problem i still have is that when I'm on (lets say) page 5 of 10, go 
into edit the edit form of one of the objects, I don't know how I can 
preserve/access the current page number from the edit view/form template so 
I can get back to page 5 of the list view when I'm done with editing of the 
current record.

I started by adding ?page=x to the edit link of each record, but how do I 
pass this down the line so I can redirect to /somemodel/list/?page=x after 
saving the data record?

Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Paginattion: How do I pass current page number around views, forms and templates?

2013-09-10 Thread DJ-Tom
Hi,

hmmm, I don't think I understand what you mean with "setting"

Thomas

Am Dienstag, 10. September 2013 17:47:41 UTC+2 schrieb ke1g:
>
> Assuming that you can't get the edit view to cooperate, maybe store it on 
> the setting?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


How to pass additional information about fields into template?

2013-09-05 Thread DJ-Tom
Hi,

Based on http://jacobian.org/writing/dynamic-form-generation I have now 
managed to create a data driven form (hooray :-)

Basically I'm reading field names from a database and append to a ModelForm 
in its __init__ method:

View:

equipments = 
equipment.objects.filter(category__in=request_extra_cat).order_by('category__name','name')
for equip in equipments:
fields.append(equip)

form = AddRequestForm(request.POST or None, extra=fields) # pass extra 
fields

Form:
def __init__(self, *args, **kwargs):
extra = kwargs.pop('extra') # Get extra fields
super(AddRequestForm, self).__init__(*args, **kwargs)

for i, question in enumerate(extra):
if 'notes' in question.name:
self.fields['custom_%s' % question.id] = 
forms.CharField(label=question.name, required=False, 
widget=forms.Textarea(attrs={'rows':'10', 'class':'input-xxlarge'}))
else:
self.fields['custom_%s' % question.id] = 
forms.ChoiceField(label=question.name, choices=REQUEST_NUMBERS, 
required=False, widget=forms.Select(attrs={'class':'span1'}))

Because I have groups of fields that belong together, I would like to add a 
header to each group of form fields.

The perfect solution would be to use a  tag, but it also would be 
OK if I could just add a Header .

The only problem is, how do I know how I can access the field that contains 
the  grouping information inside the template.

For html tables I use the following solution with ifchanged:

{% for document in documents %}
{% ifchanged %}{{ 
document.category.name }}{% endifchanged %}

The problem is that the list of fields (form.visible_fields) does not have 
the group information to do this in the form template:

{% for field in form.visible_fields %}

{% ifchanged field.groupID %}{{ field.category.name 
}}{% endifchanged %}  THIS DOES NOT WORK
{{ field.label }}
{% if field.field.required %}
*
{% endif %}


Any idea how I could achieve what I want?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ValueError: Cannot create form field for 'room_setup' yet, because its related model 'main_page.roomsetup' has not been loaded yet

2013-09-04 Thread DJ-Tom
I have now separated the form definitions into forms.py and import the 
models from models.py... so this is fixed

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: pattern matching wrong app ???

2013-09-04 Thread DJ-Tom

did you try XX84/sample*/* (trailing "/")?

You might also get more answers if you show the content of "demoproj.urls" 
and "sample.urls"

Am Dienstag, 3. September 2013 15:18:49 UTC+2 schrieb bab mis:
>
> I have 2 app inside my django project:
>
> url(r'^demoproj/$',  include('demoproj.urls')),
>
> url(r'^sample/$',  include('sample.urls')),
>
>
> XX84/sample always redirects to demoproj. Any idea why???
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


ValueError: Cannot create form field for 'room_setup' yet, because its related model 'main_page.roomsetup' has not been loaded yet

2013-09-04 Thread DJ-Tom
Hi,

given the following models and model form I get the error in the subject, 
apparently because the related model "roomsetup" is defined *after* the 
"RoomsForm" form and is not loaded at the time the form is created.

class rooms(models.Model):
[ lots of other fields]
*room_setup* = models.ForeignKey('roomsetup', verbose_name='Room 
setup', blank=False, default='')

def __unicode__(self):
return self.name


class RoomsForm(ModelForm):
class Meta:
model = rooms
fields = ('active', 'location', 'level', *'room_setup'*, 'name', 
'daylight', 'area', 'height', 'notes',)

 other models and forms...

class roomsetup(models.Model):
[lots of fields]

def __unicode__(self):
return self.name

If I move the RoomsForm declaration *below* the room setup class, 
everything works fine, but I would like to keep the model and its 
associated form together in my code (this makes sense?).

So is there another  way how can I avoid this situation?

Thanks 
Thomas 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to edit many-to-many relationships with data from custom intermediary table?

2013-08-21 Thread DJ-Tom


I'm not sure what the easiest way would be to make the Quantity field 
> editable - I thought about a* fieldset *but how do I get the data from 
> the intermediary table into that???
>
>
ooops - I meant FORMset, not fieldset... (why is there no way to edit my 
own post?) 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


How to edit many-to-many relationships with data from custom intermediary table?

2013-08-21 Thread DJ-Tom
Hi,

I'm currently working on a room management application for events.

One part of it is a list of room setups with associated equipment, each 
room can have an arbitrary number of  different equipment (such as screens, 
IT-equipment, A/, tables etc.)

Each equipment also has an attribute "number/quantity" to define how many 
of it is needed, so I created a custom intermediary table (instead of 
relying on the built-in one):

class roomsetup(models.Model):
name = models.CharField("Name", max_length=60)
equipments = models.ManyToManyField(equipment, 
through='roomsetup_equipments')  # use custom intermediary  table

class equipment(models.Model):
name = models.CharField("Name", max_length=60)

# custom intermediary m2m table...
class roomsetup_equipments(models.Model):
roomsetup = models.ForeignKey(roomsetup)
equipment = models.ForeignKey(equipment)
number = models.DecimalField('Quantity/number', max_digits=6, 
decimal_places=2, blank=True, null=False, default=1)

The "standard" roomsetup form I created just displays a plain list of 
equipment, there is no way to change the quantity:

class RoomsetupForm(ModelForm):
class Meta:
model = roomsetup
fields = ('active', 'name', 'roomlayout', 'equipments', 'notes',)

I'm not sure what the easiest way would be to make the Quantity field 
editable - I thought about a fieldset but how do I get the data from the 
intermediary table into that???

Any hint/sample would be appreciated.

thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Suddenly I keep getting this error: invalid literal for int() with base 10: ''

2013-08-11 Thread DJ-Tom

Finally - FIXED!

After a some experimenting with the command line I found out that I can not 
access the foreign key field if there is no actual record.

So this throws the error as well:

>>> doc = main_documents.objects.create(doc_name="test", 
doc_description="description")
>>> doc.created_by

But after assigning a value, created_by is available:

>>> from accounts.models import UserAccount
>>> user = UserAccount.objects.get(pk=1)
>>> doc.created_by = user
>>> doc.created_by



So finally I changed my code to this:

(maybe there is some more elegant way, but currently the main thing is that 
it works now :-)

def doc_details(request, doc_id=None):
>
> isNewRecord = False
>
> if doc_id is not None:
> document = main_documents.objects.get(pk = doc_id)
> else:
> document = None
> isNewRecord = True
>
> if request.method == 'POST': # If the form has been submitted...
> form = DocumentForm(request.POST, instance=document) # A form 
> bound to the POST data
> if form.is_valid():  # All validation rules pass
> document = form.save(commit=False)
> if isNewRecord or document.created_by is None:
> document.created_by = request.user
> document.save()
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Suddenly I keep getting this error: invalid literal for int() with base 10: ''

2013-08-11 Thread DJ-Tom
one more thing, this is the user model setting from settings.py:

AUTH_USER_MODEL = 'accounts.UserAccount'


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Suddenly I keep getting this error: invalid literal for int() with base 10: ''

2013-08-11 Thread DJ-Tom

After adding a few more databases and views to my app, I suddenly get the 
error mentioned in the subject.

Not sure what happened .. everything worked as a charm before.

This only happens when the program tries to create a new record, I can 
change existing ones

It seems as if the "created_by" column is not accessible, after this line 
   document = form.save(commit=False)
the debugger already shows the errro in the watch expression...

I marked the line where it fails in red below.

views.py

@login_required
> def doc_details(request, doc_id=None):
>
> if doc_id is not None:
> document = main_documents.objects.get(pk = doc_id)
> else:
> document = None
>
> if request.method == 'POST': # If the form has been submitted...
> form = DocumentForm(request.POST, instance=document) # A form 
> bound to the POST data
> if form.is_valid():  # All validation rules pass
> document = form.save(commit=False)
> if document.created_by is None:
> document.created_by = request.user
> document.save()
> return redirect(reverse('main_page.views.doc_index')) # 
> Redirect after POST
> else:
> form = DocumentForm(instance=document) # An unbound form
>
> form.error_css_class = 'text-error'
> form.required_css_class = 'text-info'
>
> context = {'form': form,'navi': spc_globals.getnavigation(req=request)}
>
> if doc_id is None:
> context.update({
> 'action': 'Add new document',
> 'header': 'New document'
> })
>
> else:
> context.update({
> 'action': 'Save document',
> 'header': 'Edit document'
> })
>
> return render(request, 'main_page/edit_form.html', context)
>


models.py:

from django.db import models
> from django.forms import ModelForm, DateField, DateInput
> from django.conf import settings
>
> # Main application settings.
> class main_settings(models.Model):
> eventname = models.CharField('Eventname', max_length=200, blank=False)
> start_date = models.DateField('Begin date', help_text="Please use the 
> following format: -MM-DD.")
> end_date = models.DateField('End date', help_text="Please use the 
> following format: -MM-DD.")
>
> # Input form for main application settings.
> class mainSettingsForm(ModelForm):
> start_date = DateField(widget=DateInput(format='%d.%m.%Y'), 
> input_formats=('%d.%m.%Y',), label='Begin date')
> end_date = DateField(widget=DateInput(format='%d.%m.%Y'), 
> input_formats=('%d.%m.%Y',), label='End date')
> class Meta:
> model = main_settings
> exclude = ('date_created',)
>
> # Document class
> class main_documents(models.Model):
> doc_name = models.CharField("Document name", max_length=60)
> doc_link = models.URLField("Document URL/link")
> doc_description = models.TextField("Document description", blank=True, 
> null=True)
> date_created = models.DateTimeField('Created on', auto_now_add=True, 
> blank=True, null=True)
> created_by = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, 
> blank=True, default='')
>
> class Meta:
> permissions = (
> ("view_documents", "Can see documents"),
> )
>
>
> class DocumentForm(ModelForm):
> class Meta:
> model = main_documents
> exclude = ('date_created','created_by',)
>
>
> class subevents(models.Model):
> active = models.BooleanField('Active', default=True)
> name = models.CharField("Subevent name", max_length=60, 
> help_text='Specify the name')
> refcode_prefix = models.CharField("Reference code prefix", 
> max_length=8, help_text='Please enter a prefix to be used as a reference 
> code')
> refcode_counter = models.PositiveIntegerField(editable=False, 
> default=1)
> description = models.TextField("Description", blank=True, null=True, 
> default='', help_text='Enter a short description')
> start_date = models.DateField('Begin date', help_text="Please use the 
> following format: -MM-DD.")
> end_date = models.DateField('End date', help_text="Please use the 
> following format: -MM-DD.")
> date_created = models.DateTimeField('Created on', auto_now_add=True, 
> blank=True, null=True)
> created_by = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, 
> blank=True, default='')
>
>
> class SubeventForm(ModelForm):
> class Meta:
> model = subevents
> exclude = ('date_created', 'created_by',)
>
>
> class locations(models.Model):
> active = models.BooleanField('Active', default=True)
> name = models.CharField("Location name", max_length=60)
> address = models.TextField("Postal address", blank=True, default='')
> notes = models.TextField("Notes", blank=True, null=True, default='')
> date_created = models.DateTimeField('Created on', auto_now_add=True, 
> blank=True, null=True)
> created_by = models.ForeignKey(settings.AUTH_USER_MODEL, 

Re: Newbie: do I need to upload in order to access data?

2013-08-11 Thread DJ-Tom
Hi Bob


> I'm trying to achieve the following:
>
>- user indicates a file on his/her machine 
>- the program opens the file, reads the data and acts on that
>
>
>
What you want to do is not possible - at least not without client-side 
scripting.

The "program" you refer to is running on your web server, not on the 
machine of the user. 

So before your code can do anything to the users file, it needs to be 
transferred (uploaded) to your server. So there is nothing you can do with 
Django/Python before that.

After that processing, you may give the user a result page with a link to 
the processed file - but from your description I don't know if if this is 
what you want to do.

regards
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to store position of current/active navigation entry

2013-08-10 Thread DJ-Tom
I now came up with this solution:

path = req.get_full_path()
if path.startswith(entry['href']):
entry['active'] = True

thanks for helping :-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Problem with custom user model and built-in admin-forms...

2013-08-10 Thread DJ-Tom
Hi,

I'm trying to get a custom user model to work with the built-in admin app, 
based on the sample code in the documentation 
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#auth-custom-user

Here is my code:

https://gist.github.com/anonymous/91f2c30bdc48a4ca3248

I either get a 

FieldError at /
> Unknown field(s) (date_created) specified for UserAccount
>

or 

ImproperlyConfigured at /
> 'SpcUserAdmin.fieldsets[1][1]['fields']' refers to field 'is_admin' that 
> is missing from the form.
>


When I remove date_created form the field list of the meta class in 
UserCreationForm.

I'm sure there is a small and stupid error on my side, but I just can't 
spot it... HELP :-)



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to store position of current/active navigation entry

2013-08-04 Thread DJ-Tom
Hi,

I don't think I know how to actually do what you are suggesting.

Lets say I have three menu options with the following URLS:

"One" - /one/show
"Two" - /two/show
"Three" - /three/show

Currently I have somthing like this in my main.html page template:

{% if navi %}
> {% for entry in navi %}
> {{ entry.name 
> }}
> {% endfor %}
> {%  endif %}
>

With the following view function:

def show_mainPage(request):
>
> navigation = [ {'href':'/one', 'name':"One"},
>{'href':'/two', 'name':"Two"},
>{'href':'/three', 'name':"Three"}]
> return TemplateResponse(request, 'main_page/main.html', {'navi': 
> navigation, 'main_settings':main_settings.objects.get(id=1)})
>

So how would I set the "active" CSS class in my template for the correct 
nav entry? 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




How to store position of current/active navigation entry

2013-08-01 Thread DJ-Tom
Hi,

I'm currently creating a web app with django that will have a side bar menu 
with several sub-sections.

I'm wondering if there is a "standard" way to store the "current" or 
"active" menu entry so I can highlite it in the menu area each time a 
request takes place.

Is it possible to attach arbitrary information to the current users session 
object?

thanks
thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Looking for best practices regarding Development and production server paths

2013-03-21 Thread DJ-Tom


Am Donnerstag, 21. März 2013 13:04:53 UTC+1 schrieb Tom Evans:
>
> In my settings.py, I set the path to the project template folder and 
> project static files like so: 
>
> import os.path 
> ROOT = os.path.abspath(__file__).rsplit(os.path.sep, 2)[0] 
> TEMPLATE_DIRS = ( 
>   os.path.join(ROOT, 'templates'), 
>   ) 
> STATICFILES_DIRS = ( 
>   os.path.join(ROOT, 'static'), 
>   ) 
>

Ok - this should do the job nicely :-) Thanks! 

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




Re: Looking for best practices regarding Development and production server paths

2013-03-21 Thread DJ-Tom



>
> On Thu, Mar 21, 2013 at 5:05 PM, DJ-Tom <event...@gmail.com 
> >wrote:
> Simple, you maintain two settings.py files, make one with Dev_settings.py 
> and  two with Prod_settings.py.
> You can run dev and production  applications like this 
>
> python manage.py runserver --settings=Dev_settings
>
> python manage.py runserver --settings=Prod_settings
>
> it is all about switching between settings.py files. 
>  


This won't work for me since I'm not using "runserver" on the production 
machine, but Apache/WSGI 

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




Looking for best practices regarding Development and production server paths

2013-03-21 Thread DJ-Tom
Hi,

I'm still a beginner and currently I'm trying to get more familiar with 
Django.

I'm looking for any more detailed best-practices-type description on how 
the development cycle is meant to be managed.

In settings.py, there are paths like TEMPLATE_DIRS and STATICFILE_DIRS, how 
is this supposed to work when paths on the development machine differ from 
the production server?

I suppose I do not have to adjust those paths every time I upload a new 
version of my application?

Another point, how do I manage the time until the database schemes are 
updated to a new version (I'm planning to use south for database scheme 
maintenance) and nobody is supposed to use the application until 
everything's able to work again?

So far that's all I can think of right now - but I'm sure a lot more 
questions will rise the next few days :-)

Thomas

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




FreeBSD+wsgi+django static and media how-to-do

2013-03-13 Thread dj-konst
Hi, I'm new in django 
I use FreeBSD9+wsgi+django (unique host) but meet problems with static 
files...
There are sections in Django Documentation 1.5 ( 4.13.4 Serving static 
files in production )... 
but there is no enough details for me. Where to read about serving static 
files in more detals (examples ...)?
Thanks

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




Re: Problems install/download Django 1.5

2013-03-11 Thread DJ-Tom

Fixed - downloaded from Github and installed manually... everything's fine 
:-)

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




Problems install/download Django 1.5

2013-03-11 Thread DJ-Tom
Hi,

I'm trying to get the new Django release, but the download of the .tar.gz 
file stops with errors:
*
*
*  Downloading from URL 
http://pypi.python.org/packages/source/D/Django/Django-1.5.tar.gz#md5=fac09e1e0f11bb83bb187d652a9be967
*
*Exception:*
*Traceback (most recent call last):*
*  File "D:\Python27\lib\site-packages\pip\basecommand.py", line 107, in 
main*
*status = self.run(options, args)*
*  File "D:\Python27\lib\site-packages\pip\commands\install.py", line 256, 
in run*
*requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, 
bundle=self.bundle)*
*  File "D:\Python27\lib\site-packages\pip\req.py", line 1018, in 
prepare_files*
*self.unpack_url(url, location, self.is_download)*
*  File "D:\Python27\lib\site-packages\pip\req.py", line 1142, in unpack_url
*
*retval = unpack_http_url(link, location, self.download_cache, 
self.download_dir)*
*  File "D:\Python27\lib\site-packages\pip\download.py", line 463, in 
unpack_http_url*
*download_hash = _download_url(resp, link, temp_location)*
*  File "D:\Python27\lib\site-packages\pip\download.py", line 380, in 
_download_url*
*chunk = resp.read(4096)*
*  File "D:\Python27\lib\socket.py", line 380, in read*
*data = self._sock.recv(left)*
*  File "D:\Python27\lib\httplib.py", line 561, in read*
*s = self.fp.read(amt)*
*  File "D:\Python27\lib\socket.py", line 380, in read*
*data = self._sock.recv(left)*
*error: [Errno 10054] Eine vorhandene Verbindung wurde vom Remotehost 
geschlossen*

are there currently any known download server issues?

thx 
thomas

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




Re: Struggling with static files

2012-10-22 Thread DJ-Tom


Am Montag, 22. Oktober 2012 12:06:44 UTC+2 schrieb DJ-Tom:
>
> If I add this to STATICFILES_DIR:
>
>   '/el_test/static'
>
>
AHHH - I was missing the trailing comma after the path name... so 
STATICFILES_DIR was not a valid list.

Everthing's fine now.

Thanks anyways :-)
Thomas

-- 
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/-/XgCWsaAhaqoJ.
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: Struggling with static files

2012-10-22 Thread DJ-Tom


Am Montag, 22. Oktober 2012 11:19:42 UTC+2 schrieb Xavier Ordoquy:
>
> Hi,
>
> Your static folder should be declared in STATICFILES_DIRS if you want him 
> to be served (see 
> https://docs.djangoproject.com/en/1.4/howto/static-files/#basic-usage about 
> that).
>
>  
>

All the documentation refers to  STATICFILES_DIRS as "this is where tu put 
additional paths" with INSTALLED_APPS/static being the default path. 

If I add this to STATICFILES_DIR:

  '/el_test/static'

...the admin page login completely loses any styling because it can't serve 
the admin css files anymore
(the url's are http://localhost:8000/static/admin/css/login.css and 
http://localhost:8000/static/admin/css/base.css)

So either the documentation is wrong or I understand the word "additional" 
in a different way as the author of the documentation... 

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



Struggling with static files

2012-10-22 Thread DJ-Tom
Hi,

I'm fairly new with Django and currently I'm only "playing around" to get a 
better feeling for the framework.

I have read the documentation and almost all of the posts here about 
configuring static files with the development server but can't get it 
working.

I wanted to modify the admin login screen to show a company logo, so I 
copied base_site.html to /templates/admin/ and added this:

   


This is how my directory structure looks like:

el_test
  el_test
static
   logo.gif
settings.py
urls.py
  templates
admin
  base_site.html

- Settings.py:

STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

I also added the following to urls.py

   urlpatterns += staticfiles_urlpatterns()

The HTML in the admin logon screen looks like this, so basically the URL 
seems to be OK


  
  Test Admin


Calling http://localhost:8000/static/logo.gif directly shows a 404 error.

As far as I have understood this should work with the dev server and 
debug=true without calling collectstatic

I have also tried moving the /static/ folder around various locations below 
the project directory... 

I'm sure there is only some small thing missing...

Any help is highly appreciated :-)

Thomas

-- 
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/-/YqVkguDtVwEJ.
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: Problems with simple "hello world" test - "ImportError: Could not import settings"

2012-09-19 Thread DJ-Tom

I have now found extensive documentation as to why and how Apache has to be 
configured with Django and mod_wsgi here 
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

-- 
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/-/WQXagLAa1bsJ.
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: Problems with simple "hello world" test - "ImportError: Could not import settings"

2012-09-13 Thread DJ-Tom


> Ok... GREAT! Now it works :-) (well... sort of, more below... ) but I had 
>> to restart Apache to make config changes effective... is that "normal"?
>>
>> I think important things like "you have to restart the webserver to make 
>> changes life" should go into the tutorial in *BIG RED LETTERS* 
>>
>
>
> The tutorial, by design, doesn't mention Apache at all. That's because 
> it's heavily recommended that you use the built-in devserver for 
> development, for precisely this reason. That's what it's for.
>
>
Basically I always try to have the same environment for development as I 
also use for actual production - I'm lucky that my projects are small 
enough so i can do that :-) to avoid last minute surprises when trying to 
deploy the application to the public.

-- 
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/-/qPvYvgWTXS8J.
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: Problems with simple "hello world" test - "ImportError: Could not import settings"

2012-09-11 Thread DJ-Tom


Am Dienstag, 11. September 2012 10:20:16 UTC+2 schrieb Chang.Jian:
>
> "d:/wwwroot/djtest/djtest/" was already in system path, so I think you 
> should set DJANGO_SETTINGS_MODULE like this: 
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
>
> try it!
>
>
Ok... GREAT! Now it works :-) (well... sort of, more below... ) but I had 
to restart Apache to make config changes effective... is that "normal"?

I think important things like "you have to restart the webserver to make 
changes life" should go into the tutorial in *BIG RED LETTERS* 

Now I get a "regular" Django exception:

NameError: name 'admin' is not defined


-- 
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/-/y4GYmsDZkKwJ.
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: Problems with simple "hello world" test - "ImportError: Could not import settings"

2012-09-11 Thread DJ-Tom
Am Dienstag, 11. September 2012 00:43:44 UTC+2 schrieb Mike Dewhirst:
>
>
> Try dropping this down to "djtest.settings". Also make sure you have a 
> file in each of your folders called __init__.py 
>
> This tells Python the folder is part of the package. 
>

Sorry - but this does not help. Just to be sure that I'm not missing 
anything essential, this is all I have so far:

d:\djtest\
   manage.py
   data.sql
   \djtest\
  __init__.py
  settings.py
  urls.py
  wsgi.py

Am I correct to assume that this should be sufficient to call at least the 
/admin/ interface?

I have activated this in urls.py:  url(r'^admin/', 
include(admin.site.urls)),

And this in settings.py: 'django.contrib.admin',

But as django does not seem to be able to find settings.py... hm

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



Problems with simple "hello world" test - "ImportError: Could not import settings"

2012-09-10 Thread DJ-Tom
Hi,

I'm new to django and python at the same time (Nightmare ) and currently 
struggling to get a basic understanding of how everything works and how the 
different components are connected to each other.

My setup is a s follows:

- Apache 2.2 running as a service under Windows 7
- mod_wsgi
- Python 2.7.3
- django 1.4.1
- web server docroot under d:\wwwroot
- test project under d:\wwwroot\djtest\djtest set up with 

django-admin.py startproject djtest


Basically I think that almost everything is set up correctly, things like 
"python manage.py syncdb" work without probkems, I could activate 
django.contrib.admin and create the database without errors - only if I try 
to access the admin I get the following apache error.log:

mod_wsgi (pid=6804): Exception occurred processing WSGI script 
> 'D:/wwwroot/djtest/djtest/wsgi.py'.
> Traceback (most recent call last):
>   File 
> "D:\\Python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 
> 219, in __call__
> self.load_middleware()
>   File 
> "D:\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 
> 39, in load_middleware
> for middleware_path in settings.MIDDLEWARE_CLASSES:
>   File "D:\\Python27\\lib\\site-packages\\django\\utils\\functional.py", 
> line 184, in inner
> self._setup()
>   File "D:\\Python27\\lib\\site-packages\\django\\conf\\__init__.py", line 
> 42, in _setup
> self._wrapped = Settings(settings_module)
>   File "D:\\Python27\\lib\\site-packages\\django\\conf\\__init__.py", line 
> 95, in __init__
> raise ImportError("Could not import settings '%s' (Is it on 
> sys.path?): %s" % (self.SETTINGS_MODULE, e))
> ImportError: Could not import settings 'djtest.djtest.settings' (Is it on 
> sys.path?): No module named djtest.djtest.settings
>

wsgi.py looks like this:


import os
> import sys
>
> path = 'd:/wwwroot/djtest/djtest/'
> if path not in sys.path:
> sys.path.append(path)
>
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djtest.djtest.settings")
>
> # This application object is used by any WSGI server configured to use this
> # file. This includes Django's development server, if the WSGI_APPLICATION
> # setting points here.
> from django.core.wsgi import get_wsgi_application
> application = get_wsgi_application()
>

HELP! :-)))

-- 
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/-/fl5wkcGjpuQJ.
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: Attribute error

2011-05-01 Thread DJ Ango
Capitalize class names.

class Wish(models.Model):
 the_wish = models.CharField(max_length=100)

On Apr 30, 4:26 pm, Pulkit Mehrotra  wrote:
> changed the name but nothing happened
> the django version is 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: form input

2011-05-01 Thread DJ Ango
in models.py you define your database fields:

The use a ModelForm: 
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelform

Or try the generic create/update/delete views:
http://docs.djangoproject.com/en/dev/ref/generic-views/?from=olddocs#create-update-delete-generic-views

On Apr 30, 4:24 pm, Pulkit Mehrotra  wrote:
> can anyone tell me the precise way of taking an input from a form and
> storing it in a database
> or provide a good link where i can find one
>
> i am a newbie so please help me
>
> 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.



Where can I find the admin/base_site.html

2011-02-23 Thread DJ Chung
I am going through the tutorial on Djangoproject.com.  I'm trying to
work on templates and I don't know where to find admin/base_site.html

Where's the actual code I can copy and paste?

-- 
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 ORM memory leaks in standalone script

2010-06-04 Thread Dj Gilcrease
On Fri, Jun 4, 2010 at 6:44 AM, yakovenko  wrote:
> import os
> import sys
> os.environ['DJANGO_SETTINGS_MODULE'] = 'md.settings'
> sys.path.append('/md/lib')
> from django.db import close_connection, reset_queries
> from md.mddata.models import Info
> def test():
>  for i in Info.objects.all():
>  pass

do

for i in Info.objects.all().iterator(): #or just .iterator() forget which

and you wont leak

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



Re: hello django users, I have one doubt. I am doing one django project. It shows one SyntaxError in the line(if not created:) in views.py file.I attached the particular in that. I want the reason o

2010-06-04 Thread Dj Gilcrease
syntax error is because of capitol 'I' in if

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



Re: Looping through models

2010-06-01 Thread Dj Gilcrease
On Tue, Jun 1, 2010 at 12:57 PM, Luca Casagrande
 wrote:
> Is there a way to create a loop changing only the model name?

geo_models = [model1, model2, model3, ...]
for m in geo_models:
m.objects.filter(geom__intersects=fs[0].geom)

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



Re: Uploaded File Security

2010-05-20 Thread Dj Gilcrease
On Thu, May 20, 2010 at 12:38 AM, Lee Hinde  wrote:
> This is going to be a hosted solution and if I add LDAP maintenance to the
> new things they have to do, I think they'll go back to shuffling Excel files
> back and forth via email.
> One Apache log-in and then one Django log-in? Blech.
> Let's see what anyone else has to say...

We solved this issue by having django upload the file to a directory
that is not reachable via the web server and then server the files in
a view. This is slower and more memory intensive then letting the web
server handle it, but you can permission the view how you want and not
require extra logins

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



Re: Is it possible to add a table on my database with a django code ?

2010-05-19 Thread Dj Gilcrease
On Wed, May 19, 2010 at 8:18 AM, Pep  wrote:
> Hi everybody !
>
> I would like to know if it's possible to add automatically a table on
> my database when, for example, a new member subscribe on my website ?
>
> I mean, if I would like to do it manually, I'll have to change my
> Model and then to do manage.py syncdb. And that's all. But
> automatically ???

Yes you can, as long as you have a model to create. How to do it is a
little convoluted, and the need to do this in reality is rare, but
here is how I would do it

1) Create a dynamic_models app that has a models.py that only has the
required imports
2) During registration at the point you activate the users account you
have a method that will append a new model to the dynamic_models
models.py file. The model must be uniquely named
3) Then once the new model is in the file call 'call_command('syncdb',
verbosity=0, interactive=False)'

And poof you have a new model in the DB for each user registered.

Details on programmatically calling management commands can be found
in the django documentation.

Now that I have told you how to do it I would like to hear your use
case because there is an 80+% chance you dont need to do this to
achieve the results you are looking for.

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



Re: Problem_Inline_max_num

2010-05-10 Thread Dj Gilcrease
On Mon, May 10, 2010 at 3:29 PM, Javier Guerra Giraldez
 wrote:
> On Mon, May 10, 2010 at 11:23 AM, carlos  wrote:
>> I'm sorry but this is a translation of google
>
> even worse, it's a google translation of a text without punctuations.


It isnt all that hard to figure out his meaning if you take a second to read it.

Basically he is saying that in 1.2RC1 setting the max_num option on a
InlineModelAdmin  to a number less then the current number of objects
that should show causes an error. He does not however give any
traceback which would be helpful.

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



Re: permissions at per specific object instance

2010-05-05 Thread Dj Gilcrease
On Wed, May 5, 2010 at 4:09 PM, zweb  wrote:
> I need to build "permissions at per specific object instance" for my
> app.
>
> Anyone has already done it ?  Also it says django developers are
> already discussing it..
>
> You can please refer me to the threads or blog posts on it.

http://djangoadvent.com/1.2/object-permissions/

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



Re: django_audit 0.0.2

2010-05-05 Thread Dj Gilcrease
On Wed, May 5, 2010 at 10:49 AM, Gustavo Narea
<gna...@tech.2degreesnetwork.com> wrote:
> On May 5, 3:45 pm, Dj Gilcrease <digitalx...@gmail.com> wrote:
>> I also think Euan Goddard has already registered django-audit on pypi
>> (http://pypi.python.org/pypi/django-audit/0.9/)
>
> That's what I meant, Euan and I work together :)


Ahh ok, well I wont be pushing my audit app to PYPI in the near future
so no worries about naming conflicts there

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



Re: [ANN] django_nav 0.6

2010-05-05 Thread Dj Gilcrease
Now in PYPI
http://pypi.python.org/pypi/django_nav/

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



Re: django_audit 0.0.2

2010-05-05 Thread Dj Gilcrease
On Wed, May 5, 2010 at 10:06 AM, Gustavo Narea
 wrote:
> Hello,
>
> I would suggest you try to register "django_audit" on PYPI and see if
> it allows you to do so.
>
> We had already registered the package"django-audit" (note the hyphen
> instead of an underscore, which is exactly how we've always spelled
> it). I'm not sure if PYPI will let you register "django_audit" because
> when you create Python eggs hyphens are replaced with underscores.

I personally have little to no interest in pushing my project to PYPI
as that would mean I am committed to  maintaining it for others which
I am not at this point. I developed it as an internal solution and
figured it might be useful to other people so put the project up.

I also think Euan Goddard has already registered django-audit on pypi
(http://pypi.python.org/pypi/django-audit/0.9/)

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



[ANN] django_nav 0.6

2010-05-05 Thread Dj Gilcrease
Code @ http://code.google.com/p/django-nav/

This is a bug fix release to make conditionals work again.

Before 1.0 is ready to go I want to add the ability to dynamically
generate nav manus either via a DB, Config file, Cache, etc.

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



Re: django_audit 0.0.2

2010-05-04 Thread Dj Gilcrease
On Tue, May 4, 2010 at 4:21 AM, Euan Goddard
 wrote:
> This is all very well, but should either of these projects get to pypi
> there's going to be some serious trouble. Since I'm the main author of
> the "noSQL" django-audit, please let me know how you want to proceed.
> I'm already using the project in some pre-production code so would
> rather not rename my project. If you could rename yours that would be
> really helpful as this clearly a case of two people simultaneously
> coming up with the same name.

Google code wont let me change the project name without deleting and
recreating the project so I just added a note to the top

"This is a fairly comprehensive Audit Trail App for use with standard
RDBMS databases. If you are looking for a solution for NoSQL there is
a great project by the same name but differing author @
https://launchpad.net/django-audit that uses MongoDB."

and a little NoSQL vs SQL comparison of the two solutions

"Not all of us can use a NoSQL audit solution due to business rules or
other constraints. Django Audit for MongoDB preserves field type in
the audit history, which is lost django-audit for SQL. This loss of
field type is mitigated by the field formatters which allow you to
record the field how you want to display it to the person reading the
audit history.

Ultimately the solution you pick will depend on your requirements and
capabilities, both work, though I believe my solution takes a bit more
work for the developer to setup and configure on each model then then
MongoDB solution (have not looked too deeply into the code over there
as I cannot use MongoDB for the projects I need an Audit history in)"



I also added links to a few of the other audit solutions out there

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



Re: django_audit 0.0.2

2010-04-30 Thread Dj Gilcrease
On Fri, Apr 30, 2010 at 9:28 AM, Gustavo Narea
 wrote:
> Sorry, but did you know there's already a project with that name?
> https://launchpad.net/django-audit

Ya I saw the announcement on it the day I pushed my code to google,
hence my remark about not being tied to a "NoSQL" solution. I had
already created the project name by the time I saw the announcement so
just went with 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to filter a query set based on a calculated date value?

2010-04-30 Thread Dj Gilcrease
On Fri, Apr 30, 2010 at 6:26 AM, Derek  wrote:
> MyModel.objects.filter( (my_date_field + relativedelta(months =
> +my_month_field))__lt = today )

wouldnt that be the same as my_date_field__gt=(today -
relativedelta(months=my_month_field))

my_date_field + my_month_field < today
my_date_field > today - my_month_field

but assuming you want a range of dates from (my_date_field +
my_month_field) to today

__range=(start_date, end_date)

would be what you are looking for.

if you mean using the values stored in the DB without first fetching
them to perform the calculations, then the general answer is no, but
you can always dig into ModelManagers and use raw sql

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



  1   2   >