jonashaag / django-addanother Goto Github PK
View Code? Open in Web Editor NEW"Add another" buttons outside the Django admin
Home Page: http://django-addanother.readthedocs.org/
License: ISC License
"Add another" buttons outside the Django admin
Home Page: http://django-addanother.readthedocs.org/
License: ISC License
Can be upgraded to the 2.0.1 version?
includes support for Django 3.0
http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=2015-6186
django/django@93c5386
I guess this affects us as well, and maybe other project of you @jpic?
How do I update fields of the same form using the same model?
Example:
...
'client': AddAnotherEditSelectedWidgetWrapper(
forms.Select,
reverse_lazy('client-create'),
reverse_lazy('client-update', args=['__fk__'])
),
'sender': AddAnotherEditSelectedWidgetWrapper(
forms.Select,
reverse_lazy('client-create'),
reverse_lazy('client-update', args=['__fk__'])
)
Hi,
Thanks for the app, its coming together nicely.
I am trying to integrate with select2 using the Select2AddAnother widget and its works to a certain degree.
Only issue i have is that when i add another instance and the pop-up window closes the option is selected, but not set as initial using select2 in my form.
Any ideas on this one?
Thanks guys!
django-addanother use in link title the string "Edit related" and "Add another", but django uses "Change selected {{ model }}" and "Add another {{ model }}" here.
Even though it has in the context of the model, I think it would be valid to exchange this title for him to change based on the language in settings.
Could this be done? Anything I can submit a PR.
Hey there,
The widget works great for adding new values, no problem at all. But, the Edit button seems to fail. I'm wrapping the DAL widget and when I select a value, the fk value is never populated, and the Edit button remains disabled. Is there some trick with DAL?
Edit: To clarify, when you create a new object via addanother
and return to the page the id
for the new item is populated correctly, but when you pick a new one from the DAL widget, that id value never gets updated.
Cheers
Hi, how to implement multiple stack popup?
Hi !
This app is great, nice and simple.
Did you consider allowing to add the "edit" button as well ?
It could be either specific wrapper classes, or an argument to choose between add link only, edit link only, or both links.
Thanks !
Hi there!
Would it be possible to use bootstrap modal instead of a pop-up window? Are there any howtos around?
Thank you very much! :)
Best
Teco
First of all thanks for the amazing tool!
I'm trying to use the edit/new wrapper for a select 2 widget, the multiple select to be precise .
What i'm doing is
#urls
path("models/creator/add", views.CreatorAddView.as_view(), name="creator_add"),
path("models/creator/edit/<pk>", views.CreatorEditView.as_view(), name=creator_edit"),
# form
widgets = {
"creator" : Select2MultipleAddAnotherEditSelected(
reverse_lazy("main:creator_add"),
reverse_lazy("main:creator_edit", args=["__fk__"]),
)
}
The create works fine, but the edit does some weird behavior ...
The data are stored in the database, so in a refresh of the page they show, but the selected value isn't changing, its just appended on the input field and its not editable or select-able.
Also, since the field is multi-select, if there are 2 or more values selected, the edit button view gets all their id as input. I get that's probably intended, but any way to disable it if none or 2+ are selected? I'm using a UpdateView.
Thanks for any help!
https://travis-ci.org/github/jonashaag/django-addanother/jobs/673335514
@jpic sorry to bother you again, these tests seem to be flaky, do have an idea what's going on here?
I don't get the "if" in this template. What does <nav>...</nav>
mean here?
If the view is a popup the navigation should be hidden....
Or is there a negation missing in the template snippet?
{{{
You may want to hide header, footer and navigation elements for the popups. When the create view is opened in a popup, the view.is_popup template variable is set:
{% if view.is_popup %}
<nav>...</nav>
{% endif %}
Hi Jonas,
is it possible to filter the given queryset of a widget based on the current user? So that the Select displays only the entries for objects that belong to the currently authenticated user?
Kind regards
Christopher
Hi there!
Since I've updated Django from version 4.0.7
to 4.1
, django-addanother does not work properly.
The popup, when I'm click on the plus button, does not show up, but instead it just opens another page (in the same browser tab).
Also, in the opened page, when i add new object, it throws an error:
popup_response.js:13` Uncaught TypeError: Cannot read properties of null (reading 'dismissAddRelatedObjectPopup')
at popup_response.js:13:16
I'll be glad to supply other info or code if requested.
Jonas, thank you for creating this and putting this out there for others to use. I was able to install it and get the included demo project running with no problem. The demo is very useful to answer questions.
I am trying to get django-addanother to run correctly with a Django formset. It works fine for the first form in the formset, but in subsequent forms in the formset, upon closing, the popup window inserts the new record into the first form in the formset only. I'm not sure if there is an existing way to create the desired behavior. Is it possible or does django-addanother not accommodate formsets?
Thanks, Paul
Two bugs here:
We should be using deepcopy to make copies of the inner widget to avoid state sharing of inner widgets if someone passes a widget instance rather than a widget class. django/django@09da1e7
We should make sure that when a widget is being copied using deepcopy, the inner widget is deepcopied too.
This would be nice to have in the documentation.
Hi! i just cloned the repo and when i try to run the migrate command, the console throws the follow error:
django.db.utils.OperationalError: no such table: auth_group
Any idea?
Thanks!
In Django 3.0 they removed six from django.utils. https://docs.djangoproject.com/en/3.0/releases/3.0/#removed-private-python-2-compatibility-apis
Error:
File "/usr/local/lib/python3.7/site-packages/django_addanother/views.py", line 6, in
from django.utils import six
ImportError: cannot import name 'six' from 'django.utils' (/usr/local/lib/python3.7/site-packages/django/utils/init.py)
Hi I am getting the above error, I am running Django 4.1.1 and setup the widget as follows:
form.fields['venue'].widget = AddAnotherWidgetWrapper(
forms.Select,
reverse_lazy('create-venue'),
)
Are all the Django 4x related fixes releases in pypi? I am using 2.2.2 version (the last tag I can see here is 2.1.0)
Thank you
Thanks for your great work.
I'm not sure if this is a bug or a mistake on my side (more likely), but when I load an existing instance in a form the AddAnotherWidgets are not filled with the current value. The "normal" fields are filled however.
I based my code on the example app, but that only has a submit option and does not let you load an existing instance.
Any idea what could be going wrong?
At first thank you for very good and useful add-ons.
I have mostly a question than an issue. Sorry to ask it here, the issues are probably not for this purpose, but I didn't find any other place to ask it.
My problem is that I want to use django-addanother add-on not for add the new item, but to choose from existing one.
In two words...
I have a model with ForeignKey field. In the form this field is done using Select Dropdown menu.
I'd like instead to have a button that will open a popup window where user choose the Object, click Submit, then popup is closed and the chosen Object is inserted into initial Form.
So my questions are :
Do you think I could realize such functionality with django-addanother ?
Is this functionality already included in django-addanother ? I could not find any explicit example in the doc.
I allow myself to ask this question as the desired functionality is not very hard to obtain.
In fact, if in the very basic example we inherit class PersonCreate
not form CreateView
but from ListView
we could easily get the list of related objects :
class PersonCreate(CreatePopupMixin, ListView):
The only question is that I should return from this PersonCreate popup to get it into thi initial form.
Once again, sorry for this not very relevant question.
Hi,
My project relies heavily on django-smart-selects.
After i integrated django-addanother into my project, django-smart-selects (out of admin) stopped working. I think It's something related to javascript in the view created by smart-selects which is being overwritten or deleted by addanother.
I use overridden valid_form() method like this in my views:
from django_addanother.views import PopupMixin
class LuogoCreate(PopupMixin, CreateView):
success_url = reverse_lazy("ipms:nuovo_luogo")
[...]
def valid_form(self, form, addanother, savecontinue, delete):
self.object = form.save()
if addanother:
return redirect("nrms:nuovo_luogo")
elif savecontinue:
return redirect("nrms:modifica_luogo", self.object.id)
elif delete:
return redirect("nrms:elimina_luogo", self.object.id)
elif self.is_popup():
return self.respond_script(self.object)
else:
return redirect("nrms:luoghi")
Any hints?
From: http://django-addanother.readthedocs.org/en/latest/usage.html#make-your-view-popup-compatible
You use one CreateView for normal adding and for adding inside the pop-up.
This results in an unavoidable "if" in the template (hiding the navigation stuff inside the poup)
I like the goal "conditionless code" even if this means typing in some more characters.
I will use two CreateViews:
What do you think?
Hi folks,
I noticed that the popup mechanism does not work when the view sends, for the form, a variable that has a different name than 'form'.
This works, and a new window pops-up when clicking on the add button :
At contrario, this does not work, whereas I made the changes in the template of course :
The form and the button are well displayed, but it opens the new form in the same window instead of poping-up.
I think it's a bug since it's just the variable the template uses, thus this sould not have an impact.
I'm using Django 4.1.7 and python 3.11.2.
Thanks a lot for the job done.
When do you plan to release the new version to pypi?
Hi, thank you for developing django-addanother; I have been using it with the default AddAnotherWidgetWrapper widget for a while now (in Django 1.11) and it works very well. However, I am now attempting to use it in a project that requires an autocomplete widget (currently using dal.autocomplete.ModelSelect2, but would really like a popup form to create new choices).
Following your documentation (http://django-addanother.readthedocs.io/en/latest/select2.html and http://django-addanother.readthedocs.io/en/latest/reference/select2_widgets.html#select2ref), I had no trouble to reproduce the example given with Select2AddAnother, but no luck so far in my attempts to use ModelSelect2AddAnother instead.
Could you please add an example using ModelSelect2AddAnother to http://django-addanother.readthedocs.io/en/latest/select2.html ?
Many thanks!
Hi,
Currently, one can't add custom get parameters to the urls, because ?popup=1
gets appended to the end. So you end up with test.com/myurl/?custom=abc?popup=1
which isn't valid.
I have a fix but it doesn't apply to master (since I work on the edit_links branch) : olivierdalang@b89ea33
I'll open a PR when the edit_links branch gets merged.
is required because if try run pip install django-addanother -U
, pip will also force update Django
to the latest version
django-addanother v. 1.0.1
I get an error if I try to put a text with accented characters like ç
, ã
....
Traceback:
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django/views/generic/base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
34. return bound_func(*args, **kwargs)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
30. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/luzfcb/projetos/solar_gitlab_master/djdocuments/views/documentos.py" in dispatch
407. return super(TipoDocumentoCriar, self).dispatch(request, *args, **kwargs)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
89. return handler(request, *args, **kwargs)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django/views/generic/edit.py" in post
249. return super(BaseCreateView, self).post(request, *args, **kwargs)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django/views/generic/edit.py" in post
215. return self.form_valid(form)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django_addanother/views.py" in form_valid
25. return self.respond_script(self.object)
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django_addanother/views.py" in respond_script
32. escapejs(self.label_from_instance(created_obj)),
File "/home/luzfcb/virtualenvs/solar_master/local/lib/python2.7/site-packages/django_addanother/views.py" in get_script_response_html
40. label=created_obj_label
Exception Type: UnicodeEncodeError at /docs/t/criar_tipo_documento/
Exception Value: 'ascii' code
Hi
I failed to find your repo before making my own implementation. This issue is about removing my duplicate repo. The two implementations differ though, so I'd like to know your thoughts about the possibilities we have to unite the repos.
Here are the differences:
What do you think ? Would you prefer to upgrade to the newer implementation, add it and support both, or just keep it in two separate apps ?
Best
@jpic can you have a look at the xvfb parts of the tests, they seem broken I have no idea how it works
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.