Struggling with formsets

2012-05-18 Thread David
Given 2 models: class Person(models.Model): first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) class PersonAttendance(models.Model): person = models.ForeignKey(Person) attend_date = models.DateField() I need to produce a formset that lists

Re: Struggling with formsets

2012-05-18 Thread David
Thanks Pedesen for your reply. I have tried inline-formsets and as you say unfortunately I could only get it to work with a single object. -- 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

Re: Struggling with formsets

2012-05-29 Thread David
Anyone else have any suggestions please? 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/-/-8zgkyBbFBoJ. To post to this group, send email to djang

jquery, json and forms

2012-07-02 Thread David
Hello I have a form that saves, and displays errors correctly when using javascript and without. However, when my form saves I need to refresh the form with the new form data. How can I pass the form object through json back to my template please? Thank you for any help. -- You received thi

_set.all()

2012-07-27 Thread David
Hello This may be more of a Python question that a Django question, but ... I am trying to make one of my apps more abstract. Using _set.all() I can return all of the m2m relations. I can then loop through them doing what I like *providing *I know the model field names. if not isinstance(f, Ge

Re: _set.all()

2012-07-27 Thread David
hmm nvm print unicode(a) seems to do the trick. -- 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/-/KR3z7jzCPusJ. To post to this group, send email to django-

Returning data belonging to a model (FK)

2012-07-27 Thread David
Hi I am trying to abstract one of my applications. for f in self._meta.fields: print f if f.get_internal_type() == "ForeignKey": for o in f.related.parent_model.objects.all(): I am using the above code to isolate any fields in self._meta.fields tha

Re: Returning data belonging to a model (FK)

2012-07-27 Thread David
Hi Victor I am using contenttypes already and am finding it hugely useful. I am trying to decouple the applications need to "know" the model that the contenttype has linked to. This way it should generically understand, interpret and perform functions on any given instance of an object regardl

TemplateResponse and json

2012-09-17 Thread David
Hello I am aware of the options to set the content_type when using TemplateResponse, but is it possible to make the response itself return json converted rendered template and not just a rendered template? Thank you -- You received this message because you are subscribed to the Google Groups

How to use ModelForm for both new or existing data

2011-09-05 Thread David
Hi, I'm having trouble figuring out the best way to use ModelForm in the following situation. I have these post variables coming into the view course_id course_department course_number And course_id may or may not be an empty string. If I do course_form = CourseForm(request.POST) Then the pro

Create/update/delete generic views

2011-09-13 Thread David
Hello This is my code so far from urls.py from django.views.generic import ListView, create_update url(r'^reportwriting/types/edit/(?P\d+)/?$', create_update.update_object( model=Type )), I am trying to use the new CRUD generic views but am repeatedly getting the followi

Re: Create/update/delete generic views

2011-09-13 Thread David
Hi Daniel That is very helpful and I have it working now. Is there a way to have my success_url go to my ListView class-based view as it isn't named? url(r'^reportwriting/types/$', ListView.as_view( model=Type, paginate_by=2 )), url(r'^reportwriting/types/edit/(?P\d+)/?$',

Re: Create/update/delete generic views

2011-09-13 Thread David
Or alternatively to redirect to the update form that has just been submitted. -- 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 djan

Re: Create/update/delete generic views

2011-09-13 Thread David
Got it url(r'^reportwriting/types/$', ListView.as_view( model=Type, paginate_by=2 )), url(r'^reportwriting/types/edit/(?P\d+)/?$', UpdateView.as_view( model=Type, success_url='/reportwriting/types/' )), or url(r'^reportwriting/types/$', Lis

form success_url redirect to previous paginated page

2011-09-13 Thread David
This is my template: {% block content %} Report Writing Types {% for type in object_list %} {{ type.name }} Edit {% endfor %} {% if page_obj.has_previous %} previous {% endif %} Page {{ page_obj.numb

Is it possible to use required_css_class with ModelForm?

2011-09-16 Thread David
Hi I'm using ModelForm but cannot attach a class="required" to the labels of my form. Is this possible? or would I have to construct my form? -- 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@googl

Re: Is it possible to use required_css_class with ModelForm?

2011-09-16 Thread David
Answered my own question. It's fine in the class, I had it in META :-) -- 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-user

Populating form and having access to related objects

2011-09-16 Thread David
Hello This is my view @login_required @transaction.commit_on_success def companyedit(request, pk): if request.method == 'POST': a = Company.objects.get(pk=pk) form = CompanyForm(request.POST, instance=a) if form.is_valid(): form.save() else: co

Re: Populating form and having access to related objects

2011-09-16 Thread David
I should add that Person has the foreign key relationship to Company. I know how to do this in SQL but not in the ORM. Thanks for any assistance. -- 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

Re: Populating form and having access to related objects

2011-09-16 Thread David
Hi Javier Thanks for your reply. I have modified my view like this: def companyedit(request, pk): if request.method == 'POST': a = Company.objects.select_related().get(pk=pk) form = CompanyForm(request.POST, instance=a) if form.is_valid(): form.save()

Re: Populating form and having access to related objects

2011-09-16 Thread David
Is this because my Company model contains no foreign keys as the relationship is from Person to company and Person contains the foreign key? -- 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@google

Re: Populating form and having access to related objects

2011-09-16 Thread David
Javier That's great and working, thank you. I have modified my code and it appears to be working now. Does what I have done now account for the GET scenario please? Thanks again! def companyedit(request, pk): if request.method == 'POST': a = Company.objects.select_related().get(pk=pk

select_related

2011-09-19 Thread David
Hello Can/does select_related traverse models in other installed apps? and if not, can it be? I have the following app1 class company no FKs class person FK to company app2 class purchase FK to person I can access both company and person rendering like this in my template: company.person_set

Re: select_related

2011-09-19 Thread David
Hi Daniel Re: (2.) company.purchase_set.all returns nothing in my template. This is my select_related line: a = Company.objects.select_related().get(pk=pk) Regarding your reply (1.) because there are no FK's in the company table I had assumed that Django must be using reverse relations to acce

Re: select_related

2011-09-19 Thread David
Hi Daniel Having installed Django debug toolbar it looks like select_related is only performing one level of relation finding as opposed to following relationships through to their conclusion. -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: select_related

2011-09-19 Thread David
Even when specifying depth in the select_related line I cannot get Django's ORM to look past one level below Company. -- 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 unsubscr

Re: select_related

2011-09-19 Thread David
OK I think I know why, and is this correct please? class Company class Person class Purchase Person is related to Company by a FK in Person called company. Class Purchase is related to Person by a FK in Person called FK - not company. Therefore is it correct that Django's ORM only pursues comp

Re: select_related

2011-09-19 Thread David
Thank you Sebastien and Daniel for your replies. Daniel, I am new to Django and Python which is why it's taking a while to get used to it. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googleg

How to make a query form depend on a field?

2011-09-25 Thread David
hints or snippets would be greatly appreciated. Thanks very much. --David -- 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 d

Accessing sum in templates

2011-09-26 Thread David
Hello In my view I have: a = Person.objects.select_related().get(pk=pk) b = a.issue_set.filter(resolution_date__isnull=True).aggregate(Sum('type__severity')) variables = RequestContext(request, { 'person': a, 'issue': b, }) r

Re: Accessing sum in templates

2011-09-26 Thread David
Sorted: {{ issue.type__severity__sum }} doh :-/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegr

Help with image file upload

2011-09-27 Thread David
Hello This is my view: @login_required @transaction.commit_on_success def update_person(request): try: person_id = int(request.POST['person_id']) except KeyError: raise Http404 person = Person.objects.select_related().get(pk=person_id) form = PersonForm(request.POS

Re: Help with image file upload

2011-09-27 Thread David
Thank you for the link but unfortunately it hasn't got me any further. I believe I have my model set up correctly: image_width = models.IntegerField(editable=False, null=True) image_height = models.IntegerField(editable=False, null=True) image = models.ImageField(upload_to='persons/%Y

commit=false and user id

2011-09-27 Thread David
Hopefully this will make sense. You are on a page displaying information about a Person. You want to add a log to this person so you fill in the form at the bottom of the page. When that form is saved to a log object both the user that has submitted the log, and the person to whom the log belongs

Re: commit=false and user id

2011-09-27 Thread David
Hi Tom I am unsure, yes it could be request.person that isn't populated. How can I pass that through my form submission ? Thanks for your reply. -- 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@

Re: commit=false and user id

2011-09-27 Thread David
Hi Tom I had been using ajax on the form and thus hadn't got my traceback. I removed all ajax to get the traceback and it says: 'WSGIRequest' object has no attribute 'person' Relating to: f.person = request.person I guess. Do I have to add a hidden field for the person id? -- You received th

Re: commit=false and user id

2011-09-27 Thread David
Great food for thought. Thank you for your help Tom! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@goog

Help with forms (really struggling)

2011-09-29 Thread David
Hi I have a page called Person which lists basic contact details. I intend to have a series of forms on this page in hidden div's that enable a user to submit data pertaining to this contact such as contact logs. Each form will be submitted by ajax which is why I am making their form actions point

Re: Help with forms (really struggling)

2011-09-29 Thread David
Hi Kurtis Thanks for your reply. That wasn't a silly question. A person is not a user. I modified my view like this: @login_required def update_log(request, pk): try: person = Person.objects.get(pk=pk) except KeyError: raise Http404 if req

Re: Help with forms (really struggling)

2011-09-29 Thread David
Thank you both for your assistance. When I try to use the following (which is my interpretation Tom of your modifications) I get this error: Cannot assign "u'1'": "Log.person" must be a "Person" instance. @login_required @transaction.commit_on_success def update_log(request, pk): if requ

Re: Help with forms (really struggling)

2011-09-29 Thread David
I should add that person is a FK in the log 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...@google

Re: Help with forms (really struggling)

2011-09-29 Thread David
Thank you both so much for your help! I had been fighting this for some time; doesn't help starting Django whilst still learning Python and OOP. The following works perfectly: @login_required @transaction.commit_on_success def update_log(request, pk): if request.method == 'POST' and reque

Form validation with ImageFields

2011-10-03 Thread David
Hello I need to upload an image through a form. I also need to have the ability to use the "clear" checkbox built into the imagefield widget to have the image reference in the database removed. Images should also be checked for filetype, dimensions and rejected if appropriate. So I did this:

DetailView

2012-11-21 Thread David
Hello I am trying to use a class based generic view (DetailView) to view user profiles. What I am trying to achieve is: if no user PK is provided in the URL show the logged in user. If there is a user PK in the URL show that user. Thus reducing the need to have 2 views. My code currently erro

Re: DetailView

2012-11-21 Thread David
Thank you for you reply Tom. I am now getting: "Generic detail view home must be called with either an object pk or a slug." I have tried using the pk line you pointed to in the get_queryset method. Should I instead be trying to use def get: ? -- You received this message because you are sub

Re: DetailView

2012-11-21 Thread David
Think I now have this working with the following: def get_queryset(self): self.kwargs['pk'] = self.kwargs.get('pk', self.request.user.id) UserModel = get_user_model() profile = UserModel.objects.filter(pk=self.kwargs['pk']) return profile Thanks for your replie

Re: DetailView

2012-11-21 Thread David
Hi Patrick The error exists on this line: pk = self.kwargs['pk'] KeyError at /accounts/profile/ 'pk' Request Method: GET Request URL: http://127.0.0.1:8000/accounts/profile/ Django Version: 1.5 Exception Type: KeyError Exception Value: 'pk' Exception Location: C:\Users\DavidWills.DELTAGEM\Dja

Re: DetailView

2012-11-22 Thread David
Sergiy Some of your points cover my old code (which was very much a first draft). This is the updated version: class home(DetailView): context_object_name = 'profile' template_name = 'view_profile.html' def get_context_data(self, **kwargs): context = super(home, self).get_co

Re: DetailView

2012-11-22 Thread David
Hi Sergiy That line outputs: 1 -- 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/-/p3yEqcw-2_cJ. To post to this group, send email to django-users@googlegrou

Formsets and auto_id's

2013-02-07 Thread David
Hi I have a formset. Each form will only contain a checkbox. This checkbox needs to indicate which PK the form applies to. The idea is that a user can scroll through this formset. Check which records they wish to delete and then remove them through a delete view. auto_id's always seem to show

Re: Formsets and auto_id's

2013-02-07 Thread David
I've kinda managed to achieve what I want but I can't help but think it's a bit of a fudge: Especially this part: form.id.html_name -- 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

Tutorials for formsets using PKs as checkboxes

2013-02-08 Thread David
Hi Does anyone know of any good tutorials or guides for using formsets, with PKs as checkboxes? Something not to dissimilar to the functionality found in the django admin when listing records belonging to a model. I have tried looking through Django's code but can't find what I need. Thanks fo

Re: django-admin.py and manage.py both fail in dev

2013-02-10 Thread David
and that the code fragment in my OP works and returns the dev version. On Sunday, February 10, 2013 10:43:14 AM UTC-5, David Flory wrote: > > I should have said that I am running Windows 7 (64 bit) and 64 bit VC10 > versions of my software. -- You received this message becaus

Re: django-admin.py and manage.py both fail in dev

2013-02-10 Thread David
is not passing the validate parameter to manage.py. I recall that under Win NT and XP you could adjust how parameters were passed when a program was set to execute an extension by default. If you can still set that I cannot find it. On Sunday, February 10, 2013 1:22:17 AM UTC-5, David wrote

def __unicode__(self) in models.py is not working

2013-02-12 Thread David
I am working through the tutorial and find that the *def __unicode__(self):*command to give an object a readable name in admin is not working. I am cutting code from the tutorial. When I access the detail screen in /admin/ all I see is [table name] object and not the name I defined in def __

Re: def __unicode__(self) in models.py is not working

2013-02-13 Thread David
It appears as though when using Python3.3 and Django 1.6dev you should use __str__ and not __unicode__. __unicode__ seems to be gone from Python3.3 On Tuesday, February 12, 2013 4:45:33 PM UTC-5, David wrote: > > I am working through the tutorial and find that the *def > __unico

cURL or wget with contrib.auth and CSRF

2011-04-14 Thread David
Hello, I am sorry for asking this, I know similar questions have been asked before but I could not piece together the answer I needed from previous contribution! I have a view, for example: @login_required def clever_view(request): #Render a PDF to a string response = HttpResponse(conten

Case insensitive filter

2011-05-18 Thread David
I have a table that stores file paths and it has about 80 million rows and I'm trying to optimize case insensitive SELECT queries. I have created an index on the lower() of the path column: CREATE INDEX lower_path_idx ON file_table ((lower(path))); A well constructed query like the one below uses

Re: When next part of Django Tutorial?

2011-06-06 Thread David
Let's start with a more concrete question: what do users think should be in tutorial 5 and beyond? On Jun 6, 1:20 pm, Paweł wrote: > When next part of Django > Tutorial?https://docs.djangoproject.com/en/1.3/intro/tutorial04/ -- You received this message because you are subscribed to the Google

Re: Displaying results in Template in a Table ? What is the proper way ?Any app?

2011-08-10 Thread David
I'm a fan of django_tables2. You have to write the CSS yourself if you want anything special, but I'm ok with that. It does a good job of handling server side pagination and sorting as well as custom column renderers. It also ties in pretty well with Django models if you need that kind of thing. O

Re: RPC for python functions in a Django project

2011-08-18 Thread David
I'm the developer of rpc4django. The package does support SMD generation and it makes it available in the system.describe() method by default. However, JSONRPC is not nearly as well defined as XMLRPC and nobody seems to agree exactly how an SMD should look let alone what SMD even stands for. I trie

joining across databases

2011-01-07 Thread David
Strictly, joining across databases is usually impossible. However, I'm looking at mechanisms to achieve that functionality and I just wanted to get a sanity check to see that what I'm doing makes sense or if there is a better way. I have one database in Postgres and a legacy database in MSSql. I ha

Re: Can I store full dates (mmddyyyy) and year-only dates (yyyy) in the same field?

2011-01-25 Thread David
Malcolm Tredinnick gave a talk at Djangocon last year that touched on this. He used a similar approach to Tim. Essentially he had a model that had a DateField and a precision. Malcolm has his slides up: https://github.com/malcolmt/django-modeling-examples/blob/master/slides/modeling-challenges.pdf

Re: pyodbc: Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)')

2011-01-30 Thread David
As far as I know, the only way to connect to MSSql using pyodbc on Linux is to use FreeTDS. conn = pyodbc.connect(r"DRIVER={FreeTDS};SERVER=testserver \mssql2008;DATABASE=eoffice;UID=erp;PWD=123") The "SQL Server" driver is a Windows driver and the above connection string might work on the same W

ListView CBV and a form

2015-04-24 Thread David
Hi I am using the following: class CreateComment(ListView): model = Comment paginate_by = 2 form_class = CommentForm def post(self, request, *args, **kwargs): if not request.user.is_authenticated(): return HttpResponseForbidden() self.object = self.get_object() self.object.creator = request.use

Re: ListView CBV and a form

2015-04-24 Thread David
This appears to work. Using a view for 2 functions seems pretty fugly though. Are there better ways to achieve this? class CreateComment(ListView, FormMixin): model = Comment paginate_by = 2 form_class = CommentForm def post(self, request, *args, **kwargs): form = CommentForm(self.request.POST)

form_invalid redirection with CBVs

2015-04-24 Thread David
Following a form_invalid I need to redirect to the CreateComment view below with the errors shown in the form. Is this possible please? Highlighted is where I need help. Thank you for any assistance. class Comments(View): def get(self, request, *args, **kwargs): view = CreateComment.as_view()

Re: form_invalid redirection with CBVs

2015-04-24 Thread David
This is what I am working from btw: https://docs.djangoproject.com/en/1.8/topics/class-based-views/mixins/#an-alternative-better-solution -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails

Re: form_invalid redirection with CBVs

2015-04-27 Thread David
Got this working. See below: class CreateComment(MultipleObjectMixin, FormView): template_name = 'comment/comment_list.html' form_class = CommentForm model = Comment paginate_by = 5 def post(self, request, *args, **kwargs): if not request.user.is_authenticated(): return HttpResponseForbidden() se

Generic template; determining information about calling view/app

2015-05-08 Thread David
Hi Sorry if this is confusing, it's the best I can describe. I have been separating my templates for inheritance clarity. I have a generic template 'category_list.html'. This can be used by different apps because the layout is the same. What I need to do in order to use appropriate links in th

Getting self.request.user for form cleaning

2015-05-13 Thread David
Hi I am using both FormMixin, and ListView. When validating the form I need the users id. How can I get that into the form for cleaning? I am presuming somehow using get_form and then using the form's init to grab it, but am unsure of the syntax. Any ideas? Many thanks def post(self, request

Re: Getting self.request.user for form cleaning

2015-05-13 Thread David
For anyone else needing this: In form: def __init__(self, *args, **kwargs): self.creator = kwargs.pop('creator', None) In view: form = PostForm(request.POST, creator=self.request.user.pk) -- You received this message because you are subscribed to the Google Groups "Django users"

Re: Getting self.request.user for form cleaning

2015-05-13 Thread David
Thank you for your reply. I had previously tried that, but must have had the syntax wrong. Am now using get_form_kwargs() as it looks nicer. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving ema

form_invalid and missing ob

2015-05-14 Thread David
Hi When I submit my form with no errors it correctly processes and returns after completing form_valid. However, when I submit my form with errors I get a django dump stating that 'ShowForumPostsView' object has no attribute 'object_list'. I am struggling to make it return to the same page bu

Re: form_invalid and missing ob

2015-05-14 Thread David
Doh, fixed. Fix below for anyone else with the same problem: def post(self, request, *args, **kwargs): form = self.get_form() if form.is_valid(): return self.form_valid(form) else: return self.form_invalid(form, *args, **kwargs) def form_invalid(self, form, *args, **kwargs): messages.error(self.

Re: form_invalid and missing ob

2015-05-14 Thread David
Fixed. Was missing: self.form = self.get_form(self.form_class) self.object_list = self.get_queryset() from def form_invalid(self, form): -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails f

select_related() / prefetch_related() and sharding

2015-05-21 Thread David
longer be used. In Christophe Pettus' videos I have not found such a comment, in fact select_related() and prefetch_related() seem to be habitually recommended to speed database connections up. Thanks for your insights! David -- You received this message because you are subscribed to the G

Newbie: ImportError during syncdb

2014-03-05 Thread David
following "Learning Website Development with Django" by Ayman Hourieh. I am not working in a virtualenv. Thanks for your guidance and hints! David settings.py: INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contentt

Re: Newbie: ImportError during syncdb

2014-03-07 Thread David
Dear Robin and Jay, thanks, I was able to solve my problem: setting.py just wants the name of the app. Cheers, David On 06/03/14 08:42, Jay Parikh wrote: > Let say for example i am going to create new app say bookmarks then i > will do something like *"python manage.py startap

[newbie] BASE_DIR vs. SETTINGS_DIR

2014-03-08 Thread David
(os.path.dirname(__file__)) that looks very similar to the next three lines I added. Am I reproducing code here? Do I make a mistake if I take the BASE_DIR~ line out? Thanks for your guidance! David settings.py (slection): # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import

Re: [newbie] BASE_DIR vs. SETTINGS_DIR

2014-03-09 Thread David
Dear Russell, thanks -- brilliant advice! Greetings from Copenhagen, David On 09/03/14 01:10, Russell Keith-Magee wrote: > > On Sun, Mar 9, 2014 at 5:09 AM, David <mailto:ld...@gmx.net>> wrote: > > Dear list, > > I follow > http://www.tan

[newbie] -- Regex-matching ("Tango with Django")

2014-03-14 Thread David
sure this was intended. The author possibly wanted to create http://127.0.0.1:8000/about/instead of http://127.0.0.1:8000/rango/about/ Thanks for clarifying this issue for me! Cheers, David Here is my project/urls.py from django.conf.urls import patterns, include, url from django.contrib impo

Re: admin popup + button help

2016-10-14 Thread David
Hi Giuseppe, I was upgrading to a later version of django and ran into the same issue. Did you find a work-around? On Wednesday, April 27, 2016 at 11:37:19 AM UTC-7, Giuseppe wrote: > > I managed to get this working, sort of. I learned that I need to include > jquery.init.js to my parent form. o

Extended user model to add Profile class want to slugify first_name last_name in profile class

2017-01-25 Thread David
Hi I have extended Django's default user model to add a Profile model; bio etc. I want to slugify the users first_name last_name in profile class, so I can search for all X entities written by a specific user in the url form: /blog/authors/bob-smith When I try to add the slug field to my profi

Re: Extended user model to add Profile class want to slugify first_name last_name in profile class

2017-01-25 Thread David
: (admin.E030) The value of 'prepopulated_fields["slug"][0]' refers to 'profile__first_name', which is not an attribute of 'accounts.Profile'. : (admin.E030) The value of 'prepopulated_fields["slug"][1]' refers to 'profile__last_name', which is not an attribute of 'accounts.Profile'. -- You r

Re: Extended user model to add Profile class want to slugify first_name last_name in profile class

2017-01-25 Thread David
Thank you. That's very helpful. Now just need to work out how to make it a mandatory field in django admin, such that it is always created when a user is. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop

Re: Extended user model to add Profile class want to slugify first_name last_name in profile class

2017-01-25 Thread David
Thank you Melvyn. You've been very helpful! -- 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, sen

ModelForm access slug from url

2017-02-06 Thread David
I have a modelform something like this: class EventContactForm(ModelForm): def __init__(self, *args, **kwargs): super(EventContactForm, self).__init__(*args, **kwargs) self.fields['event'].queryset = Event.objects.filter(category__slug= *SLUGFROMURLHERE* ).filter(active=True).filter(start_date__gt

Re: ModelForm access slug from url

2017-02-06 Thread David
I should add that this is in conjunction with a CreateView CBV. -- 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 pos

Re: ModelForm access slug from url

2017-02-06 Thread David
Sorted by using def get_form_kwargs(self): kwargs = super(EventForm, self).get_form_kwargs() kwargs.update({'category_slug': self.kwargs['category_slug']}) return kwargs -- You received this message because you are subscribed to the Google Groups "Django users" group

Restricting CreateView

2015-07-30 Thread David
Hi Using other CBV's I can use get_queryset to filter out users that don't belong to a certain group. AFAIK createview doesn't have get_queryset. Can I achieve this with CreateView somehow? The context is: All forums: have to be a member of X to view anything A particular Forum: have to be a m

Re: Restricting CreateView

2015-07-31 Thread David
Hi James Many thanks for your reply. David -- 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

[newbie] import error after restart (virtualenv)

2015-09-18 Thread David
essage that was not there beforehand: (Percival_TDD)david@lubuntu:~/PycharmProjects/Percival_TDD/superlists/lists$ python tests.py Traceback (most recent call last): File "tests.py", line 5, in from lists.views import home_page ImportError: No module named 'lists' I nei

Multiple formsets and when posting associating them with an instance

2018-08-21 Thread David
Hi I don't know if this is a common question, but I couldn't find anything resembling my problem. I have a page called "Case". On this page some basic information is added along with the creation of 1 or 2 clients (fixed) Client's are FK to the Case model. These are added using inlineformset f

Re: Multiple formsets and when posting associating them with an instance

2018-08-21 Thread David
Changing all modelformset factories to inlineformsets and then specifying an instance on both the post and get methods resolved this issue. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails

Multiple annotations in one query

2018-09-24 Thread David
Hi I understand that performing multiple annotations on a queryset will produce incorrect results, I was wondering how anyone else gets around this? "Combining multiple aggregations with annotate() will yield the wrong results because joins are use

Re: Multiple annotations in one query

2018-09-24 Thread David
Thanks Matthew will take a look. On Monday, 24 September 2018 15:40:44 UTC+1, Matthew Pava wrote: > > Hi David, > > Performing multiple annotations on a queryset is not the same as combining > multiple aggregations. > > Saying that, if you truly are getting wrong results

Django unit testing and pk's changing

2018-10-24 Thread David
Hi When I run tests on my app they run through fine. When I run tests just using "manage.py test" the app mentioned above contains failures. Example code: def test_lumpsum_get_absolute_url(self): lumpsum = LumpSum.objects.get() self.assertEquals(lumpsum.get_absolute_url(),

Re: Django unit testing and pk's changing

2018-10-24 Thread David
The issue was my using incorrect def get_absolute_url's in my model My error. On Wednesday, 24 October 2018 12:24:07 UTC+1, David wrote: > > Hi > > When I run tests on my app they run through fine. > > When I run tests just using "manage.py test" the app men

Re: Where is my Django?

2008-10-23 Thread David Reynolds
and i don't > find de directory 'django' in site-packages on /usr/lib/python2.5/ > site- > packages or /usr/lib/python-django > > Some body can help me? dpkg -L python-django This will give you a list of all of the files in that packa

<    1   2   3   4   5   6   7   8   9   10   >