noisebridge / pyclass-project

Other
8 stars 2 forks source link

Allow users to create tags #43

Closed Belgand closed 12 years ago

Belgand commented 12 years ago

Currently users can create Tasks and Interests, but we don't have any way available for them to create tags other than the admin.

Since the fields and logic involved are pretty simple it would probably make the most sense to just use a generic view and a ModelForm to do this rather than writing our own. Currently the ToDoItem, and Interest detail pages use some simple generic views like we'd use here. The most sensible generic view to use for this would be the CreateView which will also create the form for us.

This should comprise the following parts:

As Kellan mentioned in class on 5/30 the documentation for generic views isn't very good right now so I'll try to provide the basics we need for this issue. The main things to do in this case would be to set the keyword argument model= to the model we're using (remember to import it first).

Documentation

Generic views - Overview This will show the basics of how to use generic views and explain more about them.

CreateView I've pulled out the necessary parts above, but this is the reference to the generic view we're using. Just keep in mind that this documentation is pretty bad and tends to leave important things out sometimes. Since this is made of modular parts you'll need to click around to the "mixins" it's made up of to see all of the attributes and methods.

ModelForm This is handled for us by CreateView, but if you want to know more about how that's working behind the scenes and how we could modify it (Adding ToDoItems and updating the user settings use these modified to only show certain fields).

Belgand commented 12 years ago

As written this will throw an error if issue #38 isn't closed first. If you're getting an error of

ImproperlyConfigured at /todo/add/tag/

No URL to redirect to. Either provide a url or define a get_absolute_url method on the Model.

this is the cause. Fix #38 (defining that get_absolute_url method it wants) and it should resolve the error.