Re: Abridged summary of django-users@googlegroups.com - 18 updates in 5 topics

2024-02-22 Thread jonas john
Hello guys,

My name is Jonas, please I would be happy to join the project
+234 8176473566

On Wed, 21 Feb 2024 at 14:02,  wrote:

> django-users@googlegroups.com
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/django-users/topics>
>  Google
> Groups
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview>
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview>
> Today's topic summary
> View all topics
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/django-users/topics>
>
>- I am interested. +2348162698617 Github: fosajeffRe: Exciting
>Opportunity: Join Our Django WhatsApp Bulk Messaging Project!
><#m_4150572243922862916_group_thread_0> - 13 Updates
>- Redesign of agricultural project with python django and next.js
>technologies. <#m_4150572243922862916_group_thread_1> - 2 Updates
>- how to display group and create user permission in templates?
><#m_4150572243922862916_group_thread_2> - 1 Update
>- Question about `_meta` API's naming
><#m_4150572243922862916_group_thread_3> - 1 Update
>- Agricultural and livestock project using python, django and next
>technologies. <#m_4150572243922862916_group_thread_4> - 1 Update
>
> I am interested. +2348162698617 Github: fosajeffRe: Exciting Opportunity:
> Join Our Django WhatsApp Bulk Messaging Project!
> <http://groups.google.com/group/django-users/t/4c27c87e899e0fe3?utm_source=digest&utm_medium=email>
> Eleuthere Aluma : Feb 20 01:34AM +0200
>
> Hello, my name is Eleuthère AL. I'm interested in these opportunity my num
> for whatsapp is +243893111979
> ..
>
> Le lun. 19 févr. 2024 à 18:21, Efosa Jeffrey Okooboh <
> okoobohef...@gmail.com> ...more
> <http://groups.google.com/group/django-users/msg/3188436276725?utm_source=digest&utm_medium=email>
> Ogunkoya Mayowa : Feb 20 04:27AM +0100
>
> I'd love to join Django group
>
> On Sun, Feb 18, 2024, 5:49 PM Amitesh Tripathi 
> wrote:
>
> ...more
> <http://groups.google.com/group/django-users/msg/318848820a28a?utm_source=digest&utm_medium=email>
> Galuh Akbar Putra : Feb 20 09:15AM +0700
>
> Saya tertarik
>
> Pada Sel, 20 Feb 2024 07.22, Chisom Iheanacho 
> menulis:
>
> ...more
> <http://groups.google.com/group/django-users/msg/318849920b37a?utm_source=digest&utm_medium=email>
> Fabrice coder : Feb 20 07:32AM +0200
>
> I am interested
>
> On Tue, Feb 20, 2024 at 2:22 AM Chisom Iheanacho 
> wrote:
>
> ...more
> <http://groups.google.com/group/django-users/msg/3188828686c9c?utm_source=digest&utm_medium=email>
> Yoan Bello : Feb 20 10:11AM -0500
>
> Hello, my name is yoan and i am interested in this exciting opportunity.
>
> El dom, 18 feb 2024 a la(s) 11:48 a.m., SURAJ TIWARI (
> suraj12go...@gmail.com)
> escribió:
>
> ...more
> <http://groups.google.com/group/django-users/msg/31ba204f12308?utm_source=digest&utm_medium=email>
> miclem abasie : Feb 20 10:56AM +0100
>
> I'm interested, please how do I go about it?
>
> ...more
> <http://groups.google.com/group/django-users/msg/31ba2295b6d81?utm_source=digest&utm_medium=email>
> cleyson cassio : Feb 20 01:54PM -0300
>
> Olá !
>
> Tenho interesse!
>
> Estou disponível: Aqui no Whatsapp <https://wa.me/5584998059947>
>
> E-mail: mailto:cleysoncas...@gmail.com  ...more
> <http://groups.google.com/group/django-users/msg/3225b70503f85?utm_source=digest&utm_medium=email>
> Atif Usman : Feb 20 11:39PM +0500
>
> I am interested +923343467875
>
> On Mon, Feb 19, 2024 at 9:20 PM Efosa Jeffrey Okooboh <
> ...more
> <http://groups.google.com/group/django-users/msg/15143553e58c?utm_source=digest&utm_medium=email>
> Noah Nkalan : Feb 20 10:14PM +0300
>
> i want to join on this opportunity i like django i was try to about learn
> about documentation is so amazing
>
> ...more
> <http://groups.google.com/group/django-users/msg/17dceb24369d?utm_source=digest&utm_medium=email>
> Mordecai Etukudo : Feb 20 12:48PM -0800
>
> How do I join the project
>
> On Tuesday, February 20, 2024 at 8:32:04 PM UTC+1 Noah Nkalan wrote:
>
> ...more
> <http://groups.google.com/group/django-users/msg/1c04802f0e25?utm_source=digest&utm_medium=email>
> Christopher Esiso : Feb 20 10:56PM +0200
>
> I'm interested to join you guys.
>
> Best regards!
>
> ...more
> <http://groups.google.com/group/django-users/msg/1e7fae242898?utm_source=digest&utm_medium=email>
> Atif Usman : Feb 21 1

django.core.exceptions.FieldError: Related Field got invalid lookup: relation_type

2021-02-22 Thread Jonas Kiefer

Hi folks,

i implemetned the following models:

```python
class MetadataRelation(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
from_metadata = models.ForeignKey('Metadata', on_delete=models.CASCADE, 
related_name='from_metadatas')
to_metadata = models.ForeignKey('Metadata', on_delete=models.CASCADE, 
related_name='to_metadatas')
relation_type = models.CharField(max_length=255, null=True, blank=True, 


class Metadata(Resource):
...
related_metadatas = models.ManyToManyField('self', through=
'MetadataRelation', symmetrical=False, related_name='related_to+', blank=
True)
```

