Re: Function-based Views vs Class-based Views

2023-03-06 Thread Carsten Fuchs
I would like to recommend this excellent guide by Luke Plant: https://spookylukey.github.io/django-views-the-right-way/ Best regards, Carsten Am 06.03.23 um 21:19 schrieb Michael Starr: > What are the pros and cons of either method of rendering HTTP request > responses? > > https://ww

Re: How Important Is Writing Unit Tests For Django Applications?

2022-03-13 Thread Carsten Fuchs
Am 13.03.22 um 10:53 schrieb Antonis Christofides: > This topic is always interesting for me. > > [...] > I didn't expect this reply to become that long, neither that I would not > answer the question in the end. I hope it was helpful anyway. Good luck! > A great text! Thank you! Best regards,

Re: The SECRET_KEY setting must not be empty - os.environ.get('SECRET_KEY')

2022-03-02 Thread Carsten Fuchs
outside of the project directory, where it is in even less danger to be accidentally committed. Or to store the values not in a py, but in a json, ini, txt, ... file that is loaded and parsed in settings.py. Best regards, Carsten > On Wed, Mar 2, 2022 at 7:49 AM Carsten Fuchs <mailto:

Re: The SECRET_KEY setting must not be empty - os.environ.get('SECRET_KEY')

2022-03-01 Thread Carsten Fuchs
Am 02.03.22 um 04:23 schrieb Mike Dewhirst: > ... where you write get_secret_key() to pull it from the environment or a > file somewhere which is not in your repository. A variant of this that I like is to have a file like localconfig.example in the repository next to settings.py that contains e

Re: Resource leaks from FieldFile's implicit open?

2022-02-03 Thread Carsten Fuchs
ut to use plain CharFields instead to just store the file names and then to use the storage directly. This removes an entire layer of abstraction without which things seem to be a lot clearer. Best regards, Carsten > On 01/02/2022 21.22, Carsten Fuchs wrote: >> Dear group, >> &g

Resource leaks from FieldFile's implicit open?

2022-02-01 Thread Carsten Fuchs
Dear group, despite a lot of reading and searching I still don't understand how FieldFiles work. The documentation at https://docs.djangoproject.com/en/4.0/ref/models/fields/#django.db.models.fields.files.FieldFile says: > The API of FieldFile mirrors that of File, with one key difference: Th

Re: Eliminating inter-request race conditions

2021-12-31 Thread Carsten Fuchs
Hello, Am 31.12.21 um 11:31 schrieb Nick Farrell: > Correct. To be clear, I am not advocating this behaviour by default, but > making it as seamless as possible to enable when required, rather than > needing to attempt to hand-roll safe locking semantics each time it's needed. Thanks for the cl

Re: Eliminating inter-request race conditions

2021-12-31 Thread Carsten Fuchs
Hi Nick, I've thought a bit more about this, but it seems that my requirements are different from yours: E.g. I don't need the client-side validation and especially don't want the complexity that goes with it; on the other hand, I need something that also works with formsets, not only with indi

Re: Eliminating inter-request race conditions

2021-12-28 Thread Carsten Fuchs
Hi Nick, maybe this is a case for optimistic locking? Does the thread at https://groups.google.com/d/msg/django-users/R7wJBTlC8ZM/MIzvYkWyCwAJ help? Best regards, Carsten Am 27.12.21 um 06:36 schrieb Nick Farrell: > Hi all. > > I've been using Django for quite a number of years now, in variou

Re: Declarative mechanism for Django model rows

2021-12-09 Thread Carsten Fuchs
Hello, Am 08.12.21 um 20:25 schrieb Alex Dehnert: > With some frequency, I end up with models who contents are approximately > constant. Are there good ways of handling this? If I understand your question correctly, you have a model that you always query like: plans = Plan.objects.all(

Re: Good Django libraries to read to really understand class-based views?

2021-01-12 Thread Carsten Fuchs
Dear Robert, I recommend you consider https://spookylukey.github.io/django-views-the-right-way/ Best regards, Carsten Am 11.01.21 um 16:14 schrieb Robert F.: > Are there any Django libraries that make extensive use of class-based views > that I might study if I want to gain an in-depth unders

Re: Tests: How to messages.add_message() before self.client.get() ?

2020-11-13 Thread Carsten Fuchs
used by the messages framework.  If it is set to session, then you'll need > to obtain a session from the client and stick it onto your request object if > you want that to persist through your subsequent test requests. > > HTH /d > >> On 10 Nov 2020, at 18:41, Carste

Tests: How to messages.add_message() before self.client.get() ?

2020-11-09 Thread Carsten Fuchs
Dear group, in my tests I would like to test the processing of messages in the view. For example: def test_is_message_properly_handled(self): # The problem: We have no `request` here! messages.info(request, 'Hello') response = self.client.get("/handling-messages-view/

Re: Django user model. 1 admin account, 1 customer account with the same email and different password

2020-04-13 Thread Carsten Fuchs
Hello, Am 13.04.20 um 02:59 schrieb Kenny Soh: > * An admin account must not share the same password as the customer account. Your entire problem would become much easier if you just dropped that requirement. Whatever you want to achieve with forcing a single user to keep two passwords, I'm s

Re: Is a Custom User Model worth the headache?

2020-02-15 Thread Carsten Fuchs
Hi Mike, Am 2020-02-14 um 23:30 schrieb Mike Dewhirst: > In your documentation you mention "from accounts.models import User" > > I have been maybe taking things too literally. After migrating to my custom > user I have used "from django.contrib.auth import get_user_model" followed by > "User =

Re: Is a Custom User Model worth the headache?

2020-02-14 Thread Carsten Fuchs
Am 14.02.20 um 09:03 schrieb Mike Dewhirst: > Definitely start a new project with a custom user and I would consider > aborting an existing project to restart with a custom user if it was started > with the standard user. Which may not be possible for large, existing projects. Switching to a cu

Re: About extending the django inbuilt user

2020-01-14 Thread Carsten Fuchs
Besides what others have said, I suggest you have a look at https://docs.djangoproject.com/en/3.0/topics/auth/customizing/#extending-the-existing-user-model and all subsequent sections. If you have not started your project yet (have no migrations yet), look at https://github.com/jambonsw/django-im

Re: Changing to a custom user model mid-project

2019-12-26 Thread Carsten Fuchs
Hello Mike, unfortunately I cannot answer your questions, but have you considered contacting Tobias directly? I too am currently at the point of switching two of my projects to a custom user model. But honestly, Tobias' procedure looks complicated and error prone to me. Aymeric's description d

Re: Using forms to handle request.GET data?

2019-04-04 Thread Carsten Fuchs
Am 04.04.19 um 16:23 schrieb Matthew Pava: > If you need a default year in your template context, put it there. > > def get_context_data(self, request, *args, **kwargs): > context = super().get_context_data(request, *args, **kwargs) > context['default_year'] = 2019 > return context >

Re: Using forms to handle request.GET data?

2019-04-04 Thread Carsten Fuchs
Am 04.04.19 um 16:24 schrieb Matthew Pava: > And, since you really don't want constants littering your code, you probably > want something like this: > context['default_year'] = timezone.now().year Sure, thanks, but the year was only used to keep the example code minimal and the focus on how to

Re: Using forms to handle request.GET data?

2019-04-04 Thread Carsten Fuchs
To elaborate on this further: Searching the web for this yields numerous hits, e.g. https://stackoverflow.com/questions/16026479/django-forms-default-values-for-bound-forms mentions some ways to address this, but I've not come across a fully satisfactory solution. Another approach might be thi

Re: Using forms to handle request.GET data?

2019-04-04 Thread Carsten Fuchs
Hello, Am 03.04.19 um 21:28 schrieb Mohammad Etemaddar: > Set default value: > year = forms.ChoiceField(required=False, choices=[(j, j) for j in range(2018, > 2021)], default=2019) Thanks for your reply, but unfortunately, `default` is a keyword for model fields only, not for form fields: TypeE

Using forms to handle request.GET data?

2019-04-02 Thread Carsten Fuchs
Dear Django group, I would like to show users a form that they can use to customize the view, for example a ChoiceField from which the year of the report can be chosen. It seems straightforward to use a forms.Form to handle the request.GET data: from django import forms class JahrAuswahl(form

Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Carsten Fuchs
Well, you're adding choices to q = Question.objects.get(pk=1). But is this also the question you call the view with? I suggest you add a few more print statements below your existing print(question) For example: print(question.pk) print(question.choice_set.all()) # Or, a bit mo

Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-02 Thread Carsten Fuchs
Hi Nori, does the choice actually exist? Can you find it if you query the choices using the ORM in `./manage.py shell`? Best regards, Carsten Am 03.02.19 um 03:59 schrieb Atsunori Kaneshige: > Hi Django users, > > I started using Django recently. > I am following the official Django tutorial.

Re: Unable to access mysql db and apply changes using "python manage.py migrate"

2019-02-02 Thread Carsten Fuchs
Am 02.02.19 um 11:10 schrieb Emmanuel klutse: > yes im talking about using "python manage.py migrate" command to create > tables in the db(djangoproject) i have already created in mysql server `manage.py migrate` is trying to access your MySQL database, but the database denies the access to the

Re: Unable to access mysql db and apply changes using "python manage.py migrate"

2019-02-02 Thread Carsten Fuchs
Am 02.02.19 um 10:33 schrieb Emmanuel klutse: > [...] creat a db for me in mysql instead of sqlite and the error is talking > about authentication. > these are the changes made in my djangoproject/settings file: > DATABASES = { >     'default': { >     'ENGINE': 'django.db.backends.mysql', Yo

Re: Unable to access mysql db and apply changes using "python manage.py migrate"

2019-02-02 Thread Carsten Fuchs
Hi Emmanuel, the error message is clear, isn't it? (1045, "Access denied for user 'root'@'localhost' (using password: YES)") Check your password. Use the mysql client to check. Best regards, Carsten Am 02.02.19 um 10:07 schrieb Emmanuel klutse: > hello team, > Can someone help me with the prob

Re: Migration question: why causes this change a non-empty migration?

2019-02-01 Thread Carsten Fuchs
Am 01.02.19 um 17:39 schrieb Tim Graham: > I'm reluctant to continue investigation as you're using an old version of > Django and many bugs have been fixed since then. If you can reproduce a > problem with Django 2.2 alpha and a fresh database, feel free to create a > ticket if you can't find an

Migration question: why causes this change a non-empty migration?

2019-02-01 Thread Carsten Fuchs
Dear Django group, using a model like this: ``` class Kostenstelle(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=60, blank=True) # ... omitted fields class Meta: db_table = 'kostenstelle' ``` I replaced the `id` line with ```

Re: Questions about MySQL notes in Django docs

2019-01-26 Thread Carsten Fuchs
Hi Jason, Am 24.01.19 um 14:47 schrieb Jason: > It doesn't look like the fixes were backported to 1.11, after looking in the > django 1.11 release notes. > As Tim said,  >> Based on the commits there, it looks like Django 2.0.7 and above >> received the fixes Yes, that's part of my problem.

Re: Questions about MySQL notes in Django docs

2019-01-24 Thread Carsten Fuchs
Hi Michael, Am 23.01.19 um 13:56 schrieb Michal Petrucha: >> d) Why is isolation level "read committed" preferred over "repeatable read"? >> The text says "Data loss is possible with repeatable read.", but how can >> "repeatable read" have data loss that "read committed" has not? > > I can't answ

Re: Questions about MySQL notes in Django docs

2019-01-23 Thread Carsten Fuchs
, Django supports MySQL 8. If you google "django mysql 8" the second > result is https://code.djangoproject.com/ticket/29451. Based on the commits > there, it looks like Django 2.0.7 and above received the fixes. > > On Wednesday, January 23, 2019 at 5:10:18 AM UTC-5, Carsten Fuc

Questions about MySQL notes in Django docs

2019-01-23 Thread Carsten Fuchs
Dear Django group, can you please help me with some questions about https://docs.djangoproject.com/en/2.1/ref/databases/#mysql-notes ? (I've been using Django with an Oracle database for years, but I'm new to MySQL.) a) Does "Django supports MySQL 5.6 and higher." cover MySQL 8? (I'm not sur

Re: best way to generate PDFs in django - handling concurrency

2018-12-27 Thread Carsten Fuchs
ps.google.com/d/msgid/django-users/9f06d9aa-7d89-4700-8cd0-9ae3343b3128%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/9f06d9aa-7d89-4700-8cd0-9ae3343b3128%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups

Re: How to hide the password of postgresql in settings.py

2018-11-30 Thread Carsten Fuchs
Am 30.11.18 um 18:50 schrieb Sandip Nath: I am a newbie to Django. Using Postgresql for CRUD operations. Although its working but I need to write the password of my Postgresql server in the settings.py. How can I hide that without hampering the operation? In your settings.py, you could write

Re: difference between class based view and function based view

2018-11-22 Thread Carsten Fuchs
Hi Andrew, many thanks for your clear and detailed explanation! Having used Django for several years, FVs are still my favorite approach over CBVs and GCBVs. In the past, I made several starts with CBVs, but never found or understood why CBVs and GCBVs seem to be in many people's center of at

Template filter {{ value|date:"M" }} in Python

2018-11-06 Thread Carsten Fuchs
Hello, complementing template filters, sometimes it is necessary to format dates also in Python code, that is, achieve the equivalent to {{ value|date:"M" }} For this, I'm using from django.utils import dateformat dateformat.format(value, "M") (This works in Django views and in

Re: Prepopulate blog in b.entry_set.all()[i].blog ?

2018-10-20 Thread Carsten Fuchs
Can anyone help please? Am 2018-10-11 um 16:58 schrieb Carsten Fuchs: Dear Django group, with Django 1.11.15, using the example models Blog and Entry at <https://docs.djangoproject.com/en/2.1/topics/db/queries/#related-objects> for reference, I have code like this:

Prepopulate blog in b.entry_set.all()[i].blog ?

2018-10-11 Thread Carsten Fuchs
Dear Django group, with Django 1.11.15, using the example models Blog and Entry at for reference, I have code like this: b = Blog.objects.get(name="...") for e in b.entry_set.all(): print(e.blog) Obvio

Re: Problem with views PasswordChangeView vs. password_change

2017-07-14 Thread Carsten Fuchs
Am 13.07.2017 um 22:44 schrieb Tim Graham: The success_url of PasswordChangeView (actually the behavior comes from the inherited FormView) only accepts a URL, not a URL name. You can update to your code like this: from django.urls import reverse_lazy ... success_url=reverse_lazy('lori:pwd_done')

Re: Problem with views PasswordChangeView vs. password_change

2017-07-13 Thread Carsten Fuchs
Am 13.07.2017 um 16:56 schrieb Carsten Fuchs: the success_url='lori:pwd_done' seems to be a problem This seems to be the root also of the original problem (SuspiciousOperation…): If I insert a plain URL, e.g. success_url='/pwd_done/', then I can no longer reproduce

Problem with views PasswordChangeView vs. password_change

2017-07-12 Thread Carsten Fuchs
Dear Django group, using Django 1.11.3 with Python 2.7, please consider the following test: def test_passwort_aendern(self): u = User.objects.create_user("Test", "t...@example.com", "Passwort") self.client.force_login(u) response = self.client.post("/change_passwor

Re: Run model check with Django 1.11 as deployment check only?

2017-04-10 Thread Carsten Fuchs
Hi Matthew, Am 10.04.2017 um 15:51 schrieb Matthew Pava: I would argue that your code should be able to run successfully with an empty database. I would change your assignment of maxID to this: maxID = cls.objects.aggregate(Max('id'))['id__max'] or 0 Normally, I would happily agree. However,

Run model check with Django 1.11 as deployment check only?

2017-04-10 Thread Carsten Fuchs
Dear Django group, with Django 1.10, I used a model check like this: class Status(models.Model): id = models.AutoField(primary_key=True) MAX_ID = 38 text = models.CharField(max_length=20, blank=True) @classmethod def check(cls, **kwargs): errors = super(Status

Re: template {% url } tag syntax

2017-02-26 Thread Carsten Fuchs
Hi Richard, Am 27.02.2017 um 04:01 schrieb Richard Belew: {%url 'djggApp/guest'guest.guestId 'update'%} but this generates a /NoReverseMatch/ error /Reverse for 'djggApp/guest' with arguments '(1, u'update')' and keyword arguments '{}' not found. 0 pattern(s) tried: []/ In the {% url %}, yo

Re: Mocking date and time in LiveServerTestCase?

2017-01-30 Thread Carsten Fuchs
Hi Adam, Am 25.01.2017 um 21:01 schrieb Adam Stein: When I need to set the date to a known day for tests, I use forbiddenfruit (https://github.com/clarete/forbiddenfruit). Thanks for mentioning this, I didn't know it before! However, I have not yet tried it, because I had hoped that there was

Mocking date and time in LiveServerTestCase?

2017-01-25 Thread Carsten Fuchs
Dear Django fellows, I'm using LiveServerTestCase with Selenium. The application code run by LiveServerTestCase's live server works well and a view's call to date.today() returns the current date. For the tests, however, it would be helpful if we could fix the time and date at which the test

Re: Django 1.10.3 with Oracle database and --keepdb

2016-11-07 Thread Carsten Fuchs
Am 05.11.2016 um 15:55 schrieb Carsten Fuchs: Am 2016-11-05 um 13:11 schrieb Mariusz Felisiak: Yes. Please, make sure that your main oracle user has *ALTER USER* permission. I'll check (it may take until Monday or Tuesday though) and post an update here. Indeed, after having added the

Re: Django 1.10.3 with Oracle database and --keepdb

2016-11-05 Thread Carsten Fuchs
Hi Mariusz, Am 2016-11-05 um 13:11 schrieb Mariusz Felisiak: Yes. Please, make sure that your main oracle user has *ALTER USER* permission. It is well possible that that is the culprit. I've set my database user's privileges as described at https://docs.djangoproject.com/en/1.10/ref/database

Re: Django 1.10.3 with Oracle database and --keepdb

2016-11-05 Thread Carsten Fuchs
Hi Simon, Am 05.11.2016 um 08:46 schrieb Simon Charette: [0] https://code.djangoproject.com/ticket/27435#ticket Thank you! Best regards, Carsten -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receivi

Django 1.10.3 with Oracle database and --keepdb

2016-11-04 Thread Carsten Fuchs
Dear Django fellows, using Django 1.10.3 with Oracle database, is running ./manage.py test --keepdb supposed to work without having an explicit test password set? DATABASES = { 'default': { 'ENGINE': 'django.db.backends.oracle', # ... 'TEST': { # --kee

Re: Starting new project -- version 1.10

2016-08-23 Thread Carsten Fuchs
Am 23.08.2016 um 14:11 schrieb Michal Petrucha: Finally, you need one Python package that serves as the “app” that glues all the other packages together. This is the package (or app) that contains the settings module, the root URL configuration, the WSGI entry point, and often also static files,

Re: How to atomically create and lock an object?

2016-05-12 Thread Carsten Fuchs
se because a transaction is already started by the demonstrate_the_problem() atomic wrapper. Else the connection is left in an unusable state by the integrity error. Cheers, Simon Le jeudi 12 mai 2016 10:48:30 UTC-4, Carsten Fuchs a écrit : Hi Simon, many thanks for your reply! Pleas

Re: How to atomically create and lock an object?

2016-05-12 Thread Carsten Fuchs
Hi Simon, many thanks for your reply! Please see below for some follow-up questions. Am 11.05.2016 um 16:04 schrieb Simon Charette: Did you try using select_for_update() with get_or_create()[1] in an atomic()[2] context? @transation.atomic def demonstrate_the_problem(): d = date.today()

How to atomically create and lock an object?

2016-05-11 Thread Carsten Fuchs
Dear Django group, please consider this code: from datetime import date from django.db import models class TestModel(models.Model): jahr = models.SmallIntegerField() monat = models.SmallIntegerField() some_value = models.SmallIntegerField() class M

Re: How to learn Django stepwise Effectively

2016-01-21 Thread Carsten Fuchs
Hi Andrew, Am 20.01.2016 um 15:31 schrieb Andrew Pinkham: There are many resources for learning Django (NB: this email assumes you’re not looking to learn Python). Thank you very much for assembling this list, it's very much appreciated! I knew many of these resources, but certainly not all.

Re: Django for Data Tables to group by when coloumn hidden

2015-12-10 Thread Carsten Fuchs
Hi Sid, if with Data Tables you are in fact referring to http://datatables.net/, then you should put your questions with the folks over there. I guess what you want is possible with DataTables (I haven't checked), but be prepared for some customization with JavaScript being required. If you

Re: Problem with appending slash at the end of the url

2015-12-07 Thread Carsten Fuchs
Hello, Am 07.12.2015 um 13:37 schrieb Dongwon Kang: I don't know even it's a problem, but anyway, I just updated django 1.8.7 to django 1.9 and found application isn't working. I found out django wasn't redirecting not-slashed url. it returns 500 error if slash hadn't been at the end of the u

Re: Locking / serializing access to one element in database

2015-11-05 Thread Carsten Fuchs
Hi Collin, Am 05.11.2015 um 16:36 schrieb Collin Anderson: If you're just updating one field, this _might_ work for you: Why just one? | try: TestMonthModel.objects.create(jahr=Jahr,monat=Monat)# create() uses force_insert. exceptIntegrityError: pass # It already exists. No Proble

Re: update_or_create() always creates (or recreates)

2015-11-05 Thread Carsten Fuchs
Hi Yunti, Am 05.11.2015 um 18:19 schrieb Yunti: I have tried to use the update_or_create() method assuming that it would either, create a new entry in the db if it found none or update an existing one if it found one and had differences to the defaults passed in - or wouldn't update if there

Re: formset concurrency control

2015-10-29 Thread Carsten Fuchs
Hi all, continuing my previous post, I've implemented most of the ideas mentioned in this thread now, and would like, for completeness and future reference, add some related findings and thoughts: As mentioned in my previous post, reconstructing the formset's initial data (the queryset) in t

Re: Locking / serializing access to one element in database

2015-10-28 Thread Carsten Fuchs
Hi Collin, hi all, Am 27.10.2015 um 19:56 schrieb Collin Anderson: Yes, an exception will be raised. Thinking further about this, all we need is a method that gives us an exception if we accidentally create a second object when in fact only one is wanted. Your suggestion with manually dealin

Re: Locking / serializing access to one element in database

2015-10-22 Thread Carsten Fuchs
Am 22.10.2015 um 01:16 schrieb Simon Charette: I would suggest you use select_for_update() in a transaction. This only covers the case where the object with the given ID already exists, doesn't it? That is, if a

Re: Reverse access model through a “double” ForeignKey

2015-10-14 Thread Carsten Fuchs
Am 14.10.2015 um 11:11 schrieb Gergely Polonkai: This setup, though, doesn’t feel right, as it contains redundancy. Is there a way to access the list of Values directly from Build without having this redundancy? Well, you can filter your Value queryset by Build, see https://docs.djangoproject.

Re: If appears doesn't work in template, why?

2015-10-14 Thread Carsten Fuchs
Am 14.10.2015 um 13:36 schrieb Fellipe Henrique: But, always enter in "else"... even the record was saved with "A"... I tried with 'A' and "A", same "problem"... Any ideas, what's going on? Have you cross-checked? I.e., what is the output of {{ status }} ? Best regards, Carsten -- You recei

Re: formset concurrency control

2015-10-09 Thread Carsten Fuchs
Hi Tim, Am 08.10.2015 um 21:03 schrieb Tim Graham: I think the problem is also described in https://code.djangoproject.com/ticket/15574. Probably if we had a simple solution, that ticket wouldn't be open for 5 years. :-) :-) Yes, having read all of it, I too think that #15574 describes the

Re: formset concurrency control

2015-10-08 Thread Carsten Fuchs
Hi Daniel, Am 08.10.2015 um 18:48 schrieb Daniel Roseman: Can you explain further why you think the pk is not sufficient? Ordering by name, or adding and removing entities, does not change the pk of other entities; indeed that's the whole point of a pk. What exactly are you concerned about?

formset concurrency control

2015-10-08 Thread Carsten Fuchs
Dear Django fellows, as far as I understand this, there seem to be two kinds of concurrency control: - the one that occurs between request and save, as addressed by e.g. [1] and [2], - the one that occurs between GET request and POST request, especially with formsets. I'm currently trying

Re: Formset questions: data vs. initial values

2015-10-08 Thread Carsten Fuchs
Hi Shawn, many thanks for your reply. Am 07.10.2015 um 15:54 schrieb Shawn Milochik: You /can/ use ModelForms for this. You don't need an active instance. Thanks, I'll definitively check this out! However, using a ModelForm wastes performance when the POST request is processed, doesn't it?

Re: Formset questions: data vs. initial values

2015-10-06 Thread Carsten Fuchs
Anyone please? Best regards, Carsten Am 07.09.2015 um 21:18 schrieb Carsten Fuchs: Dear Django group, after having read all of the Django docs that I could find, I still have two questions about the proper use of formsets. Summary first: 1. What is a good way to make sure the data

Re: Converting implicit m2m through table to explicit through model with Django 1.7 migrations

2015-10-03 Thread Carsten Fuchs
Am 2015-10-02 um 23:28 schrieb John Lucas: Thanks for the replies. Carsten - that link is broken for me unfortunately. Sorry, this seems to be a problem with gmane. The same thread at Google groups is here: https://groups.google.com/d/msg/django-users/K0X8P3s3DOw/cH5PDxYjLtYJ Best regards, Ca

Re: Converting implicit m2m through table to explicit through model with Django 1.7 migrations

2015-09-29 Thread Carsten Fuchs
Hi John, Am 28.09.2015 um 15:54 schrieb John Lucas: So - is my approach safe? Or will there be complications down the line? I've recently had a similar / the same question. See this thread, which also contains the solution that worked very well for me: http://thread.gmane.org/gmane.comp.pyth

Re: Advanced Annotate

2015-09-17 Thread Carsten Fuchs
Hi Paolo, Am 16.09.2015 um 22:52 schrieb Paolo C.: [...], I need to annotate not only the price but also which is the book that has that max value. Isn't that exactly what I was wondering about, too? "1) Is there a way to annotate each Store object with the actual Book objects related to th

Re: Advanced Annotate

2015-09-16 Thread Carsten Fuchs
Hi Paolo, Am 15.09.2015 um 00:32 schrieb Paolo C.: How can obtain details from the last comment when listing ll posts? If I understood your question correctly -- I recently had the same question, see https://groups.google.com/d/msg/django-users/adRe2_BWMz0/G71BVUEI_7oJ for details. It seems

Formset questions: data vs. initial values

2015-09-07 Thread Carsten Fuchs
Dear Django group, after having read all of the Django docs that I could find, I still have two questions about the proper use of formsets. Summary first: 1. What is a good way to make sure the data received in the POST request agrees with the "initial" data (number of items and items order

Transaction questions

2015-07-27 Thread Carsten Fuchs
Hi all, using Django 1.8.3, at this time I have code like this: try: mm = TestMonthModel.objects.select_for_update().get(jahr=Jahr, monat=Monat) except TestMonthModel.DoesNotExist: mm = TestMonthModel(jahr=Jahr, monat=Monat) # A *long* computation, eventually setti

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-24 Thread Carsten Fuchs
Hi all, just wanted to let you know that I was successful! I followed Gergely's final recipe, using RunPython for the data migrations and separate migration files for each of the steps. For step 3 (the deletion of the ManyToManyField) I temporarily had to remove the django.contrib.admin from

Re: Why is Admin login template at admin/login.html instead of registration/login.html?

2015-07-24 Thread Carsten Fuchs
Hi Carl, Am 23.07.2015 um 20:07 schrieb Carl Meyer: Of course it's _possible_ to have just a single login page instead, if you want that, but it's not at all clear to me that that's better. I prefer to keep the admin relatively separate from the public site. And I think the same is true for pas

Re: Why is Admin login template at admin/login.html instead of registration/login.html?

2015-07-23 Thread Carsten Fuchs
Hi Tim, many thanks for your reply! Am 23.07.2015 um 18:49 schrieb Tim Graham: The admin login only allows staff users to login so it makes sense to me that if you wanted to add regular user login to your site, it should have separate URLs. I think what confuses me is the fact that (in the A

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-23 Thread Carsten Fuchs
Hi Carl, Am 23.07.2015 um 18:28 schrieb Carl Meyer: Overall I think it might be simpler to go with your initial approach. I'd first rename the old field to some other temporary name (you don't have to update any other code to use this name, as you'll commit all of these migrations in one commi

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-23 Thread Carsten Fuchs
Am 16.07.2015 um 16:05 schrieb Carsten Fuchs: Alas... are there any viable alternatives to this? I'd be very grateful for any hint! :-) Anyone please? Best regards, Carsten -- You received this message because you are subscribed to the Google Groups "Django users" group.

Why is Admin login template at admin/login.html instead of registration/login.html?

2015-07-23 Thread Carsten Fuchs
Dear Django fellows, using Django 1.8.3, I see that the Admin contrib uses the Auth contrib's views (in contrib/admin/sites.py). The implementation overrides the auth views' defaults only if explicitly specified in the AdminSite object. For example, changing the user password is implemented i

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-20 Thread Carsten Fuchs
Hi Gergely, Am 16.07.2015 um 20:44 schrieb Carsten Fuchs: 3) change the m2m field by adding the through option, and add this change to the migrations file. [...] And won't this last step trigger the same error as before? ("... you cannot alter to or from M2M fields, or add or remo

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-16 Thread Carsten Fuchs
Hi Gergely, many thanks for your quick reply! Am 2015-07-16 um 18:15 schrieb Gergely Polonkai: 1) create the "through" model, add it to the migration file 2) migrate all m2m instances (e.g. iterate over all Bereich objects then iterate through its users, creating a UserBereichAssignment object

Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-16 Thread Carsten Fuchs
Dear Django fellows, using Django 1.8.3, in a fully migrated app I have a model with a many-to-many relationship like this: from django.db import models from django.contrib.auth.models import User class Bereich(models.Model): benutzer = models.ManyToManyField(User) Now I

Re: Which is the best tutorial to learn django, djangobook.com or djangoproject.com?

2015-05-24 Thread Carsten Fuchs
Hi all, Am 2015-05-23 um 19:47 schrieb Daniel Roseman: On Saturday, 23 May 2015 18:17:15 UTC+1, Preeti wrote: Which is the best tutorial to learn django, djangobook.com or djangoproject.com ? Why do you even need to ask that question, g

Re: Fields outside Aggregation functions

2015-05-04 Thread Carsten Fuchs
Hi Alex, Am 04.05.2015 um 12:48 schrieb Alex-droid AD: So the question... How can I get records storemin/max price */_book ???_/* I recently had the same question, please see this thread: https://groups.google.com/forum/#!topic/django-users/adRe2_BWMz0 If you ever find a more direct solu

Re: annotate() questions

2015-04-24 Thread Carsten Fuchs
Am 17.04.2015 um 21:14 schrieb Carsten Fuchs: Now if only I knew how to obtain the actual book objects related to the min/max prices... Just for future reference, the best answer that I've found so far is: http://blog.roseman.org.uk/2010/08/14/getting-related-item-aggregate/ Best re

Re: Cannot delete with overridden ModelAdmin.save_formset()

2015-04-20 Thread Carsten Fuchs
Hi all, Am 20.04.2015 um 15:29 schrieb Carsten Fuchs: I use a ModelAdmin.save_formset() method exactly like in the Django Admin documentation: https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset [...] The problem is, if I check the "d

Cannot delete with overridden ModelAdmin.save_formset()

2015-04-20 Thread Carsten Fuchs
Dear Django fellows, I use a ModelAdmin.save_formset() method exactly like in the Django Admin documentation: https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset This is the exact code: def save_formset(self, request, form, formset, change)

Re: annotate() questions

2015-04-17 Thread Carsten Fuchs
Hi Ramiro, Am 2015-04-16 um 19:30 schrieb Ramiro Morales: https://docs.djangoproject.com/en/1.8/topics/db/aggregation/#aggregations-and-other-queryset-clauses "...When used with an annotate() clause, a filter has the effect of constraining the objects for which an annotation is calculated. For

Re: annotate() questions

2015-04-16 Thread Carsten Fuchs
Hello, Am 08.04.2015 um 20:07 schrieb Carsten Fuchs: 1) Is there a way to annotate each Store object with the actual Book objects related to the minimum and maximum prices? 2) Can this annotation be filtered? For example, if for each Store we wanted to learn the min and max prices of

annotate() questions

2015-04-08 Thread Carsten Fuchs
Dear Django fellows, at https://docs.djangoproject.com/en/1.8/topics/db/aggregation/#joins-and-aggregates the first example is: >>> from django.db.models import Max, Min >>> Store.objects.annotate(min_price=Min('books__price'), max_price=Max('books__price')) which will annotate each Store ob

Re: TemplateSyntaxError with {% cycle "Hello, how are you?" "Fine!" %}

2015-03-05 Thread Carsten Fuchs
Hi Vijay, hi Alasdair, many thanks for your quick replies! I've thus just filed a bug: https://code.djangoproject.com/ticket/24451 Am 05.03.2015 um 17:53 schrieb Alasdair Nicol: I think the reason is that the cycle tag supports an older syntax for backwards compatibility reasons. Yes, that wa

TemplateSyntaxError with {% cycle "Hello, how are you?" "Fine!" %}

2015-03-05 Thread Carsten Fuchs
Dear Django fellows, using Django 1.7.5, I have a problem with commas in string literals in the cycle tag, e.g. with {% cycle "Hello, how are you?" "Fine!" %}. Please consider (newlines added for clarity): $ ./manage.py shell >>> from django.template import * >>> t = Template('''{% cycl

Re: Model field with default value and choices is always reported as changed, even if unchanged

2015-02-27 Thread Carsten Fuchs
Am 26.02.2015 um 19:06 schrieb Carsten Fuchs: The expected output is `False`,[...] Just for future reference, this is continued here: https://code.djangoproject.com/ticket/24428 Best regards, Carsten -- You received this message because you are subscribed to the Google Groups "Django

Re: Model field with default value and choices is always reported as changed, even if unchanged

2015-02-26 Thread Carsten Fuchs
Hi, Am 25.02.2015 um 19:11 schrieb Carsten Fuchs: the parent model's History view claims that field "monat" of TestModel has been changed, I got at least a little bit further: This is easily reproducible in a minimal project/app test case with SQLite exactly as described in

Re: Migrations force me to have, forever, any name/reference I use in field validators=, choices=, whatever, valid forever (even if the requirements change).

2015-02-26 Thread Carsten Fuchs
Hi all, Am 26.02.2015 um 13:54 schrieb Tim Graham: Yes, it's expected behavior. Please see the documentation on the topic: https://docs.djangoproject.com/en/stable/topics/migrations/#historical-models I have not yet tried this, but won't squashing migrations as a side effect also get us rid o

Model field with default value and choices is always reported as changed, even if unchanged

2015-02-25 Thread Carsten Fuchs
Hi all, please consider this model definition: def PrevMonth(): h = date.today() return 12 if h.month == 1 else h.month-1 MONTHS_CHOICES = ( (1, "Januar"), (2, "Februar"), (3, "März"), (4, "April"), (5, "Mai"), (6, "Juni"), (7, "Juli"), (8, "August"), (9, "September"), (10,

  1   2   >