I want to filter a queryset of `Metadata` objects by the related field 
called `relation_type` like: `Metadata.objects.filter(
metadata_type=MetadataEnum.SERVICE.value,
is_active=True).exclude(related_metadatas__relation_type
=MetadataRelationEnum.HARVESTED_THROUGH.value) django raises 
django.core.exceptions.FieldError: Related Field got invalid lookup: 
relation_type. 

Why i can't use the related fields as filters if i use the through argument 
for the m2m field?


greetings

Jonas

-- 
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/80e10688-94a5-407a-bd9f-6065f23e8224n%40googlegroups.com.


Django Sass verwenden

2017-05-01 Thread Jonas Niedermair
Ich habe vor einiger Zeit begonnen Django zu lernen. Bisher habe ich immer 
direkt CSS verwendet. Ich möchte jedoch Sass verwenden, weiß jedoch nicht 
wo ich die Sass Dateien in meinem Django Projekt speichern soll und wie ich 
die Sass Datein am besten in CSS konvertieren kann. 

Ich habe bereits versucht mit Pipeline die Sass Dateien in CSS zu 
konvertieren. Das hat auch funktioniert, aber wie schaffe ich es dass die 
CSS Dateien nicht nur im static Ordner des Projektordners sondern im static 
Ordner der jeweiligen App gespeichert werden ?

Ich hoffe ihr könnt mir weiterhelfen

-- 
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/933a2ef5-2a30-493f-be56-12e77a90a073%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Many to Many in Django Admin

2017-02-23 Thread José Vicente Jonas França
Hello!

I Like to know if its possible to display the many-to-many field in both 
pages of Model at Django Admin.
If it is possible how can i do this?

Thanks.

Best Regards,

José Vicente.

-- 
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/12cbbbef-ca8d-4a6d-9454-6e3c2bf2bd4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: parallel test running throwing pickleError

2016-08-04 Thread Jonas Trappenberg
You can debug by adding code like this to django/test/runner.py just after 
it determined the args (around line 315 in django 1.9):

import pickle
for arg in args:
print(arg)
pickle.dumps(arg)

I found that pickle raises the same exceptions as cPickle, but, since it's 
all Python, lets you set breakpoints around the exception to find out 
what's going on.

The ModuleImportFailure for example comes from python's system-wide 
unittest/loader.py from a function called _make_failed_import_test where 
it's dynamically created and hence can't be pickled. Setting a breakpoint 
inside that method around the error message should give you the required 
pointers to fix the import and thus the pickle exception.

For anyone else coming here and debugging pickle exceptions: another 
failure I ran into was from calling unittest.TestCase.addCleanup() with an 
instancemethod, e.g. something like self.addCleanup(self.remove_things). 
Making self.remove_things a global function fixed this too.

Hope this helps!


On Monday, February 29, 2016 at 12:13:08 PM UTC-5, girish ramnani wrote:
>
> when running the django test in parallel using the runner.py . 
> _pickle.PicklingError: Can't pickle  'unittest.loader.ModuleImportFailure'>: attribute lookup 
> ModuleImportFailure on unittest.loader failed
>
> error is thrown, and when the runner is run using a single process. the 
> test suite executes.
>
> I am using a new virtualenv with django installed in editable mode.
>

-- 
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/3989ea02-ce27-4283-b24f-b121d364afea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How force DJANGo choice MEDIA_URL or STATIC_URL in template?

2016-03-01 Thread Jonas Svensson
It seems like you want to use display a default picture if the user does 
not have one.
{% load static %}
{% static "images/default_pic.jpg" as default_pic %}
{{ account.accountuserinfo.picture|default:default_pic }}

Cheers

On Monday, February 29, 2016 at 10:49:53 PM UTC+1, setivo...@gmail.com 
wrote:
>
>
> I need choice base url MEDIA_URL (/media/) - for uploaded user picture, or 
> STATIC_URL (/static/) - picture by default
>
> I am try next:
>
> p> alt="picture_for_{{ account.name }}" id="account_picture">
>
> , but result is MEDIA_URL(STATIC_URL) and path to file.
>
> I am next try:
>
> {% templatetag openvariable %} url 'entry_list' {% templatetag closevariable 
> %}
>
>
> but result is {{ MEDIA_URL }} or {{ STATIC_URL }} (not working)
>
> may by anyone known how solved this problem
> ---
>
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ad20612d-2a90-4108-8737-d4bbe99a262c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to install on windows?

2016-02-16 Thread Jonas Svensson
Hi,
you already have virtualenv with python3.5.

To create a new virtual environment you can do.

c:\Temp>c:\Python35\python c:\Python35\Tools\Scripts\pyvenv.py myenv


(https://docs.python.org/3/library/venv.html)

Cheers

On Monday, February 15, 2016 at 1:49:33 AM UTC+1, bob gailer wrote:
>
> I tried following the instructions at 
> https://docs.djangoproject.com/en/1.9/howto/windows/. 
>
> I installed Python in C:\python35. After that most things didn't seems 
> to work as promised. 
>
> Python 3.5 does not appear in the PATH. (Python 3.3 is there.) Yes I 
> checked |Add Python 3.5 to PATH. 
>
> C:\>python --version 
> Python 3.3.3 
>
> I typed (at the C: prompt) pip install virtualenvwrapper-win 
>
> 'pip' is not recognized as an internal or external command, 
> operable program or batch file. 
>
> After searching I found pip in C:\python35/scripts 
>
> So I changed to that directory and typed 
> ||C:\python35/scripts>||pip install virtualenvwrapper-win 
>
> That worked.| 
>
> |Then I tried |mkvirtualenv myproject and got 
> 'virtualenv.exe' is not recognized as an internal or external command, 
> operable program or batch file. 
>
> A few years ago I tried to install Django. I recall running into similar 
> issues. 
>
> I must be missing something. Any guidance would be appreciated. 
>

-- 
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/e3d50098-cc28-4937-8960-8544ccad0df7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why do the IDs in many to many join tables change when there is no change.

2015-01-19 Thread jonas hagstedt
First off: this sounds like a bug, please log an issue on Github with as 
much info as possible (router, serializer and model etc. if you can)

I would recommend not using `SelfPublishModel` in this scenario, instead 
publish the event manually.
If you do it manually you lose out on having it publish when you save via 
admin (but you do get more control over when the publish occur, and you 
could of course add an action to admin to do this).

Two ways you can publish the model:

Using `publish_data` you could go about it this way


from swampdragon.pubsub_providers.data_publisher import publish_data

def publish_event(event):
serializer = EventSerializer(instance=event)
channel = 'public_events'
publish_data(channel, serializer.serialize())


The "drawback" of this is that you have to know the actual channel you are 
publishing to, and you wouldn't be able to use the `DataMapper` in 
JavaScript since it doesn't know if this set of data was a create, delete 
or an update action (publish_data was made with the intent to publish 
dictionaries rather than models).

If you use the `DataMapper` in JS, or have lots of subscribers on various 
channels all relating to the same model, or don't know the channel name, 
then use `publish_model` instead (this is probably the most recommended 
way).

`publish_model` will find the channels for you, but requires to know the 
action (was it an update, was it a delete or was it created?)

 from swampdragon.pubsub_providers.model_publisher import publish_model

def publish_event(event):
action = 'created'  # you can use created, updated, deleted
publish_model(event, EventSerializer, action)


So if you have a view where you create/update events you can simply add 
this (assuming CBV) to your view:

class EventCreateView(CreateView):
model = Event

def form_valid(form):
event = form.save()
publish_event(event)
return HttpResponseRedirect(self.get_success_url())

You could easily modify `publish_event` to take the action as a parameter





On Monday, January 19, 2015 at 2:57:16 PM UTC+1, Shazwi Suwandi wrote:
>
> I'm using Swampdragon to provide real time updates to the system since I 
> don't want users to keep refreshing their page to get them. I used the
> *ModelPublisherRouter* which causes me to get any updates to a particular 
> model. 
>
> I currently have an Events model with the following attributes:
> class Event(SelfPublishModel, models.Model):
> serializer_class = EventSerializer
> name = models.CharField(max_length=250)
> description = models.CharField(max_length=250)
> location = models.CharField(max_length=250)
> privacy = models.CharField(max_length=250)
> startDate = models.DateField()
> endDate = models.DateField()
> allDay = models.BooleanField(default=False)
> noOfAttendees = models.IntegerField(default=0)
> noOfNonAttendees = models.IntegerField(default=0)
> noOfInvitees = models.IntegerField(default=0)
> eventOwner = models.ForeignKey(User, related_name='eventsOwned')
> eventInvitees = models.ManyToManyField(User, 
> related_name='eventInvitees')
> eventAttendees = models.ManyToManyField(User, 
> related_name='eventAttendees')
> eventNonAttendees = models.ManyToManyField(User, 
> related_name='eventNonAttendees')
>
> As you can see, there are three many to many relationships with the User 
> table. If I edit an event's name and description without doing any 
> changes to eventInvitees, eventAttendees or eventNonAttendees, I was 
> expecting just one "publish" from Swampdragon since there is a change
> in the Events row. However, it "publishes" the update, 6 more times and I 
> suspect it is because of the rows in the join tables as it does not publish
> 6 times when I comment out these relationships. 
>
> I then checked the join tables and every time I do an update through the 
> admin UI, even if I did not add or remove users, it changes the primary key 
> of the rows, causing the publish from Swampdragon to be done. Is there any 
> way I can avoid having the IDs change?
>

-- 
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/9bdf564e-2456-4326-b965-213b0fd5307c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need some advice on how to go about building a real time web app.

2015-01-03 Thread jonas hagstedt
Yes I am the author of that article.

Libraries does make life easier, as long as they are the right libraries 
for the job.

If you are unfamiliar with Angular I would actually recommend not using it.

*  Angular 2.0 is supposedly not going to be backwards compatible (it 
actually looks like a totally different framework).
*  As you mentioned, you don't need to use Angular with SwampDragon.
*  It's another layer of complexity.
*  The blog post I linked to pretty much covers the basis for doing real 
time notifications, and isn't using Angular, so you could more or less just 
tweak that code and add it to your project.


On Friday, January 2, 2015 4:12:10 PM UTC+1, Shazwi Suwandi wrote:
>
> Michiel: Ah, that's myopic on my part. Both sides are important. 
>
> Jonas: I see I see. I keep thinking that libraries will make my life a bit 
> easier but maybe what I currently need now does not require the use of 
> them. And are you the author of 
> the article? (I'm assuming it's the same Jonas) Thank you so much for this 
> link!! I'll go read it up. 
>

-- 
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/378c226c-9a93-4be6-8dfc-e2d282b98d12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need some advice on how to go about building a real time web app.

2015-01-02 Thread jonas hagstedt
Personally I don't use any library between Angular and Django (so I don't 
know about django-angular).

I create specific templates for Angular so I don't have to change the {{ 
and }] syntax (you can also use the {% verbatim %} tag in your templates if 
you don't want to create individual templates).

If you want to do notifications with SwampDragon there is a blog post about 
that here: 
http://wildfish.com/blog/2014/12/09/swampdragon-real-time-django-notifications/ 
(including desktop notifications from the browser) along with a Github repo 
with the source code.
You could probably take most of that code and adopt it to your own project.


On Friday, January 2, 2015 1:36:40 PM UTC+1, Shazwi Suwandi wrote:
>
> Hi group,
>
> I'd like to get some guidance on how to go about thinking about the 
> structure of the web app I'm trying to build.
> From a high level perspective, I'm trying to make a web app that 
> facilitates a small business doing camera rentals. 
>
> To give a use case, if a user makes a rental booking for a customer in the 
> web app, it'll send a notification to the user
> who is in charge of packing the items in real-time. I was searching up 
> about real-time Django and I landed onto 
> Swampdragon, which led me to learn about Angular.js (I know, I don't have 
> to use Angular for Swampdragon but I was
> kinda curious). That then led me to learn how much I can shift items like 
> validation to the client side and leave Django to 
> do the rest. 
>
> Some questions I'd like to ask: 
> 1) Am I adopting the right approach to make the app real time? In this 
> case, using Swampdragon for subscribing to messages etc.
> 2) Is django-angular an appropriate way to integrate Angular.js with 
> Django? It'd be nice to use a lot of the client side functionalities of 
> Angular.
>
> Curious and a little bit overwhelmed.
>
>
>

-- 
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/31bbb0e2-1997-40d4-87dd-0a0c61b28653%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Swampdragon, the realtime framework for Django seems interesting. But will it scale ?

2014-12-17 Thread jonas hagstedt
I ignore E501 as I find it a silly rule, but if I don't then there will be 
pep8 issues a plenty, so that would explain it.

Thanks for taking the time to looking at the code though. 
Next version will have some JS rewrite (hopefully without breaking 
backwards compatibility)


On Wednesday, December 17, 2014 2:46:12 PM UTC+1, Cal Leeming wrote:
>
> Thanks for the reply, I was almost sure there were more PEP8 violations, 
> line length and such, but perhaps my eyes failed me so I'll recheck that. 
>
> And sure I'd be more than happy to go into detail/specifics on my 
> reasoning about the API, I've got two other promised reviews in the queue 
> (Django itself and DRF) so it'll be a couple of weeks before I can spend 
> some time on this.
>
> I completely agree on the tunnel vision, I've worked on projects in the 
> past where I was so sure it was the right way, and then others came along 
> and absolutely destroyed my code with their review (and they were right to 
> do so). Code reviews can be a bit demoralizing sometimes, especially when 
> you have vested a lot of time/effort into them, hence why I tried to focus 
> on the positives more than the negatives.
>
> Cal
>
> On Wed, Dec 17, 2014 at 1:33 PM, jonas hagstedt  > wrote:
>>
>> You are right about pep8, there were two pep8 violations in there (fixed 
>> that after reading this).
>>
>> *  There is a CI setup with Codeship. After reading this I made the badge 
>> available on Github (good point).
>> *  It is deeply integrated with Django by design.
>> *  I am reviewing the JavaScript, but it works so there is nothing 
>> stopping anyone from using it (but you are right about the JS).
>> *  I honestly don't remember the exact date I started developing 
>> SwampDragon but I don't think it was long before the initial commit.
>>
>> I am interested in knowing what it is about the API implementation that 
>> looks wonky. 
>> It's always good with fresh eyes on a project, so I would love to hear 
>> more details on this.
>>
>> It's been good to read these comments as you tend to get tunnel vision 
>> when you work on something after a while.
>>
>> None of these points are actually qualifying if you should use it in 
>> production or not (don't get me wrong, the points are all good).
>>
>> Should you use this in production?:
>> *  Does it perform well enough?
>> *  Is it secure enough?
>>
>> and these two questions depends a lot on your code base / project 
>> requirements.
>>
>> I would love to hear more about the wonky API though if you wouldn't mind.
>>
>> Cheers
>>
>>
>> On Wednesday, December 17, 2014 12:23:52 AM UTC+1, Cal Leeming wrote:
>>>
>>> This actually looks like an interesting framework, and I'd like to start 
>>> off with the good points.
>>>
>>> The author (Jonas) has very kindly shared his work the community, and I 
>>> really do applaud the effort he has put into this. SPAs (single page 
>>> applications) are becoming much more common, and frameworks like this help 
>>> raise awareness about why they are so awesome. Using websockets can help in 
>>> many ways, it can greatly reduce the overhead of each request by reducing 
>>> the total req/resp size and increase async throughput by pipelining 
>>> potentially thousands of queries per second on the same connection (using 
>>> pub/sub channels). It also lets you think outside the box in terms of API 
>>> design, if you use a guaranteed pub/sub delivery mechanism then recovering 
>>> from broken connection state becomes super easy.
>>>
>>> This project does have good intentions, but the question of "can it be 
>>> used in production" doesn't just come down to performance, and upon code 
>>> inspection I do have some concerns;
>>>
>>> * Lack of maturity, initial commit was March 2014, not many 
>>> closed/opened issues, the author has not made it clear how long this has 
>>> been in dev for.
>>> * Reasonable amount of downloads on pypi and "stars" on github
>>> * Code is not up to PEP8 standards
>>> * No public CI testing
>>> * JS does not have modular structure, does not have a sane design 
>>> pattern, and does not adhere to require/AMD
>>> * JS has some unit tests, but they don't appear to be functional or 
>>> recently updated. On first glance, I'd say coverage is minimal and that TDD 
>>> probably hasn't been followed.
>>> * API implementat

Re: Swampdragon, the realtime framework for Django seems interesting. But will it scale ?

2014-12-17 Thread jonas hagstedt
You are right about pep8, there were two pep8 violations in there (fixed 
that after reading this).

*  There is a CI setup with Codeship. After reading this I made the badge 
available on Github (good point).
*  It is deeply integrated with Django by design.
*  I am reviewing the JavaScript, but it works so there is nothing stopping 
anyone from using it (but you are right about the JS).
*  I honestly don't remember the exact date I started developing 
SwampDragon but I don't think it was long before the initial commit.

I am interested in knowing what it is about the API implementation that 
looks wonky. 
It's always good with fresh eyes on a project, so I would love to hear more 
details on this.

It's been good to read these comments as you tend to get tunnel vision when 
you work on something after a while.

None of these points are actually qualifying if you should use it in 
production or not (don't get me wrong, the points are all good).

Should you use this in production?:
*  Does it perform well enough?
*  Is it secure enough?

and these two questions depends a lot on your code base / project 
requirements.

I would love to hear more about the wonky API though if you wouldn't mind.

Cheers


On Wednesday, December 17, 2014 12:23:52 AM UTC+1, Cal Leeming wrote:
>
> This actually looks like an interesting framework, and I'd like to start 
> off with the good points.
>
> The author (Jonas) has very kindly shared his work the community, and I 
> really do applaud the effort he has put into this. SPAs (single page 
> applications) are becoming much more common, and frameworks like this help 
> raise awareness about why they are so awesome. Using websockets can help in 
> many ways, it can greatly reduce the overhead of each request by reducing 
> the total req/resp size and increase async throughput by pipelining 
> potentially thousands of queries per second on the same connection (using 
> pub/sub channels). It also lets you think outside the box in terms of API 
> design, if you use a guaranteed pub/sub delivery mechanism then recovering 
> from broken connection state becomes super easy.
>
> This project does have good intentions, but the question of "can it be 
> used in production" doesn't just come down to performance, and upon code 
> inspection I do have some concerns;
>
> * Lack of maturity, initial commit was March 2014, not many closed/opened 
> issues, the author has not made it clear how long this has been in dev for.
> * Reasonable amount of downloads on pypi and "stars" on github
> * Code is not up to PEP8 standards
> * No public CI testing
> * JS does not have modular structure, does not have a sane design pattern, 
> and does not adhere to require/AMD
> * JS has some unit tests, but they don't appear to be functional or 
> recently updated. On first glance, I'd say coverage is minimal and that TDD 
> probably hasn't been followed.
> * API implementation looks a bit wonky
> * Deeply integrated with Django, rather than a modular fashion which could 
> then be used as standalone or with other frameworks/ORMs.
>
> For my own taste/use cases, I would say this is lacks the maturity and 
> stability to be considered production ready. This project feels to me like 
> a "prototype draft", something that could be used for a hobby project, 
> bleeding edge experimentation, prototype inspiration etc. If this came up 
> for internal code review at our work, it wouldn't pass.
>
> But again - huge kudos to the author for what he's done so far, and I 
> really hope he continues to improve on it.
>
> tl;dr - It's feels pretty alpha, YMMV :)
>
> Cal
>
> On Wed, Nov 12, 2014 at 4:37 AM, Suren Sth 
> > wrote:
>>
>> I recently came across Swampdragon ( Visit official site 
>> <http://swampdragon.net/>). I am curious can it be used in production 
>> sites and will it scale ? If it can be, what is the best way?
>>
>> -- 
>> 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/74092e59-801e-48f6-ba99-9d6231516b84%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/74092e59-801e-48f6-ba99-9d6231516b84%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.goo

Re: PDF generator in Django

2013-08-06 Thread Jonas Geiregat
On 04/08/2013, navnath gadakh wrote:
> Which is best tool to generate PDF in python django

I sucessfully used django-appypod before. It uses a rather strange
library called appy.pod that uses openoffice odt files as a template.

If you have an openoffice server running you can generate a pdf out of
the generated template.

It's rather verbose and heavy weight but you don't have to fiddle with
pixel placement and such like you have to do with the reportlab pdf
library.

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

-- 
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: Something similar to a WAMP stack for Django?

2013-06-05 Thread Jonas Geiregat

On 05 Jun 2013, at 18:07, Nafiul Islam wrote:

> Hi!
> 
> Is there something similar to a WAMP stack for django and python development, 
> like there is for PHP? It gives you a better way of emulating how a real 
> server would work.

There is: http://bitnami.com/stack/django 

-- 
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: linux or windows

2013-05-31 Thread Jonas Geiregat

On 31 May 2013, at 13:26, Kakar Arunachal Service wrote:

> thanks!! So, for the production purpose, one must use linux?
> 

No you can also run django and python applications in general on a window 
system, even in production.

But in is most cases it's easier to deploy a django/python application on a 
*nix based system.

-- 
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: CBVs and using existing forms for user authentication etc

2013-05-31 Thread Jonas Geiregat

On 31 May 2013, at 12:36, tony gair wrote:

> 
> I'm trying to write my first django app using cbv's and good practice ala 2 
> scoops!
> 
> (thanks for all the help so far in this forum btw!)
> 
> I have constructed the app using django braces and CBV's and have noticed 
> that I can only authenticate into my app through the admin panel.
> 
> I suspect that django already has the logging mechanism for my abstractuser 
> and its just a matter of declaring it in my urls, 
> 
> is this so?
> 

Yes, take a look in django.contrib.auth.views, it has many function based views 
I just reuse and add to my urls.py to quickly get a login system up and running.

-- 
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: linux or windows

2013-05-31 Thread Jonas Geiregat

On 31 May 2013, at 13:11, Kakar Arunachal Service wrote:

> Hi!
> I know this question is one absurd question, but just out of curiosity, is it 
> important to use linux other than the windows, related to django. Cause i'm 
> in windows, and if it is, then i was thinking to use Ubuntu. Please advise.

The platform is unimportant, if you feel at home in windows then use windows 
else use whatever you like as long as it is supported by django.

On a UNIX based system, you could perfectly run/debug django, without touching 
anything like a shell, inside your IDE of choice . 

-- 
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: App-structure: how to have a bunch of data in all the pages.

2013-02-05 Thread Jonas Geiregat
On Tue, Feb 05, 2013 at 02:06:28AM -0800, Stefano Tranquillini wrote:
> Now, i can create a base.html template where i render the data. but, how 
> should i do the population of these lists?
> Should i create a middleware that for each request populates the lists?
> or what?
I think that a Context Processor will be a better option.

-- 
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: how to deploy django project to lighttpd server

2013-01-07 Thread Jonas Geiregat
I have several account on djangoeurope.com.

What I mostly do is like you did, create a new project using their admin 
interface.

Next I backup the RUN script and delete that directory completely! The I 
checkout my project code, just make sure the project you are checking out (or 
copying) has the same name as the project you created in the admin interface.

Copy the RUN file back, for you development startup. 

Next thing you'll probably need to do is edit the ~/init/project_name file

If you are using virtualenv the DAEMON line and point it to the python binary 
of the env you which to use.
For example: DAEMON=$HOME/Envs/project/bin/python

You might also want to change the SETTINGS to point to your production settings 
or whatever.

If you want to serve static files you should take a look in 
~/lighthttp/django.conf.
For each project created an entry has been added to this file.
Just make sure the directories are setup correctly.

That should be all and you should now be able to start your project 

~/init/project_name start

Good luck!


> Hi there, 
> 
> i am stumbling over this step: i have django project running at my pc local, 
> i want to deploy it to server to see it online. I have bought the hosting 
> service from djangoeurope.com. they have that one-click django installer, it 
> installs the environment with its lighttpd settings. now i dont know where to 
> upload my django files and where to set and how to get it running,
> 
> in the server i have this files which are installed by one-click django 
> installer: 
> under ~/projectname
> projectname, projectname.pid, projectname.sock, manage.py, RUN
> 
> do i have to upload here? 
> 
> thanks a lot for help in advance
> 
> -- 
> 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/-/U8n69IPW0kgJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: Converting Django app into a Desktop app

2012-12-18 Thread Jonas Geiregat


> Hi
> 
> I am very comfortable with Django, and I was wondering about whether there is 
> some way to convert a Django web app into a Desktop app (may be not 100%), so 
> that I can distribute it to users. May be wrapping it in a light web server 
> "if there is something like this". 
> 
> 
> 

You might try http://www.python-camelot.com/ 

-- 
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: Foreignkey Form

2012-12-12 Thread Jonas Geiregat
Thanks for the response Serge,

So basically I was on the right path.

But I don't see what the DetailView has to do with this ? Don't you mean the 
CreateView ?

Jonas.

> 1) you  should create a form for building
> 2) you should create a form for inhabitant and set key to the  correct
> value  before saving
> 
> IMHO   simple way is create a edit form for buiding which has buttons
> add/remove inhabitant .  check  DetailView  in docs please
> 
> thanks, Serge
> skype: skhohlov
> tel: +380636150445
> 
> 
> 2012/12/12 Jonas Geiregat :
>> Hello,
>> 
>> Suppose I have a model with a foreign key.
>> 
>> class Building(models.Model):
>>pass
>> class Inhabitant(models.Model):
>>building = models.ForeignKey(Building)
>> 
>> 
>> I would like to display a form where all fields from the Building model and 
>> Inhabitant model are visible (but only once)
>> 
>> Should I create 2 forms, one for Building and one for Inhabitant ? And upon 
>> submission add the Building to the Inhabitant.
>> 
>> Currently I've worked together a little working something using the 
>> CreateView (Generic views)
>> 
>> 
>> def post(..)
>>self.inhabitant_form = InhabitantForm(data=request.POST)
>>if form.is_valid() and self.inhabitant_form.is_valid():
>>….
>> 
>> def form_valid(self, form):
>># form is an instance of BuildingForm
>>building = form.instance
>>building.save()
>> 
>># I'm also overriding the post method where self.inhabitant_form is being 
>> set
>>inhabitant = self.inhabitant_form.instance
>>self.inhabitant.building = building
>>self.inhabitant.save()
>> 
>> 
>> Am I on the right path or are there are better ways of handling such 
>> situations ?
>> 
>> Regards,
>> 
>> Jonas.
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Foreignkey Form

2012-12-12 Thread Jonas Geiregat
Hello,

Suppose I have a model with a foreign key.

class Building(models.Model):
pass
class Inhabitant(models.Model):
building = models.ForeignKey(Building)


I would like to display a form where all fields from the Building model and 
Inhabitant model are visible (but only once)

Should I create 2 forms, one for Building and one for Inhabitant ? And upon 
submission add the Building to the Inhabitant.

Currently I've worked together a little working something using the CreateView 
(Generic views)


def post(..)
self.inhabitant_form = InhabitantForm(data=request.POST)
if form.is_valid() and self.inhabitant_form.is_valid():
….

def form_valid(self, form):
# form is an instance of BuildingForm
building = form.instance
building.save()

# I'm also overriding the post method where self.inhabitant_form is being 
set
inhabitant = self.inhabitant_form.instance
self.inhabitant.building = building
self.inhabitant.save()


Am I on the right path or are there are better ways of handling such situations 
?

Regards,

Jonas.

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



django CMS security release issued

2012-12-04 Thread Jonas Obrist
We just issued a security release for the django CMS to fix a vulnerability
in the page_attribute template tag, which allowed admins with restricted
permissions to elevate their permissions through XSS.

All django CMS users are encouraged to update their django CMS
installations immediately.

Read more at http://bit.ly/django-cms-2-3-5

- Jonas

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



can't get translation to work

2012-11-16 Thread Jonas Geiregat
I've got an app with the following translation settings:

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'nl-BE'

gettext = lambda s: s
LANGUAGES = ( 
   ('en', gettext('English')),
   ('nl', gettext('Dutch')),
)

MODELTRANSLATION_DEFAULT_LANGUAGE = 'nl'

SITE_ID = 1 

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True


TEMPLATE_CONTEXT_PROCESSORS = ( 
   "django.contrib.auth.context_processors.auth",
   "django.core.context_processors.i18n",
   "django.core.context_processors.debug",
   "django.core.context_processors.media",
   "django.core.context_processors.static",
   "django.core.context_processors.tz",
   "django.contrib.messages.context_processors.messages"
)

MIDDLEWARE_CLASSES = ( 
   'django.contrib.sessions.middleware.SessionMiddleware',
   # i18n
   'django.middleware.locale.LocaleMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   # Uncomment the next line for simple clickjacking protection:
   'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
In my templates I have several {% trans ".." %} tags I run ./manage.py 
makemessages -l en

processing language en

Which runs just fine. The generated file located at 
project/locale/en/LC_MESSAGES/django.po starts with the following:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR , YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-11-16 05:39-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: peltracom/settings.py:37
msgid "English"
msgstr ""

#: peltracom/settings.py:38
msgid "Dutch"
msgstr ""

#: qr_app/templates/product.html:14
msgid "Gemaakt van"
msgstr ""

#: qr_app/templates/product.html:15
msgid "Afkomstig uit"
msgstr ""
After editing the file and adding the correct translations I run:

/manage.py compilemessages -L EN processing file django.po in 
/Volumes/DATA/http/peltracom/locale/en/LC_MESSAGES

My base urls.py contains:

urlpatterns += i18n_patterns('',
url(r'', include('qr_app.urls')),
)
But when I point my browser to /en/some-url everything within trans template 
tags is displayed in Dutch and not in english. I even tried setting the 
accept-language header to en which didn't help at all.

Any clues on what might be going wrong here are welcome!

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



model field not null

2012-09-26 Thread Jonas Geiregat
Hello,

While setting up a new model I'm trying to have a strong data model.

One of the requirements is that a certain field cannot be null.

lastname = models.CharField(
blank=False,
default=None,
..)

I'm accomplishing this by the above code. This ensure that even on a database 
level lastname will not be NULL, by setting default to None.

I'm aware that I can just use blank=False to ensure that on a form level it 
will never be allowed to be empty.  But I want a strong, fully tested, business 
model from the beginning.

As this is a CharField, according to the docs, I cannot use null=True since 
empty string will get stored as empty strings and not as NULL.

Is this an appropriate way of modeling my models, or are there other solutions ?

Regards,

Jonas.


-- 
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: content management in django

2012-09-24 Thread Jonas Geiregat
I would advise you to take a look at feincms, it has exactly what you need.


> Hello,
> 
> I'm converting a static website to a Django application and I need a piece of 
> advice from more experienced people what is the right way to store content.
> The website will have some static pages like "about","contacts", etc. and a 
> dynamic content like news and photo galleries that should be updated from the 
> web interface. So my best guess is that static pages should be implemented 
> using templates and news should be stored in a database. I believe this is a 
> common task so is there a better way to solve it? And how is news editing 
> implemented? Does the editor create an html in some html-editor and then 
> paste it into the database, or is a web-based WYSIWYG-editor usually used?
> 
> Thank you!
> 
> -- 
> 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/-/_wtR7b_RXKYJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: testing a django package

2012-09-13 Thread Jonas Geiregat
Found the answer:

I need to put from tests import * in the tests/__init__.py file 

> Actually, Django TestCases can override the URLConf, which allows you to have 
> a given URL for a given view in your test:
> 
> from django.test import TestCase
> 
> class MyTestCase(TestCase):
> urls = 'mypackage.tests.urls'
> 
> def test_something():
> # Do stuff...
> 
> 
> From there, you can *totally* just create a tests/views.py file where you add 
> your test view with the actual implementation you're missing, and add it in 
> your tests/urls.py file.
> 
> And everything will be fine : )
> 
> Le mercredi 12 septembre 2012 23:36:03 UTC+2, jonas a écrit :
> 
> 
> 
> > I think you could create an urls.py file for your tests and attach 
> > your views there. Then use the test client to direct requests to those 
> > test URLs and assert that the response is what you expect. 
> 
> I didn't know that could work. 
> I think I'll also need to create views that extend these views that I want to 
> test. 
> Since they need actual implementation, I think, such as template_name and 
> model etc .. 
> 
> How would the test client then now where to look for these views, since there 
> will be some reversing involved I think. 
> 
> self.client.get(reverse("ajax_form_view")) 
> 
> I don't see how the client will find my urls.py file and without the broader, 
> actual django application as context ? 
> 
> 
> > 
> > Now, this is probably not going to be practical to test your jQuery 
> > components, but you might want to ask on a JS-focused list regarding 
> > unittesting JS for this purpose. 
> > 
> > Thomas 
> > 
> > 2012/9/12 Jonas Geiregat : 
> >> 
> >> I can now show you what I really would like to write tests for. 
> >> 
> >> https://github.com/jonasgeiregat/django-ajax-forms 
> >> 
> >> The code I would like to test is in ajax_forms/views.py mainly the 
> >> AjaxFormView and the AjaxModelFormView. 
> >> 
> >> Any help is appreciated! 
> >> 
> >> 
> >> Is it a view mix in? 
> >> 
> >> The package actually already changed from containing a view mix in to 
> >> actual 
> >> views that should be subclassed by the users using the package. 
> >> 
> >> It's a bit difficult to tell you much without more information. 
> >> 
> >> For example, a view derived from FormView. Like I said the user should 
> >> subclass this view again as you would normally do with CBV. 
> >> 
> >> Currently the package is just a package/directory with views.py, 
> >> models.py, 
> >> urls.py and of course __init__.py to make it a module. 
> >> 
> >> It's hard to test views without having an actual django project to test it 
> >> again, I think.  Correct me if I'm wrong here. 
> >> So I created an example django project that is using this package in the 
> >> directory below the package, thus the directory containing the README, 
> >> setup.py etc .. files. 
> >> 
> >> The example app will hold a tests.py file which will contain my tests 
> >> which 
> >> will be testing the actual functionality of my views. 
> >> 
> >> Basically I'm asking do I need an actual django project to test just a 
> >> views.py file or can I just write some tests without a containing django 
> >> project to test a views.py file. 
> >> And if so, I'm kinda lost on how you would start on such a task. 
> >> 
> >> A few you things that you may find useful or not for testing : 
> >> 
> >> .  Test cases can override settings such as the urlconf 
> >> .  There's a test client to test views 
> >> .  Class based views can sometimes be tested without any of the former by 
> >> just testing the methods in them 
> >> .   You can always use mocking library 
> >> .  Tests are basically just python code with a lot of asserts, you can 
> >> always add viewed in them 
> >> .  You can use fixtures for test data if you see fit 
> >> 
> >> Hope this helps! 
> >> 
> >> Thomas 
> >> 
> >> On Sep 10, 2012 5:23 PM, "Jonas Geiregat"  wrote: 
> >>> 
> >>> Hello, 
> >>> 
> >>> I've created a simple reusable django package. This package basically 
> >>> consists out of a views.py file, with some helper functions. 
> >>> 
> >>> I want to write som

Re: testing a django package

2012-09-13 Thread Jonas Geiregat
Thanks you for your help. 

I understand now how I should setup testing for a django package. I'm using 
django-registration as an example , which works a similar way.

I have a weird problem at hand.
I'm creating a django package and would like to provide some test cases for it.
The package is named ajax_forms and the full path is part of my PYTHONPATH. 
This directory also contains a tests directory (with the init.py file) a 
tests.py file (containing the tests) and a urls.py file.
Now I want to run the tests.

The ajax_forms parent directory has an example project setup with ajax_forms in 
INSTALLED_APPS.

But I can't seem to let the tests run:

 >> ./manage.py test ajax_forms
Creating test database for alias 'default'...

--
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...

No tests are found so I try to be more specific:

 >> ./manage.py test ajax_forms.tests

raise ValueError("Test label '%s' does not refer to a test" % label)
ValueError: Test label 'ajax_forms.tests' does not refer to a test
(ajax-validation)

Even ./manage.py ajax_forms.tests.tests.AjaxFormViewTest will not find the 
tests and gives the same error as above.

But trying to import the test case from the ./manage.py shell works fine

In [2]: from ajax_forms.tests.tests import AjaxFormViewTest

I'm kinda clueless here, on what's going on.


> 
> 
> 
>> I think you could create an urls.py file for your tests and attach
>> your views there. Then use the test client to direct requests to those
>> test URLs and assert that the response is what you expect.
> 
> I didn't know that could work. 
> I think I'll also need to create views that extend these views that I want to 
> test.
> Since they need actual implementation, I think, such as template_name and 
> model etc ..
> 
> How would the test client then now where to look for these views, since there 
> will be some reversing involved I think.
> 
> self.client.get(reverse("ajax_form_view"))
> 
> I don't see how the client will find my urls.py file and without the broader, 
> actual django application as context ?
> 
> 
>> 
>> Now, this is probably not going to be practical to test your jQuery
>> components, but you might want to ask on a JS-focused list regarding
>> unittesting JS for this purpose.
>> 
>> Thomas
>> 
>> 2012/9/12 Jonas Geiregat :
>>> 
>>> I can now show you what I really would like to write tests for.
>>> 
>>> https://github.com/jonasgeiregat/django-ajax-forms
>>> 
>>> The code I would like to test is in ajax_forms/views.py mainly the
>>> AjaxFormView and the AjaxModelFormView.
>>> 
>>> Any help is appreciated!
>>> 
>>> 
>>> Is it a view mix in?
>>> 
>>> The package actually already changed from containing a view mix in to actual
>>> views that should be subclassed by the users using the package.
>>> 
>>> It's a bit difficult to tell you much without more information.
>>> 
>>> For example, a view derived from FormView. Like I said the user should
>>> subclass this view again as you would normally do with CBV.
>>> 
>>> Currently the package is just a package/directory with views.py, models.py,
>>> urls.py and of course __init__.py to make it a module.
>>> 
>>> It's hard to test views without having an actual django project to test it
>>> again, I think.  Correct me if I'm wrong here.
>>> So I created an example django project that is using this package in the
>>> directory below the package, thus the directory containing the README,
>>> setup.py etc .. files.
>>> 
>>> The example app will hold a tests.py file which will contain my tests which
>>> will be testing the actual functionality of my views.
>>> 
>>> Basically I'm asking do I need an actual django project to test just a
>>> views.py file or can I just write some tests without a containing django
>>> project to test a views.py file.
>>> And if so, I'm kinda lost on how you would start on such a task.
>>> 
>>> A few you things that you may find useful or not for testing :
>>> 
>>> .  Test cases can override settings such as the urlconf
>>> .  There's a test client to test views
>>> .  Class based views can sometimes be tested without any of the former by
>>> just testing the methods in them
>>> .   You can always use mocking library
>>> .  Tests are basic

Re: testing a django package

2012-09-12 Thread Jonas Geiregat



> I think you could create an urls.py file for your tests and attach
> your views there. Then use the test client to direct requests to those
> test URLs and assert that the response is what you expect.

I didn't know that could work. 
I think I'll also need to create views that extend these views that I want to 
test.
Since they need actual implementation, I think, such as template_name and model 
etc ..

How would the test client then now where to look for these views, since there 
will be some reversing involved I think.

self.client.get(reverse("ajax_form_view"))

I don't see how the client will find my urls.py file and without the broader, 
actual django application as context ?


> 
> Now, this is probably not going to be practical to test your jQuery
> components, but you might want to ask on a JS-focused list regarding
> unittesting JS for this purpose.
> 
> Thomas
> 
> 2012/9/12 Jonas Geiregat :
>> 
>> I can now show you what I really would like to write tests for.
>> 
>> https://github.com/jonasgeiregat/django-ajax-forms
>> 
>> The code I would like to test is in ajax_forms/views.py mainly the
>> AjaxFormView and the AjaxModelFormView.
>> 
>> Any help is appreciated!
>> 
>> 
>> Is it a view mix in?
>> 
>> The package actually already changed from containing a view mix in to actual
>> views that should be subclassed by the users using the package.
>> 
>> It's a bit difficult to tell you much without more information.
>> 
>> For example, a view derived from FormView. Like I said the user should
>> subclass this view again as you would normally do with CBV.
>> 
>> Currently the package is just a package/directory with views.py, models.py,
>> urls.py and of course __init__.py to make it a module.
>> 
>> It's hard to test views without having an actual django project to test it
>> again, I think.  Correct me if I'm wrong here.
>> So I created an example django project that is using this package in the
>> directory below the package, thus the directory containing the README,
>> setup.py etc .. files.
>> 
>> The example app will hold a tests.py file which will contain my tests which
>> will be testing the actual functionality of my views.
>> 
>> Basically I'm asking do I need an actual django project to test just a
>> views.py file or can I just write some tests without a containing django
>> project to test a views.py file.
>> And if so, I'm kinda lost on how you would start on such a task.
>> 
>> A few you things that you may find useful or not for testing :
>> 
>> .  Test cases can override settings such as the urlconf
>> .  There's a test client to test views
>> .  Class based views can sometimes be tested without any of the former by
>> just testing the methods in them
>> .   You can always use mocking library
>> .  Tests are basically just python code with a lot of asserts, you can
>> always add viewed in them
>> .  You can use fixtures for test data if you see fit
>> 
>> Hope this helps!
>> 
>> Thomas
>> 
>> On Sep 10, 2012 5:23 PM, "Jonas Geiregat"  wrote:
>>> 
>>> Hello,
>>> 
>>> I've created a simple reusable django package. This package basically
>>> consists out of a views.py file, with some helper functions.
>>> 
>>> I want to write some tests for what's in this file. This file contains a
>>> mixin , so I probably can't test it directly.
>>> 
>>> What's the best way to test a django package ?
>>> 
>>> Do I need to include some kind of example project that, uses my mixin and
>>> has tests files just as one would test a normal django application ?
>>> 
>>> I've tried googling but, there's little about this. Most of the things
>>> I've found where related to testing actual django applications.
>>> 
>>> Any help is appreciated.
>>> 
>>> Jonas
>>> 
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>> 
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users&q

Re: testing a django package

2012-09-12 Thread Jonas Geiregat

I can now show you what I really would like to write tests for.

https://github.com/jonasgeiregat/django-ajax-forms

The code I would like to test is in ajax_forms/views.py mainly the AjaxFormView 
and the AjaxModelFormView.

Any help is appreciated!

> 
>> Is it a view mix in?
>> 
> The package actually already changed from containing a view mix in to actual 
> views that should be subclassed by the users using the package.
>> It's a bit difficult to tell you much without more information.
>> 
> For example, a view derived from FormView. Like I said the user should 
> subclass this view again as you would normally do with CBV.
> 
> Currently the package is just a package/directory with views.py, models.py, 
> urls.py and of course __init__.py to make it a module.
> 
> It's hard to test views without having an actual django project to test it 
> again, I think.  Correct me if I'm wrong here.
> So I created an example django project that is using this package in the 
> directory below the package, thus the directory containing the README, 
> setup.py etc .. files.
> 
> The example app will hold a tests.py file which will contain my tests which 
> will be testing the actual functionality of my views.
> 
> Basically I'm asking do I need an actual django project to test just a 
> views.py file or can I just write some tests without a containing django 
> project to test a views.py file.
> And if so, I'm kinda lost on how you would start on such a task.
> 
>> A few you things that you may find useful or not for testing :
>> 
>> .  Test cases can override settings such as the urlconf 
>> .  There's a test client to test views 
>> .  Class based views can sometimes be tested without any of the former by 
>> just testing the methods in them 
>> .   You can always use mocking library 
>> .  Tests are basically just python code with a lot of asserts, you can 
>> always add viewed in them 
>> .  You can use fixtures for test data if you see fit
>> 
>> Hope this helps!
>> 
>> Thomas
>> 
>> On Sep 10, 2012 5:23 PM, "Jonas Geiregat"  wrote:
>> Hello,
>> 
>> I've created a simple reusable django package. This package basically 
>> consists out of a views.py file, with some helper functions.
>> 
>> I want to write some tests for what's in this file. This file contains a 
>> mixin , so I probably can't test it directly.
>> 
>> What's the best way to test a django package ?
>> 
>> Do I need to include some kind of example project that, uses my mixin and 
>> has tests files just as one would test a normal django application ?
>> 
>> I've tried googling but, there's little about this. Most of the things I've 
>> found where related to testing actual django applications.
>> 
>> Any help is appreciated.
>> 
>> Jonas
>> 
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: testing a django package

2012-09-11 Thread Jonas Geiregat

> Is it a view mix in?
> 
The package actually already changed from containing a view mix in to actual 
views that should be subclassed by the users using the package.
> It's a bit difficult to tell you much without more information.
> 
For example, a view derived from FormView. Like I said the user should subclass 
this view again as you would normally do with CBV.

Currently the package is just a package/directory with views.py, models.py, 
urls.py and of course __init__.py to make it a module.

It's hard to test views without having an actual django project to test it 
again, I think.  Correct me if I'm wrong here.
So I created an example django project that is using this package in the 
directory below the package, thus the directory containing the README, setup.py 
etc .. files.

The example app will hold a tests.py file which will contain my tests which 
will be testing the actual functionality of my views.

Basically I'm asking do I need an actual django project to test just a views.py 
file or can I just write some tests without a containing django project to test 
a views.py file.
And if so, I'm kinda lost on how you would start on such a task.

> A few you things that you may find useful or not for testing :
> 
> .  Test cases can override settings such as the urlconf 
> .  There's a test client to test views 
> .  Class based views can sometimes be tested without any of the former by 
> just testing the methods in them 
> .   You can always use mocking library 
> .  Tests are basically just python code with a lot of asserts, you can always 
> add viewed in them 
> .  You can use fixtures for test data if you see fit
> 
> Hope this helps!
> 
> Thomas
> 
> On Sep 10, 2012 5:23 PM, "Jonas Geiregat"  wrote:
> Hello,
> 
> I've created a simple reusable django package. This package basically 
> consists out of a views.py file, with some helper functions.
> 
> I want to write some tests for what's in this file. This file contains a 
> mixin , so I probably can't test it directly.
> 
> What's the best way to test a django package ?
> 
> Do I need to include some kind of example project that, uses my mixin and has 
> tests files just as one would test a normal django application ?
> 
> I've tried googling but, there's little about this. Most of the things I've 
> found where related to testing actual django applications.
> 
> Any help is appreciated.
> 
> Jonas
> 
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
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: Marketplace for Django apps

2012-09-11 Thread jonas




I want to ask you again, what you think about such service? Would you
buy or sell apps (or paid support) out there and why?



If the apps are more then good enough and would spare companies time 
and there are no better or equal opensource alternatives,
then yes I do believe some people might be willing to buy apps in such 
a market place. For example there is no real outstanding e-commerce 
application for django.


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



testing a django package

2012-09-10 Thread Jonas Geiregat
Hello,

I've created a simple reusable django package. This package basically consists 
out of a views.py file, with some helper functions.

I want to write some tests for what's in this file. This file contains a mixin 
, so I probably can't test it directly. 

What's the best way to test a django package ? 

Do I need to include some kind of example project that, uses my mixin and has 
tests files just as one would test a normal django application ?

I've tried googling but, there's little about this. Most of the things I've 
found where related to testing actual django applications.

Any help is appreciated.

Jonas


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



[ANN] django-ajax-form-mixin v.0.0.1

2012-09-03 Thread Jonas Geiregat
Hello everyone,

I made a small application last weekend that is ready to be released.

It's takes on django-ajax-validation by replacing the view with a mixin and 
improving the jQuery callback possibilities.

Source: https://github.com/jonasgeiregat/django-ajax-form-mixin

Documentation: http://django-ajax-form-mixin.readthedocs.org/en/latest/

Hope you enjoy it!

Regards,

Jonas Geiregat.

-- 
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: model sends two requests

2012-07-10 Thread jonas peters
Thanks, helped me a lot.



Em segunda-feira, 9 de julho de 2012 17h53min23s UTC-3, Dennis Lee Bieber 
escreveu:
>
> On Mon, 9 Jul 2012 09:26:15 -0700 (PDT), jonas peters 
>  declaimed the following in 
> gmane.comp.python.django.user: 
>
> > I have a model and use standard django administration, when a user 
> clicks 
> > the save button it sends the request, it takes time to respond and the 
> user 
> > clicks the save button again and then sends another request, and 
> creating 
> > two records. have some setting in django to avoid this problem? I 
> thought 
> > about locking the save button when it is clicked so the user does not 
> click 
> > more than once to complete the request. 
> > 
> In general (that is, not Django specific), my experience is that 
> potentially slow sites in which an extra submittal would cause problems 
> tend to include a warning message to only click once (the sites I've 
> seen this on tend to be online markets -- where the warning is that 
> double clicking could result in a second order charged to the credit 
> card. 
>
> The other general solution would be to collect the data, send it 
> to 
> a separate worker thread/process and immediately return a "please wait" 
> type response -- this response should have an automatic redirect (using 
> a cookie to identify the worker) to a page that will either find the 
> worker thread has finished and can return the real next page -- or if 
> the worker is still busy resend the "please wait" page. 
>
> More specific modes: 
> http://www.turnkeylinux.org/blog/prevent-double-click-form-submission 
> (general search: prevent double click form submit 
>
> http://www.google.com/#hl=en&sclient=psy-ab&q=prevent+double+click+form+submit&oq=prevent+double+click+form+submit&gs_l=serp.3..0i30j0i5i30.8464.23704.0.23926.28.25.2.1.1.6.503.4601.0j21j3j5-1.25.0...0.0.c3W_7yOZRzI&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=9da4b66dc5fd8e9a&biw=1044&bih=748
>  
>
> ) 
>
>
>  
> > Sorry my english Thanks! 
> -- 
> Wulfraed Dennis Lee Bieber AF6VN 
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ 
>
>

-- 
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/-/ZU-HtLFqcp4J.
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.



model sends two requests

2012-07-09 Thread jonas peters
hi!

I have a model and use standard django administration, when a user clicks 
the save button it sends the request, it takes time to respond and the user 
clicks the save button again and then sends another request, and creating 
two records. have some setting in django to avoid this problem? I thought 
about locking the save button when it is clicked so the user does not click 
more than once to complete the request.

Sorry my english Thanks!

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



Django CMS 2.3 Released!

2012-06-29 Thread Jonas Obrist
Today I am very excited that we just released Django CMS 2.3, with Django
1.4 support.

You can read the release notes at Django at http://bit.ly/django-cms-23.

Best regards,

Jonas 'ojii' Obrist

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



Re: how to manage range of hours in models and forms in django1.4

2012-06-29 Thread jonas

Nikhil Verma wrote:


How can i design this form field as well in models or What should be
the type of this field both in models and forms such that weekdays
remain dynamic(i can simply generate them from loop) and the user can
fill the time  and when he hits submit it will get saved.



I would create an extra Model which defines these opening times:

class OpeningTimes(models.Model):
day = models.CharField(max_length=10)
start = models.DateTimeField()
end = models.DateTimeField()

and define a manytomany relation ship from the UserProfile to your 
OpeningTimes model.


I've opted for the DateTimeField here, there's no Time Field in django 
by default. But you could just use any date (maybe use some kind of 
default date or use the current date)
and make sure the time has been filled in correctly. And then just 
extract the right hour from the DateTime field.


Regards,

Jonas;

--
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: 'CSRF verification failed." from django.contrib.comments. can you help solve it? django 1.3

2012-06-28 Thread Jonas Geiregat
On do, jun 28, 2012 at 09:14:36 -0700, brycenesbitt wrote:
> http://127.0.0.1:8000/comments/post/>" method="post">
>/>
>id="id_timestamp" />
>value="6e85e1c846861c80575ce435b21a855706725b00" id="id_security_hash" 
> />

After the starting form tag add {% csrf_token %}

More information about it: 
https://docs.djangoproject.com/en/dev/ref/contrib/csrf/

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



Translated urls and accept-language header

2012-06-27 Thread Jonas Geiregat
Hello,

I've setup translated urls for some languages. The default language 
for django has been set to en-US.

If you request a page /registration/ with nl-NL as Accept-Language
header, I get a 404. 
I wasn't expecting such behaviour. Rather I was hoping I would be 
redirected to /registratie/ ,the tranlated url that corresponds my
Accept-Language header.
Ofcourse /registratie/ with the nl-Nl Accept-Language header, works
fine and gives me the expected 200.

I'm guessing this is just as normal as it can get ?

Isn't there a chance a user might get link from some website and
the link is build for the English language, but the user in question
has a different supported language setting, Accept-Language header ?
In such a case he would be presented with a 404.
He should be presented with or the English (default) content or
or be redirected to the correct url for his language if supported.

Also what happens if a user has a not supported language setting ?
Will the django default LANGUAGE_CODE be used, en-US in my case ?

Is there a way to work around this or handle it in a different better way ?

an extract from my urls.py file, shows how I've setup translated urls:

url(_(r'^step1/$'), AccountTypeSelectionView.as_view(), 
name="registration_step1"),

-- 
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: Server error caused by too many database look-ups

2012-05-04 Thread Jonas Ghyllebert
The site is in debug mode. The problem however is that we build the 
application step-by-step, because we need data from our client for the next 
steps. 
That's why we already deployed the site on Google App Engine.

As of the syntax errors you mention, we don't get any errors while testing 
the app. But we'll look into it.

I'll give database caching a try for my original problem.

On Thursday, May 3, 2012 8:53:20 AM UTC+2, koenb wrote:
>
> You should use DEBUG=True in your development settings, so you get a 
> proper traceback of what is going on. 
>
> As far as I can see, you do have syntax errors in your models.py file (eg 
> line 266). You should fix them first.
>
> As a side note, your unicode methods are not all correct, some of them are 
> returning bytestrings (this may bite you once you start using non-ascii 
> data).
>
> Koen
>
> Op woensdag 2 mei 2012 21:37:30 UTC+2 schreef Jonas Ghyllebert het 
> volgende:
>>
>> Hi everybody,
>>
>> I've got a problem while accessing a model in the Django Adminpanel.
>> I uploaded the models file, i hope this makes it easier for you to 
>> understand my problem.
>>
>> When I try to add or view a *Region *in the adminpanel, the server 
>> usually gives me an 500 server error.
>> This is what i get to see:
>>  
>> Error: Server ErrorThe server encountered an error and could not 
>> complete your request.
>>
>> If the problem persists, please 
>> report<http://code.google.com/appengine/community.html> your 
>> problem and mention this error message and the query that caused it.
>>
>> Now, in the uploaded file you may (or not) have seen that I want to have 
>> 25 fields from Zip.
>>
>> My guess is that Django connects to the database for every listbox it is 
>> generating.
>> Is there a way to cache the 2000+ zips?
>> Or, am I seeing it wrong? What should I do then?
>>
>> Greetings
>>
>>
>>

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



Server error caused by too many database look-ups

2012-05-02 Thread Jonas Ghyllebert
Hi everybody,

I've got a problem while accessing a model in the Django Adminpanel.
I uploaded the models file, i hope this makes it easier for you to 
understand my problem.

When I try to add or view a *Region *in the adminpanel, the server usually 
gives me an 500 server error.
This is what i get to see:
 
Error: Server ErrorThe server encountered an error and could not complete 
your request.

If the problem persists, please 
report your 
problem and mention this error message and the query that caused it.

Now, in the uploaded file you may (or not) have seen that I want to have 25 
fields from Zip.

My guess is that Django connects to the database for every listbox it is 
generating.
Is there a way to cache the 2000+ zips?
Or, am I seeing it wrong? What should I do then?

Greetings


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

from django.db import models
from django.contrib import admin

### Zip
class Province(models.Model):
province_name = models.CharField(max_length=145)

class Meta:
verbose_name =  "provincie"

def __unicode__(self):
return self.province_name 

class Zip(models.Model):
zip_code = models.IntegerField()
zip_name = models.CharField(max_length=75)
zip_lang = models.CharField(max_length=2)
province = models.ForeignKey(Province)

class Meta:
ordering = ["zip_name"]
verbose_name = "postcode"

def __unicode__(self):
return self.zip_name + ' (' + unicode(self.zip_code) +')'

### Contact
class Contact_type(models.Model):
contact_type = models.CharField(max_length=50)
class Meta:
verbose_name = "contact type"
verbose_name_plural = "contact types"

def __unicode__(self):
return self.contact_type


### Collaborator
class Collaborator_function(models.Model):
collaborator_function_name = models.CharField(max_length=100)

class Meta:
verbose_name = "medewerker functie"
verbose_name_plural = "medewerker functies"

def __unicode__(self):
return self.collaborator_function_name

class Collaborator_type(models.Model):
Collaborator_type_name = models.CharField(max_length=100)
def __unicode__(self):
return self.Collaborator_type_name

class Meta:
verbose_name = "medewerker type"
verbose_name_plural = "medewerker types"

class Collaborator(models.Model):
collaborator_first_name = models.CharField(max_length=45)
collaborator_last_name = models.CharField(max_length=45)
collaborator_birth_year = models.DateField()
collaborator_start_year = models.DateField()
collaborator_end_year = models.DateField(blank=True,null=True)
collaborator_function = models.ForeignKey(Collaborator_function)
collaborator_type = models.ForeignKey(Collaborator_type)
collaborator_legal = models.CharField(max_length=100,blank=True,null=True)
collaborator_vat = models.CharField(max_length=100,blank=True,null=True)
collaborator_zoho_id= models.IntegerField(blank=True,null=True)
collaborator_maximmo_id = models.IntegerField(blank=True,null=True)
collaborator_biv_number = models.IntegerField(blank=True,null=True)
collaborator_drupal_id = models.IntegerField(blank=True,null=True)

def __unicode__(self):
return self.collaborator_first_name + ' ' + self.collaborator_last_name

class Meta:
verbose_name = "medewerker"
verbose_name_plural = "medewerkers"

class Contact_per_collaborator(models.Model):
collaborator = models.ForeignKey(Collaborator)
contact_link = models.CharField(max_length=150)
contact_type = models.ForeignKey(Contact_type)
def __unicode__(self):
return self.contact_link

class Meta:
verbose_name = "contact"

class commission_collaborator_percentage(models.Model):
collaborator = models.ForeignKey(Collaborator)
commission_collaborator_percentage = models.IntegerField()
commission_collaborator_start_date = models.DateField()
commission_collaborator_end_date = models.DateField()

class Meta:
verbose_name = "Medewerker commissie (percentage)"
verbose_name_plural = "Medewerker commissies (percentage)"

### Office
class Office(models.Model):
office_name = models.CharField(max_length=100)
office_legal = models.CharField(max_length=100)
office_address_street = models.CharField(max_length=100)
office_address_number = models.CharField(max_length=25)
 

Re: Testing Google Charts within Django Unit Tests

2012-04-26 Thread Jonas Geiregat


> I'm looking for a way to test the data that a google chart displays on
> a web site with a unit test. Is this at all possible, and if so, where
> should I look to accomplish this? I've tried accessing the Google
> visualization datatable that is used to create the chart, but it
> doesn't seem to be a part of the context of the HTTP responses that I
> am getting.

Take a look at selenium or windmill, they might be able to solve your issue.

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



Re: Where are the women?

2012-04-25 Thread Jonas Obrist
Hi everyone,

I'm one of the organizers of DjangoCon Europe 2012 and as Daniele pointed 
out, it made me sad when seeing the amount of women that submitted a talk. 
While we have no statistics of a gender breakdown for the tickets sold so 
far, just glancing at the list of names makes me sad.

I wonder how much of this is just bad organizing and communication from our 
part, and how much it is because there are less women in the Django 
community than men (if that's even the case). On that note, thanks for 
giving your views on this topic everyone.

I will see which suggestions we can still implement for DjangoCon Europe 
and if you have any more suggestions, please feel free to contact me 
directly at ojiido...@gmail.com, as I often forget to check mailing lists.

We'll publish a code of conduct soon, the reason why this was not done yet 
is because I naively thought that it is unnecessary, as 
everything usually mentioned in a code of conduct is covered by Swiss law 
anyway (especially discrimination).

Jonas Obrist

On Wednesday, April 25, 2012 8:28:07 PM UTC+2, Katie Cunningham wrote:
>
> If you want to get more women to a conference, a few things have been 
> successful on this side of the pond: 
>
>  - Scholarships set aside for female attendees 
>  - Specifically invite potential female speakers to talk, or at least 
> submit a talk 
>  - Reach out to women-based tech groups, and make sure they know about 
> the conference 
>  - Talk to females that are already attending, and see if they can share a 
> room 
>  - Encourage sponsors to sponsor costs for a female attendee. 
>  - Have a code of conduct that is public, explicit, and enforced. 
>
> Even doing the scholarships for a few spots shows that your conference 
> shows that you're serious about women attending. I don't know, when 
> looking into a conference, whether your conference is going to be one 
> where I'm going to get cat-called or one where I'm going to feel 
> completely at home. 
>
> Katie Cunningham 

-- 
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/-/KCWMuExf0n8J.
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: Slow page in admin

2012-04-25 Thread Jonas Ghyllebert
Hi,

Thanks for the quick reply.

when we test the application local, it works like a charm.
But when we deployed it on Google App engine using Cloud SQL, the 
application works now and then and this particular page is much slower than 
the others.
When there's an error, Django shows the 500 - internal server error.

These are my models:
*Zip*

class Zip(models.Model):

zip_code = models.IntegerField()

zip_name = models.CharField(max_length=75)

zip_lang = models.CharField(max_length=2)

province = models.ForeignKey(Province)



class Meta:

ordering = ["zip_name"]

verbose_name = "postcode"

verbose_name_plural = "postcodes"



def __unicode__(self):
return self.zip_name + ' (' + unicode(self.zip_code) +')'

*
*
*Region*

class Region(models.Model):

region_name = models.CharField(max_length=75)

office = models.ForeignKey(Office)

region_primary = models.BooleanField()

def __unicode__(self):

return self.region_name



class Meta:

verbose_name = "regio"

verbose_name_plural = "regio's"


There is an extra table which stores which zips are included in one Region:
*Zip_per_region*

class Zip_per_region(models.Model):

region = models.ForeignKey(Region)

zip = models.ForeignKey(Zip)



class Meta:

verbose_name = "postcode"

*
*

how can i use the select_related method?


On Wednesday, April 25, 2012 2:52:13 PM UTC+2, akaariai wrote:
>
> On Apr 25, 3:35 pm, Jonas Ghyllebert  wrote: 
> > I'm new to Django and I would like to apologize if it's been asked 
> before. 
> > 
> > I have two models *Region *and *Zip*. In the admin system, Zip is an 
> inline 
> > model in Region 
> > 
> > Whenever i want to add a Region it shows directly 25 listboxes with 
> zips. 
> > This however takes a long time to load the page and results in an 
> internal 
> > error. 
> > There are 2,774 records in the zip table. 
> > I suspect the cause of this error is that for each list, Django connects 
> to 
> > the database to fetch those records. 
> > Is there a way to solve this? 
>
> Your question is a little hard to answer - it is always a good idea to 
> include the full error message, and preferably the model definitions 
> etc in your post. You leave all who try to help guessing what the 
> problem might be... 
>
> Without knowing more about the situation I suggest you check the 
> queries the page loading generates (using logging, django-debug- 
> toolbar or your database's query logging utilities). Then check if 
> there is a possibility to use select_related or prefetch_related to 
> ease the situation. 
>
> The internal error seems a little strange. Can you share more details 
> about that? 
>
>  - Anssi

-- 
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/-/REr-mpYLw9sJ.
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.



Slow page in admin

2012-04-25 Thread Jonas Ghyllebert
I'm new to Django and I would like to apologize if it's been asked before.

I have two models *Region *and *Zip*. In the admin system, Zip is an inline 
model in Region

Whenever i want to add a Region it shows directly 25 listboxes with zips. 
This however takes a long time to load the page and results in an internal 
error.
There are 2,774 records in the zip table.
I suspect the cause of this error is that for each list, Django connects to 
the database to fetch those records.
Is there a way to solve this?

Thanks in advance

-- 
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/-/kEDmCO8GQZYJ.
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: mocking out a Model

2012-04-15 Thread Jonas Geiregat


>> @patch('apps.market.models.House')
> 
> Is create house in apps.market.models, or is it somewhere else? If
> it's somewhere else, mock it relative to that file eg:
> @patch('apps.some_file.House')

def create_house can be found in apps/deps/house_factory.py
Inside house_factory I ' from apps.market.models import House '


I tried running the test like you said by patching it like:
@patch('apps.deps.house_factory.House')

But for some reason I'm getting a MemoryError by nose.

I tried patching it with patch.object next,
@patch.object('apps.deps.house_factory', 'House')

Then I'm receiving a:
AttributeError: apps.deps.house_factory does not have the attribute 'House'

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



mocking out a Model

2012-04-14 Thread Jonas Geiregat
Hello,

I'm trying to test a function that imports and acts upon a django model, named 
House.

from apps.market.models import House

def create_house(location, date, price):
house = House(id=None, date, price)
house.save()

# calculate some stuff and further expand the house instance
# for example house.tag.add("some-tag")

# save after calculations
house.save()

I like to mock out the House model.
This is what I've tried so far, this is a method of a TestCase class:

@patch('apps.market.models.House')
   def create_house_test(self, MockedHouse):

   """ Constants """
   DAYS_FROM_TODAY = 55
   DATE = datetime.date.today() + datetime.timedelta(days=DAYS_FROM_TODAY)
PRICE = 25

# A location is also a django module , I'm using factory_boy here for 
building a 'mocked' location
   location = LocationFactory.build()


   create_house(DATE, PRICE)
   MockedHouse.assert_called_with(None, DATE, PRICE)   
MockedHouse.save.assert_called_with()


I keep getting an assertionError, the Class is never called.

I'm also wondering if it's possible to inspect MockedHouse to see if it has for 
example some tags added to it.

Any help is appreciated,

Jonas.

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



DjangoCon Europe 2012 Early Bird registration and Call For Papers

2012-03-20 Thread Jonas Obrist
Hello Django users,

A few days ago we launched the full website for this years DjangoCon
Europe. Early bird registration as well as our call for papers is now open.
We also posted the details for our sponsoring options and would love to
gain you as a sponsor for DjangoCon Europe 2012.

DjangoCon Europe will be held in Zurich, Switzerland from the 4th of June
to the 6th of June, followed by two days of sprints.

The early bird registration will run until the 31st of March, so sign up
now! The call for paper will be until the 15th of April.

More information and sign up on http://2012.djangocon.eu

If you have any questions or problems, don't hesitate to contact us.

Best regards,

Jonas Obrist, Co-Chair DjangoCon Europe 2012

-- 
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: RequestContext(request)

2012-01-09 Thread Jonas Geiregat
I'm no expert but the problem should most likely lay with how STATIC_URL is 
populated.

When the line:  str(request.POST.get('question')) , email = "" +
> str(request.POST.get('email')))
>p.save()
> 
>else:
>form = newform() # An unbound form
> 
>return render_to_response('index.html', {
>'form': form,
>},context_instance=RequestContext(request))
> 
> 
> 
> but everytime i add the context_instance=RequestContext(request)  all
> the images in me website goes away !! why
> 
> 
> 
> my html page  index.html :
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  width="800" height="200" id="movie_name" align="middle">
>> 
>
>
>
>
>http://www.adobe.com/go/getflash";>
>http://www.adobe.com/images/shared/
> download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/>
>
>
>
>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> About Us
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut dictum
> enim. Quisque posuere justo sem, posuere lobortis ligulaLorem ipsum
> dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
> Quisque posuere justo sem, posuere lobortis ligula
> 
> 
> 
> 
> 
> About Us
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut dictum
> enim. Quisque posuere justo sem, posuere lobortis ligulaLorem ipsum
> dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
> Quisque posuere justo sem, posuere lobortis ligula
> 
> 
> 
> 
> 
> About Us
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut dictum
> enim. Quisque posuere justo sem, posuere lobortis ligulaLorem ipsum
> dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
> Quisque posuere justo sem, posuere lobortis ligula
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Welcome
> Lorem ipsum
> dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
> Quisque posuere justo sem, posuere lobortis ligula. Etiam erat diam,
> elementum in dapibus bibendum, ultrices eget enim. Nulla et nibh nec
> elit venenatis commodo sit amet pretium eros. Duis vel velit at augue
> tristique vehicula. Nulla in lectus quis nisi egestas egestas at ac
> lacus. Donec rutrum volutpat rhoncus. Proin condimentum, odio eu
> commodo laoreet, turpis leo tincidunt nisi, nec mollis quam justo
> vitae velit.
> 
> 
> 
> 
> textarea{
> background-color:#CC;
> border-color:#1B4D90;
> width:250px;
> height:150px;
> margin-left:20px;
> }
> 
> input[type=text]{
> background-color:#CC;
> border-color:#1B4D90;
> width:250px;
> margin-left:20px;
> 
> }
> input[type=submit]{
> background-color:#1B4D90;
> color:#ff;
> width:100px;
> margin-left:170px;
> 
> }
> 
> {% csrf_token %}
> Quick
> Question 
> {{ form.question }}
> E-
> Mail
> {{ form.email }}
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Global (c) 2011 | Privet policy
>  Powerd by http://www.gardeniatelco.com";>Gardeniatelco a>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> and my settings.py is :
> 
> # Django settings for global project.
> 
> import os
> PROJECT_ROOT =
> os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
> 
> 
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
> 
> ADMINS = (
># ('Your Name', 'your_em...@example.com'),
> )
> 
> MANAGERS = ADMINS
> 
> DATABASES = {
>'default': {
>'ENGINE': 'django.db.backends.sqlite3', # Add
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>'NAME': 'sqlite.db',  # Or path to
> database file if using sqlite3.
>'USER': '',  # Not used with sqlite3.
>'PASSWORD': '',  # Not used with sqlite3.
>'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
>'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
>}
> }
> 
> # Local time zone for this installation. Choices can be found here:
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> # although not all choices may be available on all operating systems.
> # On Unix systems, a value of None will cause Django to use the same
> # timezone as the operating system.
> # If running in a Windows environment this must be set to the same as
> your
> # system time zone.
> TIME_ZONE = 'America/Chicago'
> 
> # Language code for this installation. All choices can be found here:
> # http://www.i18nguy.com/unicode/language-identifiers.html
> LANGUAGE_CODE = 'en-us'
> 
> SITE_ID = 1
> 
> # If you set this to False, Django will make some optimizations so as
> not
> # to load the internationalization machinery.
> USE_I18N = True
> 
> # If you set this to False, Django will not format dates, numbers and
> # calendars according to the current locale
> USE_L10N = True
> 
> # Absolute filesystem path to the directory that will hold user-
> uploaded files.
> # Example: "/home/media/media.lawrence.com/media/"
> MEDIA_ROOT = os.path.join(PROJECT_ROOT, "media")
> 
> # 

Re: RequestContext(request)

2012-01-09 Thread Jonas Geiregat
I'm no expert but the problem should most likely lay with how STATIC_URL is 
populated.

When the line:  str(request.POST.get('question')) , email = "" +
> str(request.POST.get('email')))
>p.save()
> 
>else:
>form = newform() # An unbound form
> 
>return render_to_response('index.html', {
>'form': form,
>},context_instance=RequestContext(request))
> 
> 
> 
> but everytime i add the context_instance=RequestContext(request)  all
> the images in me website goes away !! why
> 
> 
> 
> my html page  index.html :
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  width="800" height="200" id="movie_name" align="middle">
>> 
>
>
>
>
>http://www.adobe.com/go/getflash";>
>http://www.adobe.com/images/shared/
> download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/>
>
>
>
>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> About Us
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut dictum
> enim. Quisque posuere justo sem, posuere lobortis ligulaLorem ipsum
> dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
> Quisque posuere justo sem, posuere lobortis ligula
> 
> 
> 
> 
> 
> About Us
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut dictum
> enim. Quisque posuere justo sem, posuere lobortis ligulaLorem ipsum
> dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
> Quisque posuere justo sem, posuere lobortis ligula
> 
> 
> 
> 
> 
> About Us
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut dictum
> enim. Quisque posuere justo sem, posuere lobortis ligulaLorem ipsum
> dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
> Quisque posuere justo sem, posuere lobortis ligula
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Welcome
> Lorem ipsum
> dolor sit amet, consectetur adipiscing elit. In ut dictum enim.
> Quisque posuere justo sem, posuere lobortis ligula. Etiam erat diam,
> elementum in dapibus bibendum, ultrices eget enim. Nulla et nibh nec
> elit venenatis commodo sit amet pretium eros. Duis vel velit at augue
> tristique vehicula. Nulla in lectus quis nisi egestas egestas at ac
> lacus. Donec rutrum volutpat rhoncus. Proin condimentum, odio eu
> commodo laoreet, turpis leo tincidunt nisi, nec mollis quam justo
> vitae velit.
> 
> 
> 
> 
> textarea{
> background-color:#CC;
> border-color:#1B4D90;
> width:250px;
> height:150px;
> margin-left:20px;
> }
> 
> input[type=text]{
> background-color:#CC;
> border-color:#1B4D90;
> width:250px;
> margin-left:20px;
> 
> }
> input[type=submit]{
> background-color:#1B4D90;
> color:#ff;
> width:100px;
> margin-left:170px;
> 
> }
> 
> {% csrf_token %}
> Quick
> Question 
> {{ form.question }}
> E-
> Mail
> {{ form.email }}
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Global (c) 2011 | Privet policy
>  Powerd by http://www.gardeniatelco.com";>Gardeniatelco a>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> and my settings.py is :
> 
> # Django settings for global project.
> 
> import os
> PROJECT_ROOT =
> os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
> 
> 
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
> 
> ADMINS = (
># ('Your Name', 'your_em...@example.com'),
> )
> 
> MANAGERS = ADMINS
> 
> DATABASES = {
>'default': {
>'ENGINE': 'django.db.backends.sqlite3', # Add
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>'NAME': 'sqlite.db',  # Or path to
> database file if using sqlite3.
>'USER': '',  # Not used with sqlite3.
>'PASSWORD': '',  # Not used with sqlite3.
>'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
>'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
>}
> }
> 
> # Local time zone for this installation. Choices can be found here:
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> # although not all choices may be available on all operating systems.
> # On Unix systems, a value of None will cause Django to use the same
> # timezone as the operating system.
> # If running in a Windows environment this must be set to the same as
> your
> # system time zone.
> TIME_ZONE = 'America/Chicago'
> 
> # Language code for this installation. All choices can be found here:
> # http://www.i18nguy.com/unicode/language-identifiers.html
> LANGUAGE_CODE = 'en-us'
> 
> SITE_ID = 1
> 
> # If you set this to False, Django will make some optimizations so as
> not
> # to load the internationalization machinery.
> USE_I18N = True
> 
> # If you set this to False, Django will not format dates, numbers and
> # calendars according to the current locale
> USE_L10N = True
> 
> # Absolute filesystem path to the directory that will hold user-
> uploaded files.
> # Example: "/home/media/media.lawrence.com/media/"
> MEDIA_ROOT = os.path.join(PROJECT_ROOT, "media")
> 
> # 

Re: Joining Tables

2012-01-08 Thread Jonas Geiregat


> Thanks Jonas, the statements you had provided would give me a list of users 
> who belong that group, but how can I retrieve the photos of those users? 
> Actually I was looking for a single statement which would join all these 
> tables and returns the data based on the Group ID.

I would recommend reading through 
https://docs.djangoproject.com/en/dev/topics/db/queries/

Getting a row by ID:

Group.objects.get(pk=group_id)

-- 
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: Joining Tables

2012-01-08 Thread Jonas Geiregat


> The user field is a foreign key to django auth User model. Each user is 
> assigned to a group (django Auth Group model). I want to retrieve all the 
> photos which belongs to users of a specific group. How can it be done?
> 

from django.contrib.auth.models import Group

group = Group.objects.get(name='your_group')
users = group.user_set.all()

Haven't tested it, but I think that's what you want/need.


-- 
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: Joining Tables

2012-01-08 Thread Jonas Geiregat


> The user field is a foreign key to django auth User model. Each user is 
> assigned to a group (django Auth Group model). I want to retrieve all the 
> photos which belongs to users of a specific group. How can it be done?
> 

from django.contrib.auth.models import Group

group = Group.objects.get(name='your_group')
users = group.user_set.all()

Haven't tested it, but I think that's what you want/need.


-- 
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: Creating clean URLS

2012-01-01 Thread Jonas Geiregat


> I want my url to be free from parameters being passed.
> 
> I have handled the request in "twitter_after_auth" function of view
> and
> 
> I am redirecting user to the new url "http://localhost/create_cr/";
> 
> but instead the url shows some additional parameters that I have
> already handled.

> something like below:-
> 
> "http://localhost/create_cr/?
> oauth_token=SOME_VALUE&oauth_verifier=SOME_VALUE"
> 
> I just want my url to be of something like below:-
> 
> "http://localhost/create_cr/";
> 

It would be interesting to see some part of the view code for further 
inspection of the problem.


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



Re: Django CMS and django-admin-tools are together?

2011-12-27 Thread Jonas Obrist
"but I read that django-admin-tools is one of django-cms apps."

that is incorrect. The initial design and idea started on our blog [1] but 
it was never implemented by us, so someone else did and thus 
django-admin-tools was created.

[1] https://www.django-cms.org/en/blog/2009/10/29/dashboard-proposal-update/

-- 
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/-/AOvbwFHlCtgJ.
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 CMS

2011-12-27 Thread Jonas Obrist
Hi there, if you're asking about django CMS (https://django-cms.org), you 
should use the proper mailing list to ask 
questions: https://groups.google.com/forum/#!forum/django-cms

Also, I do not fully understand your questions. Could you maybe try to 
explain a bit better what you're trying to achieve?

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



Keep getting TemplateDoesNotExist when unit testing

2011-12-24 Thread Jonas Geiregat
Hello,

I'm fairly new to Unit Testing.

As I'm trying to setup a simple unit test in one of my Projects,
it keeps returning a TemplateDoesNotExist Exception.

It looks like for some reason the unit test framework can't locate my template 
directory I've correctly defined in settings.py

Here's the traceback:

==
ERROR: test_url (gig.tests.GigURLTest)
--
Traceback (most recent call last):
  File "/home/jonasg/dev/wiespeeltwaar/gig/tests.py", line 14, in test_url
response = c.get('/')
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/test/client.py",
 line 445, in get
response = super(Client, self).get(path, data=data, **extra)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/test/client.py",
 line 229, in get
return self.request(**r)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/core/handlers/base.py",
 line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
  File "/home/jonasg/dev/wiespeeltwaar/../wiespeeltwaar/gig/views.py", line 74, 
in index
http_res = render_to_response('gig/index.html', c , 
context_instance=RequestContext(request))
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/shortcuts/__init__.py",
 line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), 
**httpresponse_kwargs)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/template/loader.py",
 line 181, in render_to_string
t = get_template(template_name)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/template/loader.py",
 line 157, in get_template
template, origin = find_template(template_name)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/template/loader.py",
 line 138, in find_template
raise TemplateDoesNotExist(name)
TemplateDoesNotExist: gig/index.html


The unit test itself is simple:

from django.test import TestCase
from django.test.client import Client

class GigURLTest(TestCase):
def test_url(self):
c = Client()
response = c.get('/')
self.assertEqual(response.status_code, 200) 

   

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



Keep getting TemplateDoesNotExist when unit testing

2011-12-24 Thread Jonas Geiregat
Hello,

I'm fairly new to Unit Testing.

As I'm trying to setup a simple unit test in one of my Projects,
it keeps returning a TemplateDoesNotExist Exception.

It looks like for some reason the unit test framework can't locate my template 
directory I've correctly defined in settings.py

Here's the traceback:

==
ERROR: test_url (gig.tests.GigURLTest)
--
Traceback (most recent call last):
  File "/home/jonasg/dev/wiespeeltwaar/gig/tests.py", line 14, in test_url
response = c.get('/')
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/test/client.py",
 line 445, in get
response = super(Client, self).get(path, data=data, **extra)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/test/client.py",
 line 229, in get
return self.request(**r)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/core/handlers/base.py",
 line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
  File "/home/jonasg/dev/wiespeeltwaar/../wiespeeltwaar/gig/views.py", line 74, 
in index
http_res = render_to_response('gig/index.html', c , 
context_instance=RequestContext(request))
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/shortcuts/__init__.py",
 line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), 
**httpresponse_kwargs)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/template/loader.py",
 line 181, in render_to_string
t = get_template(template_name)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/template/loader.py",
 line 157, in get_template
template, origin = find_template(template_name)
  File 
"/home/jonasg/.virtualenvs/wiespeeltwaar/lib/python2.6/site-packages/django/template/loader.py",
 line 138, in find_template
raise TemplateDoesNotExist(name)
TemplateDoesNotExist: gig/index.html


The unit test itself is simple:

from django.test import TestCase
from django.test.client import Client

class GigURLTest(TestCase):
def test_url(self):
c = Client()
response = c.get('/')
self.assertEqual(response.status_code, 200) 

   

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



DjangoCon Europe 2012: June 4-6, in Zürich, Switzerland

2011-12-20 Thread Jonas Obrist
Hi all,

We are excited to announce the dates for DjangoCon Europe 2012. The 
conference will be held in Zürich, Switzerland from June 4th to June 6th 
2012, followed by two days of sprints.

The conference will be at Stadion Letzigrund [1] and the sprints will be at 
Cigarettenfabrik Zürich directly at the river.

We have not yet finalized our budget, but we will announce the ticket 
prices as soon as we know them.

We also launched our website, which you can find at 2012.djangocon.eu where 
we will keep you up to date. Also make sure you follow @djangocon on 
twitter.

Looking forward to see you in Zürich in June!

Yours,

Jonas Obrist

[1] http://www.stadionletzigrund.ch/

-- 
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/-/WfIR6rhGBlwJ.
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: Can model subclass change field options?

2011-10-02 Thread Jonas Cleve
Hi Brian,

that works so far for displaying the correct choices in the admin
interface. But the problem now is the validation. He always tells me
that my choice is not a correct value.
I have been looking for a way to change validation but I can't figure
out how to do this...

Thanks for your help so far.

Jonas

Am 02.10.2011 19:41, schrieb Brian Mehrman:
> HI, Artemis,
> 
> If I understand you correctly you want to use a Select Widget for your
> CharField. And feed your choices to the select widget.
> 
> In your admin.py file of your app you will want to override the model's
> form field. 
> 
> 
> # models.py
> from django.db import models
> 
> myModel(models.Model):
>   person = models.CharField()
>   title = models.CharField()
> 
> # admin.py
> from django.contrib import admin
> from django.forms import widgets
> 
> myModelAdmin(admin.ModelAdmin):
>   title = CharField(widget=widgets.Select(choices=('mr','mrs','miss'))
> 
> admin.site.register(myModel, myModelAdmin)
> 
> This code hasnt been tested but should be the route you want to take.
> You can find more info on widgets
> here(https://docs.djangoproject.com/en/1.3/ref/forms/widgets/). I hope
> this helps you.
> 
> -Brian
> 
> On Sun, Oct 2, 2011 at 12:20 PM, Artemis  <mailto:cleve.jo...@googlemail.com>> wrote:
> 
> Hi,
> 
> I have an model which contains a CharField.
> Now I want to have different subclasses of this model each one with
> different *choices* for the CharFiel. How can I implement this?
> 
> --
> 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
> <mailto:django-users@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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: Can model subclass change field options?

2011-10-02 Thread Jonas Cleve
HI, Artemis,

If I understand you correctly you want to use a Select Widget for your
CharField. And feed your choices to the select widget.

In your admin.py file of your app you will want to override the model's
form field. 


# models.py
from django.db import models

myModel(models.Model):
  person = models.CharField()
  title = models.CharField()

# admin.py
from django.contrib import admin
from django.forms import widgets

myModelAdmin(admin.ModelAdmin):
  title = CharField(widget=widgets.Select(choices=('mr','mrs','miss'))

admin.site.register(myModel, myModelAdmin)

This code hasnt been tested but should be the route you want to take.
You can find more info on widgets
here(https://docs.djangoproject.com/en/1.3/ref/forms/widgets/). I hope
this helps you.

-Brian

On Sun, Oct 2, 2011 at 12:20 PM, Artemis mailto:cleve.jo...@googlemail.com>> wrote:

Hi,

I have an model which contains a CharField.
Now I want to have different subclasses of this model each one with
different *choices* for the CharFiel. How can I implement this?

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


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

-- 
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: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Jonas Geiregat



> So you want to edit the User object through the ModelForm of the other model, 
> or you just want to display it?
> 

I want to edit the User object through the ModelForm.

-- 
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: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Jonas Geiregat

> Hi,
> 
> ModelForm should automatically create a dropdown list for your foreign key.
> If there is nor such drop-down created probably you are doing something wrong.
> 

I don't want the dropdown list I want the values of the foreinkey to be 
expaneded into fields

For example I have user as ForeignKey to the contrib.auth.models.User model. 
This model has username as field.

I want to display the username field of the user foreinkey.

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



Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Jonas Geiregat
Hello,

I have a UserProfile model:

class UserProfile(FacebookProfileModel):
user = models.ForeignKey(User, unique=True) 

 
lastfm_user = models.CharField(max_length=20, blank=True)

This should be turned into a real HTML form , I which to use the ModelForm 
class for this.

class UserProfileForm(ModelForm):
class Meta:
model = UserProfile
# I can select lastfm_user or any other properties I have 
defined in the UserProfile model 
# But what if I wanted to only show the user__username field in 
the form ?

# This doesn't work
fields = ('user__username',)

I've searched the docs , read the page about creating froms from models but 
didn't found any clues. 
Is this even possible at all ?

Now I'm implementing the form by hand , which is a lot of work , being able to 
use the ModelForm would speed up this process.

Regards,


Jonas Geiregat
jo...@geiregat.org





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



Re: order by + group by

2011-09-14 Thread Jonas H.

On 09/14/2011 11:37 AM, Иван Иванов wrote:

The problem here is, like Peter said, that you cannot order before
grouping. And that's very annoying.


Of course you can, using a subselect just like I showed. SQLite example:

> .schema
CREATE TABLE a (name varchar, mod int);

e> select * from a;
b1|1
b1|2
b1|3

> select * from a group by name;
b1|3

> select * from (select * from a order by mod desc) group by name;
b1|1

--
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: order by + group by

2011-09-14 Thread Jonas H.

On 09/14/2011 04:35 AM, Peter of the Norse wrote:

What are you trying to do? The outer GROUP BY destroys the inner ORDER BY. Try 
putting them on the same level and see what happens.


Say I've got an Event table and some records like this

  name: foo, timestamp: 9 pm
  name: foo, timestamp: 10pm
  name: bar, timestamp: 3pm

I want the latest event for every `name`:

  name: foo, timestamp: 10pm
  name: bar, timestamp: 3pm

On PostgreSQL one could use DISTINCT ON but it's not yet supported by 
Django, either.


--

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

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



order by + group by

2011-09-11 Thread Jonas H.

Hi!

How can I express this SQL query

  SELECT ... FROM (
SELECT ... FROM ...
  )

in the ORM? Specifically, I want to express

  SELECT ... FROM (
SELECT ... FROM app_model
ORDER BY field1
  )
  GROUP BY field2

Is it possible without writing SQL by hand?

Thanks,
Jonas

--
Django + MongoDB: http://django-mongodb.org

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



Re: Weird Problem: Template Shows Templatevariable's Name Instead Of It's Value

2011-08-14 Thread Jonas H.

On 08/14/2011 09:57 PM, bruno desthuilliers wrote:

{% for current, entry, month, n in months %}


Please think about what "months" is here... Yes, a list of dicts. So
this line is the equivalent of:

current = months[0] # first dict in the list
entry = months[1]# second dict in the list
month = months[2]  # etc
n = months[3]


It is not. If you define multiple loop variables, Python will unpack 
every item in the sequence into those variables -- so this code


for a, b in [...]:
...

is equivalent to

for item in [...]:
a, b = item
...

or

for item in [...]:
a = item[0]
b = item[0]
...

So what happens if your sequence is [{'foo': 1, 'bar': 2}]? The dict 
gets unpacked into the loop variables:


for item in [{'foo': 1, 'bar': 2}]:
a, b = item

And what happens if you loop over a dict? You get a sequence of keys. 
That's why in the OPs output, those keys will show up in the output.


@Schmidtchen: Use mlist.append([n+1, month, entry, current]) instead of 
a dict and you're done -- that also solves the ordering issue.


And Bruno, Schmidtchen's code might really need some cleanup but that's 
beyond the scope of this thread: You might have noticed that your 
comments did *not help* the OP fixing his issues *at all*.


--
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: Redisplay form with different field value?

2011-08-13 Thread Jonas H.

On 08/13/2011 05:00 PM, Karen Tracey wrote:

Plus, afaik, fields can not access form instances so this code would have
to live in the form subclass -- not practical in my use case.


Where I have done this (reluctantly) has been in the form (or perhaps it was
the field) clean method, where self is the form. I am not sure why in your
case you believe that to be not practical.


The field's clean method does not have access to the form; but the 
value-changing logic should go into the field code because I want to 
re-use the field on multiple forms.  Well, I guess that's just not 
possible with Django's form framework. I'll have to find some workarounds.


--
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: Redisplay form with different field value?

2011-08-13 Thread Jonas H.

On 08/13/2011 06:33 AM, Karen Tracey wrote:

On Thu, Aug 11, 2011 at 7:03 AM, Jonas H.  wrote:


On 08/09/2011 12:45 AM, Jonas H. wrote:


Hello list!

Is there any way to use a different value for a field when re-displaying
a form? I.e. if a user enters '42' into an IntegerField but made the
other fields not validate, how could that IntegerField be re-displayed
with '43'?



Change the value in the form's data dictionary.

Karen


Thanks Karen but that's not easily possible because that's an immutable 
QueryDict. Plus, afaik, fields can not access form instances so this 
code would have to live in the form subclass -- not practical in my use 
case.


--
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: Redisplay form with different field value?

2011-08-11 Thread Jonas H.

On 08/09/2011 12:45 AM, Jonas H. wrote:

Hello list!

Is there any way to use a different value for a field when re-displaying
a form? I.e. if a user enters '42' into an IntegerField but made the
other fields not validate, how could that IntegerField be re-displayed
with '43'?

Jonas



anyone?

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



Redisplay form with different field value?

2011-08-08 Thread Jonas H.

Hello list!

Is there any way to use a different value for a field when re-displaying 
a form? I.e. if a user enters '42' into an IntegerField but made the 
other fields not validate, how could that IntegerField be re-displayed 
with '43'?


Jonas

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



limit foreignkey of queryset

2011-07-22 Thread Jonas Geiregat
Hello,

How would I limit the results of a foreign key of a queryset ?
Ie. I have the models Person and Task. I want to get all Person's but only get 
their 2 latest tasks.

Person__task points to Task__name 
It's a ManyToMany Relationship.


Jonas Geiregat
jo...@geiregat.org





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



Re: django.contrib.auth.view.login reuse

2011-07-21 Thread Jonas Geiregat


> Hello,
> 
> I would like to add login fields to each page. But I want to keep it as DRY 
> as possible.
> I'm pretty satisfied until now about using django.contrib.auth.views.login 
> ,but that's just one specific view in my case host.com/login. With a urls.py 
> line as: 
> (r'^/login/$', 'django.contrib.auth.views.login', {'template_name': 
> 'myapp/login.html'}),
> 
> All this django builtin view does is add stuff to the context of the request 
> and render one single template.
> 
> My problem now is, can I reuse that view in other views or use it so I can as 
> a template context processor, so it's always available ? 
> I'm having trouble figuring out which would be the best route to take.

I've figured some stuff out already. Being able to read the django source code 
is such a bless!
I can use the form stored at django.contrib.auth.forms.AuthenticationForm.

Knowing I can easily access the login from I could create my own context 
processor and add it side-wide from 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-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: import django models without runing the server

2011-07-21 Thread Jonas Geiregat

> Alexander,
> 
> Try use this
> 
> #test.py
> import os, sys
> sys.path.append('../')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
> 
> myproject/test.py
> 


This is a good read on the subject , it presents an elegant solution.

http://superjared.com/entry/django-and-crontab-best-friends/

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



django.contrib.auth.view.login reuse

2011-07-21 Thread Jonas Geiregat
Hello,

I would like to add login fields to each page. But I want to keep it as DRY as 
possible.
 I'm pretty satisfied until now about using django.contrib.auth.views.login 
,but that's just one specific view in my case host.com/login. With a urls.py 
line as: 
(r'^/login/$', 'django.contrib.auth.views.login', {'template_name': 
'myapp/login.html'}),

All this django builtin view does is add stuff to the context of the request 
and render one single template.

My problem now is, can I reuse that view in other views or use it so I can as a 
template context processor, so it's always available ? 
I'm having trouble figuring out which would be the best route to take.

Any advise is welcome,

Regards,

Jonas.

-- 
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: session and caching

2011-07-13 Thread Jonas Geiregat


> I have site with with a lay-out depending on a session, set in my
> view. I first tried site-wide caching, and this obviously didn't work.
> The caching is not session aware, and the lay-out changes almost
> randomly.

Are you sure because in the docs I find the opposite.

https://docs.djangoproject.com/en/dev/topics/http/sessions/#using-cached-sessions



-- 
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: Inspecting objects

2011-07-12 Thread Jonas Geiregat

Op 13-jul-2011, om 08:25 heeft Jirka Vejrazka het volgende geschreven:

>> Thank you all for your help!!!
> 
> I know I'm a bit late to the party (blame timezones :), but thought
> I'd put my 2 cents worth in :)
> 
> For inspecting models from command lines (usually when working with
> models from legacy databases) I often use model_to_dict which is
> "hidden" in django.forms.models.



This is new for me. I've noticed before that django's API docs doesn't all 
function available. There's probably a good reason for it.

What's the advantage of using model_to_dict against dict(some_queryset) ?

-- 
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: Inspecting objects

2011-07-12 Thread Jonas Geiregat
I like to add:

import pdb; pdb.set_trace();

To my code.

Reload the page.

Go to the development server instance. You'll see that the page hangs forever 
,since we started the python debugger. 
Now you can easily inspect all variables, classes and functions from PDB. 
Of course you're not limited to using set_trace().

Good luck !


>> Thank you all for your help!!!
> 
> I know I'm a bit late to the party (blame timezones :), but thought
> I'd put my 2 cents worth in :)
> 
> For inspecting models from command lines (usually when working with
> models from legacy databases) I often use model_to_dict which is
> "hidden" in django.forms.models.
> 
>>>> from django.forms.models import model_to_dict
>>>> print model_to_dict(some_model)
> 
>  HTH
> 
> Jirka
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 


Jonas Geiregat
jo...@geiregat.org





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



Re: get all objects that are related to current, reverse look up

2011-07-12 Thread Jonas Geiregat

Op 12-jul-2011, om 09:18 heeft bruno desthuilliers het volgende geschreven:

> On Jul 12, 4:32 am, garagefan  wrote:
>> simply put, here's my code
>> 
>> class ContentBlock(Orderable, Displayable):
>>   location = models.ManyToManyField(ContentBlockLocation, blank=True,
>> null=True, help_text="list of locations to display content block")
>>   page = models.ManyToManyField(Page, blank=True, null=True,
>> help_text="list of pages to display content block")
>>   height = models.IntegerField(blank=True, null=True)
>>   width = models.IntegerField(blank=True, null=True)
>> 
>>   def __unicode__(self):
>> return self.title
>> 
>> class StaticContent(Displayable, RichText):
>>  content_block =  models.ForeignKey(ContentBlock, blank=True,
>> null=True)
>> 
>> class StaticContent2(Displayable, RichText):
>>  content_block =  models.ForeignKey(ContentBlock, blank=True,
>> null=True)
>> 
>> putting together a template tag that will return all the items
>> associated with a given ContentBlock, but i would like to do so
>> without knowing upfront all of the classes that have a foreign key to
>> ContentBlock as i'll want to be able to add more content types at any
>> time
> 
> 
> Are you sure your data model is right ?
> 

Displayable and RichText are probably classes that inherit from 
django.db.models.Model.




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



Re: block bots and spiders

2011-07-12 Thread Jonas Geiregat


> Hi all,
> 
> has someone an effective way to block away bots and spiders?
> There are so many ignoring robots.txt - besides facebook and tons of
> Java/xyz clients there are many more illegal spiders around.
> 
> So does anyone have a performance effective way to block them out?
> Or do you think - if performance matters, leave them crawling...
> 
> regards
> 
> Henrik

The only thing I can think of is checking the request.META dictionary. It 
contains the HTTP_HOST and HTTP_USER_AGENT settings by the client. You could 
check if those are valid but of course a spider could fake those values. But 
I'm guessing not all spiders fake them.
You could at least filter out those that don't set these values.

It would probably require lot's of heavy regular expression code (since there 
are so many valid client headers) which would be best implemented as a 
decorator on each view method.  Or you could probably put the code in a 
middleware.
Eventually taking out those spiders would slow down your request.

Again I have no experience on this field, it's just an idea that might be 
possible.

Regards,

Jonas.

-- 
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: request.method GET or POST

2011-07-12 Thread Jonas Geiregat

Op 12-jul-2011, om 07:04 heeft Venkatraman S het volgende geschreven:

> We have to check for request.method to suitably route the request to the 
> logic.
> 
> Would it be nice if we have something like doGet or doPost(similar to java 
> servlets) that we have in our views,
> so that the request gets automatically routed , and the code is structured 
> nicely?
> 
> So a view would look like:
> def funcname(request,itemid,..):
>   def doPOST():
> #.do things when the request is POST
>   def doGET():
> #.do things when the request is GET..
> 

How would that be different from doing something like

@require_http_methods(["GET", "POST"])
def funcname(request, itemid):
if request.method == 'POST':
# do something

 #We can savely assume it's a GET request since it's not a POST request and 
those are the only two allowed
# do something 


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



Django API

2011-07-12 Thread Jonas Geiregat
Hello,

I really love django's documentation. It covers a lot of ground and is really 
well written. 
I do have one problem with it. It might be best explained with an example.

I want to see all methods and properties of the request parameter in the view. 
Search the docs for "request" doesn't help me much. In fact searching the docs 
for a particular method often doesn't point me to the correct page.

What I sometimes need is a tree view of all django's modules, classes, methods 
and properties. It also might help me better understand the structure of how 
django was written.

Is there something like that out there ?

Regards,

Jonas Geiregat
jo...@geiregat.org





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



Re: need help with calling following complex query

2011-07-11 Thread Jonas Geiregat
> 
> results.extra(select={
> 'distance': 
> '(acos(sin(latitude)*sin(%(latitude)f)+cos(latitude)*cos(%(latitude)f)*cos(%(longitude)f-longitude)))'
>   % {
>  'latitude': latitude,
>  'longitude': longitude
> }
> }).order_by('distance')  
> 

This is an interesting solution to the issue. I never really looked into the 
extra method. 
So I read the docs and I'm wondering if it wouldn't be better to use the 
select_params parameter ?


-- 
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: need help with calling following complex query

2011-07-10 Thread Jonas Geiregat
> 
> 
> In order to find the places in near by area I want to make following
> mysql query. but I am not sure how should I translate it using django
> models and managers.

You could execute the raw sql query string, see: 
https://docs.djangoproject.com/en/dev/topics/db/sql/
for more information on the subject. Seeing the complexity of the query and 
knowing it's a good working version why should you even bother translating it 
to django's ORM framework ?

> 
> orig.lat = x
> orig.lon = y
> 
> "SELECT  destination.*,
> 3956 * 2 * ASIN(SQRT(  POWER(SIN((orig.lat - dest.lat) * pi()/180 /
> 2), 2) +
> COS(orig.lat * pi()/180) *  COS(dest.lat * pi()/180) *
> POWER(SIN((orig.lon -dest.lon) * pi()/180 / 2), 2)  )) as
> distance
> FROM place as dest
> WHERE  dest.longitude
> BETWEEN lon1 and lon2
> AND dest.latitude
> BETWEEN lat1 and lat2
> "
> 
> the model which talks to database is called Place in my case.
> 
> Thank you all for the help,
> sanket
> 
> -- 
> 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.
> 


Jonas Geiregat
jo...@geiregat.org





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



Re: Extending User model with Inheritance - Attribute Error

2011-07-10 Thread Jonas Geiregat

Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven:

> 
> This is not good design. If you want to store some extra fields for a User - 
> i would define just another model called ProfileDetails, FK it to User and 
> use it as such.

That's also how I would do it, some example code to make it even more clear:

from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
url = models.URLField("Website", blank=True)
company = models.CharField(max_length=50, blank=True)

-- 
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: login form

2011-07-09 Thread Jonas Geiregat

> @ All
> i have created a login form in django.
> but after filling the username and password when click on submit, it
> shows the following error :
> 
> Forbidden (403)
> 
> CSRF verification failed. Request aborted.


This has been asked many times before on this list.  
I advise you to read the extra guidelines that come with the error message , as 
they explain what you should do in order to get the page working.



-- 
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: cropping of an image

2011-07-07 Thread Jonas Geiregat


> 
> I want the code for including an image with crop feature.

Django doesn't come with any image handling libraries.
I've done this before and have used PIL (Python Image Library) for it.

It might be advised to use this in combination with celery if you're handling 
large files. 
That way it wouldn't slow down the request.

Regards,

Jonas

-- 
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/python performance vs play/java

2011-07-05 Thread Jonas Geiregat
>  99% 38
> 100% 47 (longest request)
> 
> 
> so play is outperforming django! obviously django is not in debug mode
> ecc..., is there something wrong in my test setup (I already tried to
> adjust the uwsgi launch line I tryed more process or 1 process with
> threads ecc with no relevant improvement) or django/python is simply
> much slower than java? I tried to run play behind nginx proxy too: the
> results are pratically identical. Note the response time too: the
> slowest play response is 47 ms, the fastest django one is 110 ms,
> 
> any suggestion to improve performance is appreciated,
> 
> thanks in advance,
> drakkan
> 
> -- 
> 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.
> 


Jonas Geiregat
jo...@geiregat.org





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



complex query

2011-07-03 Thread Jonas Geiregat
Hello,

I have the following models

class Book(models.Model):
author = models.ManyToManyField(Author)
pub_date = models.DateTimeField()
...

class Author(models.Model):
tag = models.ManyToManyField(Tag)

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

What I want to query for is:

The most used Tags (and their count) for all books who's pub_date is greater 
then today.

I can solve the last part 
Book.objects.filter(pub_date__gt=datetime.date.today())

But how do I count all the tags for all these books ?

Jonas Geiregat
jo...@geiregat.org





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



Re: Stuck on "ViewDoesNotExist" last step of tutorial part 4

2011-06-18 Thread Jonas Geiregat
The view function may have been deleted but the urls.py file (in the root of 
your project) is still (probably) referring to those functions. So look at your 
urls.py file and you'll figure it out!

Good luck!

> I am using Django 1.3 with SQlite. I got through the entire tutorial
> except the last step of part 4.
> 
> It says "You can now delete the index(), detail() and results() views
> from polls/views.py. We don't need them anymore -- they have been
> replaced by generic views."
> 
> However when I do this I get the following error:
> 
> Environment:
> 
> 
> Request Method: POST
> Request URL: http://localhost:8000/polls/1/vote/
> 
> Django Version: 1.3
> Python Version: 2.7.2
> Installed Applications:
> ['django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'polls',
> 'django.contrib.admin']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware')
> 
> 
> Traceback:
> File "c:\Python27\lib\site-packages\django\core\handlers\base.py" in
> get_response
>  111. response = callback(request,
> *callback_args, **callback_kwargs)
> File "C:\Documents and Settings\ask\Desktop\Stream Coding Project
> \Django First Tutorial\mysite\polls\views.py" in vote
>  24. return HttpResponseRedirect(reverse('poll_results',
> args=(p.id,)))
> File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
> reverse
>  391. *args, **kwargs)))
> File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
> reverse
>  312. possibilities = self.reverse_dict.getlist(lookup_view)
> File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
> _get_reverse_dict
>  229. self._populate()
> File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
> _populate
>  220. lookups.appendlist(pattern.callback, (bits,
> p_pattern))
> File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
> _get_callback
>  170. raise ViewDoesNotExist("Tried %s in module %s.
> Error was: %s" % (func_name, mod_name, str(e)))
> 
> Exception Type: ViewDoesNotExist at /polls/1/vote/
> Exception Value: Tried results in module polls.views. Error was:
> 'module' object has no attribute 'results'
> 
> -- 
> 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.
> 


Jonas Geiregat
jo...@geiregat.org





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



Re: django database

2011-05-26 Thread Jonas Geiregat


> do i have to install mysql to create a database in my website?

As mentioned before you can use sqlite but consider the disadvantages:

* Speed (sqlite for me ,even when developing a serious application, is a no go) 
When deleting large rows sqlite is remarkably slower then mysql.
* I've seen some issues where sqlite locks tables when there are multiple 
requests or queries.

I don't see any advantages for mysql over postgresql. But then again I'm no 
expert in this area.




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



Re: How do you organize your deployment enviroment

2011-05-25 Thread Jonas Geiregat
I'm just wondering how you could handle database changes.

Let's say you have a existing working project and the client asks for some 
changes.

These changes force you to create an extra table and modify some tables 
(models). 
On the development server I could modify the changes to the database and the 
models files myself.
But deploying these changes to the production server seems a bit harder to 
overcome without the fear of loosing your data.

I don't think the newly created models and database tables would form a 
problem. Simply running ./manage.py syncdb would create the table(s) for us 
without any problems. 
But what about tables (models) that are modified ?

How would you best handle such cases of deployment ?


Op 23-mei-2011, om 09:00 heeft DK het volgende geschreven:

> Hi,
> 
> I am having a django project that  is being frequently deployed on clean 
> linux installation. After a few deployments I have noticed that this process 
> is very time consuming for me (every time I am preparing run scripts for 
> everything, configuring cronjobs, paths to log files, etc) but this could be 
> easily automated.
> 
> What are a ready solutions to manage such deployments?
> 
> My typical workflow is:
> 1) install packages on debian/ubuntu via aptitude (like database, etc)
> 2) creating new virtualenv + getting pip
> 3) pip install -r requirements (to setup enviroment)
> 4) fetch django project from code repository
> 5) setup runtime dir (I keep there: run - for pid files, logs, conf - for 
> some config variables or scritps, scripts - some starting srcipts)
> 6) setup crontab jobs 
> 7) setup webserver + django wsgi to be started 
> 
> 
> Sure - I can write some custom made installer for that, but wondering if 
> there is some generic tool for such things.
> 
> PS. I have heard about fabric, but didn't investigate this tool yet. 
> 
> 
> 
> 
> -- 
> 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.


Jonas Geiregat
jo...@geiregat.org





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



Re: Authenticating from a mysql database

2011-05-23 Thread Jonas Geiregat

> Hello Jonas,
> 
> thanks again for your reply. I think migrating the database over to
> django may be a good idea, however it's still being used as a legacy
> authentication database for other projects.
> 
> In case I'd decide to migrate the existing users over to the new
> database, how could I make sure the passwords end up in django
> correctly? All I have is the old_password()-crypted user passwords,
> can I simply insert those as values into the auth_user db field?

That might be one of the bigger things to overcome.

In order to succeed you must find out how django stores passwords and how your 
current passwords are stored.
That way you can start converting , probably by writing some python conversion 
script.
You can find out more on how django stores it's passwords here 
http://docs.djangoproject.com/en/dev/topics/auth/#passwords

For the Zope part you're on you're own, I've never looked at it in my life. 


> 
> All the best, Uwe
> 
> -- 
> 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.
> 


Jonas Geiregat
jo...@geiregat.org





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



Re: Authenticating from a mysql database

2011-05-23 Thread Jonas Geiregat
Defining your specific user profile as described in my previous post would 
work. It might need some work arounds and
additional methods to get it working.

If possible I think migrating the database table (the login , name and password 
fields only) you presented to the database your django project database is 
using, seems more elegant.
There would be no need for writing extra code to get this working. 
The only code extra would be , again, a user profile. For storing the role 
column.

For more information about user profiling and django , take a look at:

open http://docs.djangoproject.com/en/dev/topics/auth/#auth-profiles

> Thanks much for your reply Jonas, I'll give it a try later.
> 
> SimpleUserFolder is a Zope "Product" that allows for authentication
> via other mechanisms than Zope's built-in user management. I'm sure
> there is a way to bend Django around the database tables in some way,
> but as i've never tried that before I thought it a good idea to ask
> the experts first.
> 
> The database table is called "users" and has, among others, the
> following columns:
> 
> mysql> desc users;
> +-++--+-
> +---++
> | Field   | Type   | Null | Key |
> Default   | Extra  |
> +-++--+-
> +---++
> | user_id | int(11)| NO   | PRI |
> NULL  | auto_increment |
> | login   | varchar(16)| NO   | UNI
> |   ||
> | name| varchar(80)| NO   | MUL
> |   ||
> | password| varchar(16)| YES  | |
> NULL  ||
> | role| set('Manager','User','Driver') | YES  | MUL |
> Driver||
> 
> The password is encrypted using mysql's password() function, but I
> guess that would not pose too much of a problem, right?
> 
> All the best, Uwe
> 
> 
> On 23 Mai, 00:16, Jonas Geiregat  wrote:
>> Hello,
>> 
>> I've never worked with Zope so SompleUserFolder doesn't ring a bell.
>> I'm assuming it's a database table name.
>> 
>> You can always extend the default user's profile.
>> 
>> This is done by creating a class , most people use UserProfile
>> 
>> class UserProfile(models.Model):
>> user = models.ForeignKey(User, unique=True, related_name='profile')
>> #your fields that point to your SimpleUserFolder
>> 
>> Then add the following to your settings.py file to let django use your class
>> 
>> AUTH_PROFILE_MODULE = 'accounts.UserProfile' # assuming you have created a 
>> accounts application
>> 
>> Op 22-mei-2011, om 17:31 heeft Uwe Schuerkamp het volgende geschreven:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Hi folks,
>> 
>>> I'm in the process of migrating (or re-designing for that matter) a
>>> Zope-based user database /ranking system over to Django with roughly
>>> 30,000 accounts in it. The Zope instance uses SimpleUserFolder for
>>> authentication, so I was wondering if there is a way to authenticate
>>> django users from within the existing mysql database.
>> 
>>> Would it be possible to extract roles information from the user table
>>> as well?
>> 
>>> Thanks in advance for any ideas,
>> 
>>> Uwe
>> 
>>> --
>>> 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 
>>> athttp://groups.google.com/group/django-users?hl=en.
>> 
>> Jonas Geiregat
>> jo...@geiregat.org
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 


Jonas Geiregat
jo...@geiregat.org





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



Re: How do you organize your deployment enviroment

2011-05-23 Thread Jonas Geiregat
I'm using Fabric for my deployment it's python based although it still leans on 
some shell scripting.

Op 23-mei-2011, om 09:00 heeft DK het volgende geschreven:

> Hi,
> 
> I am having a django project that  is being frequently deployed on clean 
> linux installation. After a few deployments I have noticed that this process 
> is very time consuming for me (every time I am preparing run scripts for 
> everything, configuring cronjobs, paths to log files, etc) but this could be 
> easily automated.
> 
> What are a ready solutions to manage such deployments?
> 
> My typical workflow is:
> 1) install packages on debian/ubuntu via aptitude (like database, etc)
> 2) creating new virtualenv + getting pip
> 3) pip install -r requirements (to setup enviroment)
> 4) fetch django project from code repository
> 5) setup runtime dir (I keep there: run - for pid files, logs, conf - for 
> some config variables or scritps, scripts - some starting srcipts)
> 6) setup crontab jobs 
> 7) setup webserver + django wsgi to be started 
> 
> 
> Sure - I can write some custom made installer for that, but wondering if 
> there is some generic tool for such things.
> 
> PS. I have heard about fabric, but didn't investigate this tool yet. 
> 
> 
> 
> 
> -- 
> 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.


Jonas Geiregat
jo...@geiregat.org





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



Re: Authenticating from a mysql database

2011-05-22 Thread Jonas Geiregat
Hello,

I've never worked with Zope so SompleUserFolder doesn't ring a bell.
I'm assuming it's a database table name.

You can always extend the default user's profile.

This is done by creating a class , most people use UserProfile

class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True, related_name='profile')
#your fields that point to your SimpleUserFolder


Then add the following to your settings.py file to let django use your class

AUTH_PROFILE_MODULE = 'accounts.UserProfile' # assuming you have created a 
accounts application


Op 22-mei-2011, om 17:31 heeft Uwe Schuerkamp het volgende geschreven:

> Hi folks,
> 
> I'm in the process of migrating (or re-designing for that matter) a
> Zope-based user database /ranking system over to Django with roughly
> 30,000 accounts in it. The Zope instance uses SimpleUserFolder for
> authentication, so I was wondering if there is a way to authenticate
> django users from within the existing mysql database.
> 
> Would it be possible to extract roles information from the user table
> as well?
> 
> Thanks in advance for any ideas,
> 
> Uwe
> 
> -- 
> 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.
> 


Jonas Geiregat
jo...@geiregat.org




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



Re: Json serialization for use in JS

2011-05-20 Thread Jonas Geiregat
> 
> class Serializer(PythonSerializer):
> def end_object(self, obj):
> self.objects.append({
> "fields" : self._current
> })  
> self._current = None
> 
> 

I've made a small mistake I was importing PythonSerializer while It should've 
been JsonSerializer

Corrected code bellow:

from django.core.serializers.json import Serializer as JsonSerializer

class Serializer(JsonSerializer):
def end_object(self, obj):
self.objects.append({
"fields" : self._current
})
self._current = None



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



Re: Json serialization for use in JS

2011-05-20 Thread Jonas Geiregat

> 
> Your idea of overriding the Serializer class sounds like a better idea to me. 
> It should be possible (and will be interesting) ,I'll think I'll look into 
> that tonight.

Overwriting django's default serializers is possible.
This is how I've done it:

In the root of my django project:

mkdir serializers
touch serializers/__init__.py

create serializers/json.py and add the following (I've just removed the pk and 
model fields which I don't like , but can of course be modified to your liking)

from django.core.serializers.python import Serializer as PythonSerializer

class Serializer(PythonSerializer):
def end_object(self, obj):
self.objects.append({
"fields" : self._current
})  
self._current = None


I've only tested this interactively but it seems to work

In [15]: from serializers.json import Serializer as JsonSerializer

In [16]: json_serializer = JsonSerializer()

In [17]: json_serializer.serialize(Item.objects.all())
Out[17]: [{'fields': {'name': u'foobar'}}]




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



  1   2   3   >